From f2a5a2786c2064d320ec524901aaaee24db834b1 Mon Sep 17 00:00:00 2001 From: twyen Date: Tue, 19 Dec 2017 10:52:03 -0800 Subject: Ignore deleted voicemail for notification Some voicemail sources keep deleted voicemails in the database for a while. Before this CL if the voicemail is deleted through blocking it will still be returned with CallLogNotificationQueryHelper.getNewVoicemail(), and deleted again. The Deletion triggers a notification update, and the phone enters a loop. If there are other voicemails, the phone will alert every time. In this CL, deleted voicemails are no longer returned with the new voicemail query. Also if All voicemails already has a notification, the user will not be alerted. Bug: 70585368 Test: VisualVoicmailUpdateTaskTest, CallLogNotificationQueryHelperTest PiperOrigin-RevId: 179575512 Change-Id: I352bbf7d0a9d5e2132b5f968e5b5776c9fd518c6 --- .../calllog/CallLogNotificationsQueryHelper.java | 6 ++++++ .../app/calllog/VisualVoicemailUpdateTask.java | 25 ++++++++++++++++++++-- 2 files changed, 29 insertions(+), 2 deletions(-) (limited to 'java/com') 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 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