[Multi-user] Decouple UserBMS and BMS creation
The BMS constructor is now only responsible for setting up the system
service. User registration logic is moved to its own helper that
Trampoline calls during a user unlock callback.
** Logic **
All IBackupManager methods that BMS implements now use bookkeeping to
get the UserBMS instance to act on. Currently the system user instance
is hardcoded in most methods as we don't pass in the user id parameter
(except for a few added in ag/5667585).
If these methods are called on a non-registered user, we log and return
a default value.
** Tests **
Each IBackupManager method now has four corresponding tests:
1) Permission denial test: No INTERACT_ACROSS_USERS_FULL permission +
non-calling user id = security exception (added in ag/5667585, only for
methods that take in an user id param currently).
2) Permission grant test: INTERACT_ACROSS_USERS_FULL permission +
non-calling user id = call forwarded.
3) Registered user test: Passing an user id that has a corresponding
UserBMS instance -> delegate call to that UserBMS instance.
4) Unknown user test: Passing an user id that has no corresponding
UserBMS instance -> no call forwarded.
These tests will be updated when more methods take in an user id param.
Bug: 120212806
Test: 1) atest RunFrameworksServicesRoboTests
2) Unlock system user -> starts service, registers transports
3) adb shell bmgr flows
4) atest TrampolineTest
5) CTS + GTS Backup test cases
6) SUW + Cloud restore; D2D
Change-Id: Ic04f754c75af905ee34c609063c08406e23671d5
4 files changed