美文网首页
ITelephony.endCall 混淆后挂断电话失败

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

作者: 大胡子的机器人 | 来源:发表于2019-08-29 14:24 被阅读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();
        }
    }

    相关文章

      网友评论

          本文标题:ITelephony.endCall 混淆后挂断电话失败

          本文链接:https://www.haomeiwen.com/subject/yrsiectx.html