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

Commit d0a91a53 authored by Bryce Lee's avatar Bryce Lee Committed by Android (Google) Code Review
Browse files

Merge "Do not block gestures when dream is not active." into main

parents c48b5d8a 95ce4932
Loading
Loading
Loading
Loading
+37 −0
Original line number Diff line number Diff line
@@ -1171,6 +1171,43 @@ class DreamOverlayServiceTest : SysuiTestCase() {
            .removeGestureBlockedMatcher(eq(matcher), eq(GestureInteractor.Scope.Global))
    }

    @Test
    fun testDreamActivityGesturesNotBlockedDreamEndedBeforeKeyguardStateChanged() {
        val client = client

        // Inform the overlay service of dream starting.
        client.startDream(
            mWindowParams,
            mDreamOverlayCallback,
            DREAM_COMPONENT,
            false /*isPreview*/,
            false /*shouldShowComplication*/
        )
        mMainExecutor.runAllReady()

        val matcherCaptor = argumentCaptor<TaskMatcher>()
        verify(gestureInteractor)
            .addGestureBlockedMatcher(matcherCaptor.capture(), eq(GestureInteractor.Scope.Global))
        val matcher = matcherCaptor.firstValue

        val dreamTaskInfo = TaskInfo(mock<ComponentName>(), WindowConfiguration.ACTIVITY_TYPE_DREAM)
        assertThat(matcher.matches(dreamTaskInfo)).isTrue()

        client.endDream()
        mMainExecutor.runAllReady()
        clearInvocations(gestureInteractor)

        val callbackCaptor = ArgumentCaptor.forClass(KeyguardUpdateMonitorCallback::class.java)
        verify(mKeyguardUpdateMonitor).registerCallback(callbackCaptor.capture())

        // Notification shade opens.
        callbackCaptor.value.onShadeExpandedChanged(true)
        mMainExecutor.runAllReady()

        verify(gestureInteractor)
            .removeGestureBlockedMatcher(eq(matcher), eq(GestureInteractor.Scope.Global))
    }

    @Test
    fun testComponentsRecreatedBetweenDreams() {
        clearInvocations(
+2 −1
Original line number Diff line number Diff line
@@ -552,7 +552,8 @@ public class DreamOverlayService extends android.service.dreams.DreamOverlayServ
    }

    private void updateGestureBlockingLocked() {
        final boolean shouldBlock = !isDreamInPreviewMode() && !mShadeExpanded && !mBouncerShowing;
        final boolean shouldBlock = mStarted && !mShadeExpanded && !mBouncerShowing
                && !isDreamInPreviewMode();

        if (shouldBlock) {
            mGestureInteractor.addGestureBlockedMatcher(DREAM_TYPE_MATCHER,