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

Commit e0e84eef authored by Android Build Coastguard Worker's avatar Android Build Coastguard Worker
Browse files

Snap for 9243084 from 67eab634 to tm-qpr2-release

Change-Id: Iab1147049537e2ae7a420949fc1bfd1708ebf4e7
parents 922ae274 67eab634
Loading
Loading
Loading
Loading
+6 −1
Original line number Diff line number Diff line
@@ -2458,7 +2458,12 @@ public class WallpaperManager {

        public void waitForCompletion() {
            try {
                mLatch.await(30, TimeUnit.SECONDS);
                final boolean completed = mLatch.await(30, TimeUnit.SECONDS);
                if (completed) {
                    Log.d(TAG, "Wallpaper set completion.");
                } else {
                    Log.d(TAG, "Timeout waiting for wallpaper set completion!");
                }
            } catch (InterruptedException e) {
                // This might be legit: the crop may take a very long time. Don't sweat
                // it in that case; we are okay with display lagging behind in order to
+1 −0
Original line number Diff line number Diff line
@@ -578,6 +578,7 @@ public abstract class WallpaperService extends Service {
         */
        public void reportEngineShown(boolean waitForEngineShown) {
            if (mIWallpaperEngine.mShownReported) return;
            Log.d(TAG, "reportEngineShown: shouldWait=" + waitForEngineShown);
            if (!waitForEngineShown) {
                Message message = mCaller.obtainMessage(MSG_REPORT_SHOWN);
                mCaller.removeMessages(MSG_REPORT_SHOWN);
+10 −1
Original line number Diff line number Diff line
@@ -141,6 +141,10 @@ public final class TransitionInfo implements Parcelable {
    /** The first unused bit. This can be used by remotes to attach custom flags to this change. */
    public static final int FLAG_FIRST_CUSTOM = 1 << 17;

    /** The change belongs to a window that won't contain activities. */
    public static final int FLAGS_IS_NON_APP_WINDOW =
            FLAG_IS_WALLPAPER | FLAG_IS_INPUT_METHOD | FLAG_IS_SYSTEM_WINDOW;

    /** @hide */
    @IntDef(prefix = { "FLAG_" }, value = {
            FLAG_NONE,
@@ -579,11 +583,16 @@ public final class TransitionInfo implements Parcelable {
            return mFlags;
        }

        /** Whether the given change flags has included in this change. */
        /** Whether this change contains any of the given change flags. */
        public boolean hasFlags(@ChangeFlags int flags) {
            return (mFlags & flags) != 0;
        }

        /** Whether this change contains all of the given change flags. */
        public boolean hasAllFlags(@ChangeFlags int flags) {
            return (mFlags & flags) == flags;
        }

        /**
         * @return the bounds of the container before the change. It may be empty if the container
         * is coming into existence.
+12 −16
Original line number Diff line number Diff line
@@ -69,6 +69,7 @@ import com.android.wm.shell.common.InteractionJankMonitorUtils;
import com.android.wm.shell.common.split.SplitScreenConstants.SplitPosition;

import java.io.PrintWriter;
import java.util.function.Consumer;

/**
 * Records and handles layout of splits. Helps to calculate proper bounds when configuration or
@@ -599,7 +600,7 @@ public final class SplitLayout implements DisplayInsetsController.OnInsetsChange

    /** Swich both surface position with animation. */
    public void splitSwitching(SurfaceControl.Transaction t, SurfaceControl leash1,
            SurfaceControl leash2, Runnable finishCallback) {
            SurfaceControl leash2, Consumer<Rect> finishCallback) {
        final boolean isLandscape = isLandscape();
        final Rect insets = getDisplayInsets(mContext);
        insets.set(isLandscape ? insets.left : 0, isLandscape ? 0 : insets.top,
@@ -617,18 +618,13 @@ public final class SplitLayout implements DisplayInsetsController.OnInsetsChange
        distBounds1.offset(-mRootBounds.left, -mRootBounds.top);
        distBounds2.offset(-mRootBounds.left, -mRootBounds.top);
        distDividerBounds.offset(-mRootBounds.left, -mRootBounds.top);
        // DO NOT move to insets area for smooth animation.
        distBounds1.set(distBounds1.left, distBounds1.top,
                distBounds1.right - insets.right, distBounds1.bottom - insets.bottom);
        distBounds2.set(distBounds2.left + insets.left, distBounds2.top + insets.top,
                distBounds2.right, distBounds2.bottom);

        ValueAnimator animator1 = moveSurface(t, leash1, getRefBounds1(), distBounds1,
                false /* alignStart */);
                -insets.left, -insets.top);
        ValueAnimator animator2 = moveSurface(t, leash2, getRefBounds2(), distBounds2,
                true /* alignStart */);
                insets.left, insets.top);
        ValueAnimator animator3 = moveSurface(t, getDividerLeash(), getRefDividerBounds(),
                distDividerBounds, true /* alignStart */);
                distDividerBounds, 0 /* offsetX */, 0 /* offsetY */);

        AnimatorSet set = new AnimatorSet();
        set.playTogether(animator1, animator2, animator3);
@@ -638,14 +634,14 @@ public final class SplitLayout implements DisplayInsetsController.OnInsetsChange
            public void onAnimationEnd(Animator animation) {
                mDividePosition = dividerPos;
                updateBounds(mDividePosition);
                finishCallback.run();
                finishCallback.accept(insets);
            }
        });
        set.start();
    }

    private ValueAnimator moveSurface(SurfaceControl.Transaction t, SurfaceControl leash,
            Rect start, Rect end, boolean alignStart) {
            Rect start, Rect end, float offsetX, float offsetY) {
        Rect tempStart = new Rect(start);
        Rect tempEnd = new Rect(end);
        final float diffX = tempEnd.left - tempStart.left;
@@ -661,15 +657,15 @@ public final class SplitLayout implements DisplayInsetsController.OnInsetsChange
            final float distY = tempStart.top + scale * diffY;
            final int width = (int) (tempStart.width() + scale * diffWidth);
            final int height = (int) (tempStart.height() + scale * diffHeight);
            if (alignStart) {
            if (offsetX == 0 && offsetY == 0) {
                t.setPosition(leash, distX, distY);
                t.setWindowCrop(leash, width, height);
            } else {
                final int offsetX = width - tempStart.width();
                final int offsetY = height - tempStart.height();
                t.setPosition(leash, distX + offsetX, distY + offsetY);
                final int diffOffsetX = (int) (scale * offsetX);
                final int diffOffsetY = (int) (scale * offsetY);
                t.setPosition(leash, distX + diffOffsetX, distY + diffOffsetY);
                mTempRect.set(0, 0, width, height);
                mTempRect.offsetTo(-offsetX, -offsetY);
                mTempRect.offsetTo(-diffOffsetX, -diffOffsetY);
                t.setCrop(leash, mTempRect);
            }
            t.apply();
+29 −13
Original line number Diff line number Diff line
@@ -335,6 +335,7 @@ public class PipTransition extends PipTransitionController {
        final ActivityManager.RunningTaskInfo taskInfo = mPipOrganizer.getTaskInfo();
        if (taskInfo != null) {
            startExpandAnimation(taskInfo, mPipOrganizer.getSurfaceControl(),
                    mPipBoundsState.getBounds(), mPipBoundsState.getBounds(),
                    new Rect(mExitDestinationBounds), Surface.ROTATION_0);
        }
        mExitDestinationBounds.setEmpty();
@@ -475,6 +476,20 @@ public class PipTransition extends PipTransitionController {
                    taskInfo);
            return;
        }

        // When exiting PiP, the PiP leash may be an Activity of a multi-windowing Task, for which
        // case it may not be in the screen coordinate.
        // Reparent the pip leash to the root with max layer so that we can animate it outside of
        // parent crop, and make sure it is not covered by other windows.
        final SurfaceControl pipLeash = pipChange.getLeash();
        startTransaction.reparent(pipLeash, info.getRootLeash());
        startTransaction.setLayer(pipLeash, Integer.MAX_VALUE);
        // Note: because of this, the bounds to animate should be translated to the root coordinate.
        final Point offset = info.getRootOffset();
        final Rect currentBounds = mPipBoundsState.getBounds();
        currentBounds.offset(-offset.x, -offset.y);
        startTransaction.setPosition(pipLeash, currentBounds.left, currentBounds.top);

        mFinishCallback = (wct, wctCB) -> {
            mPipOrganizer.onExitPipFinished(taskInfo);
            finishCallback.onTransitionFinished(wct, wctCB);
@@ -496,18 +511,17 @@ public class PipTransition extends PipTransitionController {
            if (displayRotationChange != null) {
                // Exiting PIP to fullscreen with orientation change.
                startExpandAndRotationAnimation(info, startTransaction, finishTransaction,
                        displayRotationChange, taskInfo, pipChange);
                        displayRotationChange, taskInfo, pipChange, offset);
                return;
            }
        }

        // Set the initial frame as scaling the end to the start.
        final Rect destinationBounds = new Rect(pipChange.getEndAbsBounds());
        final Point offset = pipChange.getEndRelOffset();
        destinationBounds.offset(-offset.x, -offset.y);
        startTransaction.setWindowCrop(pipChange.getLeash(), destinationBounds);
        mSurfaceTransactionHelper.scale(startTransaction, pipChange.getLeash(),
                destinationBounds, mPipBoundsState.getBounds());
        startTransaction.setWindowCrop(pipLeash, destinationBounds);
        mSurfaceTransactionHelper.scale(startTransaction, pipLeash, destinationBounds,
                currentBounds);
        startTransaction.apply();

        // Check if it is fixed rotation.
@@ -532,19 +546,21 @@ public class PipTransition extends PipTransitionController {
                y = destinationBounds.bottom;
            }
            mSurfaceTransactionHelper.rotateAndScaleWithCrop(finishTransaction,
                    pipChange.getLeash(), endBounds, endBounds, new Rect(), degree, x, y,
                    pipLeash, endBounds, endBounds, new Rect(), degree, x, y,
                    true /* isExpanding */, rotationDelta == ROTATION_270 /* clockwise */);
        } else {
            rotationDelta = Surface.ROTATION_0;
        }
        startExpandAnimation(taskInfo, pipChange.getLeash(), destinationBounds, rotationDelta);
        startExpandAnimation(taskInfo, pipLeash, currentBounds, currentBounds, destinationBounds,
                rotationDelta);
    }

    private void startExpandAndRotationAnimation(@NonNull TransitionInfo info,
            @NonNull SurfaceControl.Transaction startTransaction,
            @NonNull SurfaceControl.Transaction finishTransaction,
            @NonNull TransitionInfo.Change displayRotationChange,
            @NonNull TaskInfo taskInfo, @NonNull TransitionInfo.Change pipChange) {
            @NonNull TaskInfo taskInfo, @NonNull TransitionInfo.Change pipChange,
            @NonNull Point offset) {
        final int rotateDelta = deltaRotation(displayRotationChange.getStartRotation(),
                displayRotationChange.getEndRotation());

@@ -556,7 +572,6 @@ public class PipTransition extends PipTransitionController {
        final Rect startBounds = new Rect(pipChange.getStartAbsBounds());
        rotateBounds(startBounds, displayRotationChange.getStartAbsBounds(), rotateDelta);
        final Rect endBounds = new Rect(pipChange.getEndAbsBounds());
        final Point offset = pipChange.getEndRelOffset();
        startBounds.offset(-offset.x, -offset.y);
        endBounds.offset(-offset.x, -offset.y);

@@ -592,11 +607,12 @@ public class PipTransition extends PipTransitionController {
    }

    private void startExpandAnimation(final TaskInfo taskInfo, final SurfaceControl leash,
            final Rect destinationBounds, final int rotationDelta) {
            final Rect baseBounds, final Rect startBounds, final Rect endBounds,
            final int rotationDelta) {
        final PipAnimationController.PipTransitionAnimator animator =
                mPipAnimationController.getAnimator(taskInfo, leash, mPipBoundsState.getBounds(),
                        mPipBoundsState.getBounds(), destinationBounds, null,
                        TRANSITION_DIRECTION_LEAVE_PIP, 0 /* startingAngle */, rotationDelta);
                mPipAnimationController.getAnimator(taskInfo, leash, baseBounds, startBounds,
                        endBounds, null /* sourceHintRect */, TRANSITION_DIRECTION_LEAVE_PIP,
                        0 /* startingAngle */, rotationDelta);
        animator.setTransitionDirection(TRANSITION_DIRECTION_LEAVE_PIP)
                .setPipAnimationCallback(mPipAnimationCallback)
                .setDuration(mEnterExitAnimationDuration)
Loading