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

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

Merge "DesktopCtr/SplitScreenCtr: Supply dispId when starting New Window Split." into main

parents fef0af8b 45be4fce
Loading
Loading
Loading
Loading
+4 −1
Original line number Diff line number Diff line
@@ -68,6 +68,7 @@ import android.widget.Toast
import android.window.DesktopExperienceFlags
import android.window.DesktopExperienceFlags.DesktopExperienceFlag
import android.window.DesktopExperienceFlags.ENABLE_BUG_FIXES_FOR_SECONDARY_DISPLAY
import android.window.DesktopExperienceFlags.ENABLE_NON_DEFAULT_DISPLAY_SPLIT
import android.window.DesktopExperienceFlags.ENABLE_PER_DISPLAY_DESKTOP_WALLPAPER_ACTIVITY
import android.window.DesktopModeFlags
import android.window.DesktopModeFlags.DISABLE_NON_RESIZABLE_APP_SNAP_RESIZE
@@ -1841,7 +1842,7 @@ class DesktopTasksController(
        }

        if (
            !DesktopExperienceFlags.ENABLE_NON_DEFAULT_DISPLAY_SPLIT.isTrue ||
            !ENABLE_NON_DEFAULT_DISPLAY_SPLIT.isTrue ||
                !DesktopExperienceFlags.ENABLE_MOVE_TO_NEXT_DISPLAY_SHORTCUT.isTrue
        ) {
            return
@@ -2788,6 +2789,8 @@ class DesktopTasksController(
                    /* hideTaskToken= */ null,
                    /* forceLaunchNewTask= */ true,
                    splitIndex,
                    if (ENABLE_NON_DEFAULT_DISPLAY_SPLIT.isTrue) callingTaskInfo.displayId
                    else DEFAULT_DISPLAY,
                )
            }
            WINDOWING_MODE_FREEFORM -> {
+3 −3
Original line number Diff line number Diff line
@@ -859,7 +859,7 @@ public class SplitScreenController implements SplitDragPolicy.Starter,
            @SplitPosition int position, @Nullable Bundle options,
            @Nullable WindowContainerToken hideTaskToken, @SplitIndex int index) {
        startIntent(intent, userId1, fillInIntent, position, options, hideTaskToken,
                false /* forceLaunchNewTask */, index);
                false /* forceLaunchNewTask */, index, DEFAULT_DISPLAY);
    }

    /**
@@ -873,7 +873,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, boolean forceLaunchNewTask,
            @SplitIndex int index) {
            @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);
@@ -925,7 +925,7 @@ public class SplitScreenController implements SplitDragPolicy.Starter,
        }

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

    /**
+16 −1
Original line number Diff line number Diff line
@@ -37,6 +37,7 @@ import static android.window.WindowContainerTransaction.HierarchyOp.HIERARCHY_OP

import static com.android.window.flags.Flags.enableFullScreenWindowOnRemovingSplitScreenStageBugfix;
import static com.android.window.flags.Flags.enableMultiDisplaySplit;
import static com.android.window.flags.Flags.enableNonDefaultDisplaySplit;
import static com.android.wm.shell.Flags.enableFlexibleSplit;
import static com.android.wm.shell.Flags.enableFlexibleTwoAppSplit;
import static com.android.wm.shell.common.split.SplitLayout.PARALLAX_ALIGN_CENTER;
@@ -821,7 +822,7 @@ public class StageCoordinator implements SplitLayout.SplitLayoutHandler,
     */
    void startIntent(PendingIntent intent, Intent fillInIntent, @SplitPosition int position,
            @Nullable Bundle options, @Nullable WindowContainerToken hideTaskToken,
            @SplitIndex int index) {
            @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);
