Merge "Update ranking for uninflated updated notifs"

This commit is contained in:
Beverly Tai
2020-10-16 12:00:14 +00:00
committed by Android (Google) Code Review
4 changed files with 36 additions and 7 deletions

View File

@@ -618,6 +618,7 @@ public class NotificationEntryManager implements
NotificationEntry entry = mPendingNotifications.get(key);
if (entry != null) {
entry.setSbn(notification);
entry.setRanking(ranking);
} else {
entry = new NotificationEntry(
notification,

View File

@@ -41,8 +41,6 @@ import javax.inject.Inject;
*/
@SysUISingleton
public class RankingCoordinator implements Coordinator {
private static final String TAG = "RankingNotificationCoordinator";
private final StatusBarStateController mStatusBarStateController;
private final HighPriorityProvider mHighPriorityProvider;
private final NodeController mSilentHeaderController;
@@ -65,7 +63,7 @@ public class RankingCoordinator implements Coordinator {
mStatusBarStateController.addCallback(mStatusBarStateCallback);
pipeline.addPreGroupFilter(mSuspendedFilter);
pipeline.addPreGroupFilter(mDozingFilter);
pipeline.addPreGroupFilter(mDndVisualEffectsFilter);
}
public NotifSectioner getAlertingSectioner() {
@@ -114,10 +112,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;
}
@@ -130,7 +128,7 @@ public class RankingCoordinator implements Coordinator {
new StatusBarStateController.StateListener() {
@Override
public void onDozingChanged(boolean isDozing) {
mDozingFilter.invalidateList();
mDndVisualEffectsFilter.invalidateList();
}
};
}

View File

@@ -497,7 +497,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() {
// If the SystemNotifAsyncTask hasn't finished running or retrieved a value, we'll try once

View File

@@ -379,6 +379,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, 0, 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