summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEvan Laird <evanlaird@google.com>2019-12-10 17:15:03 -0500
committerandroid-build-team Robot <android-build-team-robot@google.com>2019-12-18 06:23:19 +0000
commit87670f362090b4790d85e1347be9849a7461c2a1 (patch)
tree5f6d29c2521ad2511fe64da256ee2559ee84523d
parentaa2ffea8baea65c13ac2b841b3d581f28261dd2b (diff)
downloadbase-87670f362090b4790d85e1347be9849a7461c2a1.tar.gz
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 (cherry picked from commit 323ce6205704cc1b3e13b61286069451643392b5)
-rw-r--r--packages/SystemUI/src/com/android/systemui/statusbar/notification/NotificationEntryManager.java5
-rw-r--r--packages/SystemUI/src/com/android/systemui/statusbar/notification/collection/NotificationData.java3
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 a37367e4bb25..da0f83da5a71 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/notification/NotificationEntryManager.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/notification/NotificationEntryManager.java
@@ -89,7 +89,6 @@ public class NotificationEntryManager implements
private NotificationRowBinder mNotificationRowBinder;
private NotificationPresenter mPresenter;
- private NotificationListenerService.RankingMap mLatestRankingMap;
@VisibleForTesting
protected NotificationData mNotificationData;
@@ -168,8 +167,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() {
@@ -307,7 +305,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 00092929fd49..4ad7487091e4 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
@@ -201,6 +201,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;