From 5cb83b89ddc9d581d392b76b347ed53d09e28e66 Mon Sep 17 00:00:00 2001 From: Bryce Lee Date: Thu, 7 Apr 2022 09:19:20 -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. 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: Ia668954d31e26d704f9827b378a7ab0724a6ec4f --- .../touch/BouncerSwipeTouchHandler.java | 3 +++ .../statusbar/phone/CentralSurfaces.java | 11 +++++---- .../statusbar/phone/PanelViewController.java | 2 ++ .../touch/BouncerSwipeTouchHandlerTest.java | 23 +++++++++++++++++++ 4 files changed, 34 insertions(+), 5 deletions(-) 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 990f04b58f95e..2c5c3cdf3554a 100644 --- a/packages/SystemUI/src/com/android/systemui/dreams/touch/BouncerSwipeTouchHandler.java +++ b/packages/SystemUI/src/com/android/systemui/dreams/touch/BouncerSwipeTouchHandler.java @@ -142,6 +142,9 @@ public class BouncerSwipeTouchHandler implements DreamTouchHandler { private void setPanelExpansion(float expansion) { mCurrentExpansion = expansion; + + mCentralSurfaces.setBouncerShowing(expansion != 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 1625d9b7f486c..ae26160e35aa7 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/CentralSurfaces.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/CentralSurfaces.java @@ -3468,9 +3468,7 @@ public class CentralSurfaces extends CoreStartable implements mStatusBarHideIconsForBouncerManager.setBouncerShowingAndTriggerUpdate(bouncerShowing); mCommandQueue.recomputeDisableFlags(mDisplayId, true /* animate */); updateScrimController(); - if (!mBouncerShowing) { - updatePanelExpansionForKeyguard(); - } + updateNotificationPanelTouchState(); } /** @@ -3614,10 +3612,13 @@ public class CentralSurfaces extends CoreStartable implements * collapse the panel after we expanded it, and thus we would end up with a blank * Keyguard. */ - void updateNotificationPanelTouchState() { + public void updateNotificationPanelTouchState() { boolean goingToSleepWithoutAnimation = isGoingToSleep() && !mDozeParameters.shouldControlScreenOff(); - boolean disabled = (!mDeviceInteractive && !mDozeServiceHost.isPulsing()) + boolean bouncerShowingOverDream = isBouncerShowing() + && mDreamOverlayStateController.isOverlayActive(); + boolean disabled = bouncerShowingOverDream + || (!mDeviceInteractive && !mDozeServiceHost.isPulsing()) || goingToSleepWithoutAnimation; mNotificationPanelViewController.setTouchAndAnimationDisabled(disabled); mNotificationIconAreaController.setAnimationsEnabled(!disabled); 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 71f199f330a5e..303b2585cb624 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/PanelViewController.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/PanelViewController.java @@ -419,6 +419,8 @@ public abstract class PanelViewController { expand = false; } else if (onKeyguard) { expand = true; + } else if (mCentralSurfaces.isBouncerShowingOverDream()) { + expand = false; } else if (mKeyguardStateController.isKeyguardFadingAway()) { // If we're in the middle of dismissing the keyguard, don't expand due to the // cancelled gesture. Gesture cancellation during an unlock is expected in some 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 a016a1d8ca70f..761a2c2c8e048 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 @@ -160,6 +160,28 @@ public class BouncerSwipeTouchHandlerTest extends SysuiTestCase { 2)).isTrue(); } + /** + * Ensures {@link CentralSurfaces} + */ + @Test + public void testInformBouncerShowingOnExpand() { + swipeToPosition(1f, Direction.UP, 0); + verify(mCentralSurfaces).setBouncerShowing(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).setBouncerShowing(false); + } + private enum Direction { DOWN, UP, @@ -397,6 +419,7 @@ public class BouncerSwipeTouchHandlerTest extends SysuiTestCase { } private void swipeToPosition(float percent, Direction direction, float velocityY) { + Mockito.clearInvocations(mTouchSession); mTouchHandler.onSessionStart(mTouchSession); ArgumentCaptor gestureListenerCaptor = ArgumentCaptor.forClass(GestureDetector.OnGestureListener.class);