From 494fdeaf6e21da75acb426f9290eeb1814812d1b Mon Sep 17 00:00:00 2001 From: Joshua Tsuji Date: Fri, 19 Jun 2020 15:26:09 -0400 Subject: [PATCH] When opening from locked shade, wait for the shade to unlock before expanding. Bug: 159270619 Test: open notifs from a locked shade! Change-Id: Ibc8312895c4e4321b6a98b60a24ab7c13662e239 --- .../systemui/bubbles/BubbleController.java | 45 ++++++++++++++----- 1 file changed, 33 insertions(+), 12 deletions(-) diff --git a/packages/SystemUI/src/com/android/systemui/bubbles/BubbleController.java b/packages/SystemUI/src/com/android/systemui/bubbles/BubbleController.java index c42920965ed33..5852453f9d052 100644 --- a/packages/SystemUI/src/com/android/systemui/bubbles/BubbleController.java +++ b/packages/SystemUI/src/com/android/systemui/bubbles/BubbleController.java @@ -183,6 +183,12 @@ public class BubbleController implements ConfigurationController.ConfigurationLi // Only load overflow data from disk once private boolean mOverflowDataLoaded = false; + /** + * When the shade status changes to SHADE (from anything but SHADE, like LOCKED) we'll select + * this bubble and expand the stack. + */ + @Nullable private NotificationEntry mNotifEntryToExpandOnShadeUnlock; + private final NotificationInterruptStateProvider mNotificationInterruptStateProvider; private IStatusBarService mBarService; private WindowManager mWindowManager; @@ -292,6 +298,12 @@ public class BubbleController implements ConfigurationController.ConfigurationLi if (shouldCollapse) { collapseStack(); } + + if (mNotifEntryToExpandOnShadeUnlock != null) { + expandStackAndSelectBubble(mNotifEntryToExpandOnShadeUnlock); + mNotifEntryToExpandOnShadeUnlock = null; + } + updateStack(); } } @@ -930,20 +942,29 @@ public class BubbleController implements ConfigurationController.ConfigurationLi * @param entry the notification for the bubble to be selected */ public void expandStackAndSelectBubble(NotificationEntry entry) { - String key = entry.getKey(); - Bubble bubble = mBubbleData.getBubbleInStackWithKey(key); - if (bubble != null) { - mBubbleData.setSelectedBubble(bubble); - mBubbleData.setExpanded(true); - } else { - bubble = mBubbleData.getOverflowBubbleWithKey(key); + if (mStatusBarStateListener.getCurrentState() == SHADE) { + mNotifEntryToExpandOnShadeUnlock = null; + + String key = entry.getKey(); + Bubble bubble = mBubbleData.getBubbleInStackWithKey(key); if (bubble != null) { - promoteBubbleFromOverflow(bubble); - } else if (entry.canBubble()) { - // It can bubble but it's not -- it got aged out of the overflow before it - // was dismissed or opened, make it a bubble again. - setIsBubble(entry, true /* isBubble */, true /* autoExpand */); + mBubbleData.setSelectedBubble(bubble); + mBubbleData.setExpanded(true); + } else { + bubble = mBubbleData.getOverflowBubbleWithKey(key); + if (bubble != null) { + promoteBubbleFromOverflow(bubble); + } else if (entry.canBubble()) { + // It can bubble but it's not -- it got aged out of the overflow before it + // was dismissed or opened, make it a bubble again. + setIsBubble(entry, true /* isBubble */, true /* autoExpand */); + } } + } else { + // Wait until we're unlocked to expand, so that the user can see the expand animation + // and also to work around bugs with expansion animation + shade unlock happening at the + // same time. + mNotifEntryToExpandOnShadeUnlock = entry; } }