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

Commit cecce414 authored by Maryam Dehaini's avatar Maryam Dehaini Committed by Android (Google) Code Review
Browse files

Merge "Use a seperate transaction to applying windowing mode changes after exiting pip" into main

parents 1dfb75be d89a020d
Loading
Loading
Loading
Loading
+32 −2
Original line number Diff line number Diff line
@@ -41,6 +41,7 @@ import static com.android.wm.shell.pip.PipAnimationController.TRANSITION_DIRECTI
import static com.android.wm.shell.pip.PipAnimationController.isInPipDirection;
import static com.android.wm.shell.pip.PipAnimationController.isOutPipDirection;
import static com.android.wm.shell.pip.PipTransitionState.ENTERED_PIP;
import static com.android.wm.shell.transition.Transitions.TRANSIT_CLEANUP_PIP_EXIT;
import static com.android.wm.shell.transition.Transitions.TRANSIT_EXIT_PIP;
import static com.android.wm.shell.transition.Transitions.TRANSIT_EXIT_PIP_TO_SPLIT;
import static com.android.wm.shell.transition.Transitions.TRANSIT_REMOVE_PIP;
@@ -122,6 +123,8 @@ public class PipTransition extends PipTransitionController {
    @Nullable
    private IBinder mMoveToBackTransition;
    private IBinder mRequestedEnterTransition;
    private IBinder mCleanupTransition;

    private WindowContainerToken mRequestedEnterTask;
    /** The Task window that is currently in PIP windowing mode. */
    @Nullable
@@ -232,10 +235,12 @@ public class PipTransition extends PipTransitionController {

        // Exiting PIP.
        final int type = info.getType();
        if (transition.equals(mExitTransition) || transition.equals(mMoveToBackTransition)) {
        if (transition.equals(mExitTransition) || transition.equals(mMoveToBackTransition)
                || transition.equals(mCleanupTransition)) {
            mExitDestinationBounds.setEmpty();
            mExitTransition = null;
            mMoveToBackTransition = null;
            mCleanupTransition = null;
            mHasFadeOut = false;
            if (mFinishCallback != null) {
                callFinishCallback(null /* wct */);
@@ -269,6 +274,9 @@ public class PipTransition extends PipTransitionController {
                    removePipImmediately(info, startTransaction, finishTransaction, finishCallback,
                            pipTaskInfo);
                    break;
                case TRANSIT_CLEANUP_PIP_EXIT:
                    cleanupPipExitTransition(startTransaction, finishCallback);
                    break;
                default:
                    throw new IllegalStateException("mExitTransition with unexpected transit type="
                            + transitTypeToString(type));
@@ -768,7 +776,19 @@ public class PipTransition extends PipTransitionController {
                mPipAnimationController.resetAnimatorState();
                finishTransaction.remove(pipLeash);
            }

            if (mFixedRotationState == FIXED_ROTATION_TRANSITION) {
                // TODO(b/358226697): start a new transition with the WCT instead of applying it in
                //  the {@link finishCallback}, to ensure shell creates a transition for it.
                finishCallback.onTransitionFinished(wct);
            } else {
                // Apply wct in separate transition so that it can be correctly handled by the
                // {@link FreeformTaskTransitionObserver} when desktop windowing (which does not
                // utilize fixed rotation transitions for exiting pip) is enabled (See b/288910069).
                mCleanupTransition = mTransitions.startTransition(
                        TRANSIT_CLEANUP_PIP_EXIT, wct, this);
                finishCallback.onTransitionFinished(null);
            }
        };
        mFinishTransaction = finishTransaction;

@@ -914,6 +934,16 @@ public class PipTransition extends PipTransitionController {
        finishCallback.onTransitionFinished(null);
    }

    /**
     * For {@link Transitions#TRANSIT_CLEANUP_PIP_EXIT} which applies final config changes needed
     * after the exit from pip transition animation finishes.
     */
    private void cleanupPipExitTransition(@NonNull SurfaceControl.Transaction startTransaction,
            @NonNull Transitions.TransitionFinishCallback finishCallback) {
        startTransaction.apply();
        finishCallback.onTransitionFinished(null);
    }

    /** Whether we should handle the given {@link TransitionInfo} animation as entering PIP. */
    private boolean isEnteringPip(@NonNull TransitionInfo info) {
        for (int i = info.getChanges().size() - 1; i >= 0; --i) {
+3 −0
Original line number Diff line number Diff line
@@ -193,6 +193,9 @@ public class Transitions implements RemoteCallable<Transitions>,
    /** Remote Transition that split accepts but ultimately needs to be animated by the remote. */
    public static final int TRANSIT_SPLIT_PASSTHROUGH = TRANSIT_FIRST_CUSTOM + 18;

    /** Transition to set windowing mode after exit pip transition is finished animating. */
    public static final int TRANSIT_CLEANUP_PIP_EXIT = WindowManager.TRANSIT_FIRST_CUSTOM + 19;

    /** Transition type for desktop mode transitions. */
    public static final int TRANSIT_DESKTOP_MODE_TYPES =
            WindowManager.TRANSIT_FIRST_CUSTOM + 100;
+13 −6
Original line number Diff line number Diff line
@@ -19,6 +19,7 @@ package com.android.server.wm;
import static android.app.WindowConfiguration.WINDOWING_MODE_FREEFORM;
import static android.app.WindowConfiguration.WINDOWING_MODE_FULLSCREEN;
import static android.app.WindowConfiguration.WINDOWING_MODE_MULTI_WINDOW;
import static android.app.WindowConfiguration.WINDOWING_MODE_PINNED;
import static android.content.pm.ActivityInfo.SCREEN_ORIENTATION_BEHIND;
import static android.content.pm.ActivityInfo.SCREEN_ORIENTATION_UNSET;
import static android.content.pm.ActivityInfo.SCREEN_ORIENTATION_UNSPECIFIED;
@@ -2997,12 +2998,18 @@ class WindowContainer<E extends WindowContainer> extends ConfigurationContainer<
        // Make sure display isn't a part of the transition already - needed for legacy transitions.
        if (mDisplayContent.inTransition()) return false;

        if (!ActivityTaskManagerService.isPip2ExperimentEnabled()) {
        // Screenshots are turned off when PiP is undergoing changes.
            return !inPinnedWindowingMode() && getParent() != null
                    && !getParent().inPinnedWindowingMode();
        return ActivityTaskManagerService.isPip2ExperimentEnabled() || !isPipChange();
    }
        return true;

    /** Returns true if WC is pinned and undergoing changes. */
    private boolean isPipChange() {
        final boolean isExitingPip = this.asTaskFragment() != null
                && mTransitionController.getWindowingModeAtStart(this) == WINDOWING_MODE_PINNED
                && !inPinnedWindowingMode();

        return isExitingPip || inPinnedWindowingMode()
                || (getParent() != null && getParent().inPinnedWindowingMode());
    }

    /**