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

Commit 88b422e0 authored by wilsonshih's avatar wilsonshih Committed by Wei Sheng Shih
Browse files

Abort the predictive back animation if another transition occurs.

Another transition request can occur right after starting back
navigation. In that case, the predictive back animation should be
aborted.

Bug: 438031532
Flag: com.android.window.flags.predictive_back_delay_wm_transition
Test: simulate startPredictiveBackAnimation while another transition is
collecting, verify there won't prepare animation.

Change-Id: Ie715c9bcd003e9b79e30f7cc44224d11a03e9ff3
parent 87a4aea8
Loading
Loading
Loading
Loading
+2 −1
Original line number Diff line number Diff line
@@ -379,8 +379,9 @@ interface IActivityTaskManager {
    /**
     * This setups the leashed for sysui to animate the current back gesture.
     * Only valid after startBackNavigation.
     * @return Returns whether system can prepare back animation.
     */
    void startPredictiveBackAnimation();
    boolean startPredictiveBackAnimation();

    /**
     * registers a callback to be invoked when a background activity launch is aborted.
+6 −1
Original line number Diff line number Diff line
@@ -482,10 +482,15 @@ public class BackAnimationController implements RemoteCallable<BackAnimationCont
            if (!shouldDispatchToAnimator()) {
                return;
            }
            boolean started;
            try {
                mActivityTaskManager.startPredictiveBackAnimation();
                started = mActivityTaskManager.startPredictiveBackAnimation();
            } catch (RemoteException r) {
                Log.e(TAG, "Failed to start predictive animation", r);
                started = false;
            }
            if (!started) {
                ProtoLog.d(WM_SHELL_BACK_PREVIEW, "Failed to start predictive back animation.");
                finishBackNavigation(mCurrentTracker.getTriggerBack());
                return;
            }
+1 −0
Original line number Diff line number Diff line
@@ -186,6 +186,7 @@ public class BackAnimationControllerTest extends ShellTestCase {
        mController.mTouchableArea.set(mTouchableRegion);
        mBackTransitionHandler = mController.mBackTransitionHandler;
        spyOn(mBackTransitionHandler);
        doReturn(true).when(mActivityTaskManager).startPredictiveBackAnimation();
    }

    private void createNavigationInfo(int backType,
+2 −2
Original line number Diff line number Diff line
@@ -1897,12 +1897,12 @@ public class ActivityTaskManagerService extends IActivityTaskManager.Stub {
    }

    @Override
    public void startPredictiveBackAnimation() {
    public boolean startPredictiveBackAnimation() {
        mAmInternal.enforceCallingPermission(START_TASKS_FROM_RECENTS,
                "startPredictiveBackAnimation()");
        final long origId = Binder.clearCallingIdentity();
        try {
            mBackNavigationController.startPredictiveBackAnimation();
            return mBackNavigationController.startPredictiveBackAnimation();
        } finally {
            Binder.restoreCallingIdentity(origId);
        }
+7 −2
Original line number Diff line number Diff line
@@ -128,15 +128,20 @@ class BackNavigationController {
     * Set up the necessary leashes for predictive back animation based on previous
     * startBackNavigation state.
     */
    void startPredictiveBackAnimation() {
    boolean startPredictiveBackAnimation() {
        synchronized (mWindowManagerService.mGlobalLock) {
            if (mCurrentAnimationBuilder == null) {
                return;
                return false;
            }
            if (mWindowManagerService.mAtmService.getTransitionController().inTransition()) {
                mCurrentAnimationBuilder = null;
                return false;
            }
            final AnimationHandler.ScheduleAnimationBuilder tmp = mCurrentAnimationBuilder;
            mCurrentAnimationBuilder = null;
            scheduleAnimationInner(tmp);
        }
        return true;
    }

    /**