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

Commit d89a020d authored by Maryam Dehaini's avatar Maryam Dehaini
Browse files

Use a seperate transaction to applying windowing mode changes after

exiting pip

Currently, we always use the wct that is called during
TransitionFinishCallback#onTransitionFinished in order to apply the
windowing mode vhanges after a task exits pip. This method applies the
wct during cleanup rather than applying it in its own transition. This
means that the transition is not sent to the
FreeformTaskTransitionObserver which means, when desktop windowing is
enabled, the view model is not given the chance to create the caption
needed now that the task is out of pip. By using a seperate transition
during non-fixed rotation transitions, this view model will recieve an
onTaskInfoChange call and a caption will be added.

The reason that a separate transition is not used for fixed rotation
transitions is because a new transition will reset the orientation,
positioning, and other states which were set in the original
transition., Given that this change is only required for desktop
windowing which does not utilize fixed rotations when exiting pip, the
wct is not applied as a seperate transition for fixed rotation
transitions.

This change also changes WindowContainer#canStartChangeTransition so
that screenshots are not shown in the cleanup transition as well as the
main pip transition.

Bug: 288910069
Test: Enter pip and then return task to fullscreen. Caption should be
visible.
Flag: EXEMPT bugfix

Change-Id: I2e51880b307f201096f3d40010b61453cc596749
parent 9d2ee3f3
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());
    }

    /**