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

Commit 67d6db98 authored by wilsonshih's avatar wilsonshih
Browse files

Fix the recursive call for startBackNavigation.

1. Use a delayed execution so other pending requests in the shell's
main thread have a chance to be executed.
2. Break the recursive request for startBackNavigation if no pending
transition in shell.

Flag: com.android.window.flags.predictive_back_intercept_transition
Bug: 435754613
Test: atest BackAnimationControllerTest BackNavigationControllerTests
Change-Id: I0ef62ce4a6352e906a129014f164a07889f31182
parent b554fec8
Loading
Loading
Loading
Loading
+12 −6
Original line number Diff line number Diff line
@@ -632,16 +632,21 @@ public class BackAnimationController implements RemoteCallable<BackAnimationCont
    }

    private class TransitionIdleRunner implements Runnable {
        boolean mIsEnable;
        int mRequestCount;

        @Override
        public void run() {
            if (!mIsEnable || !mCurrentTracker.isActive()) {
            if (mRequestCount == 0 || !mCurrentTracker.isActive()) {
                return;
            }
            if (mRequestCount > 2) {
                // Break from recursive call.
                mRequestCount = 0;
                return;
            }
            ProtoLog.d(WM_SHELL_BACK_PREVIEW, "Gesture hasn't finish after transition "
                    + "idle, start back navigation again.");
            mIsEnable = false;
            mRequestCount = 0;
            startBackNavigation(mCurrentTracker);
            startPredictiveBackAnimationIfNeeded();
        }
@@ -661,8 +666,9 @@ public class BackAnimationController implements RemoteCallable<BackAnimationCont
        if (backType == BackNavigationInfo.TYPE_IN_TRANSITION) {
            mBackNavigationInfo = null;
            tryPilferPointers();
            mTransitionIdleRunner.mIsEnable = true;
            mTransitions.runOnIdle(() -> mShellExecutor.execute(mTransitionIdleRunner));
            mTransitionIdleRunner.mRequestCount++;
            mTransitions.runOnIdle(() -> mShellExecutor.executeDelayed(
                    mTransitionIdleRunner, 0));
            return;
        }
        final boolean shouldDispatchToAnimator = shouldDispatchToAnimator();
@@ -889,7 +895,7 @@ public class BackAnimationController implements RemoteCallable<BackAnimationCont
        mPointersPilfered = false;
        mBackGestureStarted = false;
        activeTouchTracker.setState(BackTouchTracker.TouchTrackerState.FINISHED);
        mTransitionIdleRunner.mIsEnable = false;
        mTransitionIdleRunner.mRequestCount = 0;

        if (mPostCommitAnimationInProgress) {
            ProtoLog.w(WM_SHELL_BACK_PREVIEW, "Animation is still running");