android开发中定制系统app,自定义拨号打电话功能,在混淆后发现ITelephony.endCall返回的是false,挂断电话无效。
需要添加混淆文件配置:
-keep public interface com.android.internal.telephony.ITelephony.**{*;}
-keep public abstract interface com.android.internal.telephony.ITelephony{
public protected <methods>;
}
-keep public class * implements com.android.internal.telephony.ITelephony{
public protected <methods>;
}
顺便把挂断电话的代码贴出来(日志就是我排查混淆文件的跟踪):
private void endPhone() {
Method method = null;
try {
method = Class.forName("android.os.ServiceManager").getMethod("getService", String.class);
Log.e(TAG,"method=" + method);
IBinder binder = (IBinder) method.invoke(null, new Object[]{"phone"});
Log.e(TAG,"binder=" + binder);
ITelephony telephony = ITelephony.Stub.asInterface(binder);
Log.e(TAG,"telephony=" + telephony);
// telephony.endCall();
Log.e(TAG,"endCall binder=" + binder + ";endCall=" + telephony.endCall());
} catch (NoSuchMethodException e) {
e.printStackTrace();
} catch (ClassNotFoundException e) {
e.printStackTrace();
} catch (InvocationTargetException e) {
e.printStackTrace();
} catch (IllegalAccessException e) {
e.printStackTrace();
} catch (RemoteException e) {
e.printStackTrace();
}
}
网友评论