Minor adjustements on user visibility internals:

- Added new UserManagerInternal.unassignUserFromDisplay() method
 (instead of calling assignUserToDisplay() passing INVALID_DISPLAY)
- Refactored UserManagerService to:
  - set mUsersOnSecondaryDisplays on constructor (it will be null
    if device doesn't support it)
  - change methods that use mUsersOnSecondaryDisplays to explicitly
    check for the main display case first (which is the most common
    usage) and ignore the rest when it's not supported
- Moved all related logic from UserController to UserManagerService
- Removed extra checks for default display
- Created a DEBUG_MUMD logging guard
- Unassign user from display earlier when stopping it
- Use separate lock for mUsersOnSecondaryDisplays

These changes not only makes the code simpler, but would allow the
logic to be refactored into a helper class (which could be more
unit tested in isolation).

Test: atest CtsMultiUserTestCases:android.multiuser.cts.UserManagerTest\
 CtsMultiUserTestCases:android.multiuser.cts.MultipleUsersOnMultipleDisplaysTest

Bug: 239982558
Fixes: 243869778
Fixes: 239824814
Fixes: 244331360

Change-Id: I8df66f936825813b71a141acdbb6cd3771520fc9
3 files changed