UserTypeFactory configurable setMaxAllowed

We provide support in config_user_types.xml to change the max number of
users allowed of a given user type. This could, e.g., allow multiple
Guest users. Note that even though it can be configured, that doesn't
mean it'll work - to have more than one Guest user additional work in
UMS and other places would be required.

Test: atest UserManagerServiceUserTypeTest
Bug: 256690588
Change-Id: I02b212bb9a046bbf5662fea05d833f1717e23327
This commit is contained in:
Adam Bookatz
2022-11-03 15:50:52 -07:00
parent 9d8f4ade3d
commit 4db1b9c125
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

@@ -388,6 +388,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

@@ -347,6 +347,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()));