From 206e7d747e67fb7317b2e1b7d59728fa3fc52be8 Mon Sep 17 00:00:00 2001 From: Jeff DeCew Date: Tue, 7 Jul 2020 15:53:50 -0400 Subject: [PATCH] Prevent bell icon from disappearing on immediate followup notification. The Ranking object of a notification update has lastAudiblylertedMs of -1 if the notification did not buzz because a buzz happened within the last 5s. This causes the bell icon to disappear on a conversation where a person posted twice within 5s. This is resolved by copying the lastAudiblyAlertedMs from the NotificationEntry's existing Ranking when setting a new one, if the new Ranking's value is -1. Bug: 156887617 Test: Update an alerting notification within 5s of update which caused an alert; bell should stay even though buzz is skipped. Change-Id: Ibb72ab27c88cfa57add781e2746fff0eee5de6be --- .../notification/NotificationListenerService.java | 11 +++++++++++ .../notification/collection/NotificationEntry.java | 2 +- .../systemui/statusbar/policy/HeadsUpManager.java | 6 +++--- 3 files changed, 15 insertions(+), 4 deletions(-) diff --git a/core/java/android/service/notification/NotificationListenerService.java b/core/java/android/service/notification/NotificationListenerService.java index c52b02bb6a3ca..dfd305330b146 100644 --- a/core/java/android/service/notification/NotificationListenerService.java +++ b/core/java/android/service/notification/NotificationListenerService.java @@ -1900,6 +1900,17 @@ public abstract class NotificationListenerService extends Service { mIsBubble = isBubble; } + /** + * @hide + */ + public @NonNull Ranking withAudiblyAlertedInfo(@Nullable Ranking previous) { + if (previous != null && previous.mLastAudiblyAlertedMs > 0 + && this.mLastAudiblyAlertedMs <= 0) { + this.mLastAudiblyAlertedMs = previous.mLastAudiblyAlertedMs; + } + return this; + } + /** * @hide */ diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/notification/collection/NotificationEntry.java b/packages/SystemUI/src/com/android/systemui/statusbar/notification/collection/NotificationEntry.java index 423f85f2ddd0f..bd65ef06f3a9f 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/notification/collection/NotificationEntry.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/notification/collection/NotificationEntry.java @@ -282,7 +282,7 @@ public final class NotificationEntry extends ListEntry { + " doesn't match existing key " + mKey); } - mRanking = ranking; + mRanking = ranking.withAudiblyAlertedInfo(mRanking); } /* diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/policy/HeadsUpManager.java b/packages/SystemUI/src/com/android/systemui/statusbar/policy/HeadsUpManager.java index 07de388598b75..c43ad36d4462d 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/policy/HeadsUpManager.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/policy/HeadsUpManager.java @@ -106,9 +106,9 @@ public abstract class HeadsUpManager extends AlertingNotificationManager { public void updateNotification(@NonNull String key, boolean alert) { super.updateNotification(key, alert); - AlertEntry alertEntry = getHeadsUpEntry(key); - if (alert && alertEntry != null) { - setEntryPinned((HeadsUpEntry) alertEntry, shouldHeadsUpBecomePinned(alertEntry.mEntry)); + HeadsUpEntry headsUpEntry = getHeadsUpEntry(key); + if (alert && headsUpEntry != null) { + setEntryPinned(headsUpEntry, shouldHeadsUpBecomePinned(headsUpEntry.mEntry)); } }