Loading core/java/android/os/IUserManager.aidl +1 −0 Original line number Diff line number Diff line Loading @@ -71,6 +71,7 @@ interface IUserManager { Bundle getUserRestrictions(int userHandle); boolean hasBaseUserRestriction(String restrictionKey, int userHandle); boolean hasUserRestriction(in String restrictionKey, int userHandle); boolean hasUserRestrictionOnAnyUser(in String restrictionKey); void setUserRestriction(String key, boolean value, int userHandle); void setApplicationRestrictions(in String packageName, in Bundle restrictions, int userHandle); Loading core/java/android/os/UserManager.java +12 −0 Original line number Diff line number Diff line Loading @@ -1677,6 +1677,18 @@ public class UserManager { } } /** * @hide * Returns whether any user on the device has the given user restriction set. */ public boolean hasUserRestrictionOnAnyUser(String restrictionKey) { try { return mService.hasUserRestrictionOnAnyUser(restrictionKey); } catch (RemoteException re) { throw re.rethrowFromSystemServer(); } } /** * Return the serial number for a user. This is a device-unique * number assigned to that user; if the user is deleted and then a new Loading packages/SettingsProvider/src/com/android/providers/settings/SettingsProvider.java +12 −1 Original line number Diff line number Diff line Loading @@ -1591,6 +1591,7 @@ public class SettingsProvider extends ContentProvider { private boolean isGlobalOrSecureSettingRestrictedForUser(String setting, int userId, String value, int callingUid) { String restriction; boolean checkAllUser = false; switch (setting) { case Settings.Secure.LOCATION_MODE: // Note LOCATION_MODE will be converted into LOCATION_PROVIDERS_ALLOWED Loading Loading @@ -1656,6 +1657,12 @@ public class SettingsProvider extends ContentProvider { restriction = UserManager.DISALLOW_AMBIENT_DISPLAY; break; case Global.LOCATION_GLOBAL_KILL_SWITCH: if ("0".equals(value)) return false; restriction = UserManager.DISALLOW_CONFIG_LOCATION; checkAllUser = true; break; default: if (setting != null && setting.startsWith(Settings.Global.DATA_ROAMING)) { if ("0".equals(value)) return false; Loading @@ -1665,8 +1672,12 @@ public class SettingsProvider extends ContentProvider { return false; } if (checkAllUser) { return mUserManager.hasUserRestrictionOnAnyUser(restriction); } else { return mUserManager.hasUserRestriction(restriction, UserHandle.of(userId)); } } private int resolveOwningUserIdForSecureSettingLocked(int userId, String setting) { return resolveOwningUserIdLocked(userId, sSecureCloneToManagedSettings, setting); Loading services/core/java/com/android/server/pm/UserManagerService.java +17 −0 Original line number Diff line number Diff line Loading @@ -1486,6 +1486,23 @@ public class UserManagerService extends IUserManager.Stub { return restrictions != null && restrictions.getBoolean(restrictionKey); } /** @return if any user has the given restriction. */ @Override public boolean hasUserRestrictionOnAnyUser(String restrictionKey) { if (!UserRestrictionsUtils.isValidRestriction(restrictionKey)) { return false; } final List<UserInfo> users = getUsers(/* excludeDying= */ true); for (int i = 0; i < users.size(); i++) { final int userId = users.get(i).id; Bundle restrictions = getEffectiveUserRestrictions(userId); if (restrictions != null && restrictions.getBoolean(restrictionKey)) { return true; } } return false; } /** * @hide * Loading services/core/java/com/android/server/pm/UserRestrictionsUtils.java +10 −0 Original line number Diff line number Diff line Loading @@ -33,6 +33,7 @@ import android.os.UserHandle; import android.os.UserManager; import android.os.UserManagerInternal; import android.provider.Settings; import android.provider.Settings.Global; import android.telephony.SubscriptionInfo; import android.telephony.SubscriptionManager; import android.util.Log; Loading Loading @@ -581,6 +582,15 @@ public class UserRestrictionsUtils { Settings.Secure.DOZE_PULSE_ON_DOUBLE_TAP, "0"); } break; case UserManager.DISALLOW_CONFIG_LOCATION: // When DISALLOW_CONFIG_LOCATION is set on any user, we undo the global // kill switch. if (newValue) { android.provider.Settings.Global.putString( context.getContentResolver(), Global.LOCATION_GLOBAL_KILL_SWITCH, "0"); } break; } } finally { Binder.restoreCallingIdentity(id); Loading Loading
core/java/android/os/IUserManager.aidl +1 −0 Original line number Diff line number Diff line Loading @@ -71,6 +71,7 @@ interface IUserManager { Bundle getUserRestrictions(int userHandle); boolean hasBaseUserRestriction(String restrictionKey, int userHandle); boolean hasUserRestriction(in String restrictionKey, int userHandle); boolean hasUserRestrictionOnAnyUser(in String restrictionKey); void setUserRestriction(String key, boolean value, int userHandle); void setApplicationRestrictions(in String packageName, in Bundle restrictions, int userHandle); Loading
core/java/android/os/UserManager.java +12 −0 Original line number Diff line number Diff line Loading @@ -1677,6 +1677,18 @@ public class UserManager { } } /** * @hide * Returns whether any user on the device has the given user restriction set. */ public boolean hasUserRestrictionOnAnyUser(String restrictionKey) { try { return mService.hasUserRestrictionOnAnyUser(restrictionKey); } catch (RemoteException re) { throw re.rethrowFromSystemServer(); } } /** * Return the serial number for a user. This is a device-unique * number assigned to that user; if the user is deleted and then a new Loading
packages/SettingsProvider/src/com/android/providers/settings/SettingsProvider.java +12 −1 Original line number Diff line number Diff line Loading @@ -1591,6 +1591,7 @@ public class SettingsProvider extends ContentProvider { private boolean isGlobalOrSecureSettingRestrictedForUser(String setting, int userId, String value, int callingUid) { String restriction; boolean checkAllUser = false; switch (setting) { case Settings.Secure.LOCATION_MODE: // Note LOCATION_MODE will be converted into LOCATION_PROVIDERS_ALLOWED Loading Loading @@ -1656,6 +1657,12 @@ public class SettingsProvider extends ContentProvider { restriction = UserManager.DISALLOW_AMBIENT_DISPLAY; break; case Global.LOCATION_GLOBAL_KILL_SWITCH: if ("0".equals(value)) return false; restriction = UserManager.DISALLOW_CONFIG_LOCATION; checkAllUser = true; break; default: if (setting != null && setting.startsWith(Settings.Global.DATA_ROAMING)) { if ("0".equals(value)) return false; Loading @@ -1665,8 +1672,12 @@ public class SettingsProvider extends ContentProvider { return false; } if (checkAllUser) { return mUserManager.hasUserRestrictionOnAnyUser(restriction); } else { return mUserManager.hasUserRestriction(restriction, UserHandle.of(userId)); } } private int resolveOwningUserIdForSecureSettingLocked(int userId, String setting) { return resolveOwningUserIdLocked(userId, sSecureCloneToManagedSettings, setting); Loading
services/core/java/com/android/server/pm/UserManagerService.java +17 −0 Original line number Diff line number Diff line Loading @@ -1486,6 +1486,23 @@ public class UserManagerService extends IUserManager.Stub { return restrictions != null && restrictions.getBoolean(restrictionKey); } /** @return if any user has the given restriction. */ @Override public boolean hasUserRestrictionOnAnyUser(String restrictionKey) { if (!UserRestrictionsUtils.isValidRestriction(restrictionKey)) { return false; } final List<UserInfo> users = getUsers(/* excludeDying= */ true); for (int i = 0; i < users.size(); i++) { final int userId = users.get(i).id; Bundle restrictions = getEffectiveUserRestrictions(userId); if (restrictions != null && restrictions.getBoolean(restrictionKey)) { return true; } } return false; } /** * @hide * Loading
services/core/java/com/android/server/pm/UserRestrictionsUtils.java +10 −0 Original line number Diff line number Diff line Loading @@ -33,6 +33,7 @@ import android.os.UserHandle; import android.os.UserManager; import android.os.UserManagerInternal; import android.provider.Settings; import android.provider.Settings.Global; import android.telephony.SubscriptionInfo; import android.telephony.SubscriptionManager; import android.util.Log; Loading Loading @@ -581,6 +582,15 @@ public class UserRestrictionsUtils { Settings.Secure.DOZE_PULSE_ON_DOUBLE_TAP, "0"); } break; case UserManager.DISALLOW_CONFIG_LOCATION: // When DISALLOW_CONFIG_LOCATION is set on any user, we undo the global // kill switch. if (newValue) { android.provider.Settings.Global.putString( context.getContentResolver(), Global.LOCATION_GLOBAL_KILL_SWITCH, "0"); } break; } } finally { Binder.restoreCallingIdentity(id); Loading