From a1e64c7a9123d4323c620151cc6ca11bc25e8235 Mon Sep 17 00:00:00 2001 From: mdooley Date: Tue, 19 Sep 2017 14:50:52 -0700 Subject: Fix notification update bug The problem was that the query for looking up a voicemail by URI was broken which was causing the notifications to be cancelled then when they were supposed to be updated they were actually getting re-added thus causing the notification sound. Bug: 65692173 Test: manual and unit test PiperOrigin-RevId: 169304391 Change-Id: I1e8f648231b6f0ab984a5b0e4facd8351b01391a --- .../dialer/app/calllog/CallLogNotificationsQueryHelper.java | 9 ++++++++- java/com/android/dialer/app/calllog/VisualVoicemailNotifier.java | 2 +- .../android/dialer/app/calllog/VisualVoicemailUpdateTask.java | 4 +++- 3 files changed, 12 insertions(+), 3 deletions(-) diff --git a/java/com/android/dialer/app/calllog/CallLogNotificationsQueryHelper.java b/java/com/android/dialer/app/calllog/CallLogNotificationsQueryHelper.java index 2f8b1f476..f962e17ac 100644 --- a/java/com/android/dialer/app/calllog/CallLogNotificationsQueryHelper.java +++ b/java/com/android/dialer/app/calllog/CallLogNotificationsQueryHelper.java @@ -363,7 +363,14 @@ public class CallLogNotificationsQueryHelper { "No READ_CALL_LOG permission, returning null for calls lookup."); return null; } - try (Cursor cursor = mContentResolver.query(callsUri, PROJECTION, null, null, null)) { + final String selection = String.format("%s = '%s'", Calls.VOICEMAIL_URI, callsUri.toString()); + try (Cursor cursor = + mContentResolver.query( + Calls.CONTENT_URI_WITH_VOICEMAIL, + (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) ? PROJECTION_O : PROJECTION, + selection, + null, + null)) { if (cursor == null) { return null; } diff --git a/java/com/android/dialer/app/calllog/VisualVoicemailNotifier.java b/java/com/android/dialer/app/calllog/VisualVoicemailNotifier.java index ceae3d38e..1836416a7 100644 --- a/java/com/android/dialer/app/calllog/VisualVoicemailNotifier.java +++ b/java/com/android/dialer/app/calllog/VisualVoicemailNotifier.java @@ -52,7 +52,7 @@ import java.util.Map; /** Shows a notification in the status bar for visual voicemail. */ final class VisualVoicemailNotifier { /** Prefix used to generate a unique tag for each voicemail notification. */ - private static final String NOTIFICATION_TAG_PREFIX = "VisualVoicemail_"; + static final String NOTIFICATION_TAG_PREFIX = "VisualVoicemail_"; /** Common ID for all voicemail notifications. */ static final int NOTIFICATION_ID = 1; /** Tag for the group summary notification. */ diff --git a/java/com/android/dialer/app/calllog/VisualVoicemailUpdateTask.java b/java/com/android/dialer/app/calllog/VisualVoicemailUpdateTask.java index 219ad676d..abbb60679 100644 --- a/java/com/android/dialer/app/calllog/VisualVoicemailUpdateTask.java +++ b/java/com/android/dialer/app/calllog/VisualVoicemailUpdateTask.java @@ -126,7 +126,9 @@ class VisualVoicemailUpdateTask implements Worker