Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 09cbcfb3 authored by William Xiao's avatar William Xiao
Browse files

Fix shade not opening after opening widgets on lockscreen

The ShadeTouchHandler sends touches to NSWVC in order to open the shade
while the hub is opened from lock screen. However, this means that the
GlanceableHubContainerController can see and intercept the touches
intended only for the shade, which causes the shade to not open.

This change prevents the hub from seeing these touches. Long-term, the
scene container will handle these actions instead.

Bug: 409682586
Test: atest NotificationShadeWindowViewControllerTest
      manually verified, see bug for before/after videos
Flag: com.android.systemui.communal_shade_touch_handling_fixes
Change-Id: I6c57652c613ef6130d034e12898c5c7fb5dbbbc2
parent a88fe5ca
Loading
Loading
Loading
Loading
+10 −0
Original line number Diff line number Diff line
@@ -1295,6 +1295,16 @@ flag {
  }
}

flag {
  name: "communal_shade_touch_handling_fixes"
  namespace: "systemui"
  description: "Flags some minor bug fixes for opening the shade on the hub"
  bug: "409682586"
  metadata {
    purpose: PURPOSE_BUGFIX
  }
}

flag {
    name: "dream_overlay_updated_ui"
    namespace: "systemui"
+26 −11
Original line number Diff line number Diff line
@@ -17,6 +17,7 @@
package com.android.systemui.shade;

import static com.android.systemui.Flags.shadeLaunchAccessibility;
import static com.android.systemui.Flags.communalShadeTouchHandlingFixes;
import static com.android.systemui.keyguard.shared.model.KeyguardState.DREAMING;
import static com.android.systemui.keyguard.shared.model.KeyguardState.LOCKSCREEN;
import static com.android.systemui.statusbar.StatusBarState.KEYGUARD;
@@ -155,6 +156,10 @@ public class NotificationShadeWindowViewController implements Dumpable {
     * intercepted and all future touch events for the gesture should be processed by this view.
     */
    private boolean mExternalTouchIntercepted = false;
    /**
     * True if we are in the process of handling an external touch event.
     */
    private boolean mHandlingExternalTouch = false;
    private boolean mIsTrackingBarGesture = false;
    private boolean mIsOcclusionTransitionRunning = false;
    private DisableSubpixelTextTransitionListener mDisableSubpixelTextTransitionListener;
@@ -345,6 +350,10 @@ public class NotificationShadeWindowViewController implements Dumpable {
     * @param event The event to forward.
     */
    public void handleExternalTouch(MotionEvent event) {
        try {
            if (communalShadeTouchHandlingFixes()) {
                mHandlingExternalTouch = true;
            }
            if (event.getActionMasked() == MotionEvent.ACTION_DOWN) {
                mExternalTouchIntercepted = false;
            }
@@ -358,6 +367,9 @@ public class NotificationShadeWindowViewController implements Dumpable {
            if (mExternalTouchIntercepted) {
                mView.onTouchEvent(event);
            }
        } finally {
            mHandlingExternalTouch = false;
        }
    }

    /** Inflates the {@link R.layout#status_bar_expanded} layout and sets it up. */
@@ -431,6 +443,9 @@ public class NotificationShadeWindowViewController implements Dumpable {
                }

                if (!SceneContainerFlag.isEnabled()
                        // External touches are never intended to go the hub, only for opening the
                        // shade.
                        && !mHandlingExternalTouch
                        && mGlanceableHubContainerController.onTouchEvent(ev)) {
                    // GlanceableHubContainerController is only used pre-flexiglass.
                    return logDownDispatch(ev, "dispatched to glanceable hub container", true);
+18 −0
Original line number Diff line number Diff line
@@ -522,6 +522,24 @@ class NotificationShadeWindowViewControllerTest(flags: FlagsParameterization) :
        verify(view, never()).onTouchEvent(any())
    }

    @Test
    @EnableFlags(Flags.FLAG_COMMUNAL_SHADE_TOUCH_HANDLING_FIXES)
    @DisableSceneContainer
    fun handleExternalTouch_hubDoesNotSeeTouches() {
        underTest.setStatusBarViewController(phoneStatusBarViewController)
        whenever(view.dispatchTouchEvent(any())).thenAnswer { invocation ->
            interactionEventHandler.handleDispatchTouchEvent(
                invocation.arguments.first() as MotionEvent?
            )
            true
        }

        underTest.handleExternalTouch(DOWN_EVENT)

        // Glanceable hub never receives any external touches.
        verify(mGlanceableHubContainerController, never()).onTouchEvent(any())
    }

    @Test
    fun testGetKeyguardMessageArea() =
        testScope.runTest {