Merge "Create DISALLOW_{ADD,REMOVE}_MANAGED_PROFILE user restrictions"

This commit is contained in:
Esteban Talavera
2016-12-14 19:16:23 +00:00
committed by Android (Google) Code Review
11 changed files with 228 additions and 75 deletions

View File

@@ -1254,8 +1254,8 @@ public class DevicePolicyManager {
/**
* Result code for {@link checkProvisioningPreCondition}.
*
* <p>Returned for {@link #ACTION_PROVISION_MANAGED_PROFILE} when the device has a device owner
* and the user is a system user on a split system user device.
* <p>Returned for {@link #ACTION_PROVISION_MANAGED_PROFILE} when the device the user is a
* system user on a split system user device.
*
* @hide
*/

View File

@@ -252,6 +252,20 @@ public class UserManager {
*/
public static final String DISALLOW_REMOVE_USER = "no_remove_user";
/**
* Specifies if managed profiles of this user can be removed, other than by its profile owner.
* The default value is <code>false</code>.
* <p>
* This restriction can only be set by device owners.
*
* <p>Key for user restrictions.
* <p>Type: Boolean
* @see DevicePolicyManager#addUserRestriction(ComponentName, String)
* @see DevicePolicyManager#clearUserRestriction(ComponentName, String)
* @see #getUserRestrictions()
*/
public static final String DISALLOW_REMOVE_MANAGED_PROFILE = "no_remove_managed_profile";
/**
* Specifies if a user is disallowed from enabling or
* accessing debugging features. The default value is <code>false</code>.
@@ -322,8 +336,8 @@ public class UserManager {
public static final String DISALLOW_FACTORY_RESET = "no_factory_reset";
/**
* Specifies if a user is disallowed from adding new users and
* profiles. This can only be set by device owners and profile owners on the primary user.
* Specifies if a user is disallowed from adding new users. This can only be set by device
* owners and profile owners on the primary user.
* The default value is <code>false</code>.
* <p>This restriction has no effect on secondary users and managed profiles since only the
* primary user can add other users.
@@ -336,6 +350,20 @@ public class UserManager {
*/
public static final String DISALLOW_ADD_USER = "no_add_user";
/**
* Specifies if a user is disallowed from adding managed profiles.
* <p>The default value for an unmanaged user is <code>false</code>.
* For users with a device owner set, the default is <code>true</code>
* <p>This restriction can only be set by device owners.
*
* <p>Key for user restrictions.
* <p>Type: Boolean
* @see DevicePolicyManager#addUserRestriction(ComponentName, String)
* @see DevicePolicyManager#clearUserRestriction(ComponentName, String)
* @see #getUserRestrictions()
*/
public static final String DISALLOW_ADD_MANAGED_PROFILE = "no_add_managed_profile";
/**
* Specifies if a user is disallowed from disabling application
* verification. The default value is <code>false</code>.
@@ -1406,7 +1434,7 @@ public class UserManager {
/**
* Similar to {@link #createProfileForUser(String, int, int, String[])}
* except bypassing the checking of {@link UserManager#DISALLOW_ADD_USER}.
* except bypassing the checking of {@link UserManager#DISALLOW_ADD_MANAGED_PROFILE}.
* Requires {@link android.Manifest.permission#MANAGE_USERS} permission.
*
* @see #createProfileForUser(String, int, int, String[])

View File

@@ -120,7 +120,8 @@ public abstract class UserManagerInternal {
public abstract void onEphemeralUserStop(int userId);
/**
* Same as UserManager.createUser(), but bypasses the check for DISALLOW_ADD_USER.
* Same as UserManager.createUser(), but bypasses the check for
* {@link UserManager#DISALLOW_ADD_USER} and {@link UserManager#DISALLOW_ADD_MANAGED_PROFILE}
*
* <p>Called by the {@link com.android.server.devicepolicy.DevicePolicyManagerService} when
* createAndManageUser is called by the device owner.
@@ -129,7 +130,8 @@ public abstract class UserManagerInternal {
/**
* Same as {@link UserManager#removeUser(int userHandle)}, but bypasses the check for
* {@link UserManager#DISALLOW_REMOVE_USER} and does not require the
* {@link UserManager#DISALLOW_REMOVE_USER} and
* {@link UserManager#DISALLOW_REMOVE_MANAGED_PROFILE} and does not require the
* {@link android.Manifest.permission#MANAGE_USERS} permission.
*/
public abstract boolean removeUserEvenWhenDisallowed(int userId);