Update SBN overrideGroupKey onRankingUpdate

Test: atest NotifCollectionTest
Bug: 146571436
Change-Id: I35ac7bcd87b56030455e6d75dab26983ca2964d9
This commit is contained in:
Beverly
2020-01-08 15:31:15 -05:00
committed by Beverly Tai
parent d9c399ef6d
commit ce58b4a240
2 changed files with 17 additions and 0 deletions

View File

@@ -299,6 +299,14 @@ public class NotifCollection {
if (!isLifetimeExtended(entry)) {
Ranking ranking = requireRanking(rankingMap, entry.getKey());
entry.setRanking(ranking);
// TODO: (b/145659174) update the sbn's overrideGroupKey in
// NotificationEntry.setRanking instead of here once we fully migrate to the
// NewNotifPipeline
final String newOverrideGroupKey = ranking.getOverrideGroupKey();
if (!Objects.equals(entry.getSbn().getOverrideGroupKey(), newOverrideGroupKey)) {
entry.getSbn().setOverrideGroupKey(newOverrideGroupKey);
}
}
}
}

View File

@@ -24,6 +24,7 @@ import static com.android.systemui.statusbar.notification.collection.NotifCollec
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNotEquals;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertTrue;
import static org.mockito.ArgumentMatchers.anyInt;
import static org.mockito.ArgumentMatchers.eq;
@@ -261,9 +262,13 @@ public class NotifCollectionTest extends SysuiTestCase {
.setRank(5)
.setExplanation("baz buzz")
.build();
// WHEN entry3's ranking update includes an update to its overrideGroupKey
final String newOverrideGroupKey = "newOverrideGroupKey";
Ranking newRanking3 = new RankingBuilder(notif3.ranking)
.setRank(6)
.setExplanation("Penguin pizza")
.setOverrideGroupKey(newOverrideGroupKey)
.build();
mNoMan.setRanking(notif1.sbn.getKey(), newRanking1);
@@ -275,6 +280,10 @@ public class NotifCollectionTest extends SysuiTestCase {
assertEquals(newRanking1, entry1.getRanking());
assertEquals(newRanking2, entry2.getRanking());
assertEquals(newRanking3, entry3.getRanking());
// THEN the entry3's overrideGroupKey is updated along with its groupKey
assertEquals(newOverrideGroupKey, entry3.getSbn().getOverrideGroupKey());
assertNotNull(entry3.getSbn().getGroupKey());
}
@Test