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

Commit 0c5669aa authored by Hongwei Wang's avatar Hongwei Wang Committed by Automerger Merge Worker
Browse files

Merge "Settle auto PiP transaction in WindowContainerTransaction" into sc-dev am: 3cd3a80f

Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/13819051

Change-Id: Ibb3fc967356d0b0649855c53dfa2b857a4b998b9
parents ab696e12 3cd3a80f
Loading
Loading
Loading
Loading
+4 −1
Original line number Diff line number Diff line
@@ -43,8 +43,11 @@ interface IRecentsAnimationController {
     * accordingly. This should be called before `finish`
     * @param taskId for which the leash should be updated
     * @param destinationBounds bounds of the final PiP window
     * @param windowCrop bounds to crop as part of final transform.
     * @param float9 An array of 9 floats to be used as matrix transform.
     */
     void setFinishTaskBounds(int taskId, in Rect destinationBounds);
     void setFinishTaskBounds(int taskId, in Rect destinationBounds, in Rect windowCrop,
             in float[] float9);

    /**
     * Notifies to the system that the animation into Recents should end, and all leashes associated
+12 −3
Original line number Diff line number Diff line
@@ -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) {
+0 −19
Original line number Diff line number Diff line
@@ -20,7 +20,6 @@ import android.graphics.Matrix;
import android.graphics.Rect;
import android.graphics.RectF;
import android.view.Choreographer;
import android.view.Surface;
import android.view.SurfaceControl;

/**
@@ -91,24 +90,6 @@ public class PipSurfaceTransactionHelper {
                .setPosition(leash, positionX, positionY);
    }

    public void reset(SurfaceControl.Transaction tx, SurfaceControl leash, Rect destinationBounds,
            @Surface.Rotation int rotation) {
        resetScale(tx, leash, destinationBounds);
        if (rotation == Surface.ROTATION_90 || rotation == Surface.ROTATION_270) {
            final int degree = (rotation == Surface.ROTATION_90) ? -90 : 90;
            mTmpTransform.setRotate(degree, 0, 0);
            tx.setMatrix(leash, mTmpTransform, mTmpFloat9);
        }
        resetCornerRadius(tx, leash);
        crop(tx, leash, destinationBounds);
    }

    public void resetScale(SurfaceControl.Transaction tx, SurfaceControl leash,
            Rect destinationBounds) {
        tx.setMatrix(leash, Matrix.IDENTITY_MATRIX, mTmpFloat9)
                .setPosition(leash, destinationBounds.left, destinationBounds.top);
    }

    public void resetCornerRadius(SurfaceControl.Transaction tx, SurfaceControl leash) {
        tx.setCornerRadius(leash, 0);
    }
+6 −2
Original line number Diff line number Diff line
@@ -76,10 +76,14 @@ public class RecentsAnimationControllerCompat {
     * accordingly. This should be called before `finish`
     * @param taskId Task id of the Activity in PiP mode.
     * @param destinationBounds Bounds of the PiP window on home.
     * @param windowCrop bounds to crop as part of final transform.
     * @param float9 An array of 9 floats to be used as matrix transform.
     */
    public void setFinishTaskBounds(int taskId, Rect destinationBounds) {
    public void setFinishTaskBounds(int taskId, Rect destinationBounds, Rect windowCrop,
            float[] float9) {
        try {
            mAnimationController.setFinishTaskBounds(taskId, destinationBounds);
            mAnimationController.setFinishTaskBounds(taskId, destinationBounds, windowCrop,
                    float9);
        } catch (RemoteException e) {
            Log.d(TAG, "Failed to set finish task bounds", e);
        }
+5 −2
Original line number Diff line number Diff line
@@ -137,8 +137,11 @@ public class RemoteTransitionCompat implements Parcelable {
            mWrapped.hideCurrentInputMethod();
        }

        @Override public void setFinishTaskBounds(int taskId, Rect destinationBounds) {
            if (mWrapped != null) mWrapped.setFinishTaskBounds(taskId, destinationBounds);
        @Override public void setFinishTaskBounds(int taskId, Rect destinationBounds,
                Rect windowCrop, float[] float9) {
            if (mWrapped != null) {
                mWrapped.setFinishTaskBounds(taskId, destinationBounds, windowCrop, float9);
            }
        }

        @Override public void finish(boolean toHome, boolean sendUserLeaveHint) {
Loading