Loading services/core/java/com/android/server/notification/NotificationAttentionHelper.java +8 −0 Original line number Diff line number Diff line Loading @@ -489,6 +489,7 @@ public final class NotificationAttentionHelper { } else if ((record.getFlags() & Notification.FLAG_INSISTENT) != 0) { hasValidSound = false; hasValidVibrate = false; } } } Loading Loading @@ -753,6 +754,13 @@ public final class NotificationAttentionHelper { // notifying app does not have the VIBRATE permission. final long identity = Binder.clearCallingIdentity(); try { // Need to explicitly cancel a previously playing vibration // Otherwise a looping vibration will not be stopped when starting a new one. if (mVibrateNotificationKey != null && !mVibrateNotificationKey.equals(record.getKey())) { mVibrateNotificationKey = null; mVibratorHelper.cancelVibration(); } final float scale = getVibrationIntensity(record); final VibrationEffect scaledEffect = Float.compare(scale, DEFAULT_VOLUME) != 0 ? mVibratorHelper.scale(effect, scale) : effect; Loading services/tests/uiservicestests/src/com/android/server/notification/NotificationAttentionHelperTest.java +19 −0 Original line number Diff line number Diff line Loading @@ -2006,6 +2006,25 @@ public class NotificationAttentionHelperTest extends UiServiceTestCase { assertTrue(interrupter.isInterruptive()); } @Test public void testCanInterruptNonRingtoneInsistentBuzzWithOtherBuzzyNotification() { NotificationRecord r = getInsistentBuzzyNotification(); mAttentionHelper.buzzBeepBlinkLocked(r, DEFAULT_SIGNALS); verifyVibrateLooped(); assertTrue(r.isInterruptive()); assertNotEquals(-1, r.getLastAudiblyAlertedMs()); Mockito.reset(mVibrator); // New buzzy notification stops previous looping vibration NotificationRecord interrupter = getBuzzyOtherNotification(); mAttentionHelper.buzzBeepBlinkLocked(interrupter, DEFAULT_SIGNALS); verifyStopVibrate(); // And then vibrates itself verifyVibrate(1); assertTrue(interrupter.isInterruptive()); assertNotEquals(-1, interrupter.getLastAudiblyAlertedMs()); } @Test public void testRingtoneInsistentBeep_doesNotBlockFutureSoundsOnceStopped() throws Exception { NotificationChannel ringtoneChannel = Loading Loading
services/core/java/com/android/server/notification/NotificationAttentionHelper.java +8 −0 Original line number Diff line number Diff line Loading @@ -489,6 +489,7 @@ public final class NotificationAttentionHelper { } else if ((record.getFlags() & Notification.FLAG_INSISTENT) != 0) { hasValidSound = false; hasValidVibrate = false; } } } Loading Loading @@ -753,6 +754,13 @@ public final class NotificationAttentionHelper { // notifying app does not have the VIBRATE permission. final long identity = Binder.clearCallingIdentity(); try { // Need to explicitly cancel a previously playing vibration // Otherwise a looping vibration will not be stopped when starting a new one. if (mVibrateNotificationKey != null && !mVibrateNotificationKey.equals(record.getKey())) { mVibrateNotificationKey = null; mVibratorHelper.cancelVibration(); } final float scale = getVibrationIntensity(record); final VibrationEffect scaledEffect = Float.compare(scale, DEFAULT_VOLUME) != 0 ? mVibratorHelper.scale(effect, scale) : effect; Loading
services/tests/uiservicestests/src/com/android/server/notification/NotificationAttentionHelperTest.java +19 −0 Original line number Diff line number Diff line Loading @@ -2006,6 +2006,25 @@ public class NotificationAttentionHelperTest extends UiServiceTestCase { assertTrue(interrupter.isInterruptive()); } @Test public void testCanInterruptNonRingtoneInsistentBuzzWithOtherBuzzyNotification() { NotificationRecord r = getInsistentBuzzyNotification(); mAttentionHelper.buzzBeepBlinkLocked(r, DEFAULT_SIGNALS); verifyVibrateLooped(); assertTrue(r.isInterruptive()); assertNotEquals(-1, r.getLastAudiblyAlertedMs()); Mockito.reset(mVibrator); // New buzzy notification stops previous looping vibration NotificationRecord interrupter = getBuzzyOtherNotification(); mAttentionHelper.buzzBeepBlinkLocked(interrupter, DEFAULT_SIGNALS); verifyStopVibrate(); // And then vibrates itself verifyVibrate(1); assertTrue(interrupter.isInterruptive()); assertNotEquals(-1, interrupter.getLastAudiblyAlertedMs()); } @Test public void testRingtoneInsistentBeep_doesNotBlockFutureSoundsOnceStopped() throws Exception { NotificationChannel ringtoneChannel = Loading