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

Commit 8ad726d8 authored by wilsonshih's avatar wilsonshih
Browse files

Defer play PB animation until transition ready.

Only needed when start prepare_open(launchBehind) transition.
When opening target participant transiton, it's surface only become
visible after transition ready, so shell side shouldn't start animation
before transition ready.

Flag: com.android.window.flags.migrate_predictive_back_transition
Bug: 361726487
Test: trigger cross-activity animation without snapshot, verify
animation start with the surface of open activity become visible.

Change-Id: Icc51abe139bfc7164f0842c8eb05e465bd262cdc
parent bb0348ec
Loading
Loading
Loading
Loading
+4 −5
Original line number Diff line number Diff line
@@ -38,14 +38,13 @@ oneway interface IBackAnimationRunner {
    /**
     * Called when the system is ready for the handler to start animating all the visible tasks.
     * @param apps The list of departing (type=MODE_CLOSING) and entering (type=MODE_OPENING)
                   windows to animate,
     * @param wallpapers The list of wallpapers to animate.
     * @param nonApps The list of non-app windows such as Bubbles to animate.
     *             windows to animate,
     * @param prepareOpenTransition If non-null, the animation should start after receive open
     *             transition
     * @param finishedCallback The callback to invoke when the animation is finished.
     */
    void onAnimationStart(
            in RemoteAnimationTarget[] apps,
            in RemoteAnimationTarget[] wallpapers,
            in RemoteAnimationTarget[] nonApps,
            in IBinder prepareOpenTransition,
            in IBackAnimationFinishedCallback finishedCallback) = 2;
}
 No newline at end of file
+26 −16
Original line number Diff line number Diff line
@@ -1066,14 +1066,30 @@ public class BackAnimationController implements RemoteCallable<BackAnimationCont
        return true;
    }

    private void kickStartAnimation() {
        startSystemAnimation();

        // Dispatch the first progress after animation start for
        // smoothing the initial animation, instead of waiting for next
        // onMove.
        final BackMotionEvent backFinish = mCurrentTracker
                .createProgressEvent();
        dispatchOnBackProgressed(mActiveCallback, backFinish);
        if (!mBackGestureStarted) {
            // if the down -> up gesture happened before animation
            // start, we have to trigger the uninterruptible transition
            // to finish the back animation.
            startPostCommitAnimation();
        }
    }

    private void createAdapter() {
        IBackAnimationRunner runner =
                new IBackAnimationRunner.Stub() {
                    @Override
                    public void onAnimationStart(
                            RemoteAnimationTarget[] apps,
                            RemoteAnimationTarget[] wallpapers,
                            RemoteAnimationTarget[] nonApps,
                            IBinder token,
                            IBackAnimationFinishedCallback finishedCallback) {
                        mShellExecutor.execute(
                                () -> {
@@ -1085,21 +1101,12 @@ public class BackAnimationController implements RemoteCallable<BackAnimationCont
                                    }
                                    mBackAnimationFinishedCallback = finishedCallback;
                                    mApps = apps;
                                    startSystemAnimation();
                                    mBackTransitionHandler.consumeQueuedTransitionIfNeeded();

                                    // Dispatch the first progress after animation start for
                                    // smoothing the initial animation, instead of waiting for next
                                    // onMove.
                                    final BackMotionEvent backFinish = mCurrentTracker
                                            .createProgressEvent();
                                    dispatchOnBackProgressed(mActiveCallback, backFinish);
                                    if (!mBackGestureStarted) {
                                        // if the down -> up gesture happened before animation
                                        // start, we have to trigger the uninterruptible transition
                                        // to finish the back animation.
                                        startPostCommitAnimation();
                                    // app only visible after transition ready, break for now.
                                    if (token != null) {
                                        return;
                                    }
                                    kickStartAnimation();
                                    mBackTransitionHandler.consumeQueuedTransitionIfNeeded();
                                });
                    }

@@ -1199,6 +1206,9 @@ public class BackAnimationController implements RemoteCallable<BackAnimationCont
                @NonNull SurfaceControl.Transaction st,
                @NonNull SurfaceControl.Transaction ft,
                @NonNull Transitions.TransitionFinishCallback finishCallback) {
            if (info.getType() == WindowManager.TRANSIT_PREPARE_BACK_NAVIGATION) {
                kickStartAnimation();
            }
            // Both mShellExecutor and Transitions#mMainExecutor are ShellMainThread, so we don't
            // need to post to ShellExecutor when called.
            if (info.getType() == WindowManager.TRANSIT_CLOSE_PREPARE_BACK_NAVIGATION) {
+1 −1
Original line number Diff line number Diff line
@@ -881,7 +881,7 @@ public class BackAnimationControllerTest extends ShellTestCase {
        RemoteAnimationTarget[] targets = new RemoteAnimationTarget[]{animationTarget};
        if (mController.mBackAnimationAdapter != null) {
            mController.mBackAnimationAdapter.getRunner().onAnimationStart(
                    targets, null, null, mBackAnimationFinishedCallback);
                    targets, null /* prepareOpenTransition */, mBackAnimationFinishedCallback);
            mShellExecutor.flushAll();
        }
    }
+4 −2
Original line number Diff line number Diff line
@@ -1820,8 +1820,10 @@ class BackNavigationController {
                            mNavigationMonitor.cancelBackNavigating("cancelAnimation");
                            mBackAnimationAdapter.getRunner().onAnimationCancelled();
                        } else {
                            mBackAnimationAdapter.getRunner().onAnimationStart(
                                    targets, null, null, callback);
                            mBackAnimationAdapter.getRunner().onAnimationStart(targets,
                                    mOpenAnimAdaptor.mPreparedOpenTransition != null
                                            ? mOpenAnimAdaptor.mPreparedOpenTransition.getToken()
                                            : null, callback);
                        }
                    } catch (RemoteException e) {
                        e.printStackTrace();