ITelephony.endCall 混淆后挂断电话失败

2019-08-29  本文已影响0人  大胡子的机器人

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();
    }
}
上一篇 下一篇

猜你喜欢

热点阅读