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

Commit b72794f8 authored by Johannes Gallmann's avatar Johannes Gallmann
Browse files

Fix unrecoverable bad state in BackAnimationController

This CL makes BackAnimationController more robust. Should it ever enter the bad state of both touch trackers being in the initial state but mBackGestureStarted=true, it will recover from it with this bugfix.

Bug: 365461223
Flag: EXEMPT bugfix
Test: BackAnimationControllerTest
Test: Manual, i.e. verify that behaviour without fix matches bugreports and with fix recovers itself
Change-Id: I1ed592e60516e9ba173483aca1c3fdb8ba74bd59
parent 58613adc
Loading
Loading
Loading
Loading
+6 −1
Original line number Diff line number Diff line
@@ -120,7 +120,7 @@ public class BackAnimationController implements RemoteCallable<BackAnimationCont
    @ShellMainThread private final Handler mHandler;

    /** True when a back gesture is ongoing */
    private boolean mBackGestureStarted = false;
    @VisibleForTesting public boolean mBackGestureStarted = false;

    /** Tracks if an uninterruptible animation is in progress */
    private boolean mPostCommitAnimationInProgress = false;
@@ -511,6 +511,11 @@ public class BackAnimationController implements RemoteCallable<BackAnimationCont
            ProtoLog.d(WM_SHELL_BACK_PREVIEW,
                    "Ignoring MotionEvent because two gestures are already being queued.");
            return;
        } else if (mBackGestureStarted && mCurrentTracker.isInInitialState()
                && mQueuedTracker.isInInitialState()) {
            ProtoLog.e(WM_SHELL_BACK_PREVIEW,
                    "Both touch trackers in initial state and mBackGestureStarted=true");
            mBackGestureStarted = false;
        }

        if (keyAction == MotionEvent.ACTION_DOWN) {
+8 −0
Original line number Diff line number Diff line
@@ -776,6 +776,14 @@ public class BackAnimationControllerTest extends ShellTestCase {
        verify(mergeCallback, never()).onTransitionFinished(any());
    }

    @Test
    public void testBackAnimationControllersRecoversFromBadState() throws RemoteException {
        // put controller into bad state (initial state but mBackGestureStarted=true)
        mController.mBackGestureStarted = true;
        verifySystemBackBehavior(BackNavigationInfo.TYPE_CROSS_ACTIVITY,
                mDefaultCrossActivityBackAnimation.getRunner());
    }

    private RemoteAnimationTarget[] createAppAnimationTargets(int openTaskId, int closeTaskId) {
        final RemoteAnimationTarget openT = createSingleAnimationTarget(openTaskId,
                RemoteAnimationTarget.MODE_OPENING);