From b9be52dc69fff3dd819f3aa94fec69af5657b039 Mon Sep 17 00:00:00 2001 From: Lyn Han Date: Tue, 31 Mar 2020 22:13:34 -0700 Subject: [PATCH] Show selected bubble first, after stack expands When the stack collapses, BubbleData moves the selected bubble to first in stack, but marks accessed time instead of updated time. Sorting uses updated time (in repackAll) and moves the selected bubble back to where it was, when the stack expands later. Fixed by marking updated time in addition to accessed time. Fixes: 152883409 Test: manual: select bubble in middle of stack, collapse stack, expand stack -> see that bubble first in stack Test: manual: select bubble in middle of stack, collapse stack, add new bubble, expand stack -> see that new bubble is first in stack and previously selected bubble is repacked Change-Id: I8042549708ba3ace13d94e9cd3397af229af2dc9 --- .../android/systemui/bubbles/BubbleData.java | 3 ++- .../systemui/bubbles/BubbleDataTest.java | 17 ++++------------- 2 files changed, 6 insertions(+), 14 deletions(-) diff --git a/packages/SystemUI/src/com/android/systemui/bubbles/BubbleData.java b/packages/SystemUI/src/com/android/systemui/bubbles/BubbleData.java index 1c69594469c11..be9cd5f01c86a 100644 --- a/packages/SystemUI/src/com/android/systemui/bubbles/BubbleData.java +++ b/packages/SystemUI/src/com/android/systemui/bubbles/BubbleData.java @@ -549,6 +549,7 @@ public class BubbleData { Log.e(TAG, "Attempt to expand stack without selected bubble!"); return; } + mSelectedBubble.markUpdatedAt(mTimeSource.currentTimeMillis()); mSelectedBubble.markAsAccessedAt(mTimeSource.currentTimeMillis()); mStateChange.orderChanged |= repackAll(); } else if (!mBubbles.isEmpty()) { @@ -662,7 +663,7 @@ public class BubbleData { /** * This applies a full sort and group pass to all existing bubbles. The bubbles are grouped - * by groupId. Each group is then sorted by the max(lastUpdated) time of it's bubbles. Bubbles + * by groupId. Each group is then sorted by the max(lastUpdated) time of its bubbles. Bubbles * within each group are then sorted by lastUpdated descending. * * @return true if the position of any bubbles changed as a result 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 c86b5f76fc051..7df39838b1677 100644 --- a/packages/SystemUI/tests/src/com/android/systemui/bubbles/BubbleDataTest.java +++ b/packages/SystemUI/tests/src/com/android/systemui/bubbles/BubbleDataTest.java @@ -599,13 +599,13 @@ public class BubbleDataTest extends SysuiTestCase { sendUpdatedEntryAtTime(mEntryA1, 1000); sendUpdatedEntryAtTime(mEntryA2, 2000); sendUpdatedEntryAtTime(mEntryB1, 3000); // [B1, A2, A1] - changeExpandedStateAtTime(true, 4000L); + changeExpandedStateAtTime(true, 4000L); // B1 marked updated at 4000L mBubbleData.setListener(mListener); // Test sendUpdatedEntryAtTime(mEntryC1, 4000); verifyUpdateReceived(); - assertOrderChangedTo(mBubbleC1, mBubbleB1, mBubbleA2, mBubbleA1); + assertOrderChangedTo(mBubbleB1, mBubbleC1, mBubbleA2, mBubbleA1); } /** @@ -789,8 +789,7 @@ public class BubbleDataTest extends SysuiTestCase { * When the stack transitions to the collapsed state, the selected bubble is brought to the top. * Bubbles within the same group should move up with it. *

- * When the stack transitions back to the expanded state, the previous ordering is restored, as - * long as no changes have been made (adds, removes or updates) while in the collapsed state. + * When the stack transitions back to the expanded state, this new order is kept as is. */ @Test public void test_expansionChanges() { @@ -813,20 +812,12 @@ public class BubbleDataTest extends SysuiTestCase { // stack is expanded. When next collapsed, sorting will be applied and saved, just prior // to moving the selected bubble to the top (first). // - // In this case, the expected re-expand state will be: [B1, B2, A2*, A1] - // - // That state is restored as long as no changes occur (add/remove/update) while in - // the collapsed state. + // In this case, the expected re-expand state will be: [A2, A1, B1, B2] // // collapse -> selected bubble (A2) moves first. changeExpandedStateAtTime(false, 8000L); verifyUpdateReceived(); assertOrderChangedTo(mBubbleA2, mBubbleA1, mBubbleB1, mBubbleB2); - - // expand -> "original" order/grouping restored - changeExpandedStateAtTime(true, 10000L); - verifyUpdateReceived(); - assertOrderChangedTo(mBubbleB1, mBubbleB2, mBubbleA2, mBubbleA1); } /**