From 323ce6205704cc1b3e13b61286069451643392b5 Mon Sep 17 00:00:00 2001 From: Evan Laird Date: Tue, 10 Dec 2019 17:15:03 -0500 Subject: DO NOT MERGE: Don't let NotificationEntryManager keep around old RankingMaps When a notification becomes lifetime-extended, NotificationEntryManager was holding onto the RankingMap that was passed at the time of removal of _that_ notification, and using it again in the NotificationSafeToRemoveCallback. The problem here is that when onSafeToRemove gets called, it was passing that same stale ranking map to removeNotification, which caused any notification that arrived in the intervening time to get improperly ranked. This fixes an issue where any notification that arrives while another is lifetime-extended can get the wrong ranking applied to it, causing trouble later in time such as mis-ranking and mis-sorting until the next update from system server. Bug: 146046016 Bug: 119041698 Test: atest SystemUITests Test: manual - Post a FGS notification and immediately cancel, then post a regular notification and wait for the FGS notification to dismiss. Note that the regular notification keeps showing in the status bar. Change-Id: I3df1279f13c424fcedd878bae2095fadc75d61b4 --- .../systemui/statusbar/notification/NotificationEntryManager.java | 5 +---- .../systemui/statusbar/notification/collection/NotificationData.java | 3 +++ 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/notification/NotificationEntryManager.java b/packages/SystemUI/src/com/android/systemui/statusbar/notification/NotificationEntryManager.java index 5958d9d28c9e..cfc1a5f2ef3d 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/notification/NotificationEntryManager.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/notification/NotificationEntryManager.java @@ -85,7 +85,6 @@ public class NotificationEntryManager implements private NotificationRowBinder mNotificationRowBinder; private NotificationPresenter mPresenter; - private NotificationListenerService.RankingMap mLatestRankingMap; @VisibleForTesting protected NotificationData mNotificationData; @@ -163,8 +162,7 @@ public class NotificationEntryManager implements /** Adds a {@link NotificationLifetimeExtender}. */ public void addNotificationLifetimeExtender(NotificationLifetimeExtender extender) { mNotificationLifetimeExtenders.add(extender); - extender.setCallback(key -> removeNotification(key, mLatestRankingMap, - UNDEFINED_DISMISS_REASON)); + extender.setCallback(key -> removeNotification(key, null, UNDEFINED_DISMISS_REASON)); } public NotificationData getNotificationData() { @@ -302,7 +300,6 @@ public class NotificationEntryManager implements if (!forceRemove && !entryDismissed) { for (NotificationLifetimeExtender extender : mNotificationLifetimeExtenders) { if (extender.shouldExtendLifetime(entry)) { - mLatestRankingMap = ranking; extendLifetime(entry, extender); lifetimeExtended = true; break; diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/notification/collection/NotificationData.java b/packages/SystemUI/src/com/android/systemui/statusbar/notification/collection/NotificationData.java index fb100842f969..57830e959500 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/notification/collection/NotificationData.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/notification/collection/NotificationData.java @@ -203,6 +203,9 @@ public class NotificationData { removed = mEntries.remove(key); } if (removed == null) return null; + // NEM may pass us a null ranking map if removing a lifetime-extended notification, + // so use the most recent ranking + if (ranking == null) ranking = mRankingMap; mGroupManager.onEntryRemoved(removed); updateRankingAndSort(ranking); return removed; -- cgit v1.2.3-59-g8ed1b