diff options
author | Treehugger Robot <treehugger-gerrit@google.com> | 2017-12-19 20:25:57 +0000 |
---|---|---|
committer | Gerrit Code Review <noreply-gerritcodereview@google.com> | 2017-12-19 20:25:57 +0000 |
commit | 0f76636bba4a2c01663c98fa4f3a88d3435e45d7 (patch) | |
tree | 9dac7860ec2d4ffe3b1a011a7e6f39b3f5add60a /java/com/android/dialer/app/calllog/VisualVoicemailUpdateTask.java | |
parent | d55b09c780dad2fdbc851e60c7fd05f531b10425 (diff) | |
parent | f2a5a2786c2064d320ec524901aaaee24db834b1 (diff) |
Merge "Ignore deleted voicemail for notification"
Diffstat (limited to 'java/com/android/dialer/app/calllog/VisualVoicemailUpdateTask.java')
-rw-r--r-- | java/com/android/dialer/app/calllog/VisualVoicemailUpdateTask.java | 25 |
1 files changed, 23 insertions, 2 deletions
diff --git a/java/com/android/dialer/app/calllog/VisualVoicemailUpdateTask.java b/java/com/android/dialer/app/calllog/VisualVoicemailUpdateTask.java index e3279ce26..2e12cecf7 100644 --- a/java/com/android/dialer/app/calllog/VisualVoicemailUpdateTask.java +++ b/java/com/android/dialer/app/calllog/VisualVoicemailUpdateTask.java @@ -67,9 +67,11 @@ class VisualVoicemailUpdateTask implements Worker<VisualVoicemailUpdateTask.Inpu // Query failed, just return return; } - boolean shouldAlert = !voicemailsToNotify.isEmpty(); - voicemailsToNotify.addAll(getAndUpdateVoicemailsWithExistingNotification(context, queryHelper)); voicemailsToNotify = filterBlockedNumbers(context, queryHandler, voicemailsToNotify); + boolean shouldAlert = + !voicemailsToNotify.isEmpty() + && voicemailsToNotify.size() > getExistingNotificationCount(context); + voicemailsToNotify.addAll(getAndUpdateVoicemailsWithExistingNotification(context, queryHelper)); if (voicemailsToNotify.isEmpty()) { LogUtil.i("VisualVoicemailUpdateTask.updateNotification", "no voicemails to notify about"); VisualVoicemailNotifier.cancelAllVoicemailNotifications(context); @@ -107,6 +109,25 @@ class VisualVoicemailUpdateTask implements Worker<VisualVoicemailUpdateTask.Inpu VoicemailNotificationJobService.scheduleJob(context); } + @WorkerThread + @NonNull + private static int getExistingNotificationCount(Context context) { + Assert.isWorkerThread(); + int result = 0; + for (StatusBarNotification notification : + DialerNotificationManager.getActiveNotifications(context)) { + if (notification.getId() != VisualVoicemailNotifier.NOTIFICATION_ID) { + continue; + } + if (TextUtils.isEmpty(notification.getTag()) + || !notification.getTag().startsWith(VisualVoicemailNotifier.NOTIFICATION_TAG_PREFIX)) { + continue; + } + result++; + } + return result; + } + /** * Cancel notification for voicemail that is already deleted. Returns a list of voicemails that * already has notifications posted and should be updated. |