diff options
| -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();      }  } |