diff options
| author | 2019-11-27 17:38:40 +0000 | |
|---|---|---|
| committer | 2019-11-27 17:38:40 +0000 | |
| commit | 10f4d427cd2a75e1be91dad58e74cbd1bcfe9110 (patch) | |
| tree | 509f57774317e4f6c7c0d9f094880bb14bcd064f | |
| parent | 9e5de85e21d9373bc8248827bc12e3e995b57c98 (diff) | |
| parent | 7bb4802a03fed6aa3e7eaee7a30b7c2c4c0105f4 (diff) | |
Merge "Update NotificationRecord of snooze even after it is cancelled"
| -rw-r--r-- | services/core/java/com/android/server/notification/SnoozeHelper.java | 3 | ||||
| -rw-r--r-- | services/tests/uiservicestests/src/com/android/server/notification/SnoozeHelperTest.java | 20 |
2 files changed, 20 insertions, 3 deletions
diff --git a/services/core/java/com/android/server/notification/SnoozeHelper.java b/services/core/java/com/android/server/notification/SnoozeHelper.java index abc98412e126..fbb6d6a06433 100644 --- a/services/core/java/com/android/server/notification/SnoozeHelper.java +++ b/services/core/java/com/android/server/notification/SnoozeHelper.java @@ -231,9 +231,6 @@ public class SnoozeHelper { return; } NotificationRecord existing = pkgRecords.get(record.getKey()); - if (existing != null && existing.isCanceled) { - return; - } pkgRecords.put(record.getKey(), record); } diff --git a/services/tests/uiservicestests/src/com/android/server/notification/SnoozeHelperTest.java b/services/tests/uiservicestests/src/com/android/server/notification/SnoozeHelperTest.java index 1e645436e7ea..8939375f7ebe 100644 --- a/services/tests/uiservicestests/src/com/android/server/notification/SnoozeHelperTest.java +++ b/services/tests/uiservicestests/src/com/android/server/notification/SnoozeHelperTest.java @@ -227,6 +227,26 @@ public class SnoozeHelperTest extends UiServiceTestCase { } @Test + public void testUpdateAfterCancel() throws Exception { + // snooze a notification + NotificationRecord r = getNotificationRecord("pkg", 1, "one", UserHandle.SYSTEM); + mSnoozeHelper.snooze(r , 1000); + + // cancel the notification + mSnoozeHelper.cancel(UserHandle.USER_SYSTEM, false); + + // update the notification + r = getNotificationRecord("pkg", 1, "one", UserHandle.SYSTEM); + mSnoozeHelper.update(UserHandle.USER_SYSTEM, r); + + // verify callback is called when repost (snooze is expired) + verify(mCallback, never()).repost(anyInt(), any(NotificationRecord.class)); + mSnoozeHelper.repost(r.getKey(), UserHandle.USER_SYSTEM); + verify(mCallback, times(1)).repost(UserHandle.USER_SYSTEM, r); + assertFalse(r.isCanceled); + } + + @Test public void testGetSnoozedByUser() throws Exception { NotificationRecord r = getNotificationRecord("pkg", 1, "one", UserHandle.SYSTEM); NotificationRecord r2 = getNotificationRecord("pkg", 2, "two", UserHandle.SYSTEM); |