diff --git a/src/com/android/settings/Utils.java b/src/com/android/settings/Utils.java index b9d104a8e4e..a7e0eece410 100644 --- a/src/com/android/settings/Utils.java +++ b/src/com/android/settings/Utils.java @@ -525,7 +525,7 @@ public final class Utils extends com.android.settingslib.Utils { * @return UserInfo of the user or null for non-existent user. */ public static UserInfo getExistingUser(UserManager userManager, UserHandle checkUser) { - final List users = userManager.getUsers(true /* excludeDying */); + final List users = userManager.getAliveUsers(); final int checkUserId = checkUser.getIdentifier(); for (UserInfo user : users) { if (user.id == checkUserId) { diff --git a/src/com/android/settings/applications/appinfo/AppInfoDashboardFragment.java b/src/com/android/settings/applications/appinfo/AppInfoDashboardFragment.java index 7aad2452b05..6817bd6ca50 100755 --- a/src/com/android/settings/applications/appinfo/AppInfoDashboardFragment.java +++ b/src/com/android/settings/applications/appinfo/AppInfoDashboardFragment.java @@ -526,7 +526,7 @@ public class AppInfoDashboardFragment extends DashboardFragment @VisibleForTesting int getNumberOfUserWithPackageInstalled(String packageName) { - final List userInfos = mUserManager.getUsers(true); + final List userInfos = mUserManager.getAliveUsers(); int count = 0; for (final UserInfo userInfo : userInfos) { diff --git a/src/com/android/settings/users/UserDetailsSettings.java b/src/com/android/settings/users/UserDetailsSettings.java index 897b3c7b83a..53d984974bf 100644 --- a/src/com/android/settings/users/UserDetailsSettings.java +++ b/src/com/android/settings/users/UserDetailsSettings.java @@ -309,7 +309,7 @@ public class UserDetailsSettings extends SettingsPreferenceFragment // Update the guest's restrictions, if there is a guest // TODO: Maybe setDefaultGuestRestrictions() can internally just set the restrictions // on any existing guest rather than do it here with multiple Binder calls. - List users = mUserManager.getUsers(true); + List users = mUserManager.getAliveUsers(); for (UserInfo user : users) { if (user.isGuest()) { UserHandle userHandle = UserHandle.of(user.id); diff --git a/src/com/android/settings/users/UserSettings.java b/src/com/android/settings/users/UserSettings.java index 9669190ec96..8bfac9108da 100644 --- a/src/com/android/settings/users/UserSettings.java +++ b/src/com/android/settings/users/UserSettings.java @@ -820,7 +820,7 @@ public class UserSettings extends SettingsPreferenceFragment if (context == null) { return; } - final List users = mUserManager.getUsers(true); + final List users = mUserManager.getAliveUsers(); final ArrayList missingIcons = new ArrayList<>(); final ArrayList userPreferences = new ArrayList<>(); diff --git a/tests/robotests/src/com/android/settings/applications/appinfo/AppInfoDashboardFragmentTest.java b/tests/robotests/src/com/android/settings/applications/appinfo/AppInfoDashboardFragmentTest.java index e46cd06afe6..95d765935a9 100644 --- a/tests/robotests/src/com/android/settings/applications/appinfo/AppInfoDashboardFragmentTest.java +++ b/tests/robotests/src/com/android/settings/applications/appinfo/AppInfoDashboardFragmentTest.java @@ -297,7 +297,7 @@ public final class AppInfoDashboardFragmentTest { final List userInfos = new ArrayList<>(); userInfos.add(new UserInfo(userID1, "User1", UserInfo.FLAG_PRIMARY)); userInfos.add(new UserInfo(userID2, "yue", UserInfo.FLAG_GUEST)); - when(mUserManager.getUsers(true)).thenReturn(userInfos); + when(mUserManager.getAliveUsers()).thenReturn(userInfos); final ApplicationInfo appInfo = new ApplicationInfo(); appInfo.flags = ApplicationInfo.FLAG_INSTALLED; when(mPackageManager.getApplicationInfoAsUser( @@ -320,7 +320,7 @@ public final class AppInfoDashboardFragmentTest { final List userInfos = new ArrayList<>(); userInfos.add(new UserInfo(userID1, "User1", UserInfo.FLAG_PRIMARY)); userInfos.add(new UserInfo(userID2, "yue", UserInfo.FLAG_GUEST)); - when(mUserManager.getUsers(true)).thenReturn(userInfos); + when(mUserManager.getAliveUsers()).thenReturn(userInfos); final ApplicationInfo appInfo = new ApplicationInfo(); appInfo.flags = ApplicationInfo.FLAG_INSTALLED; when(mPackageManager.getApplicationInfoAsUser( diff --git a/tests/robotests/src/com/android/settings/users/UserSettingsTest.java b/tests/robotests/src/com/android/settings/users/UserSettingsTest.java index 2057788fb3a..27c90b02928 100644 --- a/tests/robotests/src/com/android/settings/users/UserSettingsTest.java +++ b/tests/robotests/src/com/android/settings/users/UserSettingsTest.java @@ -23,7 +23,6 @@ import static android.os.UserManager.SWITCHABILITY_STATUS_USER_SWITCH_DISALLOWED import static com.google.common.truth.Truth.assertThat; import static org.mockito.ArgumentMatchers.any; -import static org.mockito.ArgumentMatchers.anyBoolean; import static org.mockito.ArgumentMatchers.anyInt; import static org.mockito.ArgumentMatchers.eq; import static org.mockito.ArgumentMatchers.notNull; @@ -575,7 +574,7 @@ public class UserSettingsTest { verify(mUserManager, never()).getUserIcon(anyInt()); // updateUserList should be called only once - verify(mUserManager).getUsers(true); + verify(mUserManager).getAliveUsers(); } @Test @@ -592,7 +591,7 @@ public class UserSettingsTest { verify(mUserManager).getUserIcon(ACTIVE_USER_ID); // updateUserList should be called another time after loading the icons - verify(mUserManager, times(2)).getUsers(true); + verify(mUserManager, times(2)).getAliveUsers(); } @Test @@ -672,7 +671,7 @@ public class UserSettingsTest { private void givenUsers(UserInfo... userInfo) { List users = Arrays.asList(userInfo); doReturn(users).when(mUserManager).getUsers(); - doReturn(users).when(mUserManager).getUsers(anyBoolean()); + doReturn(users).when(mUserManager).getAliveUsers(); } private static void removeFlag(UserInfo userInfo, int flag) {