@@ -834,6 +835,10 @@ public class StageCoordinator implements SplitLayout.SplitLayoutHandler,
            ProtoLog.d(WM_SHELL_SPLIT_SCREEN, "Reordering hide-task to bottom");
            wct.reorder(hideTaskToken, false /* onTop */);
        }
        // For now, the only CUJ that can use this is LaunchAdjacent while on non-default displays.
        if (enableNonDefaultDisplaySplit()) {
            prepareMovingSplitscreenRoot(wct, displayId);
        }
        wct.sendPendingIntent(intent, fillInIntent, options);

        // If this should be mixed, just send the intent to avoid split handle transition directly.
@@ -1924,6 +1929,16 @@ public class StageCoordinator implements SplitLayout.SplitLayoutHandler,
        setRootForceTranslucent(false, wct);
    }

    private void prepareMovingSplitscreenRoot(WindowContainerTransaction wct, int displayId) {
        if (!enableMultiDisplaySplit()) {
            final DisplayAreaInfo displayAreaInfo = mRootTDAOrganizer.getDisplayAreaInfo(displayId);
            final WindowContainerToken token = getDisplayRootForDisplayId(DEFAULT_DISPLAY);
            if (token != null && displayAreaInfo != null) {
                wct.reparent(token, displayAreaInfo.token, true /* onTop */);
            }
        }
    }

    void finishEnterSplitScreen(SurfaceControl.Transaction finishT) {
        ProtoLog.d(WM_SHELL_SPLIT_SCREEN, "finishEnterSplitScreen");
        mSplitLayout.updateStateWithCurrentPosition();
+2 −0
Original line number Diff line number Diff line
@@ -8046,6 +8046,7 @@ class DesktopTasksControllerTest(flags: FlagsParameterization) : ShellTestCase()
                anyOrNull(),
                eq(true),
                eq(SPLIT_INDEX_UNDEFINED),
                eq(DEFAULT_DISPLAY),
            )
        assertThat(ActivityOptions.fromBundle(optionsCaptor.firstValue).launchWindowingMode)
            .isEqualTo(WINDOWING_MODE_MULTI_WINDOW)
@@ -8068,6 +8069,7 @@ class DesktopTasksControllerTest(flags: FlagsParameterization) : ShellTestCase()
                anyOrNull(),
                eq(true),
                eq(SPLIT_INDEX_UNDEFINED),
                eq(DEFAULT_DISPLAY),
            )
        assertThat(ActivityOptions.fromBundle(optionsCaptor.firstValue).launchWindowingMode)
            .isEqualTo(WINDOWING_MODE_MULTI_WINDOW)
+29 −5
Original line number Diff line number Diff line
@@ -22,6 +22,7 @@ import static android.app.WindowConfiguration.WINDOWING_MODE_FULLSCREEN;
import static android.app.WindowConfiguration.WINDOWING_MODE_MULTI_WINDOW;
import static android.content.Intent.FLAG_ACTIVITY_MULTIPLE_TASK;
import static android.content.Intent.FLAG_ACTIVITY_NO_USER_ACTION;
import static android.view.Display.DEFAULT_DISPLAY;

