From bf1b3d66315010b1671124017edad7f3d5f709c3 Mon Sep 17 00:00:00 2001 From: Lyn Han Date: Thu, 12 Mar 2020 10:31:19 -0700 Subject: [PATCH] Move overflow bubble to stack on update BubbleData#getOrCreateBubble is called per update, pre-inflation - If bubble overflowed, remove it from overflow list, - add it to pending bubbles, where it will be removed on notificationEntryUpdated, post inflation - return this bubble instead of creating a new one Fixes: 150396294 Test: atest SystemUITests Test: manual 1. Add people bubbles 2. Add more bubbles to get people in overflow 3. Add bubbles for same people, so that they are "active" in stack 4. Go to overflow => overflow no longer shows people "active" in stack Change-Id: I79c1ba92533169da0e82414f2ad507cbf20d8561 --- .../android/systemui/bubbles/BubbleData.java | 8 ++++++++ .../systemui/bubbles/BubbleDataTest.java | 18 ++++++++++++++---- 2 files changed, 22 insertions(+), 4 deletions(-) diff --git a/packages/SystemUI/src/com/android/systemui/bubbles/BubbleData.java b/packages/SystemUI/src/com/android/systemui/bubbles/BubbleData.java index cf5a4d3840cca..39abc2118d156 100644 --- a/packages/SystemUI/src/com/android/systemui/bubbles/BubbleData.java +++ b/packages/SystemUI/src/com/android/systemui/bubbles/BubbleData.java @@ -225,6 +225,14 @@ public class BubbleData { Bubble getOrCreateBubble(NotificationEntry entry) { Bubble bubble = getBubbleWithKey(entry.getKey()); if (bubble == null) { + for (int i = 0; i < mOverflowBubbles.size(); i++) { + Bubble b = mOverflowBubbles.get(i); + if (b.getKey().equals(entry.getKey())) { + mOverflowBubbles.remove(b); + mPendingBubbles.add(b); + return b; + } + } // Check for it in pending for (int i = 0; i < mPendingBubbles.size(); i++) { Bubble b = mPendingBubbles.get(i); diff --git a/packages/SystemUI/tests/src/com/android/systemui/bubbles/BubbleDataTest.java b/packages/SystemUI/tests/src/com/android/systemui/bubbles/BubbleDataTest.java index f40fc94763ab8..866dfdc9c7e42 100644 --- a/packages/SystemUI/tests/src/com/android/systemui/bubbles/BubbleDataTest.java +++ b/packages/SystemUI/tests/src/com/android/systemui/bubbles/BubbleDataTest.java @@ -268,13 +268,18 @@ public class BubbleDataTest extends SysuiTestCase { sendUpdatedEntryAtTime(mEntryB2, 5000); mBubbleData.setListener(mListener); - // Test sendUpdatedEntryAtTime(mEntryC1, 6000); verifyUpdateReceived(); - - // Verify assertBubbleRemoved(mBubbleA1, BubbleController.DISMISS_AGED); - assertThat(mBubbleData.getOverflowBubbles()).isEqualTo(ImmutableList.of(mBubbleA1)); + assertOverflowChangedTo(ImmutableList.of(mBubbleA1)); + + Bubble bubbleA1 = mBubbleData.getOrCreateBubble(mEntryA1); + bubbleA1.markUpdatedAt(7000L); + mBubbleData.notificationEntryUpdated(bubbleA1, false /* suppressFlyout*/, + true /* showInShade */); + verifyUpdateReceived(); + assertBubbleRemoved(mBubbleA2, BubbleController.DISMISS_AGED); + assertOverflowChangedTo(ImmutableList.of(mBubbleA2)); } /** @@ -931,6 +936,11 @@ public class BubbleDataTest extends SysuiTestCase { assertThat(update.expanded).named("expanded").isEqualTo(expected); } + private void assertOverflowChangedTo(ImmutableList bubbles) { + BubbleData.Update update = mUpdateCaptor.getValue(); + assertThat(update.overflowBubbles).isEqualTo(bubbles); + } + private NotificationEntry createBubbleEntry(int userId, String notifKey, String packageName) { return createBubbleEntry(userId, notifKey, packageName, 1000);