Loading core/java/android/app/admin/DevicePolicyManager.java +5 −1 Original line number Diff line number Diff line Loading @@ -3245,11 +3245,15 @@ public class DevicePolicyManager { * Called by profile or device owners to update {@link Settings.Secure} settings. Validation * that the value of the setting is in the correct form for the setting type should be performed * by the caller. * <p>The settings that can be updated with this method are: * <p>The settings that can be updated by a profile or device owner with this method are: * <ul> * <li>{@link Settings.Secure#DEFAULT_INPUT_METHOD}</li> * <li>{@link Settings.Secure#SKIP_FIRST_USE_HINTS}</li> * </ul> * <p>A device owner can additionally update the following settings: * <ul> * <li>{@link Settings.Secure#LOCATION_MODE}</li> * </ul> * @param admin Which {@link DeviceAdminReceiver} this request is associated with. * @param setting The name of the setting to update. * @param value The value to update the setting to. Loading core/java/android/provider/Settings.java +5 −5 Original line number Diff line number Diff line Loading @@ -3150,6 +3150,11 @@ public final class Settings { /** @hide */ public static boolean putStringForUser(ContentResolver resolver, String name, String value, int userHandle) { if (LOCATION_MODE.equals(name)) { // HACK ALERT: temporary hack to work around b/10491283. // TODO: once b/10491283 fixed, remove this hack return setLocationModeForUser(resolver, Integer.parseInt(value), userHandle); } if (MOVED_TO_GLOBAL.contains(name)) { Log.w(TAG, "Setting " + name + " has moved from android.provider.Settings.System" + " to android.provider.Settings.Global"); Loading Loading @@ -3265,11 +3270,6 @@ public final class Settings { /** @hide */ public static boolean putIntForUser(ContentResolver cr, String name, int value, int userHandle) { if (LOCATION_MODE.equals(name)) { // HACK ALERT: temporary hack to work around b/10491283. // TODO: once b/10491283 fixed, remove this hack return setLocationModeForUser(cr, value, userHandle); } return putStringForUser(cr, name, Integer.toString(value), userHandle); } Loading services/devicepolicy/java/com/android/server/devicepolicy/DevicePolicyManagerService.java +14 −3 Original line number Diff line number Diff line Loading @@ -166,12 +166,17 @@ public class DevicePolicyManagerService extends IDevicePolicyManager.Stub { } 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; static { SECURE_SETTINGS_WHITELIST = new HashSet(); SECURE_SETTINGS_WHITELIST.add(Settings.Secure.DEFAULT_INPUT_METHOD); SECURE_SETTINGS_WHITELIST.add(Settings.Secure.SKIP_FIRST_USE_HINTS); SECURE_SETTINGS_DEVICEOWNER_WHITELIST = new HashSet(); SECURE_SETTINGS_DEVICEOWNER_WHITELIST.addAll(SECURE_SETTINGS_WHITELIST); SECURE_SETTINGS_DEVICEOWNER_WHITELIST.add(Settings.Secure.LOCATION_MODE); GLOBAL_SETTINGS_WHITELIST = new HashSet(); GLOBAL_SETTINGS_WHITELIST.add(Settings.Global.ADB_ENABLED); GLOBAL_SETTINGS_WHITELIST.add(Settings.Global.AUTO_TIME); Loading Loading @@ -5109,11 +5114,17 @@ public class DevicePolicyManagerService extends IDevicePolicyManager.Stub { if (who == null) { throw new NullPointerException("ComponentName is null"); } ActiveAdmin activeAdmin = getActiveAdminForCallerLocked(who, DeviceAdminInfo.USES_POLICY_PROFILE_OWNER); if (!SECURE_SETTINGS_WHITELIST.contains(setting)) { if (isDeviceOwner(activeAdmin.info.getPackageName())) { if (!SECURE_SETTINGS_DEVICEOWNER_WHITELIST.contains(setting)) { throw new SecurityException(String.format( "Permission denial: Device owners cannot update %1$s", setting)); } } else if (!SECURE_SETTINGS_WHITELIST.contains(setting)) { throw new SecurityException(String.format( "Permission denial: profile/device owners cannot update %1$s", setting)); "Permission denial: Profile owners cannot update %1$s", setting)); } long id = Binder.clearCallingIdentity(); Loading Loading
core/java/android/app/admin/DevicePolicyManager.java +5 −1 Original line number Diff line number Diff line Loading @@ -3245,11 +3245,15 @@ public class DevicePolicyManager { * Called by profile or device owners to update {@link Settings.Secure} settings. Validation * that the value of the setting is in the correct form for the setting type should be performed * by the caller. * <p>The settings that can be updated with this method are: * <p>The settings that can be updated by a profile or device owner with this method are: * <ul> * <li>{@link Settings.Secure#DEFAULT_INPUT_METHOD}</li> * <li>{@link Settings.Secure#SKIP_FIRST_USE_HINTS}</li> * </ul> * <p>A device owner can additionally update the following settings: * <ul> * <li>{@link Settings.Secure#LOCATION_MODE}</li> * </ul> * @param admin Which {@link DeviceAdminReceiver} this request is associated with. * @param setting The name of the setting to update. * @param value The value to update the setting to. Loading
core/java/android/provider/Settings.java +5 −5 Original line number Diff line number Diff line Loading @@ -3150,6 +3150,11 @@ public final class Settings { /** @hide */ public static boolean putStringForUser(ContentResolver resolver, String name, String value, int userHandle) { if (LOCATION_MODE.equals(name)) { // HACK ALERT: temporary hack to work around b/10491283. // TODO: once b/10491283 fixed, remove this hack return setLocationModeForUser(resolver, Integer.parseInt(value), userHandle); } if (MOVED_TO_GLOBAL.contains(name)) { Log.w(TAG, "Setting " + name + " has moved from android.provider.Settings.System" + " to android.provider.Settings.Global"); Loading Loading @@ -3265,11 +3270,6 @@ public final class Settings { /** @hide */ public static boolean putIntForUser(ContentResolver cr, String name, int value, int userHandle) { if (LOCATION_MODE.equals(name)) { // HACK ALERT: temporary hack to work around b/10491283. // TODO: once b/10491283 fixed, remove this hack return setLocationModeForUser(cr, value, userHandle); } return putStringForUser(cr, name, Integer.toString(value), userHandle); } Loading
services/devicepolicy/java/com/android/server/devicepolicy/DevicePolicyManagerService.java +14 −3 Original line number Diff line number Diff line Loading @@ -166,12 +166,17 @@ public class DevicePolicyManagerService extends IDevicePolicyManager.Stub { } 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; static { SECURE_SETTINGS_WHITELIST = new HashSet(); SECURE_SETTINGS_WHITELIST.add(Settings.Secure.DEFAULT_INPUT_METHOD); SECURE_SETTINGS_WHITELIST.add(Settings.Secure.SKIP_FIRST_USE_HINTS); SECURE_SETTINGS_DEVICEOWNER_WHITELIST = new HashSet(); SECURE_SETTINGS_DEVICEOWNER_WHITELIST.addAll(SECURE_SETTINGS_WHITELIST); SECURE_SETTINGS_DEVICEOWNER_WHITELIST.add(Settings.Secure.LOCATION_MODE); GLOBAL_SETTINGS_WHITELIST = new HashSet(); GLOBAL_SETTINGS_WHITELIST.add(Settings.Global.ADB_ENABLED); GLOBAL_SETTINGS_WHITELIST.add(Settings.Global.AUTO_TIME); Loading Loading @@ -5109,11 +5114,17 @@ public class DevicePolicyManagerService extends IDevicePolicyManager.Stub { if (who == null) { throw new NullPointerException("ComponentName is null"); } ActiveAdmin activeAdmin = getActiveAdminForCallerLocked(who, DeviceAdminInfo.USES_POLICY_PROFILE_OWNER); if (!SECURE_SETTINGS_WHITELIST.contains(setting)) { if (isDeviceOwner(activeAdmin.info.getPackageName())) { if (!SECURE_SETTINGS_DEVICEOWNER_WHITELIST.contains(setting)) { throw new SecurityException(String.format( "Permission denial: Device owners cannot update %1$s", setting)); } } else if (!SECURE_SETTINGS_WHITELIST.contains(setting)) { throw new SecurityException(String.format( "Permission denial: profile/device owners cannot update %1$s", setting)); "Permission denial: Profile owners cannot update %1$s", setting)); } long id = Binder.clearCallingIdentity(); Loading