java - 在 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#
解决方案
packagename should be com.android.internal.telephony instead of your app package name in aidl directory.
推荐阅读
- javascript - 等待加载时的 Java 脚本事件
- node.js - Mongoose:find 后无法填充以进行 $near 查询
- react-native - 在滚动触发之前,某些项目不会显示在 SectionList 中
- mysql - 如何仅更新表中的一行但带有 ID 号
- c++ - 在 Windows 上编译 QT OPCUA
- node.js - 静态文件如何在 express js 中工作?
- c++ - 带推力减少的推力::复杂无法编译
- javascript - 谷歌广告词 | excludePlacementList -> addExcludedPlacement 不适用于通过 UI 工作的 Url
- facebook-instant-games - 排行榜奇怪的行为和问题
- html - Django 1.10 - 问题从模板传递值到视图