From 9dc721018f096a4a13372436b9830b7352ecc8ce Mon Sep 17 00:00:00 2001 From: Beverly Date: Thu, 15 Oct 2020 14:21:49 -0400 Subject: Update ranking for uninflated updated notifs Also updates notif pipeline filter name: IsDozingFilter => DndSuppressVisualEffectsFilter. Fixes: 170386608 Test: atest NotificationEntryManagerTest Test: manual 1. Turn on DND with visual effects not allowed and all messages allowed to bypass 2. In a test app post two notifications after one another (one w/o messaging style, another with messaging style) Observe: HUN, as expected Change-Id: Ife8c1b52415cd749fecdbdc59fa5b3773b543acf Merged-In: Ife8c1b52415cd749fecdbdc59fa5b3773b543acf --- .../notification/NotificationEntryManager.java | 1 + .../collection/coordinator/RankingCoordinator.java | 10 +++----- .../row/ExpandableNotificationRow.java | 2 +- .../notification/NotificationEntryManagerTest.java | 30 ++++++++++++++++++++++ 4 files changed, 36 insertions(+), 7 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 d04389d6cbe8..9fd729f425c1 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/notification/NotificationEntryManager.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/notification/NotificationEntryManager.java @@ -574,6 +574,7 @@ public class NotificationEntryManager implements NotificationEntry entry = mPendingNotifications.get(key); if (entry != null) { entry.setSbn(notification); + entry.setRanking(ranking); } else { entry = new NotificationEntry( notification, diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/notification/collection/coordinator/RankingCoordinator.java b/packages/SystemUI/src/com/android/systemui/statusbar/notification/collection/coordinator/RankingCoordinator.java index e9cbf32ee052..943ace968632 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/notification/collection/coordinator/RankingCoordinator.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/notification/collection/coordinator/RankingCoordinator.java @@ -32,8 +32,6 @@ import javax.inject.Singleton; */ @Singleton public class RankingCoordinator implements Coordinator { - private static final String TAG = "RankingNotificationCoordinator"; - private final StatusBarStateController mStatusBarStateController; @Inject @@ -46,7 +44,7 @@ public class RankingCoordinator implements Coordinator { mStatusBarStateController.addCallback(mStatusBarStateCallback); pipeline.addPreGroupFilter(mSuspendedFilter); - pipeline.addPreGroupFilter(mDozingFilter); + pipeline.addPreGroupFilter(mDndVisualEffectsFilter); } /** @@ -61,10 +59,10 @@ public class RankingCoordinator implements Coordinator { } }; - private final NotifFilter mDozingFilter = new NotifFilter("IsDozingFilter") { + private final NotifFilter mDndVisualEffectsFilter = new NotifFilter( + "DndSuppressingVisualEffects") { @Override public boolean shouldFilterOut(NotificationEntry entry, long now) { - // Dozing + DND Settings from Ranking object if (mStatusBarStateController.isDozing() && entry.shouldSuppressAmbient()) { return true; } @@ -77,7 +75,7 @@ public class RankingCoordinator implements Coordinator { new StatusBarStateController.StateListener() { @Override public void onDozingChanged(boolean isDozing) { - mDozingFilter.invalidateList(); + mDndVisualEffectsFilter.invalidateList(); } }; } diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/notification/row/ExpandableNotificationRow.java b/packages/SystemUI/src/com/android/systemui/statusbar/notification/row/ExpandableNotificationRow.java index 94e12e82f850..70dd80e71e7a 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/notification/row/ExpandableNotificationRow.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/notification/row/ExpandableNotificationRow.java @@ -504,7 +504,7 @@ public class ExpandableNotificationRow extends ActivatableNotificationView /** * Returns whether this row is considered non-blockable (i.e. it's a non-blockable system notif - * or is in a whitelist). + * or is in an allowList). */ public boolean getIsNonblockable() { boolean isNonblockable = Dependency.get(NotificationBlockingHelperManager.class) diff --git a/packages/SystemUI/tests/src/com/android/systemui/statusbar/notification/NotificationEntryManagerTest.java b/packages/SystemUI/tests/src/com/android/systemui/statusbar/notification/NotificationEntryManagerTest.java index 90423c18216a..f1e6bf604a14 100644 --- a/packages/SystemUI/tests/src/com/android/systemui/statusbar/notification/NotificationEntryManagerTest.java +++ b/packages/SystemUI/tests/src/com/android/systemui/statusbar/notification/NotificationEntryManagerTest.java @@ -381,6 +381,36 @@ public class NotificationEntryManagerTest extends SysuiTestCase { assertEquals("action", mEntry.getSmartActions().get(0).title); } + @Test + public void testUpdatePendingNotification_rankingUpdated() { + // GIVEN a notification with ranking is pending + final Ranking originalRanking = mEntry.getRanking(); + mEntryManager.mPendingNotifications.put(mEntry.getKey(), mEntry); + + // WHEN the same notification has been updated with a new ranking + final int newRank = 2345; + doAnswer(invocationOnMock -> { + Ranking ranking = (Ranking) + invocationOnMock.getArguments()[1]; + ranking.populate( + mEntry.getKey(), + newRank, /* this changed!! */ + false, + 0, + 0, + IMPORTANCE_DEFAULT, + null, null, + null, null, null, true, + Ranking.USER_SENTIMENT_NEUTRAL, false, -1, + false, null, null, false, false, false, null, false); + return true; + }).when(mRankingMap).getRanking(eq(mEntry.getKey()), any(Ranking.class)); + mEntryManager.addNotification(mSbn, mRankingMap); + + // THEN ranking for the entry has been updated with new ranking + assertEquals(newRank, mEntry.getRanking().getRank()); + } + @Test public void testLifetimeExtenders_ifNotificationIsRetainedItIsntRemoved() { // GIVEN an entry manager with a notification -- cgit v1.2.3-59-g8ed1b