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
This commit is contained in:
Felipe Leme
2020-08-11 18:25:20 -07:00
parent 271e922bb0
commit b07b092f9e
5 changed files with 7 additions and 6 deletions

View File

@@ -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();
}
}

View File

@@ -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;

View File

@@ -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++) {

View File

@@ -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;

View File

@@ -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>() {