From 1a73f63ee4cf16ab3f7a7c6fbd5267fa2a53ba50 Mon Sep 17 00:00:00 2001 From: Bryce Lee Date: Mon, 11 Apr 2022 12:34:53 -0700 Subject: [PATCH] Do not allow panel expansion with bouncer over dream. This change prevents the PanelViewController, the parent class of NotificationPanelView, from expanding on end motion when the bouncer is shown over dream. The BouncerSwipeTouchHandler now informs CentralSurfaces when the bouncer is showing over the dream. This is independent of the normal signal for bouncer showing. This prevents the panel from appearing erroneously on motion cancel during swipe down on the bouncer. This cancel comes as a result of the bouncer pilfering the touch events once the gesture has been detected. Fixed: 228347831 Test: atest BouncerSwipeTouchHandlerTest#testInformBouncerShowingOnExpand Test: atest BouncerSwipeTouchHandlerTest#testInformBouncerShowingOnCollapse Change-Id: I83a599baea904c8b1a2cea3a7c55dbe9c166c3d2 --- .../touch/BouncerSwipeTouchHandler.java | 2 ++ .../statusbar/phone/CentralSurfaces.java | 13 +++++++++- .../statusbar/phone/PanelViewController.java | 2 ++ .../touch/BouncerSwipeTouchHandlerTest.java | 24 +++++++++++++++++++ 4 files changed, 40 insertions(+), 1 deletion(-) diff --git a/packages/SystemUI/src/com/android/systemui/dreams/touch/BouncerSwipeTouchHandler.java b/packages/SystemUI/src/com/android/systemui/dreams/touch/BouncerSwipeTouchHandler.java index c147fde65cf75..517fce1b16a69 100644 --- a/packages/SystemUI/src/com/android/systemui/dreams/touch/BouncerSwipeTouchHandler.java +++ b/packages/SystemUI/src/com/android/systemui/dreams/touch/BouncerSwipeTouchHandler.java @@ -144,6 +144,8 @@ public class BouncerSwipeTouchHandler implements DreamTouchHandler { private void setPanelExpansion(float expansion) { mCurrentExpansion = expansion; + mCentralSurfaces.setBouncerShowingOverDream( + mCurrentExpansion != KeyguardBouncer.EXPANSION_HIDDEN); mStatusBarKeyguardViewManager.onPanelExpansionChanged(mCurrentExpansion, false, true); } diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/CentralSurfaces.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/CentralSurfaces.java index c77b0d6721fb6..2d3bef6319267 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/CentralSurfaces.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/CentralSurfaces.java @@ -468,6 +468,7 @@ public class CentralSurfaces extends CoreStartable implements */ protected int mState; // TODO: remove this. Just use StatusBarStateController protected boolean mBouncerShowing; + private boolean mBouncerShowingOverDream; private final PhoneStatusBarPolicy mIconPolicy; @@ -3472,6 +3473,16 @@ public class CentralSurfaces extends CoreStartable implements } } + /** + * Sets whether the bouncer over dream is showing. Note that the bouncer over dream is handled + * independently of the rest of the notification panel. As a result, setting this state via + * {@link #setBouncerShowing(boolean)} leads to unintended side effects from states modified + * behind the dream. + */ + public void setBouncerShowingOverDream(boolean bouncerShowingOverDream) { + mBouncerShowingOverDream = bouncerShowingOverDream; + } + /** * Propagate the bouncer state to status bar components. * @@ -4145,7 +4156,7 @@ public class CentralSurfaces extends CoreStartable implements } public boolean isBouncerShowingOverDream() { - return isBouncerShowing() && mDreamOverlayStateController.isOverlayActive(); + return mBouncerShowingOverDream; } /** diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/PanelViewController.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/PanelViewController.java index 518a9181ec985..ad304c54eee05 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/PanelViewController.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/PanelViewController.java @@ -424,6 +424,8 @@ public abstract class PanelViewController { // situations, such keeping your finger down while swiping to unlock to an app // that is locked in landscape (the rotation will cancel the touch event). expand = false; + } else if (mCentralSurfaces.isBouncerShowingOverDream()) { + expand = false; } else { // If we get a cancel, put the shade back to the state it was in when the // gesture started diff --git a/packages/SystemUI/tests/src/com/android/systemui/dreams/touch/BouncerSwipeTouchHandlerTest.java b/packages/SystemUI/tests/src/com/android/systemui/dreams/touch/BouncerSwipeTouchHandlerTest.java index e175af7a037d5..535023fa08c54 100644 --- a/packages/SystemUI/tests/src/com/android/systemui/dreams/touch/BouncerSwipeTouchHandlerTest.java +++ b/packages/SystemUI/tests/src/com/android/systemui/dreams/touch/BouncerSwipeTouchHandlerTest.java @@ -420,7 +420,31 @@ public class BouncerSwipeTouchHandlerTest extends SysuiTestCase { verify(mUiEventLogger).log(BouncerSwipeTouchHandler.DreamEvent.DREAM_BOUNCER_FULLY_VISIBLE); } + /** + * Ensures {@link CentralSurfaces} + */ + @Test + public void testInformBouncerShowingOnExpand() { + swipeToPosition(1f, Direction.UP, 0); + verify(mCentralSurfaces).setBouncerShowingOverDream(true); + } + + /** + * Ensures {@link CentralSurfaces} + */ + @Test + public void testInformBouncerHidingOnCollapse() { + // Must swipe up to set initial state. + swipeToPosition(1f, Direction.UP, 0); + Mockito.clearInvocations(mCentralSurfaces); + + swipeToPosition(0f, Direction.DOWN, 0); + verify(mCentralSurfaces).setBouncerShowingOverDream(false); + } + + private void swipeToPosition(float percent, Direction direction, float velocityY) { + Mockito.clearInvocations(mTouchSession); mTouchHandler.onSessionStart(mTouchSession); ArgumentCaptor gestureListenerCaptor = ArgumentCaptor.forClass(GestureDetector.OnGestureListener.class);