Merge "UserTypeFactory configurable setMaxAllowed"

This commit is contained in:
Adam Bookatz
2022-11-14 19:21:18 +00:00
committed by Android (Google) Code Review
4 changed files with 6 additions and 1 deletions

View File

@@ -83,6 +83,8 @@ Supported optional properties (to be used as shown in the example above) are as
For profile and full users:
default-restrictions (with values defined in UserRestrictionUtils.USER_RESTRICTIONS)
enabled
user-properties
max-allowed
For profile users only:
max-allowed-per-parent
icon-badge

View File

@@ -397,6 +397,7 @@ public final class UserTypeFactory {
}
setIntAttribute(parser, "enabled", builder::setEnabled);
setIntAttribute(parser, "max-allowed", builder::setMaxAllowed);
// Process child elements.
final int depth = parser.getDepth();

View File

@@ -16,7 +16,8 @@
<user-types>
<full-type
name='android.test.1'
max-allowed-per-parent='12' >
max-allowed-per-parent='12'
max-allowed='17' >
<default-restrictions no_remove_user='true' no_bluetooth='true' />
<badge-colors>
<item res='@*android:color/profile_badge_1' />

View File

@@ -355,6 +355,7 @@ public class UserManagerServiceUserTypeTest {
UserTypeDetails details = builders.get(userTypeFull).createUserTypeDetails();
assertEquals(UNLIMITED_NUMBER_OF_USERS, details.getMaxAllowedPerParent());
assertFalse(details.isEnabled());
assertEquals(17, details.getMaxAllowed());
assertTrue(UserRestrictionsUtils.areEqual(
makeRestrictionsBundle("no_remove_user", "no_bluetooth"),
details.getDefaultRestrictions()));