在实际开发过程中,某模块访问TelephonyProvider时,问题报下面的异常,而且报的频率还挺高,今天特别抽空找了一下。
01-11 19:23:49.301: E/DatabaseUtils(902): Writing exception to parcel 01-11 19:23:49.301: E/DatabaseUtils(902): java.lang.SecurityException: No permission to write APN settings: Neither user 10017 nor current process has android.permission.WRITE_APN_SETTINGS. 01-11 19:23:49.301: E/DatabaseUtils(902): at android.app.ContextImpl.enforce(ContextImpl.java:1646) 01-11 19:23:49.301: E/DatabaseUtils(902): at android.app.ContextImpl.enforceCallingOrSelfPermission(ContextImpl.java:1675) 01-11 19:23:49.301: E/DatabaseUtils(902): at com.android.providers.telephony.TelephonyProvider.checkPermission(TelephonyProvider.java:784) 01-11 19:23:49.301: E/DatabaseUtils(902): at com.android.providers.telephony.TelephonyProvider.query(TelephonyProvider.java:511) 01-11 19:23:49.301: E/DatabaseUtils(902): at android.content.ContentProvider.query(ContentProvider.java:744) 01-11 19:23:49.301: E/DatabaseUtils(902): at android.content.ContentProvider$Transport.query(ContentProvider.java:199) 01-11 19:23:49.301: E/DatabaseUtils(902): at android.content.ContentProviderNative.onTransact(ContentProviderNative.java:114) 01-11 19:23:49.301: E/DatabaseUtils(902): at android.os.Binder.execTransact(Binder.java:388) 01-11 19:23:49.301: E/DatabaseUtils(902): at dalvik.system.NativeStart.run(Native Method)
在CMD中输入 adb shell,然后再 su 到root,再输入下面的命令:
cat /data/system/packages.xml | grep 10017得到如下的结果:
<package name="com.zhao3546.testcenter" codePath="/system/app/testcenter.apk" nativeLibraryPath="/data/app-lib/testcenter_1.0.15" flags="573007" ft="14380ce7678" it="143321d14ab" ut="14380d07834" version="200101" userId="10017">