Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 7ecd402a authored by Julia Reynolds's avatar Julia Reynolds Committed by android-build-merger
Browse files

Merge "Check if notification is valid before it finally vibrates because it...

Merge "Check if notification is valid before it finally vibrates because it can be canceled as soon as enqeued" am: 172458e0
am: 186fcb58

Change-Id: Id2e61c68acd1626230eb032f385d6bce6d2391a6
parents 23a006b6 186fcb58
Loading
Loading
Loading
Loading
+11 −2
Original line number Diff line number Diff line
@@ -5001,8 +5001,17 @@ public class NotificationManagerService extends SystemService {
                    try {
                        Thread.sleep(waitMs);
                    } catch (InterruptedException e) { }

                    // Notifications might be canceled before it actually vibrates due to waitMs,
                    // so need to check the notification still valide for vibrate.
                    synchronized (mNotificationLock) {
                        if (mNotificationsByKey.get(record.getKey()) != null) {
                            mVibrator.vibrate(record.sbn.getUid(), record.sbn.getOpPkg(),
                                    effect, record.getAudioAttributes());
                        } else {
                            Slog.e(TAG, "No vibration for canceled notification : " + record.getKey());
                        }
                    }
                }).start();
            } else {
                mVibrator.vibrate(record.sbn.getUid(), record.sbn.getOpPkg(),
+16 −0
Original line number Diff line number Diff line
@@ -917,6 +917,22 @@ public class BuzzBeepBlinkTest extends UiServiceTestCase {
        assertFalse(s.isInterruptive());
    }

    @Test
    public void testCanceledNoisyNeverVibrate() throws Exception {
        NotificationRecord r = getBuzzyBeepyNotification();

        final int waitMs = mAudioManager.getFocusRampTimeMs(
                AudioManager.AUDIOFOCUS_GAIN_TRANSIENT_MAY_DUCK,
                r.getAudioAttributes());

        mService.buzzBeepBlinkLocked(r);
        mService.clearNotifications();

        verifyNeverVibrate();
        Thread.sleep(waitMs);
        verifyNeverVibrate();
    }
    
    @Test
    public void testEmptyUriSoundTreatedAsNoSound() throws Exception {
        NotificationChannel channel = new NotificationChannel("test", "test", IMPORTANCE_HIGH);