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

Commit 5ab71f09 authored by wilsonshih's avatar wilsonshih Committed by Android Build Coastguard Worker
Browse files

Trigger predictive back animation after receiving BackNavigationInfo.

Remove onGestureStarted on the gesture down event.
Also since onThresholdCrossed can happen before startBackNavigation, it
must also trigger the predictive back animation after receiving
BackNavigationInfo

Flag: com.android.window.flags.predictive_back_delay_wm_transition
Bug: 445827520
Bug: 445335540
Test: atest BackAnimationControllerTest
Test: atest GestureNavigationFlickerTest
Cherrypick-From: https://googleplex-android-review.googlesource.com/q/commit:e589d3314e15062e65eeda2b58961bf4ded8a5ee
Merged-In: I74bfce4a1abcfaef1b347030293ed86e7b9ff7b0
Change-Id: I74bfce4a1abcfaef1b347030293ed86e7b9ff7b0
parent 2630e38e
Loading
Loading
Loading
Loading
+6 −6
Original line number Diff line number Diff line
@@ -129,6 +129,7 @@ public class BackAnimationController implements RemoteCallable<BackAnimationCont
    private boolean mOnBackStartDispatched = false;
    private boolean mThresholdCrossed = false;
    private boolean mPointersPilfered = false;
    private boolean mBackAnimationTriggered = false;
    private final boolean mRequirePointerPilfer;

    /** Registry for the back animations */
@@ -480,9 +481,10 @@ public class BackAnimationController implements RemoteCallable<BackAnimationCont
            return;
        }
        mShellExecutor.execute(() -> {
            if (!shouldDispatchToAnimator()) {
            if (mBackAnimationTriggered || !shouldDispatchToAnimator()) {
                return;
            }
            mBackAnimationTriggered = true;
            boolean started;
            try {
                started = mActivityTaskManager.startPredictiveBackAnimation();
@@ -554,14 +556,10 @@ public class BackAnimationController implements RemoteCallable<BackAnimationCont
                        onThresholdCrossed();
                    }
                    mShouldStartOnNextMoveEvent = false;
                } else {
                    if (predictiveBackDelayWmTransition()) {
                        onGestureStarted(touchX, touchY, swipeEdge);
                } else {
                    mShouldStartOnNextMoveEvent = true;
                }
            }
            }
        } else if (keyAction == MotionEvent.ACTION_MOVE) {
            if (!mBackGestureStarted && mShouldStartOnNextMoveEvent) {
                // Let the animation initialized here to make sure the onPointerDownOutsideFocus
@@ -612,6 +610,7 @@ public class BackAnimationController implements RemoteCallable<BackAnimationCont
            startSystemAnimation();
        } else {
            startBackNavigation(touchTracker);
            startPredictiveBackAnimationIfNeeded();
        }
    }

@@ -899,6 +898,7 @@ public class BackAnimationController implements RemoteCallable<BackAnimationCont
        // Reset gesture states.
        mThresholdCrossed = false;
        mPointersPilfered = false;
        mBackAnimationTriggered = false;
        mBackGestureStarted = false;
        activeTouchTracker.setState(BackTouchTracker.TouchTrackerState.FINISHED);
        mTransitionIdleRunner.mRequestCount = 0;
+41 −0
Original line number Diff line number Diff line
@@ -360,6 +360,47 @@ public class BackAnimationControllerTest extends ShellTestCase {
        verify(mActivityTaskManager, times(1)).startBackNavigation(any(), any());
    }

    // Delay starting gesture tracking to allow the system to receive onPointerDownOutsideFocus
    // first. This is critical for interactions in multi-windowing mode.
    @Test
    public void noStartBackNavigationWhenActionDown() throws RemoteException {
        registerAnimation(BackNavigationInfo.TYPE_RETURN_TO_HOME);
        createNavigationInfo(BackNavigationInfo.TYPE_RETURN_TO_HOME,
                /* enableAnimation = */ true,
                /* isAnimationCallback = */ false);
        doMotionEvent(MotionEvent.ACTION_DOWN, 0);
        verify(mActivityTaskManager, never()).startBackNavigation(any(), any());
        doMotionEvent(MotionEvent.ACTION_MOVE, 100);
        verify(mActivityTaskManager).startBackNavigation(any(), any());
    }

    @EnableFlags(Flags.FLAG_PREDICTIVE_BACK_DELAY_WM_TRANSITION)
    @Test
    public void ensureStartBackAnimation_ThresholdBeforeStartBackNavigation()
            throws RemoteException {
        registerAnimation(BackNavigationInfo.TYPE_RETURN_TO_HOME);
        createNavigationInfo(BackNavigationInfo.TYPE_RETURN_TO_HOME,
                /* enableAnimation = */ true,
                /* isAnimationCallback = */ false);
        doMotionEvent(MotionEvent.ACTION_DOWN, 0);
        mController.onThresholdCrossed();
        doMotionEvent(MotionEvent.ACTION_MOVE, 100);
        mShellExecutor.flushAll();
        verify(mActivityTaskManager).startPredictiveBackAnimation();
    }

    @EnableFlags(Flags.FLAG_PREDICTIVE_BACK_DELAY_WM_TRANSITION)
    @Test
    public void ensureStarBackAnimation_ThresholdAfterStartBackNavigation() throws RemoteException {
        registerAnimation(BackNavigationInfo.TYPE_RETURN_TO_HOME);
        createNavigationInfo(BackNavigationInfo.TYPE_RETURN_TO_HOME,
                /* enableAnimation = */ true,
                /* isAnimationCallback = */ false);
        doStartEvents(0, 100);
        mShellExecutor.flushAll();
        verify(mActivityTaskManager).startPredictiveBackAnimation();
    }

    @Test
    public void backToHome_dispatchesEvents() throws RemoteException {
        registerAnimation(BackNavigationInfo.TYPE_RETURN_TO_HOME);