Loading api/current.txt +3 −0 Original line number Diff line number Diff line Loading @@ -16814,6 +16814,9 @@ package android.os { field public static final java.lang.String DISALLOW_MODIFY_ACCOUNTS = "no_modify_accounts"; field public static final java.lang.String DISALLOW_SHARE_LOCATION = "no_share_location"; field public static final java.lang.String DISALLOW_UNINSTALL_APPS = "no_uninstall_apps"; field public static final java.lang.String DISALLOW_INSTALL_UNKNOWN_SOURCES = "no_install_unknown_sources"; field public static final java.lang.String DISALLOW_CONFIG_BLUETOOTH = "no_config_bluetooth"; field public static final java.lang.String DISALLOW_USB_FILE_TRANSFER = "no_usb_file_transfer"; } public abstract class Vibrator { core/java/android/os/UserManager.java +46 −9 Original line number Diff line number Diff line Loading @@ -86,8 +86,42 @@ public class UserManager { * @see #setUserRestrictions(Bundle) * @see #getUserRestrictions() */ public static final String DISALLOW_SHARE_LOCATION = "no_share_location"; /** * Key for user restrictions. Specifies if a user is disallowed from enabling the * "Unknown Sources" setting, that allows installation of apps from unknown sources. * The default value is <code>false</code>. * <p/> * Type: Boolean * @see #setUserRestrictions(Bundle) * @see #getUserRestrictions() */ public static final String DISALLOW_INSTALL_UNKNOWN_SOURCES = "no_install_unknown_sources"; /** * Key for user restrictions. Specifies if a user is disallowed from configuring bluetooth. * The default value is <code>false</code>. * <p/> * Type: Boolean * @see #setUserRestrictions(Bundle) * @see #getUserRestrictions() */ public static final String DISALLOW_CONFIG_BLUETOOTH = "no_config_bluetooth"; /** * Key for user restrictions. Specifies if a user is disallowed from transferring files over * USB. The default value is <code>false</code>. * <p/> * Type: Boolean * @see #setUserRestrictions(Bundle) * @see #getUserRestrictions() */ public static final String DISALLOW_USB_FILE_TRANSFER = "no_usb_file_transfer"; /** @hide */ public UserManager(Context context, IUserManager service) { mService = service; Loading Loading @@ -271,6 +305,16 @@ public class UserManager { setUserRestrictions(bundle, userHandle); } /** * @hide * Returns whether the current user has been disallowed from performing certain actions * or setting certain settings. * @param restrictionKey the string key representing the restriction */ public boolean hasUserRestriction(String restrictionKey) { return getUserRestrictions().getBoolean(restrictionKey, false); } /** * 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 Loading @@ -508,13 +552,6 @@ public class UserManager { return -1; } /** * Returns whether the current user is allowed to toggle location sharing settings. * @hide */ public boolean isLocationSharingToggleAllowed() { return !getUserRestrictions().getBoolean(DISALLOW_SHARE_LOCATION, false); } /** * @hide Loading packages/SettingsProvider/src/com/android/providers/settings/SettingsHelper.java +2 −2 Original line number Diff line number Diff line Loading @@ -98,7 +98,7 @@ public class SettingsHelper { private void setGpsLocation(String value) { UserManager um = (UserManager) mContext.getSystemService(Context.USER_SERVICE); if (! um.isLocationSharingToggleAllowed()) { if (um.hasUserRestriction(UserManager.DISALLOW_SHARE_LOCATION)) { return; } final String GPS = LocationManager.GPS_PROVIDER; Loading services/java/com/android/server/accounts/AccountManagerService.java +4 −6 Original line number Diff line number Diff line Loading @@ -906,6 +906,7 @@ public class AccountManagerService } } @Override public void invalidateAuthToken(String accountType, String authToken) { if (Log.isLoggable(TAG, Log.VERBOSE)) { Log.v(TAG, "invalidateAuthToken: accountType " + accountType Loading Loading @@ -1426,8 +1427,7 @@ public class AccountManagerService checkManageAccountsPermission(); // Is user disallowed from modifying accounts? if (getUserManager().getUserRestrictions(Binder.getCallingUserHandle()) .getBoolean(UserManager.DISALLOW_MODIFY_ACCOUNTS, false)) { if (getUserManager().hasUserRestriction(UserManager.DISALLOW_MODIFY_ACCOUNTS)) { try { response.onError(AccountManager.ERROR_CODE_USER_RESTRICTED, "User is not allowed to add an account!"); Loading Loading @@ -2570,9 +2570,7 @@ public class AccountManagerService private boolean canUserModifyAccounts(int callingUid) { if (callingUid != android.os.Process.myUid()) { Bundle restrictions = getUserManager().getUserRestrictions( new UserHandle(UserHandle.getUserId(callingUid))); if (restrictions.getBoolean(UserManager.DISALLOW_MODIFY_ACCOUNTS, false)) { if (getUserManager().hasUserRestriction(UserManager.DISALLOW_MODIFY_ACCOUNTS)) { return false; } } Loading services/java/com/android/server/pm/UserManagerService.java +8 −1 Original line number Diff line number Diff line Loading @@ -26,7 +26,6 @@ import android.content.BroadcastReceiver; import android.content.Context; import android.content.Intent; import android.content.RestrictionEntry; import android.content.SharedPreferences; import android.content.pm.PackageManager; import android.content.pm.PackageManager.NameNotFoundException; import android.content.pm.UserInfo; Loading Loading @@ -619,6 +618,10 @@ public class UserManagerService extends IUserManager.Stub { writeBoolean(serializer, restrictions, UserManager.DISALLOW_INSTALL_APPS); writeBoolean(serializer, restrictions, UserManager.DISALLOW_UNINSTALL_APPS); writeBoolean(serializer, restrictions, UserManager.DISALLOW_SHARE_LOCATION); writeBoolean(serializer, restrictions, UserManager.DISALLOW_INSTALL_UNKNOWN_SOURCES); writeBoolean(serializer, restrictions, UserManager.DISALLOW_CONFIG_BLUETOOTH); writeBoolean(serializer, restrictions, UserManager.DISALLOW_USB_FILE_TRANSFER); serializer.endTag(null, TAG_RESTRICTIONS); } serializer.endTag(null, TAG_USER); Loading Loading @@ -735,6 +738,10 @@ public class UserManagerService extends IUserManager.Stub { readBoolean(parser, restrictions, UserManager.DISALLOW_INSTALL_APPS); readBoolean(parser, restrictions, UserManager.DISALLOW_UNINSTALL_APPS); readBoolean(parser, restrictions, UserManager.DISALLOW_SHARE_LOCATION); readBoolean(parser, restrictions, UserManager.DISALLOW_INSTALL_UNKNOWN_SOURCES); readBoolean(parser, restrictions, UserManager.DISALLOW_CONFIG_BLUETOOTH); readBoolean(parser, restrictions, UserManager.DISALLOW_USB_FILE_TRANSFER); } } } Loading Loading
api/current.txt +3 −0 Original line number Diff line number Diff line Loading @@ -16814,6 +16814,9 @@ package android.os { field public static final java.lang.String DISALLOW_MODIFY_ACCOUNTS = "no_modify_accounts"; field public static final java.lang.String DISALLOW_SHARE_LOCATION = "no_share_location"; field public static final java.lang.String DISALLOW_UNINSTALL_APPS = "no_uninstall_apps"; field public static final java.lang.String DISALLOW_INSTALL_UNKNOWN_SOURCES = "no_install_unknown_sources"; field public static final java.lang.String DISALLOW_CONFIG_BLUETOOTH = "no_config_bluetooth"; field public static final java.lang.String DISALLOW_USB_FILE_TRANSFER = "no_usb_file_transfer"; } public abstract class Vibrator {
core/java/android/os/UserManager.java +46 −9 Original line number Diff line number Diff line Loading @@ -86,8 +86,42 @@ public class UserManager { * @see #setUserRestrictions(Bundle) * @see #getUserRestrictions() */ public static final String DISALLOW_SHARE_LOCATION = "no_share_location"; /** * Key for user restrictions. Specifies if a user is disallowed from enabling the * "Unknown Sources" setting, that allows installation of apps from unknown sources. * The default value is <code>false</code>. * <p/> * Type: Boolean * @see #setUserRestrictions(Bundle) * @see #getUserRestrictions() */ public static final String DISALLOW_INSTALL_UNKNOWN_SOURCES = "no_install_unknown_sources"; /** * Key for user restrictions. Specifies if a user is disallowed from configuring bluetooth. * The default value is <code>false</code>. * <p/> * Type: Boolean * @see #setUserRestrictions(Bundle) * @see #getUserRestrictions() */ public static final String DISALLOW_CONFIG_BLUETOOTH = "no_config_bluetooth"; /** * Key for user restrictions. Specifies if a user is disallowed from transferring files over * USB. The default value is <code>false</code>. * <p/> * Type: Boolean * @see #setUserRestrictions(Bundle) * @see #getUserRestrictions() */ public static final String DISALLOW_USB_FILE_TRANSFER = "no_usb_file_transfer"; /** @hide */ public UserManager(Context context, IUserManager service) { mService = service; Loading Loading @@ -271,6 +305,16 @@ public class UserManager { setUserRestrictions(bundle, userHandle); } /** * @hide * Returns whether the current user has been disallowed from performing certain actions * or setting certain settings. * @param restrictionKey the string key representing the restriction */ public boolean hasUserRestriction(String restrictionKey) { return getUserRestrictions().getBoolean(restrictionKey, false); } /** * 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 Loading @@ -508,13 +552,6 @@ public class UserManager { return -1; } /** * Returns whether the current user is allowed to toggle location sharing settings. * @hide */ public boolean isLocationSharingToggleAllowed() { return !getUserRestrictions().getBoolean(DISALLOW_SHARE_LOCATION, false); } /** * @hide Loading
packages/SettingsProvider/src/com/android/providers/settings/SettingsHelper.java +2 −2 Original line number Diff line number Diff line Loading @@ -98,7 +98,7 @@ public class SettingsHelper { private void setGpsLocation(String value) { UserManager um = (UserManager) mContext.getSystemService(Context.USER_SERVICE); if (! um.isLocationSharingToggleAllowed()) { if (um.hasUserRestriction(UserManager.DISALLOW_SHARE_LOCATION)) { return; } final String GPS = LocationManager.GPS_PROVIDER; Loading
services/java/com/android/server/accounts/AccountManagerService.java +4 −6 Original line number Diff line number Diff line Loading @@ -906,6 +906,7 @@ public class AccountManagerService } } @Override public void invalidateAuthToken(String accountType, String authToken) { if (Log.isLoggable(TAG, Log.VERBOSE)) { Log.v(TAG, "invalidateAuthToken: accountType " + accountType Loading Loading @@ -1426,8 +1427,7 @@ public class AccountManagerService checkManageAccountsPermission(); // Is user disallowed from modifying accounts? if (getUserManager().getUserRestrictions(Binder.getCallingUserHandle()) .getBoolean(UserManager.DISALLOW_MODIFY_ACCOUNTS, false)) { if (getUserManager().hasUserRestriction(UserManager.DISALLOW_MODIFY_ACCOUNTS)) { try { response.onError(AccountManager.ERROR_CODE_USER_RESTRICTED, "User is not allowed to add an account!"); Loading Loading @@ -2570,9 +2570,7 @@ public class AccountManagerService private boolean canUserModifyAccounts(int callingUid) { if (callingUid != android.os.Process.myUid()) { Bundle restrictions = getUserManager().getUserRestrictions( new UserHandle(UserHandle.getUserId(callingUid))); if (restrictions.getBoolean(UserManager.DISALLOW_MODIFY_ACCOUNTS, false)) { if (getUserManager().hasUserRestriction(UserManager.DISALLOW_MODIFY_ACCOUNTS)) { return false; } } Loading
services/java/com/android/server/pm/UserManagerService.java +8 −1 Original line number Diff line number Diff line Loading @@ -26,7 +26,6 @@ import android.content.BroadcastReceiver; import android.content.Context; import android.content.Intent; import android.content.RestrictionEntry; import android.content.SharedPreferences; import android.content.pm.PackageManager; import android.content.pm.PackageManager.NameNotFoundException; import android.content.pm.UserInfo; Loading Loading @@ -619,6 +618,10 @@ public class UserManagerService extends IUserManager.Stub { writeBoolean(serializer, restrictions, UserManager.DISALLOW_INSTALL_APPS); writeBoolean(serializer, restrictions, UserManager.DISALLOW_UNINSTALL_APPS); writeBoolean(serializer, restrictions, UserManager.DISALLOW_SHARE_LOCATION); writeBoolean(serializer, restrictions, UserManager.DISALLOW_INSTALL_UNKNOWN_SOURCES); writeBoolean(serializer, restrictions, UserManager.DISALLOW_CONFIG_BLUETOOTH); writeBoolean(serializer, restrictions, UserManager.DISALLOW_USB_FILE_TRANSFER); serializer.endTag(null, TAG_RESTRICTIONS); } serializer.endTag(null, TAG_USER); Loading Loading @@ -735,6 +738,10 @@ public class UserManagerService extends IUserManager.Stub { readBoolean(parser, restrictions, UserManager.DISALLOW_INSTALL_APPS); readBoolean(parser, restrictions, UserManager.DISALLOW_UNINSTALL_APPS); readBoolean(parser, restrictions, UserManager.DISALLOW_SHARE_LOCATION); readBoolean(parser, restrictions, UserManager.DISALLOW_INSTALL_UNKNOWN_SOURCES); readBoolean(parser, restrictions, UserManager.DISALLOW_CONFIG_BLUETOOTH); readBoolean(parser, restrictions, UserManager.DISALLOW_USB_FILE_TRANSFER); } } } Loading