Merge "Check if notification is valid before it finally vibrates because it can be canceled as soon as enqeued"
am: 172458e014
Change-Id: I7832387ba4294b68865cc725e5d1e474370e8e54
This commit is contained in:
@@ -5000,8 +5000,17 @@ public class NotificationManagerService extends SystemService {
|
|||||||
try {
|
try {
|
||||||
Thread.sleep(waitMs);
|
Thread.sleep(waitMs);
|
||||||
} catch (InterruptedException e) { }
|
} catch (InterruptedException e) { }
|
||||||
mVibrator.vibrate(record.sbn.getUid(), record.sbn.getOpPkg(),
|
|
||||||
effect, record.getAudioAttributes());
|
// 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();
|
}).start();
|
||||||
} else {
|
} else {
|
||||||
mVibrator.vibrate(record.sbn.getUid(), record.sbn.getOpPkg(),
|
mVibrator.vibrate(record.sbn.getUid(), record.sbn.getOpPkg(),
|
||||||
|
|||||||
@@ -917,6 +917,22 @@ public class BuzzBeepBlinkTest extends UiServiceTestCase {
|
|||||||
assertFalse(s.isInterruptive());
|
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
|
@Test
|
||||||
public void testEmptyUriSoundTreatedAsNoSound() throws Exception {
|
public void testEmptyUriSoundTreatedAsNoSound() throws Exception {
|
||||||
NotificationChannel channel = new NotificationChannel("test", "test", IMPORTANCE_HIGH);
|
NotificationChannel channel = new NotificationChannel("test", "test", IMPORTANCE_HIGH);
|
||||||
|
|||||||
Reference in New Issue
Block a user