How to disable Mobile Data on Android

后端 未结 8 1964
予麋鹿
予麋鹿 2020-11-22 12:13

Quick back story before someone tells me to buy an app. =)

I just got an EVO and it chews through the battery fairly quick. I downloaded JuiceDefender to manage

8条回答
  •  闹比i
    闹比i (楼主)
    2020-11-22 12:47

    Switching the mobile data net connectivity by changing the APN's name doesn't work well any more since Gingerbread. And while the reflection code is probably the right way to do the trick, it won't work, because the application needs the android.permission.MODIFY_PHONE_STATE permission as explained by Alex P. Otherwise you get this nasty exception:

    03-18 21:54:55.074: WARN/System.err(1851): java.lang.reflect.InvocationTargetException
    (...)
    03-18 21:54:55.263: WARN/System.err(1851): Caused by: java.lang.SecurityException: Neither user 10037 nor current process has android.permission.MODIFY_PHONE_STATE.
    (...)
    03-18 21:54:55.303: WARN/System.err(1851):     at com.android.internal.telephony.ITelephony$Stub$Proxy.disableDataConnectivity(ITelephony.java:888)
    

    Unfortunately, you cannot set this permission, because it is a level 3 permission not allowed for applications:

    03-18 21:48:39.334: WARN/PackageManager(75): Not granting permission android.permission.MODIFY_PHONE_STATE to package XXX (protectionLevel=3 flags=0x8be46)
    

    I don't suppose anyone has a way to override the permission grant suppression other than by using own firmware.

提交回复
热议问题