summaryrefslogtreecommitdiff
path: root/PermissionController
diff options
context:
space:
mode:
author Richard MacGregor <rmacgregor@google.com> 2025-01-15 17:08:16 -0800
committer Richard MacGregor <rmacgregor@google.com> 2025-01-16 15:36:52 -0800
commit435b0bcbb316c652e53baea8381b071ceda3bc98 (patch)
tree80eaef6456ba586ccd3ae376917d53f0f13ab25c /PermissionController
parente0eb30376840ce7a289408c79046049b261d1252 (diff)
Fix which profiles show in default app list
Default app list should show all profiles when opening with profile parent Default app list should only show work profile when opening with work profile Default app list should only show private profile when opening with private profile Bug: 390247739 Flag: EXEMPT bugfix Relnote: Fix shown profiles in default app list Test: manual Change-Id: Ib7a003e48a731d6c5b79b373bc35ec703a55c347
Diffstat (limited to 'PermissionController')
-rw-r--r--PermissionController/role-controller/java/com/android/role/controller/util/UserUtils.java2
-rw-r--r--PermissionController/src/com/android/permissioncontroller/role/ui/DefaultAppListViewModel.java8
-rw-r--r--PermissionController/src/com/android/permissioncontroller/role/utils/UserUtils.java19
3 files changed, 26 insertions, 3 deletions
diff --git a/PermissionController/role-controller/java/com/android/role/controller/util/UserUtils.java b/PermissionController/role-controller/java/com/android/role/controller/util/UserUtils.java
index f3cb7926a..598057b16 100644
--- a/PermissionController/role-controller/java/com/android/role/controller/util/UserUtils.java
+++ b/PermissionController/role-controller/java/com/android/role/controller/util/UserUtils.java
@@ -127,7 +127,7 @@ public final class UserUtils {
/** Returns the parent of a given user. */
@Nullable
- private static UserHandle getProfileParent(UserHandle user, @NonNull Context context) {
+ public static UserHandle getProfileParent(UserHandle user, @NonNull Context context) {
Context userContext = getUserContext(context, user);
UserManager userManager = userContext.getSystemService(UserManager.class);
return userManager.getProfileParent(user);
diff --git a/PermissionController/src/com/android/permissioncontroller/role/ui/DefaultAppListViewModel.java b/PermissionController/src/com/android/permissioncontroller/role/ui/DefaultAppListViewModel.java
index 82253ed00..e4a3cbc17 100644
--- a/PermissionController/src/com/android/permissioncontroller/role/ui/DefaultAppListViewModel.java
+++ b/PermissionController/src/com/android/permissioncontroller/role/ui/DefaultAppListViewModel.java
@@ -58,9 +58,11 @@ public class DefaultAppListViewModel extends AndroidViewModel {
super(application);
mUser = Process.myUserHandle();
+ boolean isProfileParent = UserUtils.isProfileParent(mUser, application);
RoleListLiveData liveData = new RoleListLiveData(true, mUser, application);
RoleListSortFunction sortFunction = new RoleListSortFunction(application);
- mWorkProfile = UserUtils.getWorkProfile(application);
+ // Only show the work profile section if the current user is a full user
+ mWorkProfile = isProfileParent ? UserUtils.getWorkProfile(application) : null;
if (RoleFlags.isProfileGroupExclusivityAvailable()) {
if (mWorkProfile != null) {
// Show profile group exclusive roles from work profile in primary group.
@@ -87,7 +89,9 @@ public class DefaultAppListViewModel extends AndroidViewModel {
new RoleListLiveData(true, mWorkProfile, application), sortFunction) : null;
}
- UserHandle privateProfile = UserUtils.getPrivateProfile(application);
+ // Only show the private profile section if the current user is a full user
+ UserHandle privateProfile =
+ isProfileParent ? UserUtils.getPrivateProfile(application) : null;
if (privateProfile != null && Utils.shouldShowInSettings(
privateProfile, application.getSystemService(UserManager.class))) {
mPrivateProfile = privateProfile;
diff --git a/PermissionController/src/com/android/permissioncontroller/role/utils/UserUtils.java b/PermissionController/src/com/android/permissioncontroller/role/utils/UserUtils.java
index df0aa99f2..f03c31bd8 100644
--- a/PermissionController/src/com/android/permissioncontroller/role/utils/UserUtils.java
+++ b/PermissionController/src/com/android/permissioncontroller/role/utils/UserUtils.java
@@ -131,6 +131,25 @@ public class UserUtils {
return null;
}
+ /**
+ * Returns whether the user is a parent/full-user or not.
+ *
+ * @param userHandle the {@code UserHandle} to check is private profile
+ * @param context the {@code Context} to retrieve system services
+ */
+ public static boolean isProfileParent(@NonNull UserHandle userHandle,
+ @NonNull Context context) {
+ // If profile parent user is null, then original user is the parent
+ return com.android.role.controller.util.UserUtils.getProfileParent(userHandle, context)
+ == null;
+ }
+
+ /**
+ * Returns whether the user is a private profile or not.
+ *
+ * @param userHandle the {@code UserHandle} to check is private profile
+ * @param context the {@code Context} to retrieve system services
+ */
private static boolean isPrivateProfile(@NonNull UserHandle userHandle,
@NonNull Context context) {
if (!SdkLevel.isAtLeastV() || !android.os.Flags.allowPrivateProfile()) {