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

Commit b07b092f authored by Felipe Leme's avatar Felipe Leme
Browse files

Refactored some UserManager.getUsers(excludeDying) calls.

Replaced by getUsers() when exlcudeDying was hardcoded to false, or
getUsers(true,  excludeDying, true) when it was a variable.

This refactoring will help replacing getUsers(true) to getAliveUsers().

Bug: 157921703

Test: m
Test: atest atest LockscreenFrpTest LockSettingsServiceTests SyntheticPasswordTests

Change-Id: I139462ab329fe46d8136eae0a39ac071a7e019db
parent 271e922b
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -99,7 +99,7 @@ public class UserPackage {

    private static List<UserInfo> getAllUsers(Context context) {
        UserManager userManager = (UserManager) context.getSystemService(Context.USER_SERVICE);
        return userManager.getUsers(false);
        return userManager.getUsers();
    }

}
+1 −1
Original line number Diff line number Diff line
@@ -3282,7 +3282,7 @@ class StorageManagerService extends IStorageManager.Stub
        final UserManagerInternal umInternal =
                LocalServices.getService(UserManagerInternal.class);

        for (UserInfo user : um.getUsers(false /* includeDying */)) {
        for (UserInfo user : um.getUsers()) {
            final int flags;
            if (umInternal.isUserUnlockingOrUnlocked(user.id)) {
                flags = StorageManager.FLAG_STORAGE_DE | StorageManager.FLAG_STORAGE_CE;
+3 −1
Original line number Diff line number Diff line
@@ -6222,7 +6222,9 @@ public class AppOpsService extends IAppOpsService.Stub {

            int[] users;
            if (userId == UserHandle.USER_ALL) {
                List<UserInfo> liveUsers = UserManager.get(mContext).getUsers(false);
                // TODO(b/157921703): this call is returning all users, not just live ones - we
                // need to either fix the method called, or rename the variable
                List<UserInfo> liveUsers = UserManager.get(mContext).getUsers();

                users = new int[liveUsers.size()];
                for (int i = 0; i < liveUsers.size(); i++) {
+1 −1
Original line number Diff line number Diff line
@@ -484,7 +484,7 @@ class LockSettingsStorage {
    public Map<Integer, List<Long>> listSyntheticPasswordHandlesForAllUsers(String stateName) {
        Map<Integer, List<Long>> result = new ArrayMap<>();
        final UserManager um = UserManager.get(mContext);
        for (UserInfo user : um.getUsers(false)) {
        for (UserInfo user : um.getUsers()) {
            result.put(user.id, listSyntheticPasswordHandlesForUser(stateName, user.id));
        }
        return result;
+1 −2
Original line number Diff line number Diff line
@@ -19,7 +19,6 @@ package com.android.server.locksettings;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;
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.Mockito.doAnswer;
@@ -169,7 +168,7 @@ public abstract class BaseLockSettingsServiceTests {

        final ArrayList<UserInfo> allUsers = new ArrayList<>(mPrimaryUserProfiles);
        allUsers.add(SECONDARY_USER_INFO);
        when(mUserManager.getUsers(anyBoolean())).thenReturn(allUsers);
        when(mUserManager.getUsers()).thenReturn(allUsers);

        when(mActivityManager.unlockUser(anyInt(), any(), any(), any())).thenAnswer(
                new Answer<Boolean>() {