Put the current user to mUsers in UserManagerServiceTest.
Because of the way we construct UMS from UserManagerServiceTest, it can not populate mUsers with existing users. Because it can not find userlist.xml and fallback to single user. And the test methods which try to set a restriction for the current user fail because UMS.setUserRestriction fails with "Cannot set user restriction no_user_switch. User with id 10 does not exist." error. We're fixing this issue by manually adding the current user to UMS.mUsers via mUserManagerService.putUserInfo() method. Bug: 289517147 Test: atest UserManagerServiceTest Change-Id: I6d17fe1fc34408acde8f6b7233a7cf96a5dbfa45
This commit is contained in:
@@ -70,6 +70,9 @@ public class UserManagerServiceTest {
|
||||
|
||||
LocalServices.removeServiceForTest(UserManagerInternal.class);
|
||||
mUserManagerService = new UserManagerService(InstrumentationRegistry.getContext());
|
||||
// Put the current user to mUsers. UMS can't find userlist.xml, and fallbackToSingleUserLP.
|
||||
mUserManagerService.putUserInfo(
|
||||
new UserInfo(ActivityManager.getCurrentUser(), "Current User", 0));
|
||||
|
||||
restrictionsFile = new File(mContext.getCacheDir(), "restrictions.xml");
|
||||
restrictionsFile.delete();
|
||||
|
||||
Reference in New Issue
Block a user