Loading libs/WindowManager/Shell/src/com/android/wm/shell/desktopmode/DesktopTasksController.kt +4 −1 Original line number Diff line number Diff line Loading @@ -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 Loading Loading @@ -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 Loading Loading @@ -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 -> { Loading libs/WindowManager/Shell/src/com/android/wm/shell/splitscreen/SplitScreenController.java +3 −3 Original line number Diff line number Diff line Loading @@ -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); } /** Loading @@ -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); Loading Loading @@ -925,7 +925,7 @@ public class SplitScreenController implements SplitDragPolicy.Starter, } mStageCoordinator.startIntent(intent, fillInIntent, position, options, hideTaskToken, index); index, displayId); } /** Loading libs/WindowManager/Shell/src/com/android/wm/shell/splitscreen/StageCoordinator.java +16 −1 Original line number Diff line number Diff line Loading @@ -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; Loading Loading @@ -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); Loading @@ -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. Loading Loading @@ -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(); Loading libs/WindowManager/Shell/tests/unittest/src/com/android/wm/shell/desktopmode/DesktopTasksControllerTest.kt +2 −0 Original line number Diff line number Diff line Loading @@ -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) Loading @@ -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) Loading libs/WindowManager/Shell/tests/unittest/src/com/android/wm/shell/splitscreen/SplitScreenControllerTests.java +29 −5 Original line number Diff line number Diff line Loading @@ -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; Loading Loading @@ -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 = Loading @@ -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()); Loading Loading @@ -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()); } Loading @@ -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()); } Loading Loading
libs/WindowManager/Shell/src/com/android/wm/shell/desktopmode/DesktopTasksController.kt +4 −1 Original line number Diff line number Diff line Loading @@ -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 Loading Loading @@ -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 Loading Loading @@ -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 -> { Loading
libs/WindowManager/Shell/src/com/android/wm/shell/splitscreen/SplitScreenController.java +3 −3 Original line number Diff line number Diff line Loading @@ -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); } /** Loading @@ -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); Loading Loading @@ -925,7 +925,7 @@ public class SplitScreenController implements SplitDragPolicy.Starter, } mStageCoordinator.startIntent(intent, fillInIntent, position, options, hideTaskToken, index); index, displayId); } /** Loading
libs/WindowManager/Shell/src/com/android/wm/shell/splitscreen/StageCoordinator.java +16 −1 Original line number Diff line number Diff line Loading @@ -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; Loading Loading @@ -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); Loading @@ -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. Loading Loading @@ -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(); Loading
libs/WindowManager/Shell/tests/unittest/src/com/android/wm/shell/desktopmode/DesktopTasksControllerTest.kt +2 −0 Original line number Diff line number Diff line Loading @@ -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) Loading @@ -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) Loading
libs/WindowManager/Shell/tests/unittest/src/com/android/wm/shell/splitscreen/SplitScreenControllerTests.java +29 −5 Original line number Diff line number Diff line Loading @@ -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; Loading Loading @@ -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 = Loading @@ -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()); Loading Loading @@ -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()); } Loading @@ -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()); } Loading