在撤消权限时启用移动数据连接失败

时间:2014-02-10 09:55:26

标签: android

我需要在我的应用中打开Android设备的数据连接。我的手机已植根,其系统是android 2.3.5。不幸的是,以下失败:

// open data connection
Class telephonyManagerClz=TelephonyManager.class;
Method mGetITelephony=telephonyManagerClz
        .getDeclaredMethod("getITelephony");
mGetITelephony.setAccessible(true);
Object iTelephony = mGetITelephony.invoke(tm);
Method mEnableDataConn=iTelephony.getClass()
        .getDeclaredMethod("enableDataConnectivity");
mEnableDataConn.setAccessible(true);
mEnableDataConn.invoke(iTelephony);

这是logcat中显示的异常: enter image description here

似乎我没有MODIFY_PHONE_STATE权限,但我已将其添加到Manifest.xml中。可能是什么问题?

2 个答案:

答案 0 :(得分:0)

android.permission.MODIFY_PHONE_STATE是保留的权限。如果您的应用程序使用系统证书签名,则只能使用系统权限。

在安装应用程序期间,您应该看到PackageManager发出的警告已撤销该权限。

虽然我并不完全熟悉对root设备的覆盖权限限制,但如果您没有从源代码构建系统,则不太可能拥有证书,系统只会继续撤销您的权限。我认为根本无法签署您的应用程序来使用它。

答案 1 :(得分:0)

我找到了最佳解决方案访问http://my.oschina.net/u/578360/blog/198466