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 | |
parent | d55b09c780dad2fdbc851e60c7fd05f531b10425 (diff) | |
parent | f2a5a2786c2064d320ec524901aaaee24db834b1 (diff) |
Merge "Ignore deleted voicemail for notification"
Diffstat (limited to 'java/com/android/dialer/app')
-rw-r--r-- | java/com/android/dialer/app/calllog/CallLogNotificationsQueryHelper.java | 6 | ||||
-rw-r--r-- | java/com/android/dialer/app/calllog/VisualVoicemailUpdateTask.java | 25 |
2 files changed, 29 insertions, 2 deletions
diff --git a/java/com/android/dialer/app/calllog/CallLogNotificationsQueryHelper.java b/java/com/android/dialer/app/calllog/CallLogNotificationsQueryHelper.java index 47457360d..3a4bf8766 100644 --- a/java/com/android/dialer/app/calllog/CallLogNotificationsQueryHelper.java +++ b/java/com/android/dialer/app/calllog/CallLogNotificationsQueryHelper.java @@ -26,6 +26,7 @@ import android.database.Cursor; import android.net.Uri; import android.os.Build; import android.provider.CallLog.Calls; +import android.provider.VoicemailContract.Voicemails; import android.support.annotation.NonNull; import android.support.annotation.Nullable; import android.support.annotation.VisibleForTesting; @@ -365,6 +366,11 @@ public class CallLogNotificationsQueryHelper { .and(Selection.column(Calls.NEW).is("= 1")) .and(Selection.column(Calls.TYPE).is("=", type)) .and(Selection.column(Calls.IS_READ).is("IS NOT 1")); + + if (type == Calls.VOICEMAIL_TYPE) { + selectionBuilder.and(Selection.column(Voicemails.DELETED).is(" = 0")); + } + if (thresholdMillis != NO_THRESHOLD) { selectionBuilder = selectionBuilder.and( 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. |