From f4dfb7c4a3daf3a45a4b0472161c7ba875eb395f Mon Sep 17 00:00:00 2001 From: Hongwei Wang Date: Tue, 9 Mar 2021 15:16:33 -0800 Subject: Settle auto PiP transaction in WindowContainerTransaction At the end of autoEnterPip transition, followings happen in sequence - Transition finishes in Launcher side, which operates on the animation leash - RecentsAnimationController.TaskAnimationAdapter#onCleanup has the final chance to set the Task leash - PipTaskOrganizer gets onTaskAppeared callback and commits Task into pinned mode What's been changed here - Transition in Launcher no longer in charge of settle the final transaction - RecentsAnimationController.TaskAnimationAdapter#onCleanup sets the Task leash to be in sync with the final state in Launcher side - PipTaskOrganizer commits the final leash transaction together with WindowContainerTransaction that enters PiP Known issue: transition from landscape is not polished Video: http://rcll/aaaaaabFQoRHlzixHdtY/hT5SXvaCy28P4UtfuoKiDw Bug: 181342797 Test: see video Change-Id: Ieabd6991ea5174099714ec22970198bebde1e336 --- .../src/com/android/wm/shell/pip/PipTaskOrganizer.java | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) (limited to 'libs') diff --git a/libs/WindowManager/Shell/src/com/android/wm/shell/pip/PipTaskOrganizer.java b/libs/WindowManager/Shell/src/com/android/wm/shell/pip/PipTaskOrganizer.java index 9ec7c0d173dd..36dc4e409f98 100644 --- a/libs/WindowManager/Shell/src/com/android/wm/shell/pip/PipTaskOrganizer.java +++ b/libs/WindowManager/Shell/src/com/android/wm/shell/pip/PipTaskOrganizer.java @@ -41,6 +41,7 @@ import android.animation.Animator; import android.animation.AnimatorListenerAdapter; import android.animation.ValueAnimator; import android.annotation.NonNull; +import android.annotation.Nullable; import android.app.ActivityManager; import android.app.ActivityTaskManager; import android.app.PictureInPictureParams; @@ -423,12 +424,16 @@ public class PipTaskOrganizer implements ShellTaskOrganizer.TaskListener, if (mInSwipePipToHomeTransition) { final Rect destinationBounds = mPipBoundsState.getBounds(); + final SurfaceControl.Transaction tx = + mSurfaceControlTransactionFactory.getTransaction(); + mSurfaceTransactionHelper.resetScale(tx, mLeash, destinationBounds); + mSurfaceTransactionHelper.crop(tx, mLeash, destinationBounds); // animation is finished in the Launcher and here we directly apply the final touch. applyEnterPipSyncTransaction(destinationBounds, () -> { // ensure menu's settled in its final bounds first finishResizeForMenu(destinationBounds); sendOnPipTransitionFinished(TRANSITION_DIRECTION_TO_PIP); - }); + }, tx); mInSwipePipToHomeTransition = false; return; } @@ -490,16 +495,20 @@ public class PipTaskOrganizer implements ShellTaskOrganizer.TaskListener, // mState is set right after the animation is kicked off to block any resize // requests such as offsetPip that may have been called prior to the transition. mState = State.ENTERING_PIP; - }); + }, null /* boundsChangeTransaction */); } - private void applyEnterPipSyncTransaction(Rect destinationBounds, Runnable runnable) { + private void applyEnterPipSyncTransaction(Rect destinationBounds, Runnable runnable, + @Nullable SurfaceControl.Transaction boundsChangeTransaction) { // PiP menu is attached late in the process here to avoid any artifacts on the leash // caused by addShellRoot when in gesture navigation mode. mPipMenuController.attach(mLeash); final WindowContainerTransaction wct = new WindowContainerTransaction(); wct.setActivityWindowingMode(mToken, WINDOWING_MODE_UNDEFINED); wct.setBounds(mToken, destinationBounds); + if (boundsChangeTransaction != null) { + wct.setBoundsChangeTransaction(mToken, boundsChangeTransaction); + } wct.scheduleFinishEnterPip(mToken, destinationBounds); mSyncTransactionQueue.queue(wct); if (runnable != null) { -- cgit v1.2.3-59-g8ed1b