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

Commit 4464f3c0 authored by Ikram Gabiyev's avatar Ikram Gabiyev
Browse files

[PiP2] Handle split to PiP as a mixed transition

Make sure Split-to-PiP case (w/o replacement) is handled
by the DefaultMixedHandler, and starts a dismiss split transition
as a follow-up when dispatching the transition for the leftover handler.

Also make sure we delegate the PiP part of the animation in PiP2
similar to how it's done for TYPE_OPTIONS_REMOTE_AND_PIP_OR_DESKTOP_CHANGE
or TYPE_ENTER_PIP_FROM_ACTIVITY_EMBEDDING.

This fixes the single-activity PiP case where split is dismissed;
multi-activity case is yet to be refactored fully.

This is only handling the swipe-up from split case, btn-nav case is yet
to be fixed.

Bug: 381332669
Flag: com.android.wm.shell.enable_pip2
Test: manually repro the steps in the bug

Change-Id: I062db7850d94e59e906bb5fe72f50da30e0dd260
parent 4d5fa9fd
Loading
Loading
Loading
Loading
+8 −0
Original line number Diff line number Diff line
@@ -136,6 +136,7 @@ import com.android.wm.shell.common.DisplayInsetsController;
import com.android.wm.shell.common.LaunchAdjacentController;
import com.android.wm.shell.common.ShellExecutor;
import com.android.wm.shell.common.SyncTransactionQueue;
import com.android.wm.shell.common.pip.PipUtils;
import com.android.wm.shell.common.split.OffscreenTouchZone;
import com.android.wm.shell.common.split.SplitDecorManager;
import com.android.wm.shell.common.split.SplitLayout;
@@ -581,6 +582,13 @@ public class StageCoordinator implements SplitLayout.SplitLayoutHandler,
            return true;
        }

        if (PipUtils.isPip2ExperimentEnabled()
                && request.getPipChange() != null && getSplitPosition(
                request.getPipChange().getTaskInfo().taskId) != SPLIT_POSITION_UNDEFINED) {
            // In PiP2, PiP-able task can also come in through the pip change request field.
            return true;
        }

        // If one of the splitting tasks support auto-pip, wm-core might reparent the task to TDA
        // and file a TRANSIT_PIP transition when finishing transitions.
        // @see com.android.server.wm.RootWindowContainer#moveActivityToPinnedRootTask
+25 −5
Original line number Diff line number Diff line
@@ -17,13 +17,14 @@
package com.android.wm.shell.transition;

import static android.app.WindowConfiguration.ACTIVITY_TYPE_HOME;
import static android.view.WindowManager.TRANSIT_PIP;
import static android.view.WindowManager.TRANSIT_TO_BACK;
import static android.window.TransitionInfo.FLAG_IS_WALLPAPER;

import static com.android.wm.shell.shared.split.SplitScreenConstants.FLAG_IS_DIVIDER_BAR;
import static com.android.wm.shell.shared.split.SplitScreenConstants.SPLIT_POSITION_UNDEFINED;
import static com.android.wm.shell.pip.PipAnimationController.ANIM_TYPE_ALPHA;
import static com.android.wm.shell.shared.TransitionUtil.isOpeningMode;
import static com.android.wm.shell.shared.split.SplitScreenConstants.FLAG_IS_DIVIDER_BAR;
import static com.android.wm.shell.shared.split.SplitScreenConstants.SPLIT_POSITION_UNDEFINED;
import static com.android.wm.shell.splitscreen.SplitScreen.STAGE_TYPE_MAIN;
import static com.android.wm.shell.splitscreen.SplitScreen.STAGE_TYPE_SIDE;
import static com.android.wm.shell.splitscreen.SplitScreen.STAGE_TYPE_UNDEFINED;
@@ -36,6 +37,7 @@ import android.view.SurfaceControl;
import android.window.TransitionInfo;

import com.android.internal.protolog.ProtoLog;
import com.android.wm.shell.common.pip.PipUtils;
import com.android.wm.shell.keyguard.KeyguardTransitionHandler;
import com.android.wm.shell.pip.PipTransitionController;
import com.android.wm.shell.protolog.ShellProtoLogGroup;
@@ -54,6 +56,7 @@ public class MixedTransitionHelper {
        ProtoLog.v(ShellProtoLogGroup.WM_SHELL_TRANSITIONS, " Animating a mixed transition for "
                + "entering PIP while Split-Screen is foreground.");
        TransitionInfo.Change pipChange = null;
        TransitionInfo.Change pipActivityChange = null;
        TransitionInfo.Change wallpaper = null;
        final TransitionInfo everythingElse =
                subCopy(info, TRANSIT_TO_BACK, true /* changes */);
@@ -68,6 +71,13 @@ public class MixedTransitionHelper {
                pipChange = change;
                // going backwards, so remove-by-index is fine.
                everythingElse.getChanges().remove(i);
            } else if (change.getTaskInfo() == null && change.getParent() != null
                    && pipChange != null && change.getParent().equals(pipChange.getContainer())) {
                // Cache the PiP activity if it's a target and cached pip task change is its parent;
                // note that we are bottom-to-top, so if such activity has a task
                // that is also a target, then it must have been cached already as pipChange.
                pipActivityChange = change;
                everythingElse.getChanges().remove(i);
            } else if (isHomeOpening(change)) {
                homeIsOpening = true;
            } else if (isWallpaper(change)) {
@@ -138,9 +148,19 @@ public class MixedTransitionHelper {
                }
            }

            if (PipUtils.isPip2ExperimentEnabled()) {
                TransitionInfo pipInfo = subCopy(info, TRANSIT_PIP, false /* withChanges */);
                pipInfo.getChanges().add(pipChange);
                if (pipActivityChange != null) {
                    pipInfo.getChanges().add(pipActivityChange);
                }
                pipHandler.startAnimation(mixed.mTransition, pipInfo, startTransaction,
                        finishTransaction, finishCB);
            } else {
                pipHandler.setEnterAnimationType(ANIM_TYPE_ALPHA);
                pipHandler.startEnterAnimation(pipChange, startTransaction, finishTransaction,
                        finishCB);
            }
            // make a new finishTransaction because pip's startEnterAnimation "consumes" it so
            // we need a separate one to send over to launcher.
            SurfaceControl.Transaction otherFinishT = new SurfaceControl.Transaction();