import static com.android.wm.shell.shared.split.SplitScreenConstants.SPLIT_INDEX_0;
import static com.android.wm.shell.shared.split.SplitScreenConstants.SPLIT_POSITION_BOTTOM_OR_RIGHT;
@@ -219,13 +220,14 @@ public class SplitScreenControllerTests extends ShellTestCase {
                SPLIT_INDEX_0);

        verify(mStageCoordinator).startIntent(eq(pendingIntent), mIntentCaptor.capture(),
                eq(SPLIT_POSITION_TOP_OR_LEFT), isNull(), isNull(), eq(SPLIT_INDEX_0));
                eq(SPLIT_POSITION_TOP_OR_LEFT), isNull(), isNull(), eq(SPLIT_INDEX_0),
                eq(DEFAULT_DISPLAY));
        assertEquals(FLAG_ACTIVITY_NO_USER_ACTION,
                mIntentCaptor.getValue().getFlags() & FLAG_ACTIVITY_NO_USER_ACTION);
    }

    @Test
    public void startIntent_multiInstancesSupported_appendsMultipleTaskFag() {
    public void startIntent_multiInstancesSupported_appendsMultipleTaskFlag() {
        doReturn(true).when(mMultiInstanceHelper).supportsMultiInstanceSplit(any(), anyInt());
        Intent startIntent = createStartIntent("startActivity");
        PendingIntent pendingIntent =
@@ -240,11 +242,33 @@ public class SplitScreenControllerTests extends ShellTestCase {
                SPLIT_INDEX_0);

        verify(mStageCoordinator).startIntent(eq(pendingIntent), mIntentCaptor.capture(),
                eq(SPLIT_POSITION_TOP_OR_LEFT), isNull(), isNull(), eq(SPLIT_INDEX_0));
                eq(SPLIT_POSITION_TOP_OR_LEFT), isNull(), isNull(), eq(SPLIT_INDEX_0),
                eq(DEFAULT_DISPLAY));
        assertEquals(FLAG_ACTIVITY_MULTIPLE_TASK,
                mIntentCaptor.getValue().getFlags() & FLAG_ACTIVITY_MULTIPLE_TASK);
    }

    @Test
    public void startIntent_multiInstancesSupported_appendsDisplayId() {
        doReturn(true).when(mMultiInstanceHelper).supportsMultiInstanceSplit(any(), anyInt());
        Intent startIntent = createStartIntent("startActivity");
        PendingIntent pendingIntent =
                PendingIntent.getActivity(mContext, 0, startIntent, FLAG_IMMUTABLE);
        // Put the same component to the top running task
        ActivityManager.RunningTaskInfo topRunningTask =
                createTaskInfo(WINDOWING_MODE_FULLSCREEN, ACTIVITY_TYPE_STANDARD, startIntent);
        doReturn(topRunningTask).when(mRecentTasks).getTopRunningTask(any());

        final int secondDisplay = DEFAULT_DISPLAY + 1;
        mSplitScreenController.startIntent(pendingIntent, mContext.getUserId(), null,
                SPLIT_POSITION_TOP_OR_LEFT, null /* options */, null /* hideTaskToken */,
                false, SPLIT_INDEX_0, secondDisplay);

        verify(mStageCoordinator).startIntent(eq(pendingIntent), mIntentCaptor.capture(),
                eq(SPLIT_POSITION_TOP_OR_LEFT), isNull(), isNull(), eq(SPLIT_INDEX_0),
                eq(secondDisplay));
    }

    @Test
    public void startIntent_multiInstancesNotSupported_startTaskInBackgroundBeforeSplitActivated() {
        doNothing().when(mSplitScreenController).startTask(anyInt(), anyInt(), any(), any());
@@ -321,7 +345,7 @@ public class SplitScreenControllerTests extends ShellTestCase {
                PendingIntent.getActivity(mContext, 0, startIntent, FLAG_IMMUTABLE);
        mSplitScreenController.startIntent(pendingIntent, mContext.getUserId(), null,
                SPLIT_POSITION_TOP_OR_LEFT, null /* options */, null /* hideTaskToken */,
                true /* forceLaunchNewTask */, SPLIT_INDEX_0);
                true /* forceLaunchNewTask */, SPLIT_INDEX_0, DEFAULT_DISPLAY);
        verify(mRecentTasks, never()).findTaskInBackground(any(), anyInt(), any());
    }

@@ -332,7 +356,7 @@ public class SplitScreenControllerTests extends ShellTestCase {
                PendingIntent.getActivity(mContext, 0, startIntent, FLAG_IMMUTABLE);
        mSplitScreenController.startIntent(pendingIntent, mContext.getUserId(), null,
                SPLIT_POSITION_TOP_OR_LEFT, null /* options */, null /* hideTaskToken */,
                false /* forceLaunchNewTask */, SPLIT_INDEX_0);
                false /* forceLaunchNewTask */, SPLIT_INDEX_0, DEFAULT_DISPLAY);
        verify(mRecentTasks).findTaskInBackground(any(), anyInt(), any());
    }