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

Commit 77184dbc authored by Ben Lin's avatar Ben Lin
Browse files

Splitscreen#launchIntent: Allow usage with non-fullscreen displays.

When displays are not in fullscreen, tasks that are in fullscreen are
explicitly set as WINDOWING_MODE_FULLSCREEN as opposed to UNDEFINED that
inherits from parent windowing mode. Because of this, when we try to
then start a splitscreen pair with the existing task, which starts off
with reparenting the task to Main Stage, its windowing mode sticks - it
does not change (stays as FULLSCREEN). Then, Shell Transition framework
sees it as a no-op and does not include the Task as part of the Change
list, and so Splitscreen transition code fails to see a task to animate
and aborts the splitscreen setup.

By resetting the windowing mode and explicitly look for it in the Hop
processing, we can allow the task to be reparented and detected by shell
transition correctly.

This also introduces a new flag to disable a logic in which we restore
the task bounds to mLastNonFullscreenBounds when the task is in
freeform, which on a desktop-first / freeform display this will happen
now as we temporarily switch the task to UNDEFINED before reparenting.
This disables restoring the bounds since we are not using this variable
anymore - most of the bounds logic is all done at the Shell side.

Test: Manual. Open Chrome and attempt to start New Window using the app
handle (so it starts from shell side)
Bug: 372315420
Flag:com.android.window.flags.disable_restore_non_fullscreen_bounds_on_configuration_change

Change-Id: I9c2608888ce2a46f3bf9786ff8a4f713f7b4dd57
parent 307b1b2b
Loading
Loading
Loading
Loading
+2 −2
Original line number Diff line number Diff line
@@ -641,8 +641,8 @@ public final class WindowContainerTransaction implements Parcelable {

    /**
     * Reparent's all children tasks or the top task of {@param currentParent} in the specified
     * {@param windowingMode} and {@param activityType} to {@param newParent} in their current
     * z-order.
     * overridden {@param windowingMode} and {@param activityType} to {@param newParent} in their
     * current z-order.
     *
     * @param currentParent of the tasks to perform the operation no.
     *                      {@code null} will perform the operation on the display.
+10 −0
Original line number Diff line number Diff line
@@ -40,6 +40,16 @@ flag {
    bug: "325240072"
}

flag {
    name: "disable_restore_non_fullscreen_bounds_on_configuration_change"
    namespace: "lse_desktop_experience"
    description: "Disable restoring bounds to mLastNonFullscreenBounds on configuration change."
    bug: "372315420"
    metadata {
        purpose: PURPOSE_BUGFIX
    }
}

flag {
    name: "empty_roots_never_top"
    namespace: "lse_desktop_experience"
+4 −0
Original line number Diff line number Diff line
@@ -3082,6 +3082,9 @@ class DesktopTasksController(
        val options = createNewWindowOptions(callingTaskInfo, deskId)
        when (options.launchWindowingMode) {
            WINDOWING_MODE_MULTI_WINDOW -> {
                val wct = WindowContainerTransaction()
                wct.setWindowingMode(callingTaskInfo.token, WINDOWING_MODE_UNDEFINED)
                    .setBounds(callingTaskInfo.token, Rect())
                val splitPosition =
                    splitScreenController.determineNewInstancePosition(callingTaskInfo)
                // TODO(b/349828130) currently pass in index_undefined until we can revisit these
@@ -3097,6 +3100,7 @@ class DesktopTasksController(
                    splitPosition,
                    options.toBundle(),
                    /* hideTaskToken= */ null,
                    wct,
                    /* forceLaunchNewTask= */ true,
                    splitIndex,
                    if (ENABLE_NON_DEFAULT_DISPLAY_SPLIT.isTrue) callingTaskInfo.displayId
+4 −4
Original line number Diff line number Diff line
@@ -868,7 +868,7 @@ public class SplitScreenController implements SplitDragPolicy.Starter,
    public void startIntent(PendingIntent intent, int userId1, @Nullable Intent fillInIntent,
            @SplitPosition int position, @Nullable Bundle options,
            @Nullable WindowContainerToken hideTaskToken, @SplitIndex int index) {
        startIntent(intent, userId1, fillInIntent, position, options, hideTaskToken,
        startIntent(intent, userId1, fillInIntent, position, options, hideTaskToken, null /* wct */,
                false /* forceLaunchNewTask */, index, DEFAULT_DISPLAY);
    }

@@ -882,8 +882,8 @@ public class SplitScreenController implements SplitDragPolicy.Starter,
     */
    public void startIntent(PendingIntent intent, int userId1, @Nullable Intent fillInIntent,
            @SplitPosition int position, @Nullable Bundle options,
            @Nullable WindowContainerToken hideTaskToken, boolean forceLaunchNewTask,
            @SplitIndex int index, int displayId) {
            @Nullable WindowContainerToken hideTaskToken, @Nullable WindowContainerTransaction wct,
            boolean forceLaunchNewTask, @SplitIndex int index, int displayId) {
        ProtoLog.v(ShellProtoLogGroup.WM_SHELL_SPLIT_SCREEN,
                "startIntent(): intent=%s user=%d fillInIntent=%s position=%d", intent, userId1,
                fillInIntent, position);
@@ -935,7 +935,7 @@ public class SplitScreenController implements SplitDragPolicy.Starter,
        }

        mStageCoordinator.startIntent(intent, fillInIntent, position, options, hideTaskToken,
                index, displayId);
                wct, index, displayId);
    }

    /**
+5 −1
Original line number Diff line number Diff line
@@ -848,12 +848,16 @@ public class StageCoordinator implements SplitLayout.SplitLayoutHandler,
     */
    void startIntent(PendingIntent intent, Intent fillInIntent, @SplitPosition int position,
            @Nullable Bundle options, @Nullable WindowContainerToken hideTaskToken,
            @SplitIndex int index, int displayId) {
            @Nullable WindowContainerTransaction transaction, @SplitIndex int index,
            int displayId) {
        ProtoLog.d(WM_SHELL_SPLIT_SCREEN, "startIntent: intent=%s position=%d", intent.getIntent(),
                position);
        mSplitRequest = new SplitRequest(intent.getIntent(), position);

        final WindowContainerTransaction wct = new WindowContainerTransaction();
        if (transaction != null) {
            wct.merge(transaction, true);
        }
        options = enableFlexibleSplit()
                ? resolveStartStageForIndex(options, null /*wct*/, index)
                : resolveStartStage(STAGE_TYPE_UNDEFINED, position, options, null /* wct */);
Loading