diff options
| author | 2024-07-30 15:42:43 +0000 | |
|---|---|---|
| committer | 2024-07-30 15:42:43 +0000 | |
| commit | e49a8e93bfaabc636164ba90d324743287fae8cc (patch) | |
| tree | d57e1418bf729cab87906f4c3fbc3137c03f5dd1 | |
| parent | 8148983150f22bcbb4973d9efb38b92bd104785d (diff) | |
Do not add "Switch user" action if switching users disallowed
Only add "Mute" action to alarm notification from background user is user switching is disallowed or disabled.
Bug: 356380324
Test: manual: 1. set timer on user 11 -> switch to another user 10 -> notification shows with 2 actions. 2. set timer on user 11 -> switch to another user 10 -> adb shell pm set-user-restriction --user 10 no_user_switch 0 -> notification shows with only "Mute" action.
Flag: android.multiuser.add_ui_for_sounds_from_background_users
Change-Id: Icbc564bb017c9ac651ba450de5c32eb83ccbecaa
| -rw-r--r-- | services/core/java/com/android/server/pm/BackgroundUserSoundNotifier.java | 15 |
1 files changed, 10 insertions, 5 deletions
diff --git a/services/core/java/com/android/server/pm/BackgroundUserSoundNotifier.java b/services/core/java/com/android/server/pm/BackgroundUserSoundNotifier.java index 15e758cf6ffd..398e8e37f9b1 100644 --- a/services/core/java/com/android/server/pm/BackgroundUserSoundNotifier.java +++ b/services/core/java/com/android/server/pm/BackgroundUserSoundNotifier.java @@ -233,7 +233,8 @@ public class BackgroundUserSoundNotifier { final Notification.Action switchUser = new Notification.Action.Builder(null, fgContext.getString(R.string.bg_user_sound_notification_button_switch_user), switchIntent).build(); - return new Notification.Builder(mSystemUserContext, BUSN_CHANNEL_ID) + Notification.Builder notificationBuilder = new Notification.Builder(mSystemUserContext, + BUSN_CHANNEL_ID) .setSmallIcon(icon) .setTicker(title) .setWhen(0) @@ -242,10 +243,14 @@ public class BackgroundUserSoundNotifier { .setContentTitle(title) .setContentIntent(muteIntent) .setAutoCancel(true) - .setActions(mute, switchUser) - .setContentText(fgContext.getString(R.string.bg_user_sound_notification_message)) - .setVisibility(Notification.VISIBILITY_PUBLIC) - .build(); + .setVisibility(Notification.VISIBILITY_PUBLIC); + if (mUserManager.isUserSwitcherEnabled() && (mUserManager.getUserSwitchability( + UserHandle.of(fgContext.getUserId())) == UserManager.SWITCHABILITY_STATUS_OK)) { + notificationBuilder.setActions(mute, switchUser); + } else { + notificationBuilder.setActions(mute); + } + return notificationBuilder.build(); } } |