From a7f50f29f0a762acc7d80691a939cd54207b7533 Mon Sep 17 00:00:00 2001 From: twyen Date: Mon, 30 Apr 2018 15:33:07 -0700 Subject: Cancel all legacy voicemail notification when SIMs are removed on multi-SIM devices When the SIM is removed, telephony will signal cancel notifications on the "null" account (the framework doen't know what was there.). Previously this has no effect. In this CL, all legacy voicemail notifications are removed since all SIM will be removed together. TEST=TAP Bug: 78446801 Test: TAP PiperOrigin-RevId: 194856211 Change-Id: I5df97f0c73e0644daa46ab182f19e60044e39d96 --- .../android/dialer/notification/DialerNotificationManager.java | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'java/com/android/dialer/notification/DialerNotificationManager.java') diff --git a/java/com/android/dialer/notification/DialerNotificationManager.java b/java/com/android/dialer/notification/DialerNotificationManager.java index 0e3420169..2a66cd5ac 100644 --- a/java/com/android/dialer/notification/DialerNotificationManager.java +++ b/java/com/android/dialer/notification/DialerNotificationManager.java @@ -83,6 +83,16 @@ public final class DialerNotificationManager { notificationManager.cancel(tag, id); } + public static void cancelAll(Context context, String prefix) { + NotificationManager notificationManager = getNotificationManager(context); + StatusBarNotification[] notifications = notificationManager.getActiveNotifications(); + for (StatusBarNotification notification : notifications) { + if (notification.getTag() != null && notification.getTag().startsWith(prefix)) { + notificationManager.cancel(notification.getTag(), notification.getId()); + } + } + } + public static StatusBarNotification[] getActiveNotifications(@NonNull Context context) { Assert.isNotNull(context); return getNotificationManager(context).getActiveNotifications(); -- cgit v1.2.3