Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 47bc312b authored by Eric Biggers's avatar Eric Biggers Committed by Gerrit Code Review
Browse files

Merge "Removing non SYSTEM user before running systemUserOnlyTest" into main

parents e4f8c858 c3b2cb5f
Loading
Loading
Loading
Loading
+9 −0
Original line number Diff line number Diff line
@@ -320,11 +320,20 @@ public final class UserManagerServiceTest {
    @Test
    public void testGetBootUser_Headless_ThrowsIfOnlySystemUserExists() throws Exception {
        setSystemUserHeadless(true);
        removeNonSystemUsers();

        assertThrows(UserManager.CheckedUserOperationException.class,
                () -> mUmi.getBootUser(/* waitUntilSet= */ false));
    }

    private void removeNonSystemUsers() {
        for (UserInfo user : mUms.getUsers(true)) {
            if (!user.getUserHandle().isSystem()) {
                mUms.removeUserInfo(user.id);
            }
        }
    }

    private void mockCurrentUser(@UserIdInt int userId) {
        mockGetLocalService(ActivityManagerInternal.class, mActivityManagerInternal);