Loading src/com/android/settings/dashboard/profileselector/ProfileSelectDialog.java +17 −2 Original line number Diff line number Diff line Loading @@ -25,7 +25,9 @@ import android.content.DialogInterface.OnDismissListener; import android.content.DialogInterface.OnShowListener; import android.content.Intent; import android.content.pm.UserInfo; import android.content.pm.UserProperties; import android.os.Bundle; import android.os.Flags; import android.os.UserHandle; import android.os.UserManager; import android.util.Log; Loading Loading @@ -183,7 +185,10 @@ public class ProfileSelectDialog extends DialogFragment implements UserAdapter.O final UserManager userManager = UserManager.get(context); for (int i = userHandles.size() - 1; i >= 0; i--) { UserInfo userInfo = userManager.getUserInfo(userHandles.get(i).getIdentifier()); if (userInfo == null || userInfo.isCloneProfile()) { if (userInfo == null || userInfo.isCloneProfile() || (Flags.allowPrivateProfile() && shouldHideUserInQuietMode(userHandles.get(i), userManager))) { if (DEBUG) { Log.d(TAG, "Delete the user: " + userHandles.get(i).getIdentifier()); } Loading Loading @@ -214,7 +219,10 @@ public class ProfileSelectDialog extends DialogFragment implements UserAdapter.O final UserManager userManager = UserManager.get(context); for (UserHandle userHandle : List.copyOf(tile.pendingIntentMap.keySet())) { UserInfo userInfo = userManager.getUserInfo(userHandle.getIdentifier()); if (userInfo == null || userInfo.isCloneProfile()) { if (userInfo == null || userInfo.isCloneProfile() || (Flags.allowPrivateProfile() && shouldHideUserInQuietMode(userHandle, userManager))) { if (DEBUG) { Log.d(TAG, "Delete the user: " + userHandle.getIdentifier()); } Loading @@ -223,4 +231,11 @@ public class ProfileSelectDialog extends DialogFragment implements UserAdapter.O } } } private static boolean shouldHideUserInQuietMode( UserHandle userHandle, UserManager userManager) { UserProperties userProperties = userManager.getUserProperties(userHandle); return userProperties.getHideInSettingsInQuietMode() && userManager.isQuietModeEnabled(userHandle); } } src/com/android/settings/dashboard/profileselector/UserAdapter.java +5 −7 Original line number Diff line number Diff line Loading @@ -17,7 +17,6 @@ package com.android.settings.dashboard.profileselector; import static android.app.admin.DevicePolicyResources.Strings.Settings.PERSONAL_CATEGORY_HEADER; import static android.app.admin.DevicePolicyResources.Strings.Settings.WORK_CATEGORY_HEADER; import android.app.ActivityManager; import android.app.admin.DevicePolicyManager; Loading Loading @@ -51,11 +50,13 @@ public class UserAdapter extends BaseAdapter { /** Holder for user details */ public static class UserDetails { private final UserHandle mUserHandle; private final UserManager mUserManager; private final Drawable mIcon; private final String mTitle; public UserDetails(UserHandle userHandle, UserManager um, Context context) { mUserHandle = userHandle; mUserManager = um; UserInfo userInfo = um.getUserInfo(mUserHandle.getIdentifier()); int tintColor = Utils.getColorAttrDefaultColor(context, com.android.internal.R.attr.materialColorPrimaryContainer); Loading @@ -73,16 +74,13 @@ public class UserAdapter extends BaseAdapter { DevicePolicyManager devicePolicyManager = Objects.requireNonNull(context.getSystemService(DevicePolicyManager.class)); DevicePolicyResourcesManager resources = devicePolicyManager.getResources(); int userHandle = mUserHandle.getIdentifier(); if (userHandle == UserHandle.USER_CURRENT || userHandle == ActivityManager.getCurrentUser()) { int userId = mUserHandle.getIdentifier(); if (userId == UserHandle.USER_CURRENT || userId == ActivityManager.getCurrentUser()) { return resources.getString(PERSONAL_CATEGORY_HEADER, () -> context.getString( com.android.settingslib.R.string.category_personal)); } else { return resources.getString(WORK_CATEGORY_HEADER, () -> context.getString(com.android.settingslib.R.string.category_work)); } return (String) mUserManager.getBadgedLabelForUser(/* label= */ "", mUserHandle); } } Loading Loading
src/com/android/settings/dashboard/profileselector/ProfileSelectDialog.java +17 −2 Original line number Diff line number Diff line Loading @@ -25,7 +25,9 @@ import android.content.DialogInterface.OnDismissListener; import android.content.DialogInterface.OnShowListener; import android.content.Intent; import android.content.pm.UserInfo; import android.content.pm.UserProperties; import android.os.Bundle; import android.os.Flags; import android.os.UserHandle; import android.os.UserManager; import android.util.Log; Loading Loading @@ -183,7 +185,10 @@ public class ProfileSelectDialog extends DialogFragment implements UserAdapter.O final UserManager userManager = UserManager.get(context); for (int i = userHandles.size() - 1; i >= 0; i--) { UserInfo userInfo = userManager.getUserInfo(userHandles.get(i).getIdentifier()); if (userInfo == null || userInfo.isCloneProfile()) { if (userInfo == null || userInfo.isCloneProfile() || (Flags.allowPrivateProfile() && shouldHideUserInQuietMode(userHandles.get(i), userManager))) { if (DEBUG) { Log.d(TAG, "Delete the user: " + userHandles.get(i).getIdentifier()); } Loading Loading @@ -214,7 +219,10 @@ public class ProfileSelectDialog extends DialogFragment implements UserAdapter.O final UserManager userManager = UserManager.get(context); for (UserHandle userHandle : List.copyOf(tile.pendingIntentMap.keySet())) { UserInfo userInfo = userManager.getUserInfo(userHandle.getIdentifier()); if (userInfo == null || userInfo.isCloneProfile()) { if (userInfo == null || userInfo.isCloneProfile() || (Flags.allowPrivateProfile() && shouldHideUserInQuietMode(userHandle, userManager))) { if (DEBUG) { Log.d(TAG, "Delete the user: " + userHandle.getIdentifier()); } Loading @@ -223,4 +231,11 @@ public class ProfileSelectDialog extends DialogFragment implements UserAdapter.O } } } private static boolean shouldHideUserInQuietMode( UserHandle userHandle, UserManager userManager) { UserProperties userProperties = userManager.getUserProperties(userHandle); return userProperties.getHideInSettingsInQuietMode() && userManager.isQuietModeEnabled(userHandle); } }
src/com/android/settings/dashboard/profileselector/UserAdapter.java +5 −7 Original line number Diff line number Diff line Loading @@ -17,7 +17,6 @@ package com.android.settings.dashboard.profileselector; import static android.app.admin.DevicePolicyResources.Strings.Settings.PERSONAL_CATEGORY_HEADER; import static android.app.admin.DevicePolicyResources.Strings.Settings.WORK_CATEGORY_HEADER; import android.app.ActivityManager; import android.app.admin.DevicePolicyManager; Loading Loading @@ -51,11 +50,13 @@ public class UserAdapter extends BaseAdapter { /** Holder for user details */ public static class UserDetails { private final UserHandle mUserHandle; private final UserManager mUserManager; private final Drawable mIcon; private final String mTitle; public UserDetails(UserHandle userHandle, UserManager um, Context context) { mUserHandle = userHandle; mUserManager = um; UserInfo userInfo = um.getUserInfo(mUserHandle.getIdentifier()); int tintColor = Utils.getColorAttrDefaultColor(context, com.android.internal.R.attr.materialColorPrimaryContainer); Loading @@ -73,16 +74,13 @@ public class UserAdapter extends BaseAdapter { DevicePolicyManager devicePolicyManager = Objects.requireNonNull(context.getSystemService(DevicePolicyManager.class)); DevicePolicyResourcesManager resources = devicePolicyManager.getResources(); int userHandle = mUserHandle.getIdentifier(); if (userHandle == UserHandle.USER_CURRENT || userHandle == ActivityManager.getCurrentUser()) { int userId = mUserHandle.getIdentifier(); if (userId == UserHandle.USER_CURRENT || userId == ActivityManager.getCurrentUser()) { return resources.getString(PERSONAL_CATEGORY_HEADER, () -> context.getString( com.android.settingslib.R.string.category_personal)); } else { return resources.getString(WORK_CATEGORY_HEADER, () -> context.getString(com.android.settingslib.R.string.category_work)); } return (String) mUserManager.getBadgedLabelForUser(/* label= */ "", mUserHandle); } } Loading