Loading services/core/java/com/android/server/pm/UserManagerService.java +1 −12 Original line number Diff line number Diff line Loading @@ -1371,7 +1371,7 @@ public class UserManagerService extends IUserManager.Stub { for (int i = 0; i < userSize; i++) { UserInfo ui = mUsers.valueAt(i).info; if ((excludePartial && ui.partial) || (excludeDying && isDyingLU(ui)) || (excludeDying && mRemovingUserIds.get(ui.id)) || (excludePreCreated && ui.preCreated)) { continue; } Loading @@ -1381,17 +1381,6 @@ public class UserManagerService extends IUserManager.Stub { } } @GuardedBy("mUsersLock") private boolean isDyingLU(UserInfo ui) { if (mRemovingUserIds.get(ui.id)) { return true; } if (ui.isEphemeral() && ui.isInitialized() && ui.id != getCurrentUserId()) { return true; } return false; } @Override public List<UserInfo> getProfiles(@UserIdInt int userId, boolean enabledOnly) { boolean returnFullInfo; Loading services/tests/mockingservicestests/src/com/android/server/pm/UserManagerServiceTest.java +0 −43 Original line number Diff line number Diff line Loading @@ -777,49 +777,6 @@ public final class UserManagerServiceTest { } } @Test public void testGetAliveUsers_shouldExcludeInitialisedEphemeralNonCurrentUsers() { assertWithMessage("Ephemeral user should not exist at all initially") .that(mUmi.getUsers(false).stream().anyMatch(u -> u.id == USER_ID)) .isFalse(); // add an ephemeral full user TestUserData userData = new TestUserData(USER_ID); userData.info.flags = UserInfo.FLAG_FULL | UserInfo.FLAG_EPHEMERAL; addUserData(userData); assertWithMessage("Ephemeral user should exist as alive after being created") .that(mUmi.getUsers(true).stream().anyMatch(u -> u.id == USER_ID)) .isTrue(); // mock switch to the user (mark it as initialized & make it the current user) userData.info.flags |= UserInfo.FLAG_INITIALIZED; mockCurrentUser(USER_ID); assertWithMessage("Ephemeral user should still exist as alive after being switched to") .that(mUmi.getUsers(true).stream().anyMatch(u -> u.id == USER_ID)) .isTrue(); // switch away from the user mockCurrentUser(OTHER_USER_ID); assertWithMessage("Ephemeral user should not exist as alive after getting switched away") .that(mUmi.getUsers(true).stream().anyMatch(u -> u.id == USER_ID)) .isFalse(); assertWithMessage("Ephemeral user should still exist as dying after getting switched away") .that(mUmi.getUsers(false).stream().anyMatch(u -> u.id == USER_ID)) .isTrue(); // finally remove the user mUms.removeUserInfo(USER_ID); assertWithMessage("Ephemeral user should not exist at all after cleanup") .that(mUmi.getUsers(false).stream().anyMatch(u -> u.id == USER_ID)) .isFalse(); } @Test @RequiresFlagsEnabled({android.os.Flags.FLAG_ALLOW_PRIVATE_PROFILE, Flags.FLAG_BLOCK_PRIVATE_SPACE_CREATION, Flags.FLAG_ENABLE_PRIVATE_SPACE_FEATURES}) Loading Loading
services/core/java/com/android/server/pm/UserManagerService.java +1 −12 Original line number Diff line number Diff line Loading @@ -1371,7 +1371,7 @@ public class UserManagerService extends IUserManager.Stub { for (int i = 0; i < userSize; i++) { UserInfo ui = mUsers.valueAt(i).info; if ((excludePartial && ui.partial) || (excludeDying && isDyingLU(ui)) || (excludeDying && mRemovingUserIds.get(ui.id)) || (excludePreCreated && ui.preCreated)) { continue; } Loading @@ -1381,17 +1381,6 @@ public class UserManagerService extends IUserManager.Stub { } } @GuardedBy("mUsersLock") private boolean isDyingLU(UserInfo ui) { if (mRemovingUserIds.get(ui.id)) { return true; } if (ui.isEphemeral() && ui.isInitialized() && ui.id != getCurrentUserId()) { return true; } return false; } @Override public List<UserInfo> getProfiles(@UserIdInt int userId, boolean enabledOnly) { boolean returnFullInfo; Loading
services/tests/mockingservicestests/src/com/android/server/pm/UserManagerServiceTest.java +0 −43 Original line number Diff line number Diff line Loading @@ -777,49 +777,6 @@ public final class UserManagerServiceTest { } } @Test public void testGetAliveUsers_shouldExcludeInitialisedEphemeralNonCurrentUsers() { assertWithMessage("Ephemeral user should not exist at all initially") .that(mUmi.getUsers(false).stream().anyMatch(u -> u.id == USER_ID)) .isFalse(); // add an ephemeral full user TestUserData userData = new TestUserData(USER_ID); userData.info.flags = UserInfo.FLAG_FULL | UserInfo.FLAG_EPHEMERAL; addUserData(userData); assertWithMessage("Ephemeral user should exist as alive after being created") .that(mUmi.getUsers(true).stream().anyMatch(u -> u.id == USER_ID)) .isTrue(); // mock switch to the user (mark it as initialized & make it the current user) userData.info.flags |= UserInfo.FLAG_INITIALIZED; mockCurrentUser(USER_ID); assertWithMessage("Ephemeral user should still exist as alive after being switched to") .that(mUmi.getUsers(true).stream().anyMatch(u -> u.id == USER_ID)) .isTrue(); // switch away from the user mockCurrentUser(OTHER_USER_ID); assertWithMessage("Ephemeral user should not exist as alive after getting switched away") .that(mUmi.getUsers(true).stream().anyMatch(u -> u.id == USER_ID)) .isFalse(); assertWithMessage("Ephemeral user should still exist as dying after getting switched away") .that(mUmi.getUsers(false).stream().anyMatch(u -> u.id == USER_ID)) .isTrue(); // finally remove the user mUms.removeUserInfo(USER_ID); assertWithMessage("Ephemeral user should not exist at all after cleanup") .that(mUmi.getUsers(false).stream().anyMatch(u -> u.id == USER_ID)) .isFalse(); } @Test @RequiresFlagsEnabled({android.os.Flags.FLAG_ALLOW_PRIVATE_PROFILE, Flags.FLAG_BLOCK_PRIVATE_SPACE_CREATION, Flags.FLAG_ENABLE_PRIVATE_SPACE_FEATURES}) Loading