首页 > 解决方案 > 在 ITelephony 实现期间对错误接口的 Binder 调用

问题描述

我已经创建了 ITelephony AIDL 文件作为接口,如附图所示。使用此代码时出现以下错误。

   Class<?> loadClass = CallBlockerPhoneStateListner.class.getClassLoader().loadClass("android.os.ServiceManager");
                Method method = loadClass.getDeclaredMethod("getService", String.class);
                IBinder invoke = (IBinder) method.invoke(null, TELEPHONY_SERVICE);

                ITelephony iTelephony = ITelephony.Stub.asInterface(invoke);
                iTelephony.endCall();

抛出的错误:

06-21 11:31:26.977 17511-17511/? W/System.err: java.lang.SecurityException: Binder invocation to an incorrect interface
06-21 11:31:26.977 17511-17511/? W/System.err:     at android.os.Parcel.readException(Parcel.java:2005)
06-21 11:31:26.977 17511-17511/? W/System.err:     at android.os.Parcel.readException(Parcel.java:1951)
06-21 11:31:26.977 17511-17511/? W/System.err:     at jss.s.ITelephony$Stub$Proxy.endCall(ITelephony.java:131)

你能指导如何解决这个问题吗?Ref 取自https://www.programcreek.com/java-api-examples/?code=384401056/itheima/itheima-master/MobileSafe/src/com/blueice/mobilesafe/service/BlackListService.java#

AIDL 图像

标签: javaandroid

解决方案


packagename should be com.android.internal.telephony instead of your app package name in aidl directory.


推荐阅读