Maximum user limits, handled consistently
Makes the various methods related to max users (what is the max, have we reached it, how many more are allowed, actual creation procedure) consistent between each other, and across user types, with a single underlying source-of-truth method (getRemainingCreatableUserCount). config_multiuserMaximumUsers now serves as the actual device max, without making the situation exceptional for certain users. With both flags enabled (see below), this even includes Guest users. The goal is that OEMs can set this value to be very high (based only on storage, not UX considerations), and to instead use config_user_types.max-allowed to achieve fine-grained specification of maxima per user-type (based on UX). This will allow better support for multiple profile types, without compromising the full user experience. Some changes: * config_multiuserMaximumUsers - no longer has a bunch of exceptions, and now serves as the actual device max * canAddMoreUsers - now is correct for all user types, including demo, managed profile, and private profiles * getRemainingCreatableUserCount - simplified logic by amalgamating userType considerations into getMaxSupportedUsersOfType. Now takes into account all feature support too (including for private profiles). Serves as ultimate source-of-truth! * getRemainingCreatableProfileCount - simplified and now calls getRemainingCreatableUserCount * createUser - is now consistent with the other methods * canAddPrivateProfile - no change to behaviour, but is now integrated into the other methods properly Two flags are used to gate these changes: * android.multiuser.consistentMaxUsers Mostly just a refactor, to make a single source-of-truth for how to calculate user limits. There are technically some effects on Demo user creation, since it no longer inconsistently gets a partial exemption from the limits, but that doesn't really matter since Demo users don't get used that way in practice. * android.multiuser.consistentMaxUsersIncludingGuest Makes it so that Guest users are now subject to the overall max, just like all other user types. This would have the effect of decreasing the overall number of users that can be created, since Guests now count. This should be balanced by changing the config_multiuserMaximumUsers value, but since this requires an active change, we guard this with a separate flag. Note: preCreated users no longer are allowed to exceed their user type max. This isn't particularly desired, but precreated users are completely deprecated (see bugs 253528462 and 282987119), so there isn't any point added to the complexity to exempt them, and one could argue either way. No need to flag gate this. Flag: android.multiuser.consistent_max_users Flag: android.multiuser.consistent_max_users_including_guests Flag: android.multiuser.max_users_in_car_is_for_secondary Bug: 394178333 Test: atest FrameworksServicesTests:com.android.server.pm.UserManagerTest#testAddTooManyUsers_Secondary Test: atest FrameworksServicesTests:com.android.server.pm.UserManagerTest#testAddTooManyUsers_Guest Test: atest FrameworksServicesTests:com.android.server.pm.UserManagerTest#testAddTooManyUsers_Demo Test: atest FrameworksServicesTests:com.android.server.pm.UserManagerTest Test: atest FrameworksMockingServicesTests:com.android.server.pm.UserManagerServiceMockedTest Change-Id: I117659792735c46c2982b4e895d6629f1a9c8fa4
Loading
Please register or sign in to comment