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

Commit 741c9277 authored by Hongwei Wang's avatar Hongwei Wang
Browse files

Dismiss split-screen for direct enter PiP

When the PiP-able task requests to enter PiP while it's in
split-screen, for instance, from back-gesture, notify the split screen
controller to prepare an exit first.

- When it's a direct PiP request from app, like from back-gesture,
  split-screen dismisses and the other app was in split stays front
- When it's a swipe to enter PiP case, split-screen dismissed and the
  other app goes to background

Flag: com.android.wm.shell.enable_pip2
Bug: 381374430
Video: http://recall/-/aaaaaabFQoRHlzixHdtY/hTlJtDRTr7S8rCMBoOImUD
Test: Manual, back gesture to enter PiP from split, see Video
Test: atest PinnedStackTests
Change-Id: I437cce8ec430c32a3c7b1df6c334c357ddf1a8d2
parent 6e9fc6c7
Loading
Loading
Loading
Loading
+0 −2
Original line number Diff line number Diff line
@@ -91,8 +91,6 @@ public abstract class Pip2Module {
            @NonNull Transitions transitions,
            PipBoundsState pipBoundsState,
            PipBoundsAlgorithm pipBoundsAlgorithm,
            Optional<PipController> pipController,
            PipTouchHandler pipTouchHandler,
            PipTaskListener pipTaskListener,
            @NonNull PipScheduler pipScheduler,
            @NonNull PipTransitionState pipStackListenerController,
+0 −2
Original line number Diff line number Diff line
@@ -124,7 +124,6 @@ public class PipTransition extends PipTransitionController implements
    private final PipSurfaceTransactionHelper mPipSurfaceTransactionHelper;
    private final PipDesktopState mPipDesktopState;
    private final Optional<DesktopPipTransitionController> mDesktopPipTransitionController;
    private final PipInteractionHandler mPipInteractionHandler;

    //
    // Transition caches
@@ -185,7 +184,6 @@ public class PipTransition extends PipTransitionController implements
        mPipSurfaceTransactionHelper = pipSurfaceTransactionHelper;
        mPipDesktopState = pipDesktopState;
        mDesktopPipTransitionController = desktopPipTransitionController;
        mPipInteractionHandler = pipInteractionHandler;

        mExpandHandler = new PipExpandHandler(mContext, mPipSurfaceTransactionHelper,
                pipBoundsState, pipBoundsAlgorithm,
+26 −0
Original line number Diff line number Diff line
@@ -3193,6 +3193,32 @@ public class StageCoordinator implements SplitLayout.SplitLayoutHandler,
        }
    }

    /**
     * This is used for mixed-transition scenarios (specifically when transitioning one split task
     * into PIP). For such scenarios, just make sure to include exiting split or entering split when
     * appropriate. This is an addition to
     * {@link #addEnterOrExitForPipIfNeeded(TransitionRequestInfo, WindowContainerTransaction)},
     * for PiP2 where PiP-able task can also come in through the pip change request field,
     * and this method is provided to explicitly prepare an exit in that case.
     *
     * This is only called if requestImpliesSplitToPip() returns `true`.
     */
    public void removePipFromSplitIfNeeded(@NonNull TransitionRequestInfo request,
            @NonNull WindowContainerTransaction outWCT) {
        if (request.getPipChange() == null || request.getPipChange().getTaskInfo() == null) {
            return;
        }
        final TaskInfo info = request.getPipChange().getTaskInfo();
        @StageType int topStage = STAGE_TYPE_UNDEFINED;
        @StageType int pipStage = getStageOfTask(info.taskId);
        if (pipStage == STAGE_TYPE_MAIN) {
            topStage = STAGE_TYPE_SIDE;
        } else if (pipStage == STAGE_TYPE_SIDE) {
            topStage = STAGE_TYPE_MAIN;
        }
        prepareExitSplitScreen(topStage, outWCT, EXIT_REASON_CHILD_TASK_ENTER_PIP);
    }

    /**
     * This is used for mixed-transition scenarios (specifically when transitioning one split task
     * into PIP). For such scenarios, just make sure to include exiting split or entering split when
+4 −0
Original line number Diff line number Diff line
@@ -51,6 +51,7 @@ import com.android.wm.shell.protolog.ShellProtoLogGroup;
import com.android.wm.shell.recents.RecentsTransitionHandler;
import com.android.wm.shell.shared.TransitionUtil;
import com.android.wm.shell.shared.bubbles.BubbleAnythingFlagHelper;
import com.android.wm.shell.shared.pip.PipFlags;
import com.android.wm.shell.splitscreen.SplitScreenController;
import com.android.wm.shell.splitscreen.StageCoordinator;
import com.android.wm.shell.sysui.ShellInit;
@@ -373,6 +374,9 @@ public class DefaultMixedHandler implements MixedTransitionHandler,

            WindowContainerTransaction out = new WindowContainerTransaction();
            mPipHandler.augmentRequest(transition, request, out);
            if (PipFlags.isPip2ExperimentEnabled() && mSplitHandler.isSplitScreenVisible()) {
                mSplitHandler.removePipFromSplitIfNeeded(request, out);
            }
            mSplitHandler.addEnterOrExitForPipIfNeeded(request, out);
            return out;
        } else if (request.getType() == TRANSIT_PIP