diff options
author | Nicolas Prevot <nprevot@google.com> | 2015-02-24 18:41:50 +0000 |
---|---|---|
committer | Nicolas Prevot <nprevot@google.com> | 2015-02-26 11:57:29 +0000 |
commit | 41916d492c38055928ae5ad1e0b815ff79dc4f5c (patch) | |
tree | 0cdbd4650daa99edb67a6c60ba80e03f9e09c673 | |
parent | 08238bb6247a2c1d93aefd52a31f9d1ad5bc7ff0 (diff) | |
download | frameworks_base-41916d492c38055928ae5ad1e0b815ff79dc4f5c.zip frameworks_base-41916d492c38055928ae5ad1e0b815ff79dc4f5c.tar.gz frameworks_base-41916d492c38055928ae5ad1e0b815ff79dc4f5c.tar.bz2 |
Fail silently when changing BLUETOOTH_ON/WIFI_ON directly
If the device owner tries to change BLUETOOTH_ON or WIFI_ON via
DevicePolicyManager.setGlobalSetting, fail silently.
There was not much point for the device owner to do it since it can
also change bluetooth/wifi state via normal bluetooth and wifi apis.
BUG:19311992
Change-Id: Ifba163800aa413865b8a2877cb21aacfa5cfc6c8
-rw-r--r-- | core/java/android/app/admin/DevicePolicyManager.java | 9 | ||||
-rw-r--r-- | services/devicepolicy/java/com/android/server/devicepolicy/DevicePolicyManagerService.java | 11 |
2 files changed, 14 insertions, 6 deletions
diff --git a/core/java/android/app/admin/DevicePolicyManager.java b/core/java/android/app/admin/DevicePolicyManager.java index d0ebdbd..ca18b9c 100644 --- a/core/java/android/app/admin/DevicePolicyManager.java +++ b/core/java/android/app/admin/DevicePolicyManager.java @@ -3360,13 +3360,18 @@ public class DevicePolicyManager { * <li>{@link Settings.Global#ADB_ENABLED}</li> * <li>{@link Settings.Global#AUTO_TIME}</li> * <li>{@link Settings.Global#AUTO_TIME_ZONE}</li> - * <li>{@link Settings.Global#BLUETOOTH_ON}</li> + * <li>{@link Settings.Global#BLUETOOTH_ON} + * Changing this setting has not effect as of {@link android.os.Build.VERSION_CODES#MNC}. Use + * {@link android.bluetooth.BluetoothAdapter#enable()} and + * {@link android.bluetooth.BluetoothAdapter#disable()} instead.</li> * <li>{@link Settings.Global#DATA_ROAMING}</li> * <li>{@link Settings.Global#DEVELOPMENT_SETTINGS_ENABLED}</li> * <li>{@link Settings.Global#MODE_RINGER}</li> * <li>{@link Settings.Global#NETWORK_PREFERENCE}</li> * <li>{@link Settings.Global#USB_MASS_STORAGE_ENABLED}</li> - * <li>{@link Settings.Global#WIFI_ON}</li> + * <li>{@link Settings.Global#WIFI_ON} + * Changing this setting has not effect as of {@link android.os.Build.VERSION_CODES#MNC}. Use + * {@link android.net.wifi.WifiManager#setWifiEnabled(boolean)} instead.</li> * <li>{@link Settings.Global#WIFI_SLEEP_POLICY}</li> * </ul> * diff --git a/services/devicepolicy/java/com/android/server/devicepolicy/DevicePolicyManagerService.java b/services/devicepolicy/java/com/android/server/devicepolicy/DevicePolicyManagerService.java index 770da5b..8205fbd 100644 --- a/services/devicepolicy/java/com/android/server/devicepolicy/DevicePolicyManagerService.java +++ b/services/devicepolicy/java/com/android/server/devicepolicy/DevicePolicyManagerService.java @@ -196,13 +196,11 @@ public class DevicePolicyManagerService extends IDevicePolicyManager.Stub { GLOBAL_SETTINGS_WHITELIST.add(Settings.Global.ADB_ENABLED); GLOBAL_SETTINGS_WHITELIST.add(Settings.Global.AUTO_TIME); GLOBAL_SETTINGS_WHITELIST.add(Settings.Global.AUTO_TIME_ZONE); - GLOBAL_SETTINGS_WHITELIST.add(Settings.Global.BLUETOOTH_ON); GLOBAL_SETTINGS_WHITELIST.add(Settings.Global.DATA_ROAMING); GLOBAL_SETTINGS_WHITELIST.add(Settings.Global.DEVELOPMENT_SETTINGS_ENABLED); GLOBAL_SETTINGS_WHITELIST.add(Settings.Global.MODE_RINGER); GLOBAL_SETTINGS_WHITELIST.add(Settings.Global.NETWORK_PREFERENCE); GLOBAL_SETTINGS_WHITELIST.add(Settings.Global.USB_MASS_STORAGE_ENABLED); - GLOBAL_SETTINGS_WHITELIST.add(Settings.Global.WIFI_ON); GLOBAL_SETTINGS_WHITELIST.add(Settings.Global.WIFI_SLEEP_POLICY); } @@ -5267,8 +5265,13 @@ public class DevicePolicyManagerService extends IDevicePolicyManager.Stub { getActiveAdminForCallerLocked(who, DeviceAdminInfo.USES_POLICY_DEVICE_OWNER); if (!GLOBAL_SETTINGS_WHITELIST.contains(setting)) { - throw new SecurityException(String.format( - "Permission denial: device owners cannot update %1$s", setting)); + // BLUETOOTH_ON and WIFI_ON used to be supported but not any more. We do not want to + // throw a SecurityException not to break apps. + if (!Settings.Global.BLUETOOTH_ON.equals(setting) + && !Settings.Global.WIFI_ON.equals(setting)) { + throw new SecurityException(String.format( + "Permission denial: device owners cannot update %1$s", setting)); + } } long id = Binder.clearCallingIdentity(); |