Merge "Fixed how com.android.server.pm.Settings handle pre-created users." am: 8f0008900d

Original change: https://android-review.googlesource.com/c/platform/frameworks/base/+/1393496

Change-Id: I51d38bc7e187c40b512cf3542ac802cb309a9530
This commit is contained in:
Treehugger Robot
2020-08-07 16:43:22 +00:00
committed by Automerger Merge Worker

View File

@@ -2649,7 +2649,7 @@ public final class Settings {
private void writePackageListLPrInternal(int creatingUserId) { private void writePackageListLPrInternal(int creatingUserId) {
// Only derive GIDs for active users (not dying) // Only derive GIDs for active users (not dying)
final List<UserInfo> users = getUsers(UserManagerService.getInstance(), true); final List<UserInfo> users = getActiveUsers(UserManagerService.getInstance(), true);
int[] userIds = new int[users.size()]; int[] userIds = new int[users.size()];
for (int i = 0; i < userIds.length; i++) { for (int i = 0; i < userIds.length; i++) {
userIds[i] = users.get(i).id; userIds[i] = users.get(i).id;
@@ -4325,25 +4325,43 @@ public final class Settings {
} }
/** /**
* Return all users on the device, including partial or dying users. * Returns all users on the device, including pre-created and dying users.
*
* @param userManager UserManagerService instance * @param userManager UserManagerService instance
* @return the list of users * @return the list of users
*/ */
private static List<UserInfo> getAllUsers(UserManagerService userManager) { private static List<UserInfo> getAllUsers(UserManagerService userManager) {
return getUsers(userManager, false); return getUsers(userManager, /* excludeDying= */ false, /* excludePreCreated= */ false);
} }
/** /**
* Return the list of users on the device. Clear the calling identity before calling into * Returns the list of users on the device, excluding pre-created ones.
* UserManagerService. *
* @param userManager UserManagerService instance * @param userManager UserManagerService instance
* @param excludeDying Indicates whether to exclude any users marked for deletion. * @param excludeDying Indicates whether to exclude any users marked for deletion.
*
* @return the list of users * @return the list of users
*/ */
private static List<UserInfo> getUsers(UserManagerService userManager, boolean excludeDying) { private static List<UserInfo> getActiveUsers(UserManagerService userManager,
boolean excludeDying) {
return getUsers(userManager, excludeDying, /* excludePreCreated= */ true);
}
/**
* Returns the list of users on the device.
*
* @param userManager UserManagerService instance
* @param excludeDying Indicates whether to exclude any users marked for deletion.
* @param excludePreCreated Indicates whether to exclude any pre-created users.
*
* @return the list of users
*/
private static List<UserInfo> getUsers(UserManagerService userManager, boolean excludeDying,
boolean excludePreCreated) {
long id = Binder.clearCallingIdentity(); long id = Binder.clearCallingIdentity();
try { try {
return userManager.getUsers(excludeDying); return userManager.getUsers(/* excludePartial= */ true, excludeDying,
excludePreCreated);
} catch (NullPointerException npe) { } catch (NullPointerException npe) {
// packagemanager not yet initialized // packagemanager not yet initialized
} finally { } finally {