summaryrefslogtreecommitdiff
path: root/service
diff options
context:
space:
mode:
Diffstat (limited to 'service')
-rw-r--r--service/java/com/android/permission/util/UserUtils.java30
-rw-r--r--service/java/com/android/role/RoleService.java3
-rw-r--r--service/java/com/android/safetycenter/UserProfileGroup.java5
3 files changed, 19 insertions, 19 deletions
diff --git a/service/java/com/android/permission/util/UserUtils.java b/service/java/com/android/permission/util/UserUtils.java
index 82e9cbbae..ae8e794b6 100644
--- a/service/java/com/android/permission/util/UserUtils.java
+++ b/service/java/com/android/permission/util/UserUtils.java
@@ -70,8 +70,7 @@ public final class UserUtils {
return;
}
- Context userContext = UserUtils.getUserContext(userId, context);
- List<UserHandle> profiles = getUserProfiles(userContext, true);
+ List<UserHandle> profiles = getUserProfiles(userId, context, true);
final int profilesSize = profiles.size();
for (int i = 0; i < profilesSize; i++) {
int profileId = profiles.get(i).getIdentifier();
@@ -112,26 +111,29 @@ public final class UserUtils {
}
}
- /** Returns all the enabled user profiles on the device. */
+ /** Returns all the enabled user profiles on the device for a specified user. */
@NonNull
- public static List<UserHandle> getUserProfiles(@NonNull Context context) {
- return getUserProfiles(context, false);
+ public static List<UserHandle> getUserProfiles(@UserIdInt int userId,
+ @NonNull Context context) {
+ return getUserProfiles(userId, context, false);
}
/**
- * Returns all the enabled user profiles on the device
+ * Returns all the enabled user profiles on the device for a specified user
*
+ * @param userId the user id to check
* @param context the {@link Context}
* @param excludePrivate {@code true} to exclude private profiles from returned list of users
*/
@NonNull
- public static List<UserHandle> getUserProfiles(@NonNull Context context,
+ public static List<UserHandle> getUserProfiles(@UserIdInt int userId, @NonNull Context context,
boolean excludePrivate) {
- UserManager userManager = context.getSystemService(UserManager.class);
// This call requires the QUERY_USERS permission.
final long identity = Binder.clearCallingIdentity();
try {
- List<UserHandle> profiles = userManager.getUserProfiles();
+ Context userContext = getUserContext(userId, context);
+ UserManager userUserManager = userContext.getSystemService(UserManager.class);
+ List<UserHandle> profiles = userUserManager.getUserProfiles();
if (!excludePrivate) {
return profiles;
}
@@ -139,7 +141,7 @@ public final class UserUtils {
final int profilesSize = profiles.size();
for (int i = 0; i < profilesSize; i++) {
UserHandle user = profiles.get(i);
- if (!isPrivateProfile(user.getIdentifier(), context)) {
+ if (!isPrivateProfile(user.getIdentifier(), userContext)) {
filteredProfiles.add(user);
}
}
@@ -164,11 +166,11 @@ public final class UserUtils {
@Nullable
private static UserHandle getProfileParent(@UserIdInt int userId, @NonNull Context context) {
Context userContext = getUserContext(userId, context);
- UserManager userManager = userContext.getSystemService(UserManager.class);
+ UserManager userUserManager = userContext.getSystemService(UserManager.class);
// This call requires the INTERACT_ACROSS_USERS permission.
final long identity = Binder.clearCallingIdentity();
try {
- return userManager.getProfileParent(UserHandle.of(userId));
+ return userUserManager.getProfileParent(UserHandle.of(userId));
} finally {
Binder.restoreCallingIdentity(identity);
}
@@ -201,8 +203,8 @@ public final class UserUtils {
final long identity = Binder.clearCallingIdentity();
try {
Context userContext = getUserContext(userId, context);
- UserManager userManager = userContext.getSystemService(UserManager.class);
- return userManager != null && userManager.isPrivateProfile();
+ UserManager userUserManager = userContext.getSystemService(UserManager.class);
+ return userUserManager != null && userUserManager.isPrivateProfile();
} finally {
Binder.restoreCallingIdentity(identity);
}
diff --git a/service/java/com/android/role/RoleService.java b/service/java/com/android/role/RoleService.java
index 5bc79efbb..e5d20ef9d 100644
--- a/service/java/com/android/role/RoleService.java
+++ b/service/java/com/android/role/RoleService.java
@@ -564,8 +564,7 @@ public class RoleService extends SystemService implements RoleUserState.Callback
+ " for role");
return;
}
- Context userContext = UserUtils.getUserContext(userId, getContext());
- List<UserHandle> profiles = UserUtils.getUserProfiles(userContext, true);
+ List<UserHandle> profiles = UserUtils.getUserProfiles(userId, getContext(), true);
if (!profiles.contains(UserHandle.of(activeUserId))) {
Log.e(LOG_TAG, "User " + activeUserId + " is not in the same profile-group as "
+ userId);
diff --git a/service/java/com/android/safetycenter/UserProfileGroup.java b/service/java/com/android/safetycenter/UserProfileGroup.java
index 1f5258437..44cb8d3d6 100644
--- a/service/java/com/android/safetycenter/UserProfileGroup.java
+++ b/service/java/com/android/safetycenter/UserProfileGroup.java
@@ -129,9 +129,8 @@ public final class UserProfileGroup {
* is disabled.
*/
public static UserProfileGroup fromUser(Context context, @UserIdInt int userId) {
- Context userContext = UserUtils.getUserContext(userId, context);
- List<UserHandle> userProfiles = UserUtils.getUserProfiles(userContext);
- int profileParentUserId = UserUtils.getProfileParentIdOrSelf(userId, userContext);
+ List<UserHandle> userProfiles = UserUtils.getUserProfiles(userId, context);
+ int profileParentUserId = UserUtils.getProfileParentIdOrSelf(userId, context);
int[] managedProfilesUserIds = new int[userProfiles.size()];
int[] managedRunningProfilesUserIds = new int[userProfiles.size()];