diff options
| -rw-r--r-- | services/core/java/com/android/server/notification/NotificationManagerService.java | 2 | ||||
| -rw-r--r-- | services/tests/notification/src/com/android/server/notification/BuzzBeepBlinkTest.java | 23 |
2 files changed, 25 insertions, 0 deletions
diff --git a/services/core/java/com/android/server/notification/NotificationManagerService.java b/services/core/java/com/android/server/notification/NotificationManagerService.java index 5b2bc9e10faf..1b4b5f12be2a 100644 --- a/services/core/java/com/android/server/notification/NotificationManagerService.java +++ b/services/core/java/com/android/server/notification/NotificationManagerService.java @@ -4081,6 +4081,8 @@ public class NotificationManagerService extends SystemService { buzz = playVibration(record, vibration, hasValidSound); } + } else if ((record.getFlags() & Notification.FLAG_INSISTENT) != 0) { + hasValidSound = false; } } } diff --git a/services/tests/notification/src/com/android/server/notification/BuzzBeepBlinkTest.java b/services/tests/notification/src/com/android/server/notification/BuzzBeepBlinkTest.java index 0b4d61fb783e..5335e87f813d 100644 --- a/services/tests/notification/src/com/android/server/notification/BuzzBeepBlinkTest.java +++ b/services/tests/notification/src/com/android/server/notification/BuzzBeepBlinkTest.java @@ -191,6 +191,11 @@ public class BuzzBeepBlinkTest extends NotificationTestCase { true /* noisy */, false /* buzzy*/, false /* lights */); } + private NotificationRecord getInsistentBeepyOnceNotification() { + return getNotificationRecord(mId, true /* insistent */, true /* once */, + true /* noisy */, false /* buzzy*/, false /* lights */); + } + private NotificationRecord getInsistentBeepyLeanbackNotification() { return getLeanbackNotificationRecord(mId, true /* insistent */, false /* once */, true /* noisy */, false /* buzzy*/, false /* lights */); @@ -498,6 +503,24 @@ public class BuzzBeepBlinkTest extends NotificationTestCase { verifyNeverStopAudio(); } + /** + * Tests the case where the user re-posts a {@link Notification} with looping sound where + * {@link Notification.Builder#setOnlyAlertOnce(true)} has been called. This should silence + * the sound associated with the notification. + * @throws Exception + */ + @Test + public void testNoisyOnceUpdateDoesCancelAudio() throws Exception { + NotificationRecord r = getInsistentBeepyNotification(); + NotificationRecord s = getInsistentBeepyOnceNotification(); + s.isUpdate = true; + + mService.buzzBeepBlinkLocked(r); + mService.buzzBeepBlinkLocked(s); + + verifyStopAudio(); + } + @Test public void testQuietUpdateDoesNotCancelAudioFromOther() throws Exception { NotificationRecord r = getBeepyNotification(); |