From ec2bb18c92dc489a0b54bfc96118007261e3e7be Mon Sep 17 00:00:00 2001 From: Jean-Michel Trivi Date: Fri, 23 Mar 2018 18:04:00 -0700 Subject: NotificationManagerService: don't play notif in SILENT mode Fix the test for playing a notification sound: play sound when 1/ no exclusive focus AND 2/ volume not 0 Previous test would play a notification if device was in SILENT mode (volume was 0, but ringer mode was != VIBRATE) Bug: 75043398 Test: enter silent mode, play notification, verify no ducking Change-Id: I0e19d068f719a89c7a8a3c239da86c1dfce701ec --- .../server/notification/NotificationManagerService.java | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/services/core/java/com/android/server/notification/NotificationManagerService.java b/services/core/java/com/android/server/notification/NotificationManagerService.java index 210857e1b097..4e8150792b44 100644 --- a/services/core/java/com/android/server/notification/NotificationManagerService.java +++ b/services/core/java/com/android/server/notification/NotificationManagerService.java @@ -4691,11 +4691,12 @@ public class NotificationManagerService extends SystemService { private boolean playSound(final NotificationRecord record, Uri soundUri) { boolean looping = (record.getNotification().flags & Notification.FLAG_INSISTENT) != 0; - // do not play notifications if there is a user of exclusive audio focus - // or the device is in vibrate mode - if (!mAudioManager.isAudioFocusExclusive() && (mAudioManager.getRingerModeInternal() - != AudioManager.RINGER_MODE_VIBRATE || mAudioManager.getStreamVolume( - AudioAttributes.toLegacyStreamType(record.getAudioAttributes())) != 0)) { + // play notifications if there is no user of exclusive audio focus + // and the stream volume is not 0 (non-zero volume implies not silenced by SILENT or + // VIBRATE ringer mode) + if (!mAudioManager.isAudioFocusExclusive() + && (mAudioManager.getStreamVolume( + AudioAttributes.toLegacyStreamType(record.getAudioAttributes())) != 0)) { final long identity = Binder.clearCallingIdentity(); try { final IRingtonePlayer player = mAudioManager.getRingtonePlayer(); -- cgit v1.2.3-59-g8ed1b