From ce58b4a240acfe66f186edbd9deec4b815b494f3 Mon Sep 17 00:00:00 2001 From: Beverly Date: Wed, 8 Jan 2020 15:31:15 -0500 Subject: [PATCH] Update SBN overrideGroupKey onRankingUpdate Test: atest NotifCollectionTest Bug: 146571436 Change-Id: I35ac7bcd87b56030455e6d75dab26983ca2964d9 --- .../notification/collection/NotifCollection.java | 8 ++++++++ .../notification/collection/NotifCollectionTest.java | 9 +++++++++ 2 files changed, 17 insertions(+) diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/notification/collection/NotifCollection.java b/packages/SystemUI/src/com/android/systemui/statusbar/notification/collection/NotifCollection.java index 873cdbc91d259..856b75b7e36c5 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/notification/collection/NotifCollection.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/notification/collection/NotifCollection.java @@ -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); + } } } } diff --git a/packages/SystemUI/tests/src/com/android/systemui/statusbar/notification/collection/NotifCollectionTest.java b/packages/SystemUI/tests/src/com/android/systemui/statusbar/notification/collection/NotifCollectionTest.java index 0837a42ae7006..28feacac8c441 100644 --- a/packages/SystemUI/tests/src/com/android/systemui/statusbar/notification/collection/NotifCollectionTest.java +++ b/packages/SystemUI/tests/src/com/android/systemui/statusbar/notification/collection/NotifCollectionTest.java @@ -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