Loading services/core/java/com/android/server/am/TaskLaunchParamsModifier.java +10 −3 Original line number Diff line number Diff line Loading @@ -135,7 +135,7 @@ class TaskLaunchParamsModifier implements LaunchParamsModifier { } // STEP 1: Determine the display to launch the activity/task. final int displayId = getPreferredLaunchDisplay(options, source, currentParams); final int displayId = getPreferredLaunchDisplay(task, options, source, currentParams); outParams.mPreferredDisplayId = displayId; ActivityDisplay display = mSupervisor.getActivityDisplay(displayId); if (DEBUG) { Loading Loading @@ -268,8 +268,8 @@ class TaskLaunchParamsModifier implements LaunchParamsModifier { return RESULT_CONTINUE; } private int getPreferredLaunchDisplay(@Nullable ActivityOptions options, ActivityRecord source, LaunchParams currentParams) { private int getPreferredLaunchDisplay(@Nullable TaskRecord task, @Nullable ActivityOptions options, ActivityRecord source, LaunchParams currentParams) { int displayId = INVALID_DISPLAY; final int optionLaunchId = options != null ? options.getLaunchDisplayId() : INVALID_DISPLAY; if (optionLaunchId != INVALID_DISPLAY) { Loading @@ -283,6 +283,13 @@ class TaskLaunchParamsModifier implements LaunchParamsModifier { displayId = sourceDisplayId; } ActivityStack stack = (displayId == INVALID_DISPLAY && task != null) ? task.getStack() : null; if (stack != null) { if (DEBUG) appendLog("display-from-task=" + stack.mDisplayId); displayId = stack.mDisplayId; } if (displayId != INVALID_DISPLAY && mSupervisor.getActivityDisplay(displayId) == null) { displayId = INVALID_DISPLAY; } Loading services/tests/servicestests/src/com/android/server/am/TaskLaunchParamsModifierTests.java +12 −0 Original line number Diff line number Diff line Loading @@ -167,6 +167,18 @@ public class TaskLaunchParamsModifierTests extends ActivityTestsBase { assertEquals(fullscreenDisplay.mDisplayId, mResult.mPreferredDisplayId); } @Test public void testUsesTaskDisplayIdIfSet() { final TestActivityDisplay freeformDisplay = createNewActivityDisplay( WINDOWING_MODE_FREEFORM); ActivityRecord source = createSourceActivity(freeformDisplay); assertEquals(RESULT_CONTINUE, mTarget.onCalculate(source.getTask(), null /* layout */, null /* activity */, null /* source */, null /* options */, mCurrent, mResult)); assertEquals(freeformDisplay.mDisplayId, mResult.mPreferredDisplayId); } // ===================================== // Launch Windowing Mode Related Tests // ===================================== Loading Loading
services/core/java/com/android/server/am/TaskLaunchParamsModifier.java +10 −3 Original line number Diff line number Diff line Loading @@ -135,7 +135,7 @@ class TaskLaunchParamsModifier implements LaunchParamsModifier { } // STEP 1: Determine the display to launch the activity/task. final int displayId = getPreferredLaunchDisplay(options, source, currentParams); final int displayId = getPreferredLaunchDisplay(task, options, source, currentParams); outParams.mPreferredDisplayId = displayId; ActivityDisplay display = mSupervisor.getActivityDisplay(displayId); if (DEBUG) { Loading Loading @@ -268,8 +268,8 @@ class TaskLaunchParamsModifier implements LaunchParamsModifier { return RESULT_CONTINUE; } private int getPreferredLaunchDisplay(@Nullable ActivityOptions options, ActivityRecord source, LaunchParams currentParams) { private int getPreferredLaunchDisplay(@Nullable TaskRecord task, @Nullable ActivityOptions options, ActivityRecord source, LaunchParams currentParams) { int displayId = INVALID_DISPLAY; final int optionLaunchId = options != null ? options.getLaunchDisplayId() : INVALID_DISPLAY; if (optionLaunchId != INVALID_DISPLAY) { Loading @@ -283,6 +283,13 @@ class TaskLaunchParamsModifier implements LaunchParamsModifier { displayId = sourceDisplayId; } ActivityStack stack = (displayId == INVALID_DISPLAY && task != null) ? task.getStack() : null; if (stack != null) { if (DEBUG) appendLog("display-from-task=" + stack.mDisplayId); displayId = stack.mDisplayId; } if (displayId != INVALID_DISPLAY && mSupervisor.getActivityDisplay(displayId) == null) { displayId = INVALID_DISPLAY; } Loading
services/tests/servicestests/src/com/android/server/am/TaskLaunchParamsModifierTests.java +12 −0 Original line number Diff line number Diff line Loading @@ -167,6 +167,18 @@ public class TaskLaunchParamsModifierTests extends ActivityTestsBase { assertEquals(fullscreenDisplay.mDisplayId, mResult.mPreferredDisplayId); } @Test public void testUsesTaskDisplayIdIfSet() { final TestActivityDisplay freeformDisplay = createNewActivityDisplay( WINDOWING_MODE_FREEFORM); ActivityRecord source = createSourceActivity(freeformDisplay); assertEquals(RESULT_CONTINUE, mTarget.onCalculate(source.getTask(), null /* layout */, null /* activity */, null /* source */, null /* options */, mCurrent, mResult)); assertEquals(freeformDisplay.mDisplayId, mResult.mPreferredDisplayId); } // ===================================== // Launch Windowing Mode Related Tests // ===================================== Loading