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

Commit 975b6d7d authored by Ben Lin's avatar Ben Lin Committed by Android (Google) Code Review
Browse files

Merge "PiP2 DW: Do not enter pip if opening a new task while in desktop mode." into main

parents 5d31679c 1b74733a
Loading
Loading
Loading
Loading
+3 −2
Original line number Diff line number Diff line
@@ -81,11 +81,12 @@ public abstract class Pip2Module {
            @NonNull PipScheduler pipScheduler,
            @NonNull PipTransitionState pipStackListenerController,
            @NonNull PipDisplayLayoutState pipDisplayLayoutState,
            @NonNull PipUiStateChangeController pipUiStateChangeController) {
            @NonNull PipUiStateChangeController pipUiStateChangeController,
            Optional<DesktopUserRepositories> desktopUserRepositoriesOptional) {
        return new PipTransition(context, shellInit, shellTaskOrganizer, transitions,
                pipBoundsState, null, pipBoundsAlgorithm, pipTaskListener,
                pipScheduler, pipStackListenerController, pipDisplayLayoutState,
                pipUiStateChangeController);
                pipUiStateChangeController, desktopUserRepositoriesOptional);
    }

    @WMSingleton
+18 −1
Original line number Diff line number Diff line
@@ -63,6 +63,7 @@ import com.android.wm.shell.common.pip.PipDisplayLayoutState;
import com.android.wm.shell.common.pip.PipMenuController;
import com.android.wm.shell.common.pip.PipUtils;
import com.android.wm.shell.common.split.SplitScreenUtils;
import com.android.wm.shell.desktopmode.DesktopUserRepositories;
import com.android.wm.shell.pip.PipTransitionController;
import com.android.wm.shell.pip2.animation.PipAlphaAnimator;
import com.android.wm.shell.pip2.animation.PipEnterAnimator;
@@ -72,6 +73,8 @@ import com.android.wm.shell.shared.pip.PipContentOverlay;
import com.android.wm.shell.sysui.ShellInit;
import com.android.wm.shell.transition.Transitions;

import java.util.Optional;

/**
 * Implementation of transitions for PiP on phone.
 */
@@ -106,6 +109,7 @@ public class PipTransition extends PipTransitionController implements
    private final PipScheduler mPipScheduler;
    private final PipTransitionState mPipTransitionState;
    private final PipDisplayLayoutState mPipDisplayLayoutState;
    private final Optional<DesktopUserRepositories> mDesktopUserRepositoriesOptional;

    //
    // Transition caches
@@ -140,7 +144,8 @@ public class PipTransition extends PipTransitionController implements
            PipScheduler pipScheduler,
            PipTransitionState pipTransitionState,
            PipDisplayLayoutState pipDisplayLayoutState,
            PipUiStateChangeController pipUiStateChangeController) {
            PipUiStateChangeController pipUiStateChangeController,
            Optional<DesktopUserRepositories> desktopUserRepositoriesOptional) {
        super(shellInit, shellTaskOrganizer, transitions, pipBoundsState, pipMenuController,
                pipBoundsAlgorithm);

@@ -151,6 +156,7 @@ public class PipTransition extends PipTransitionController implements
        mPipTransitionState = pipTransitionState;
        mPipTransitionState.addPipTransitionStateChangedListener(this);
        mPipDisplayLayoutState = pipDisplayLayoutState;
        mDesktopUserRepositoriesOptional = desktopUserRepositoriesOptional;
    }

    @Override
@@ -820,6 +826,17 @@ public class PipTransition extends PipTransitionController implements
            return false;
        }


        // Since opening a new task while in Desktop Mode always first open in Fullscreen
        // until DesktopMode Shell code resolves it to Freeform, PipTransition will get a
        // possibility to handle it also. In this case return false to not have it enter PiP.
        final boolean isInDesktopSession = !mDesktopUserRepositoriesOptional.isEmpty()
                && mDesktopUserRepositoriesOptional.get().getCurrent().getVisibleTaskCount(
                pipTask.displayId) > 0;
        if (isInDesktopSession) {
            return false;
        }

        // Assuming auto-enter is enabled and pipTask is non-null, the TRANSIT_OPEN request type
        // implies that we are entering PiP in button navigation mode. This is guaranteed by
        // TaskFragment#startPausing()` in Core which wouldn't get called in gesture nav.