Marking some globals from setGlobalSetting as not supported

Those globals don't have the intended behaviour any more.

Bug: 19967818
Change-Id: I8c7891e59280f9deb88b1f0ffead3de07f4eca56
diff --git a/core/java/android/app/admin/DevicePolicyManager.java b/core/java/android/app/admin/DevicePolicyManager.java
index 83e06d6..9812e61 100644
--- a/core/java/android/app/admin/DevicePolicyManager.java
+++ b/core/java/android/app/admin/DevicePolicyManager.java
@@ -3956,24 +3956,27 @@
      * <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}
-     * 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}
-     * 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>
      * <li>{@link Settings.Global#STAY_ON_WHILE_PLUGGED_IN}
-     * This setting is only available from {@link android.os.Build.VERSION_CODES#MNC} onwards
-     * and can only be set if {@link #setMaximumTimeToLock} is not used to set a timeout.</li>
+     *   This setting is only available from {@link android.os.Build.VERSION_CODES#MNC} onwards
+     *   and can only be set if {@link #setMaximumTimeToLock} is not used to set a timeout.</li>
      * <li>{@link Settings.Global#WIFI_DEVICE_OWNER_CONFIGS_LOCKDOWN}</li>
      * </ul>
+     * <p>Changing the following settings has no effect as of
+     * {@link android.os.Build.VERSION_CODES#MNC}:
+     * <ul>
+     * <li>{@link Settings.Global#BLUETOOTH_ON}.
+     *   Use {@link android.bluetooth.BluetoothAdapter#enable()} and
+     *   {@link android.bluetooth.BluetoothAdapter#disable()} instead.</li>
+     * <li>{@link Settings.Global#DEVELOPMENT_SETTINGS_ENABLED}</li>
+     * <li>{@link Settings.Global#MODE_RINGER}.
+     *   Use {@link android.media.AudioManager#setRingerMode(int)} instead.</li>
+     * <li>{@link Settings.Global#NETWORK_PREFERENCE}</li>
+     * <li>{@link Settings.Global#WIFI_ON}.
+     *   Use {@link android.net.wifi.WifiManager#setWifiEnabled(boolean)} instead.</li>
+     * </ul>
      *
      * @param admin Which {@link DeviceAdminReceiver} this request is associated with.
      * @param setting The name of the setting to update.
diff --git a/services/devicepolicy/java/com/android/server/devicepolicy/DevicePolicyManagerService.java b/services/devicepolicy/java/com/android/server/devicepolicy/DevicePolicyManagerService.java
index 491b412..cd6e415 100644
--- a/services/devicepolicy/java/com/android/server/devicepolicy/DevicePolicyManagerService.java
+++ b/services/devicepolicy/java/com/android/server/devicepolicy/DevicePolicyManagerService.java
@@ -225,6 +225,7 @@
     private static final Set<String> SECURE_SETTINGS_WHITELIST;
     private static final Set<String> SECURE_SETTINGS_DEVICEOWNER_WHITELIST;
     private static final Set<String> GLOBAL_SETTINGS_WHITELIST;
+    private static final Set<String> GLOBAL_SETTINGS_DEPRECATED;
     static {
         SECURE_SETTINGS_WHITELIST = new HashSet();
         SECURE_SETTINGS_WHITELIST.add(Settings.Secure.DEFAULT_INPUT_METHOD);
@@ -240,13 +241,17 @@
         GLOBAL_SETTINGS_WHITELIST.add(Settings.Global.AUTO_TIME);
         GLOBAL_SETTINGS_WHITELIST.add(Settings.Global.AUTO_TIME_ZONE);
         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_SLEEP_POLICY);
         GLOBAL_SETTINGS_WHITELIST.add(Settings.Global.STAY_ON_WHILE_PLUGGED_IN);
         GLOBAL_SETTINGS_WHITELIST.add(Settings.Global.WIFI_DEVICE_OWNER_CONFIGS_LOCKDOWN);
+
+        GLOBAL_SETTINGS_DEPRECATED = new HashSet();
+        GLOBAL_SETTINGS_DEPRECATED.add(Settings.Global.BLUETOOTH_ON);
+        GLOBAL_SETTINGS_DEPRECATED.add(Settings.Global.DEVELOPMENT_SETTINGS_ENABLED);
+        GLOBAL_SETTINGS_DEPRECATED.add(Settings.Global.MODE_RINGER);
+        GLOBAL_SETTINGS_DEPRECATED.add(Settings.Global.NETWORK_PREFERENCE);
+        GLOBAL_SETTINGS_DEPRECATED.add(Settings.Global.WIFI_ON);
     }
 
     // Keyguard features that when set of a profile will affect the profiles
@@ -5964,14 +5969,16 @@
         synchronized (this) {
             getActiveAdminForCallerLocked(who, DeviceAdminInfo.USES_POLICY_DEVICE_OWNER);
 
+            // Some settings are no supported any more. However we do not want to throw a
+            // SecurityException to avoid breaking apps.
+            if (GLOBAL_SETTINGS_DEPRECATED.contains(setting)) {
+                Log.i(LOG_TAG, "Global setting no longer supported: " + setting);
+                return;
+            }
+
             if (!GLOBAL_SETTINGS_WHITELIST.contains(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));
-                }
+                throw new SecurityException(String.format(
+                        "Permission denial: device owners cannot update %1$s", setting));
             }
 
             if (Settings.Global.STAY_ON_WHILE_PLUGGED_IN.equals(setting)) {