summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-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()) {