diff options
| author | 2024-08-27 02:04:45 +0000 | |
|---|---|---|
| committer | 2024-08-27 02:04:45 +0000 | |
| commit | 9740f471b31fa9489921dba3c48b5f5c78d8381e (patch) | |
| tree | 2d7906bddc82402d7fc7615252304413e5f408df | |
| parent | b1f88d1156aeea8cfaee1cfb50bc596ceea7f1be (diff) | |
| parent | 8ad726d8cd086fdd249b3a63d921154d7168c55b (diff) | |
Merge "Defer play PB animation until transition ready." into main
4 files changed, 35 insertions, 24 deletions
diff --git a/core/java/android/window/IBackAnimationRunner.aidl b/core/java/android/window/IBackAnimationRunner.aidl index b1d75826a948..a8017762dcc1 100644 --- a/core/java/android/window/IBackAnimationRunner.aidl +++ b/core/java/android/window/IBackAnimationRunner.aidl @@ -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 diff --git a/libs/WindowManager/Shell/src/com/android/wm/shell/back/BackAnimationController.java b/libs/WindowManager/Shell/src/com/android/wm/shell/back/BackAnimationController.java index d7da0515f228..27194b344780 100644 --- a/libs/WindowManager/Shell/src/com/android/wm/shell/back/BackAnimationController.java +++ b/libs/WindowManager/Shell/src/com/android/wm/shell/back/BackAnimationController.java @@ -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) { diff --git a/libs/WindowManager/Shell/tests/unittest/src/com/android/wm/shell/back/BackAnimationControllerTest.java b/libs/WindowManager/Shell/tests/unittest/src/com/android/wm/shell/back/BackAnimationControllerTest.java index 90e3f7fdb973..1e4b8b62a082 100644 --- a/libs/WindowManager/Shell/tests/unittest/src/com/android/wm/shell/back/BackAnimationControllerTest.java +++ b/libs/WindowManager/Shell/tests/unittest/src/com/android/wm/shell/back/BackAnimationControllerTest.java @@ -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(); } } diff --git a/services/core/java/com/android/server/wm/BackNavigationController.java b/services/core/java/com/android/server/wm/BackNavigationController.java index 87867f6ab7d2..2cbd7f22fcba 100644 --- a/services/core/java/com/android/server/wm/BackNavigationController.java +++ b/services/core/java/com/android/server/wm/BackNavigationController.java @@ -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(); |