From 443dcfbb54648034f58e1accecb54589cd0c5833 Mon Sep 17 00:00:00 2001 From: twyen Date: Mon, 11 Jun 2018 16:37:18 -0700 Subject: Ignore read voicemails for notifications Previously the notification is only auto-canceled if it is deleted from the server. In this CL it will also be canceled if it is read. TEST=TAP Bug: 80214330 Test: TAP PiperOrigin-RevId: 200134453 Change-Id: I716c4c6ee060a7b4162147d9bf9e2e1f5077317a --- .../app/calllog/CallLogNotificationsQueryHelper.java | 16 +++++++++++----- .../dialer/app/calllog/VisualVoicemailUpdateTask.java | 2 +- 2 files changed, 12 insertions(+), 6 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 b5ca0901b..152a3b837 100644 --- a/java/com/android/dialer/app/calllog/CallLogNotificationsQueryHelper.java +++ b/java/com/android/dialer/app/calllog/CallLogNotificationsQueryHelper.java @@ -260,7 +260,7 @@ public class CallLogNotificationsQueryHelper { /** Returns a {@link NewCall} pointed by the {@code callsUri} */ @Nullable - NewCall query(Uri callsUri); + NewCall queryUnreadVoicemail(Uri callsUri); } /** Information about a new voicemail. */ @@ -415,20 +415,26 @@ public class CallLogNotificationsQueryHelper { @Nullable @Override - public NewCall query(Uri callsUri) { + @SuppressWarnings("missingPermission") + public NewCall queryUnreadVoicemail(Uri voicemailUri) { if (!PermissionsUtil.hasPermission(context, Manifest.permission.READ_CALL_LOG)) { LogUtil.w( "CallLogNotificationsQueryHelper.DefaultNewCallsQuery.query", "No READ_CALL_LOG permission, returning null for calls lookup."); return null; } - final String selection = String.format("%s = '%s'", Calls.VOICEMAIL_URI, callsUri.toString()); + Selection selection = + Selection.column(Calls.VOICEMAIL_URI) + .is("=", voicemailUri) + .buildUpon() + .and(Selection.column(Calls.IS_READ).is("IS NOT", 1)) + .build(); try (Cursor cursor = contentResolver.query( Calls.CONTENT_URI_WITH_VOICEMAIL, (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) ? PROJECTION_O : PROJECTION, - selection, - null, + selection.getSelection(), + selection.getSelectionArgs(), null)) { if (cursor == null) { return null; diff --git a/java/com/android/dialer/app/calllog/VisualVoicemailUpdateTask.java b/java/com/android/dialer/app/calllog/VisualVoicemailUpdateTask.java index bae30fa7b..e3cc5158e 100644 --- a/java/com/android/dialer/app/calllog/VisualVoicemailUpdateTask.java +++ b/java/com/android/dialer/app/calllog/VisualVoicemailUpdateTask.java @@ -160,7 +160,7 @@ class VisualVoicemailUpdateTask implements Worker