Loading core/java/android/os/IUserManager.aidl +1 −0 Original line number Diff line number Diff line Loading @@ -133,6 +133,7 @@ interface IUserManager { int getUserStatusBarIconResId(int userId); boolean hasBadge(int userId); int getProfileLabelResId(int userId); int getProfileAccessibilityLabelResId(int userId); boolean isUserUnlocked(int userId); boolean isUserRunning(int userId); boolean isUserForeground(int userId); Loading core/java/android/os/UserManager.java +38 −0 Original line number Diff line number Diff line Loading @@ -18,6 +18,7 @@ package android.os; import static android.app.admin.DevicePolicyResources.Drawables.Style.SOLID_COLORED; import static android.app.admin.DevicePolicyResources.Strings.Core.WORK_PROFILE_BADGED_LABEL; import static android.app.admin.DevicePolicyResources.Strings.SystemUi.STATUS_BAR_WORK_ICON_ACCESSIBILITY; import static android.app.admin.DevicePolicyResources.UNDEFINED; import android.Manifest; Loading Loading @@ -5953,6 +5954,43 @@ public class UserManager { } } /** * Returns the string used to represent the profile associated with the given userId. This * string typically includes the profile name used by accessibility services like TalkBack. * @hide * * @return String representing the accessibility label for the given profile user. * * @throws android.content.res.Resources.NotFoundException if the user does not have a label * defined. */ @UserHandleAware( requiresAnyOfPermissionsIfNotCallerProfileGroup = { Manifest.permission.MANAGE_USERS, Manifest.permission.QUERY_USERS, Manifest.permission.INTERACT_ACROSS_USERS}) public String getProfileAccessibilityString(int userId) { if (isManagedProfile(mUserId)) { DevicePolicyManager dpm = mContext.getSystemService(DevicePolicyManager.class); dpm.getResources().getString( STATUS_BAR_WORK_ICON_ACCESSIBILITY, () -> getProfileAccessibilityLabel(userId)); } return getProfileAccessibilityLabel(userId); } private String getProfileAccessibilityLabel(int userId) { try { final int resourceId = mService.getProfileAccessibilityLabelResId(userId); return Resources.getSystem().getString(resourceId); } catch (Resources.NotFoundException nfe) { Log.e(TAG, "Accessibility label not defined for user " + userId); throw nfe; } catch (RemoteException e) { throw new RuntimeException(e); } } /** * If the user is a {@link UserManager#isProfile profile}, checks if the user * shares media with its parent user (the user that created this profile). Loading core/res/res/values/strings.xml +9 −0 Original line number Diff line number Diff line Loading @@ -6452,6 +6452,15 @@ ul.</string> <!-- Communal profile label on a screen. This can be used as a tab label for this profile in tabbed views and can be used to represent the profile in sharing surfaces, etc. [CHAR LIMIT=20] --> <string name="profile_label_communal">Communal</string> <!-- Accessibility label for managed profile user type [CHAR LIMIT=30] --> <string name="accessibility_label_managed_profile">Work profile</string> <!-- Accessibility label for private profile user type [CHAR LIMIT=30] --> <string name="accessibility_label_private_profile">Private space</string> <!-- Accessibility label for clone profile user type [CHAR LIMIT=30] --> <string name="accessibility_label_clone_profile">Clone</string> <!-- Accessibility label for clone profile user type [CHAR LIMIT=30] --> <string name="accessibility_label_communal_profile">Communal</string> <!-- Notification message used when a notification's normal message contains sensitive information [CHAR_LIMIT=NOTIF_BODY] --> <string name="redacted_notification_message">Sensitive notification content hidden</string> <!-- Notification action title used instead of a notification's normal title sensitive [CHAR_LIMIT=NOTIF_BODY] --> Loading core/res/res/values/symbols.xml +4 −0 Original line number Diff line number Diff line Loading @@ -1110,6 +1110,10 @@ <java-symbol type="string" name="profile_label_work_3" /> <java-symbol type="string" name="profile_label_test" /> <java-symbol type="string" name="profile_label_communal" /> <java-symbol type="string" name="accessibility_label_managed_profile" /> <java-symbol type="string" name="accessibility_label_private_profile" /> <java-symbol type="string" name="accessibility_label_clone_profile" /> <java-symbol type="string" name="accessibility_label_communal_profile" /> <java-symbol type="string" name="mediasize_unknown_portrait" /> <java-symbol type="string" name="mediasize_unknown_landscape" /> <java-symbol type="string" name="mediasize_iso_a0" /> Loading packages/SystemUI/src/com/android/systemui/statusbar/phone/PhoneStatusBarPolicy.java +13 −2 Original line number Diff line number Diff line Loading @@ -549,12 +549,23 @@ public class PhoneStatusBarPolicy try { final int userId = ActivityTaskManager.getService().getLastResumedActivityUserId(); final int iconResId = mUserManager.getUserStatusBarIconResId(userId); // TODO(b/170249807, b/230779281): Handle non-managed-profile String String accessibilityString = getManagedProfileAccessibilityString(); mMainExecutor.execute(() -> { final boolean showIcon; if (iconResId != Resources.ID_NULL && (!mKeyguardStateController.isShowing() || mKeyguardStateController.isOccluded())) { String accessibilityString = ""; if (android.os.Flags.allowPrivateProfile() && android.multiuser.Flags.enablePrivateSpaceFeatures()) { try { accessibilityString = mUserManager.getProfileAccessibilityString(userId); } catch (Resources.NotFoundException nfe) { Log.e(TAG, "Accessibility string not found for userId:" + userId); } } else { accessibilityString = getManagedProfileAccessibilityString(); } showIcon = true; mIconController.setIcon(mSlotManagedProfile, iconResId, Loading Loading
core/java/android/os/IUserManager.aidl +1 −0 Original line number Diff line number Diff line Loading @@ -133,6 +133,7 @@ interface IUserManager { int getUserStatusBarIconResId(int userId); boolean hasBadge(int userId); int getProfileLabelResId(int userId); int getProfileAccessibilityLabelResId(int userId); boolean isUserUnlocked(int userId); boolean isUserRunning(int userId); boolean isUserForeground(int userId); Loading
core/java/android/os/UserManager.java +38 −0 Original line number Diff line number Diff line Loading @@ -18,6 +18,7 @@ package android.os; import static android.app.admin.DevicePolicyResources.Drawables.Style.SOLID_COLORED; import static android.app.admin.DevicePolicyResources.Strings.Core.WORK_PROFILE_BADGED_LABEL; import static android.app.admin.DevicePolicyResources.Strings.SystemUi.STATUS_BAR_WORK_ICON_ACCESSIBILITY; import static android.app.admin.DevicePolicyResources.UNDEFINED; import android.Manifest; Loading Loading @@ -5953,6 +5954,43 @@ public class UserManager { } } /** * Returns the string used to represent the profile associated with the given userId. This * string typically includes the profile name used by accessibility services like TalkBack. * @hide * * @return String representing the accessibility label for the given profile user. * * @throws android.content.res.Resources.NotFoundException if the user does not have a label * defined. */ @UserHandleAware( requiresAnyOfPermissionsIfNotCallerProfileGroup = { Manifest.permission.MANAGE_USERS, Manifest.permission.QUERY_USERS, Manifest.permission.INTERACT_ACROSS_USERS}) public String getProfileAccessibilityString(int userId) { if (isManagedProfile(mUserId)) { DevicePolicyManager dpm = mContext.getSystemService(DevicePolicyManager.class); dpm.getResources().getString( STATUS_BAR_WORK_ICON_ACCESSIBILITY, () -> getProfileAccessibilityLabel(userId)); } return getProfileAccessibilityLabel(userId); } private String getProfileAccessibilityLabel(int userId) { try { final int resourceId = mService.getProfileAccessibilityLabelResId(userId); return Resources.getSystem().getString(resourceId); } catch (Resources.NotFoundException nfe) { Log.e(TAG, "Accessibility label not defined for user " + userId); throw nfe; } catch (RemoteException e) { throw new RuntimeException(e); } } /** * If the user is a {@link UserManager#isProfile profile}, checks if the user * shares media with its parent user (the user that created this profile). Loading
core/res/res/values/strings.xml +9 −0 Original line number Diff line number Diff line Loading @@ -6452,6 +6452,15 @@ ul.</string> <!-- Communal profile label on a screen. This can be used as a tab label for this profile in tabbed views and can be used to represent the profile in sharing surfaces, etc. [CHAR LIMIT=20] --> <string name="profile_label_communal">Communal</string> <!-- Accessibility label for managed profile user type [CHAR LIMIT=30] --> <string name="accessibility_label_managed_profile">Work profile</string> <!-- Accessibility label for private profile user type [CHAR LIMIT=30] --> <string name="accessibility_label_private_profile">Private space</string> <!-- Accessibility label for clone profile user type [CHAR LIMIT=30] --> <string name="accessibility_label_clone_profile">Clone</string> <!-- Accessibility label for clone profile user type [CHAR LIMIT=30] --> <string name="accessibility_label_communal_profile">Communal</string> <!-- Notification message used when a notification's normal message contains sensitive information [CHAR_LIMIT=NOTIF_BODY] --> <string name="redacted_notification_message">Sensitive notification content hidden</string> <!-- Notification action title used instead of a notification's normal title sensitive [CHAR_LIMIT=NOTIF_BODY] --> Loading
core/res/res/values/symbols.xml +4 −0 Original line number Diff line number Diff line Loading @@ -1110,6 +1110,10 @@ <java-symbol type="string" name="profile_label_work_3" /> <java-symbol type="string" name="profile_label_test" /> <java-symbol type="string" name="profile_label_communal" /> <java-symbol type="string" name="accessibility_label_managed_profile" /> <java-symbol type="string" name="accessibility_label_private_profile" /> <java-symbol type="string" name="accessibility_label_clone_profile" /> <java-symbol type="string" name="accessibility_label_communal_profile" /> <java-symbol type="string" name="mediasize_unknown_portrait" /> <java-symbol type="string" name="mediasize_unknown_landscape" /> <java-symbol type="string" name="mediasize_iso_a0" /> Loading
packages/SystemUI/src/com/android/systemui/statusbar/phone/PhoneStatusBarPolicy.java +13 −2 Original line number Diff line number Diff line Loading @@ -549,12 +549,23 @@ public class PhoneStatusBarPolicy try { final int userId = ActivityTaskManager.getService().getLastResumedActivityUserId(); final int iconResId = mUserManager.getUserStatusBarIconResId(userId); // TODO(b/170249807, b/230779281): Handle non-managed-profile String String accessibilityString = getManagedProfileAccessibilityString(); mMainExecutor.execute(() -> { final boolean showIcon; if (iconResId != Resources.ID_NULL && (!mKeyguardStateController.isShowing() || mKeyguardStateController.isOccluded())) { String accessibilityString = ""; if (android.os.Flags.allowPrivateProfile() && android.multiuser.Flags.enablePrivateSpaceFeatures()) { try { accessibilityString = mUserManager.getProfileAccessibilityString(userId); } catch (Resources.NotFoundException nfe) { Log.e(TAG, "Accessibility string not found for userId:" + userId); } } else { accessibilityString = getManagedProfileAccessibilityString(); } showIcon = true; mIconController.setIcon(mSlotManagedProfile, iconResId, Loading