Loading libs/WindowManager/Shell/src/com/android/wm/shell/desktopmode/DesktopTasksController.kt +2 −1 Original line number Diff line number Diff line Loading @@ -1225,7 +1225,8 @@ class DesktopTasksController( .determineNewInstancePosition(callingTaskInfo) splitScreenController.startIntent( launchIntent, context.userId, fillIn, splitPosition, options.toBundle(), null /* hideTaskToken */ options.toBundle(), null /* hideTaskToken */, true /* forceLaunchNewTask */ ) } WINDOWING_MODE_FREEFORM -> { Loading libs/WindowManager/Shell/src/com/android/wm/shell/splitscreen/SplitScreenController.java +15 −4 Original line number Diff line number Diff line Loading @@ -772,15 +772,25 @@ public class SplitScreenController implements SplitDragPolicy.Starter, instanceId); } @Override public void startIntent(PendingIntent intent, int userId1, @Nullable Intent fillInIntent, @SplitPosition int position, @Nullable Bundle options, @Nullable WindowContainerToken hideTaskToken) { startIntent(intent, userId1, fillInIntent, position, options, hideTaskToken, false /* forceLaunchNewTask */); } /** * Starts the given intent into split. * * @param hideTaskToken If non-null, a task matching this token will be moved to back in the * same window container transaction as the starting of the intent. * @param forceLaunchNewTask If true, this method will skip the check for a background task * matching the intent and launch a new task. */ @Override public void startIntent(PendingIntent intent, int userId1, @Nullable Intent fillInIntent, @SplitPosition int position, @Nullable Bundle options, @Nullable WindowContainerToken hideTaskToken) { @Nullable WindowContainerToken hideTaskToken, boolean forceLaunchNewTask) { ProtoLog.v(ShellProtoLogGroup.WM_SHELL_SPLIT_SCREEN, "startIntent(): intent=%s user=%d fillInIntent=%s position=%d", intent, userId1, fillInIntent, position); Loading @@ -798,7 +808,8 @@ public class SplitScreenController implements SplitDragPolicy.Starter, // To prevent accumulating large number of instances in the background, reuse task // in the background. If we don't explicitly reuse, new may be created even if the app // isn't multi-instance because WM won't automatically remove/reuse the previous instance final ActivityManager.RecentTaskInfo taskInfo = mRecentTasksOptional final ActivityManager.RecentTaskInfo taskInfo = forceLaunchNewTask ? null : mRecentTasksOptional .map(recentTasks -> recentTasks.findTaskInBackground(component, userId1, hideTaskToken)) .orElse(null); Loading libs/WindowManager/Shell/tests/unittest/src/com/android/wm/shell/desktopmode/DesktopTasksControllerTest.kt +3 −2 Original line number Diff line number Diff line Loading @@ -2902,7 +2902,8 @@ class DesktopTasksControllerTest : ShellTestCase() { runOpenNewWindow(task) verify(splitScreenController) .startIntent(any(), anyInt(), any(), any(), optionsCaptor.capture(), anyOrNull()) optionsCaptor.capture(), anyOrNull(), eq(true) ) assertThat(ActivityOptions.fromBundle(optionsCaptor.value).launchWindowingMode) .isEqualTo(WINDOWING_MODE_MULTI_WINDOW) } Loading @@ -2917,7 +2918,7 @@ class DesktopTasksControllerTest : ShellTestCase() { verify(splitScreenController) .startIntent( any(), anyInt(), any(), any(), optionsCaptor.capture(), anyOrNull() optionsCaptor.capture(), anyOrNull(), eq(true) ) assertThat(ActivityOptions.fromBundle(optionsCaptor.value).launchWindowingMode) .isEqualTo(WINDOWING_MODE_MULTI_WINDOW) Loading libs/WindowManager/Shell/tests/unittest/src/com/android/wm/shell/splitscreen/SplitScreenControllerTests.java +22 −0 Original line number Diff line number Diff line Loading @@ -296,6 +296,28 @@ public class SplitScreenControllerTests extends ShellTestCase { verify(mStageCoordinator).switchSplitPosition(anyString()); } @Test public void startIntent_forceLaunchNewTaskTrue_skipsBackgroundTasks() { Intent startIntent = createStartIntent("startActivity"); PendingIntent pendingIntent = PendingIntent.getActivity(mContext, 0, startIntent, FLAG_IMMUTABLE); mSplitScreenController.startIntent(pendingIntent, mContext.getUserId(), null, SPLIT_POSITION_TOP_OR_LEFT, null /* options */, null /* hideTaskToken */, true /* forceLaunchNewTask */); verify(mRecentTasks, never()).findTaskInBackground(any(), anyInt(), any()); } @Test public void startIntent_forceLaunchNewTaskFalse_checksBackgroundTasks() { Intent startIntent = createStartIntent("startActivity"); PendingIntent pendingIntent = PendingIntent.getActivity(mContext, 0, startIntent, FLAG_IMMUTABLE); mSplitScreenController.startIntent(pendingIntent, mContext.getUserId(), null, SPLIT_POSITION_TOP_OR_LEFT, null /* options */, null /* hideTaskToken */, false /* forceLaunchNewTask */); verify(mRecentTasks).findTaskInBackground(any(), anyInt(), any()); } @Test public void testSwitchSplitPosition_checksIsSplitScreenVisible() { final String reason = "test"; Loading Loading
libs/WindowManager/Shell/src/com/android/wm/shell/desktopmode/DesktopTasksController.kt +2 −1 Original line number Diff line number Diff line Loading @@ -1225,7 +1225,8 @@ class DesktopTasksController( .determineNewInstancePosition(callingTaskInfo) splitScreenController.startIntent( launchIntent, context.userId, fillIn, splitPosition, options.toBundle(), null /* hideTaskToken */ options.toBundle(), null /* hideTaskToken */, true /* forceLaunchNewTask */ ) } WINDOWING_MODE_FREEFORM -> { Loading
libs/WindowManager/Shell/src/com/android/wm/shell/splitscreen/SplitScreenController.java +15 −4 Original line number Diff line number Diff line Loading @@ -772,15 +772,25 @@ public class SplitScreenController implements SplitDragPolicy.Starter, instanceId); } @Override public void startIntent(PendingIntent intent, int userId1, @Nullable Intent fillInIntent, @SplitPosition int position, @Nullable Bundle options, @Nullable WindowContainerToken hideTaskToken) { startIntent(intent, userId1, fillInIntent, position, options, hideTaskToken, false /* forceLaunchNewTask */); } /** * Starts the given intent into split. * * @param hideTaskToken If non-null, a task matching this token will be moved to back in the * same window container transaction as the starting of the intent. * @param forceLaunchNewTask If true, this method will skip the check for a background task * matching the intent and launch a new task. */ @Override public void startIntent(PendingIntent intent, int userId1, @Nullable Intent fillInIntent, @SplitPosition int position, @Nullable Bundle options, @Nullable WindowContainerToken hideTaskToken) { @Nullable WindowContainerToken hideTaskToken, boolean forceLaunchNewTask) { ProtoLog.v(ShellProtoLogGroup.WM_SHELL_SPLIT_SCREEN, "startIntent(): intent=%s user=%d fillInIntent=%s position=%d", intent, userId1, fillInIntent, position); Loading @@ -798,7 +808,8 @@ public class SplitScreenController implements SplitDragPolicy.Starter, // To prevent accumulating large number of instances in the background, reuse task // in the background. If we don't explicitly reuse, new may be created even if the app // isn't multi-instance because WM won't automatically remove/reuse the previous instance final ActivityManager.RecentTaskInfo taskInfo = mRecentTasksOptional final ActivityManager.RecentTaskInfo taskInfo = forceLaunchNewTask ? null : mRecentTasksOptional .map(recentTasks -> recentTasks.findTaskInBackground(component, userId1, hideTaskToken)) .orElse(null); Loading
libs/WindowManager/Shell/tests/unittest/src/com/android/wm/shell/desktopmode/DesktopTasksControllerTest.kt +3 −2 Original line number Diff line number Diff line Loading @@ -2902,7 +2902,8 @@ class DesktopTasksControllerTest : ShellTestCase() { runOpenNewWindow(task) verify(splitScreenController) .startIntent(any(), anyInt(), any(), any(), optionsCaptor.capture(), anyOrNull()) optionsCaptor.capture(), anyOrNull(), eq(true) ) assertThat(ActivityOptions.fromBundle(optionsCaptor.value).launchWindowingMode) .isEqualTo(WINDOWING_MODE_MULTI_WINDOW) } Loading @@ -2917,7 +2918,7 @@ class DesktopTasksControllerTest : ShellTestCase() { verify(splitScreenController) .startIntent( any(), anyInt(), any(), any(), optionsCaptor.capture(), anyOrNull() optionsCaptor.capture(), anyOrNull(), eq(true) ) assertThat(ActivityOptions.fromBundle(optionsCaptor.value).launchWindowingMode) .isEqualTo(WINDOWING_MODE_MULTI_WINDOW) Loading
libs/WindowManager/Shell/tests/unittest/src/com/android/wm/shell/splitscreen/SplitScreenControllerTests.java +22 −0 Original line number Diff line number Diff line Loading @@ -296,6 +296,28 @@ public class SplitScreenControllerTests extends ShellTestCase { verify(mStageCoordinator).switchSplitPosition(anyString()); } @Test public void startIntent_forceLaunchNewTaskTrue_skipsBackgroundTasks() { Intent startIntent = createStartIntent("startActivity"); PendingIntent pendingIntent = PendingIntent.getActivity(mContext, 0, startIntent, FLAG_IMMUTABLE); mSplitScreenController.startIntent(pendingIntent, mContext.getUserId(), null, SPLIT_POSITION_TOP_OR_LEFT, null /* options */, null /* hideTaskToken */, true /* forceLaunchNewTask */); verify(mRecentTasks, never()).findTaskInBackground(any(), anyInt(), any()); } @Test public void startIntent_forceLaunchNewTaskFalse_checksBackgroundTasks() { Intent startIntent = createStartIntent("startActivity"); PendingIntent pendingIntent = PendingIntent.getActivity(mContext, 0, startIntent, FLAG_IMMUTABLE); mSplitScreenController.startIntent(pendingIntent, mContext.getUserId(), null, SPLIT_POSITION_TOP_OR_LEFT, null /* options */, null /* hideTaskToken */, false /* forceLaunchNewTask */); verify(mRecentTasks).findTaskInBackground(any(), anyInt(), any()); } @Test public void testSwitchSplitPosition_checksIsSplitScreenVisible() { final String reason = "test"; Loading