diff options
author | Steve Kondik <steve@cyngn.com> | 2015-12-07 18:50:52 -0800 |
---|---|---|
committer | Steve Kondik <steve@cyngn.com> | 2015-12-07 18:50:52 -0800 |
commit | 10c07f778a611d8723619f67e5709cbd9e502a07 (patch) | |
tree | 2747712ffb2d61348ec7b241d0c2a764397a07a5 /core/java/android/provider/Settings.java | |
parent | 45c11b1020a64aae88b859870d5b2e312dab4f76 (diff) | |
parent | 4d70bd7a928903b35c92619437c70bc382587b71 (diff) | |
download | frameworks_base-10c07f778a611d8723619f67e5709cbd9e502a07.zip frameworks_base-10c07f778a611d8723619f67e5709cbd9e502a07.tar.gz frameworks_base-10c07f778a611d8723619f67e5709cbd9e502a07.tar.bz2 |
Merge tag 'android-6.0.1_r3' of https://android.googlesource.com/platform/frameworks/base into cm-13.0
Android 6.0.1 release 3
Change-Id: I59b9e5a943e0860d43bcfb36ee0e8b8b072412ea
Diffstat (limited to 'core/java/android/provider/Settings.java')
-rw-r--r-- | core/java/android/provider/Settings.java | 52 |
1 files changed, 12 insertions, 40 deletions
diff --git a/core/java/android/provider/Settings.java b/core/java/android/provider/Settings.java index 8182855..a3de3d1 100644 --- a/core/java/android/provider/Settings.java +++ b/core/java/android/provider/Settings.java @@ -1437,25 +1437,6 @@ public final class Settings { } /** - * An app can use this method to check if it is currently allowed to change the network - * state. In order to be allowed to do so, an app must first declare either the - * {@link android.Manifest.permission#CHANGE_NETWORK_STATE} or - * {@link android.Manifest.permission#WRITE_SETTINGS} permission in its manifest. If it - * is currently disallowed, it can prompt the user to grant it this capability through a - * management UI by sending an Intent with action - * {@link android.provider.Settings#ACTION_MANAGE_WRITE_SETTINGS}. - * - * @param context A context - * @return true if the calling app can change the state of network, false otherwise. - * @hide - */ - public static boolean canChangeNetworkState(Context context) { - int uid = Binder.getCallingUid(); - return Settings.isCallingPackageAllowedToChangeNetworkState(context, uid, Settings - .getPackageNameForUid(context, uid), false); - } - - /** * System settings, containing miscellaneous system preferences. This * table holds simple name/value pairs. There are convenience * functions for accessing individual settings entries. @@ -8730,7 +8711,7 @@ public final class Settings { * write/modify system settings, as the condition differs for pre-M, M+, and * privileged/preinstalled apps. If the provided uid does not match the * callingPackage, a negative result will be returned. The caller is expected to have - * either WRITE_SETTINGS or CHANGE_NETWORK_STATE permission declared. + * the WRITE_SETTINGS permission declared. * * Note: if the check is successful, the operation of this app will be updated to the * current time. @@ -8746,31 +8727,22 @@ public final class Settings { /** * Performs a strict and comprehensive check of whether a calling package is allowed to * change the state of network, as the condition differs for pre-M, M+, and - * privileged/preinstalled apps. If the provided uid does not match the - * callingPackage, a negative result will be returned. The caller is expected to have - * either of CHANGE_NETWORK_STATE or WRITE_SETTINGS permission declared. - * @hide - */ - public static boolean isCallingPackageAllowedToChangeNetworkState(Context context, int uid, - String callingPackage, boolean throwException) { - return isCallingPackageAllowedToPerformAppOpsProtectedOperation(context, uid, - callingPackage, throwException, AppOpsManager.OP_WRITE_SETTINGS, - PM_CHANGE_NETWORK_STATE, false); - } - - /** - * Performs a strict and comprehensive check of whether a calling package is allowed to - * change the state of network, as the condition differs for pre-M, M+, and - * privileged/preinstalled apps. If the provided uid does not match the - * callingPackage, a negative result will be returned. The caller is expected to have - * either CHANGE_NETWORK_STATE or WRITE_SETTINGS permission declared. + * privileged/preinstalled apps. The caller is expected to have either the + * CHANGE_NETWORK_STATE or the WRITE_SETTINGS permission declared. Either of these + * permissions allow changing network state; WRITE_SETTINGS is a runtime permission and + * can be revoked, but (except in M, excluding M MRs), CHANGE_NETWORK_STATE is a normal + * permission and cannot be revoked. See http://b/23597341 * - * Note: if the check is successful, the operation of this app will be updated to the - * current time. + * Note: if the check succeeds because the application holds WRITE_SETTINGS, the operation + * of this app will be updated to the current time. * @hide */ public static boolean checkAndNoteChangeNetworkStateOperation(Context context, int uid, String callingPackage, boolean throwException) { + if (context.checkCallingOrSelfPermission(android.Manifest.permission.CHANGE_NETWORK_STATE) + == PackageManager.PERMISSION_GRANTED) { + return true; + } return isCallingPackageAllowedToPerformAppOpsProtectedOperation(context, uid, callingPackage, throwException, AppOpsManager.OP_WRITE_SETTINGS, PM_CHANGE_NETWORK_STATE, true); |