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

Commit ed71cd15 authored by Riddle Hsu's avatar Riddle Hsu Committed by Android (Google) Code Review
Browse files

Merge "Remove legacy fixed rotation pip" into main

parents 7b15a02b 7a56bcd5
Loading
Loading
Loading
Loading
+2 −22
Original line number Diff line number Diff line
@@ -886,6 +886,8 @@ public final class WindowContainerTransaction implements Parcelable {
        return this;
    }

    // TODO(b/365884835): Remove this method and the assertion in
    //  TaskFragmentOrganizerPolicyTest#testApplyChange_unsupportedChangeMask_throwException.
    /**
     * Notify {@link com.android.server.wm.PinnedTaskController} that the picture-in-picture task
     * has finished the enter animation with the given bounds.
@@ -894,9 +896,7 @@ public final class WindowContainerTransaction implements Parcelable {
    public WindowContainerTransaction scheduleFinishEnterPip(
            @NonNull WindowContainerToken container, @NonNull Rect bounds) {
        final Change chg = getOrCreateChange(container.asBinder());
        chg.mPinnedBounds = new Rect(bounds);
        chg.mChangeMask |= Change.CHANGE_PIP_CALLBACK;

        return this;
    }

@@ -1369,7 +1369,6 @@ public final class WindowContainerTransaction implements Parcelable {
        private @ActivityInfo.Config int mConfigSetMask = 0;
        private @WindowConfiguration.WindowConfig int mWindowSetMask = 0;

        private Rect mPinnedBounds = null;
        private SurfaceControl.Transaction mBoundsChangeTransaction = null;
        @Nullable
        private Rect mRelativeBounds = null;
@@ -1391,10 +1390,6 @@ public final class WindowContainerTransaction implements Parcelable {
            mChangeMask = in.readInt();
            mConfigSetMask = in.readInt();
            mWindowSetMask = in.readInt();
            if ((mChangeMask & Change.CHANGE_PIP_CALLBACK) != 0) {
                mPinnedBounds = new Rect();
                mPinnedBounds.readFromParcel(in);
            }
            if ((mChangeMask & Change.CHANGE_BOUNDS_TRANSACTION) != 0) {
                mBoundsChangeTransaction =
                    SurfaceControl.Transaction.CREATOR.createFromParcel(in);
@@ -1425,9 +1420,6 @@ public final class WindowContainerTransaction implements Parcelable {
                mBoundsChangeTransaction = other.mBoundsChangeTransaction;
                other.mBoundsChangeTransaction = null;
            }
            if ((other.mChangeMask & CHANGE_PIP_CALLBACK) != 0) {
                mPinnedBounds = transfer ? other.mPinnedBounds : new Rect(other.mPinnedBounds);
            }
            if ((other.mChangeMask & CHANGE_HIDDEN) != 0) {
                mHidden = other.mHidden;
            }
@@ -1544,15 +1536,6 @@ public final class WindowContainerTransaction implements Parcelable {
            return mWindowSetMask;
        }

        /**
         * Returns the bounds to be used for scheduling the enter pip callback
         * or null if no callback is to be scheduled.
         */
        @Nullable
        public Rect getEnterPipBounds() {
            return mPinnedBounds;
        }

        @Nullable
        public SurfaceControl.Transaction getBoundsChangeTransaction() {
            return mBoundsChangeTransaction;
@@ -1635,9 +1618,6 @@ public final class WindowContainerTransaction implements Parcelable {
            dest.writeInt(mConfigSetMask);
            dest.writeInt(mWindowSetMask);

            if (mPinnedBounds != null) {
                mPinnedBounds.writeToParcel(dest, flags);
            }
            if (mBoundsChangeTransaction != null) {
                mBoundsChangeTransaction.writeToParcel(dest, flags);
            }
+0 −4
Original line number Diff line number Diff line
@@ -216,10 +216,6 @@ public class PipTaskOrganizer implements ShellTaskOrganizer.TaskListener,
                    }
                    if (mWaitForFixedRotation && animationType == ANIM_TYPE_BOUNDS
                            && direction == TRANSITION_DIRECTION_TO_PIP) {
                        // Notify the display to continue the deferred orientation change.
                        final WindowContainerTransaction wct = new WindowContainerTransaction();
                        wct.scheduleFinishEnterPip(mToken, destinationBounds);
                        mTaskOrganizer.applyTransaction(wct);
                        // The final task bounds will be applied by onFixedRotationFinished so
                        // that all coordinates are in new rotation.
                        mSurfaceTransactionHelper.round(tx, mLeash, isInPip());
+0 −4
Original line number Diff line number Diff line
@@ -2062,10 +2062,6 @@ class DisplayContent extends RootDisplayArea implements WindowManagerPolicy.Disp
        if (mFixedRotationLaunchingApp == null) {
            return;
        }
        if (mPinnedTaskController.shouldDeferOrientationChange()) {
            // Wait for the PiP animation to finish.
            return;
        }
        // Update directly because the app which will change the orientation of display is ready.
        if (mDisplayRotation.updateOrientation(getOrientation(), false /* forceUpdate */)) {
            // If a transition is collecting, let the transition apply the rotation change on
+0 −83
Original line number Diff line number Diff line
@@ -16,8 +16,6 @@

package com.android.server.wm;

import static android.app.WindowConfiguration.ROTATION_UNDEFINED;

import static com.android.server.wm.WindowManagerDebugConfig.TAG_WITH_CLASS_NAME;
import static com.android.server.wm.WindowManagerDebugConfig.TAG_WM;

@@ -50,7 +48,6 @@ import java.io.PrintWriter;
class PinnedTaskController {

    private static final String TAG = TAG_WITH_CLASS_NAME ? "PinnedTaskController" : TAG_WM;
    private static final int DEFER_ORIENTATION_CHANGE_TIMEOUT_MS = 1000;

    private final WindowManagerService mService;
    private final DisplayContent mDisplayContent;
@@ -59,17 +56,8 @@ class PinnedTaskController {
    private final PinnedTaskListenerDeathHandler mPinnedTaskListenerDeathHandler =
            new PinnedTaskListenerDeathHandler();

    /**
     * Non-null if the entering PiP task will cause display rotation to change. The bounds are
     * based on the new rotation.
     */
    private Rect mDestRotatedBounds;

    /** Whether to skip task configuration change once. */
    private boolean mFreezingTaskConfig;
    /** Defer display orientation change if the PiP task is animating across orientations. */
    private boolean mDeferOrientationChanging;
    private final Runnable mDeferOrientationTimeoutRunnable;

    private boolean mIsImeShowing;
    private int mImeHeight;
@@ -88,7 +76,6 @@ class PinnedTaskController {
            synchronized (mService.mGlobalLock) {
                mPinnedTaskListener = null;
                mFreezingTaskConfig = false;
                mDeferOrientationTimeoutRunnable.run();
            }
        }
    }
@@ -96,14 +83,6 @@ class PinnedTaskController {
    PinnedTaskController(WindowManagerService service, DisplayContent displayContent) {
        mService = service;
        mDisplayContent = displayContent;
        mDeferOrientationTimeoutRunnable = () -> {
            synchronized (mService.mGlobalLock) {
                if (mDeferOrientationChanging) {
                    continueOrientationChange();
                    mService.mWindowPlacerLocked.requestTraversal();
                }
            }
        };
        reloadResources();
    }

@@ -154,52 +133,6 @@ class PinnedTaskController {
                || Float.compare(aspectRatio, mMaxAspectRatio) > 0;
    }

    /**
     * Called when a fullscreen task is entering PiP with display orientation change. This is used
     * to avoid flickering when running PiP animation across different orientations.
     */
    void deferOrientationChangeForEnteringPipFromFullScreenIfNeeded() {
        final ActivityRecord topFullscreen = mDisplayContent.getActivity(
                a -> a.providesOrientation() && !a.getTask().inMultiWindowMode());
        if (topFullscreen == null || topFullscreen.hasFixedRotationTransform()) {
            return;
        }
        final int rotation = mDisplayContent.rotationForActivityInDifferentOrientation(
                topFullscreen);
        if (rotation == ROTATION_UNDEFINED) {
            return;
        }
        // If the next top activity will change the orientation of display, start fixed rotation to
        // notify PipTaskOrganizer before it receives task appeared. And defer display orientation
        // update until the new PiP bounds are set.
        mDisplayContent.setFixedRotationLaunchingApp(topFullscreen, rotation);
        mDeferOrientationChanging = true;
        mService.mH.removeCallbacks(mDeferOrientationTimeoutRunnable);
        final float animatorScale = Math.max(1, mService.getCurrentAnimatorScale());
        mService.mH.postDelayed(mDeferOrientationTimeoutRunnable,
                (int) (animatorScale * DEFER_ORIENTATION_CHANGE_TIMEOUT_MS));
    }

    /** Defers orientation change while there is a top fixed rotation activity. */
    boolean shouldDeferOrientationChange() {
        return mDeferOrientationChanging;
    }

    /**
     * Sets the bounds for {@link #startSeamlessRotationIfNeeded} if the orientation of display
     * will be changed.
     */
    void setEnterPipBounds(Rect bounds) {
        if (!mDeferOrientationChanging) {
            return;
        }
        mFreezingTaskConfig = true;
        mDestRotatedBounds = new Rect(bounds);
        if (!mDisplayContent.mTransitionController.isShellTransitionsEnabled()) {
            continueOrientationChange();
        }
    }

    /**
     * Sets a hint if the orientation of display will be changed. This is only called when
     * finishing recents animation with pending orientation change that will be handled by
@@ -209,16 +142,6 @@ class PinnedTaskController {
        mFreezingTaskConfig = true;
    }

    /** Called when the activity in PiP task has PiP windowing mode (at the end of animation). */
    private void continueOrientationChange() {
        mDeferOrientationChanging = false;
        mService.mH.removeCallbacks(mDeferOrientationTimeoutRunnable);
        final WindowContainer<?> orientationSource = mDisplayContent.getLastOrientationSource();
        if (orientationSource != null && !orientationSource.isAppTransitioning()) {
            mDisplayContent.continueUpdateOrientationForDiffOrienLaunchingApp();
        }
    }

    /**
     * Returns {@code true} to skip {@link Task#onConfigurationChanged} because it is expected that
     * there will be a orientation change and a PiP configuration change.
@@ -231,8 +154,6 @@ class PinnedTaskController {
    /** Resets the states which were used to perform fixed rotation with PiP task. */
    void onCancelFixedRotationTransform() {
        mFreezingTaskConfig = false;
        mDeferOrientationChanging = false;
        mDestRotatedBounds = null;
    }

    /**
@@ -287,11 +208,7 @@ class PinnedTaskController {

    void dump(String prefix, PrintWriter pw) {
        pw.println(prefix + "PinnedTaskController");
        if (mDeferOrientationChanging) pw.println(prefix + "  mDeferOrientationChanging=true");
        if (mFreezingTaskConfig) pw.println(prefix + "  mFreezingTaskConfig=true");
        if (mDestRotatedBounds != null) {
            pw.println(prefix + "  mPendingBounds=" + mDestRotatedBounds);
        }
        pw.println(prefix + "  mIsImeShowing=" + mIsImeShowing);
        pw.println(prefix + "  mImeHeight=" + mImeHeight);
        pw.println(prefix + "  mMinAspectRatio=" + mMinAspectRatio);
+0 −8
Original line number Diff line number Diff line
@@ -4819,14 +4819,6 @@ class Task extends TaskFragment {
                // Nothing else to do if we don't have a window container yet. E.g. call from ctor.
                return;
            }

            // From fullscreen to PiP.
            if (topActivity != null && currentMode == WINDOWING_MODE_FULLSCREEN
                    && windowingMode == WINDOWING_MODE_PINNED
                    && !mTransitionController.isShellTransitionsEnabled()) {
                mDisplayContent.mPinnedTaskController
                        .deferOrientationChangeForEnteringPipFromFullScreenIfNeeded();
            }
        } finally {
            mAtmService.continueWindowLayout();
        }
Loading