diff options
Diffstat (limited to 'java/com/android/dialer/app/calllog')
-rw-r--r-- | java/com/android/dialer/app/calllog/VisualVoicemailNotifier.java | 18 | ||||
-rw-r--r-- | java/com/android/dialer/app/calllog/VisualVoicemailUpdateTask.java | 5 |
2 files changed, 19 insertions, 4 deletions
diff --git a/java/com/android/dialer/app/calllog/VisualVoicemailNotifier.java b/java/com/android/dialer/app/calllog/VisualVoicemailNotifier.java index 2fd9a2161..4fc956fa8 100644 --- a/java/com/android/dialer/app/calllog/VisualVoicemailNotifier.java +++ b/java/com/android/dialer/app/calllog/VisualVoicemailNotifier.java @@ -64,11 +64,16 @@ final class VisualVoicemailNotifier { */ private static final String GROUP_KEY = "VisualVoicemailGroup"; + /** + * @param shouldAlert whether ringtone or vibration should be made when the notification is posted + * or updated. Should only be true when there is a real new voicemail. + */ public static void showNotifications( @NonNull Context context, @NonNull List<NewCall> newCalls, @NonNull Map<String, ContactInfo> contactInfos, - @Nullable String callers) { + @Nullable String callers, + boolean shouldAlert) { LogUtil.enterBlock("VisualVoicemailNotifier.showNotifications"); PendingIntent deleteIntent = CallLogNotificationsService.createMarkAllNewVoicemailsAsOldIntent(context); @@ -86,7 +91,15 @@ final class VisualVoicemailNotifier { .setContentIntent(newVoicemailIntent(context, null)); if (VERSION.SDK_INT >= VERSION_CODES.O) { - groupSummary.setGroupAlertBehavior(Notification.GROUP_ALERT_CHILDREN); + if (shouldAlert) { + groupSummary.setOnlyAlertOnce(false); + // Group summary will alert when posted/updated + groupSummary.setGroupAlertBehavior(Notification.GROUP_ALERT_ALL); + } else { + // Only children will alert. but since all children are set to "only alert summary" it is + // effectively silenced. + groupSummary.setGroupAlertBehavior(Notification.GROUP_ALERT_CHILDREN); + } PhoneAccountHandle handle = getAccountForCall(context, newCalls.get(0)); groupSummary.setChannelId(NotificationChannelManager.getVoicemailChannelId(context, handle)); } @@ -203,6 +216,7 @@ final class VisualVoicemailNotifier { if (VERSION.SDK_INT >= VERSION_CODES.O) { builder.setChannelId(NotificationChannelManager.getVoicemailChannelId(context, handle)); + builder.setGroupAlertBehavior(Notification.GROUP_ALERT_SUMMARY); } ContactPhotoLoader loader = new ContactPhotoLoader(context, contactInfo); diff --git a/java/com/android/dialer/app/calllog/VisualVoicemailUpdateTask.java b/java/com/android/dialer/app/calllog/VisualVoicemailUpdateTask.java index e30623bb2..77b4c1113 100644 --- a/java/com/android/dialer/app/calllog/VisualVoicemailUpdateTask.java +++ b/java/com/android/dialer/app/calllog/VisualVoicemailUpdateTask.java @@ -67,7 +67,7 @@ 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); if (voicemailsToNotify.isEmpty()) { @@ -100,7 +100,8 @@ class VisualVoicemailUpdateTask implements Worker<VisualVoicemailUpdateTask.Inpu } } } - VisualVoicemailNotifier.showNotifications(context, voicemailsToNotify, contactInfos, callers); + VisualVoicemailNotifier.showNotifications( + context, voicemailsToNotify, contactInfos, callers, shouldAlert); // Set trigger to update notifications when database changes. VoicemailNotificationJobService.scheduleJob(context); |