Loading services/core/java/com/android/server/wm/TaskLaunchParamsModifier.java +20 −2 Original line number Diff line number Diff line Loading @@ -153,7 +153,7 @@ class TaskLaunchParamsModifier implements LaunchParamsModifier { // source is a freeform window in a fullscreen display launching an activity on the same // display. if (launchMode == WINDOWING_MODE_UNDEFINED && canInheritWindowingModeFromSource(display, suggestedDisplayArea, source)) { && canInheritWindowingModeFromSource(display, suggestedDisplayArea, source, task)) { // The source's windowing mode may be different from its task, e.g. activity is set // to fullscreen and its task is pinned windowing mode when the activity is entering // pip. Loading Loading @@ -411,8 +411,18 @@ class TaskLaunchParamsModifier implements LaunchParamsModifier { && launchMode != task.getRequestedOverrideWindowingMode(); } /** * Determines whether a task can inherit the windowing mode from its source activity. * * @param display the display where the task will be launched. * @param suggestedDisplayArea the suggested display area for the task. * @param source the source activity that initiated the launch, or null if none. * @param targetTask the task being launched, or null if creating a new task. * @return true if the target task can inherit the source's windowing mode, false otherwise. */ private boolean canInheritWindowingModeFromSource(@NonNull DisplayContent display, TaskDisplayArea suggestedDisplayArea, @Nullable ActivityRecord source) { TaskDisplayArea suggestedDisplayArea, @Nullable ActivityRecord source, @Nullable Task targetTask) { if (source == null) { return false; } Loading @@ -424,12 +434,20 @@ class TaskLaunchParamsModifier implements LaunchParamsModifier { return false; } // Only fullscreen and freeform sources are allowed to inherit their windowing mode. final int sourceWindowingMode = source.getTask().getWindowingMode(); if (sourceWindowingMode != WINDOWING_MODE_FULLSCREEN && sourceWindowingMode != WINDOWING_MODE_FREEFORM) { return false; } // Bubble task can only inherit from the fullscreen source task. // TODO(b/407669465): Replace mLaunchNextToBubble with property check in root task approach. if (sourceWindowingMode == WINDOWING_MODE_FREEFORM && targetTask != null && targetTask.mLaunchNextToBubble) { return false; } // Only inherit windowing mode if both source and target activities are on the same display. // Otherwise we may have unintended freeform windows showing up if an activity in freeform // window launches an activity on a fullscreen display by specifying display ID. Loading services/tests/wmtests/src/com/android/server/wm/TaskLaunchParamsModifierTests.java +21 −0 Original line number Diff line number Diff line Loading @@ -681,6 +681,27 @@ public class TaskLaunchParamsModifierTests extends WINDOWING_MODE_FULLSCREEN); } @Test public void testBubbleTaskDoesNotInheritFreeformModeFromSource() { final TestDisplayContent fullscreenDisplay = createNewDisplayContent( WINDOWING_MODE_FULLSCREEN); // Source activity is in a freeform trampoline task. final ActivityRecord source = createSourceActivity(fullscreenDisplay); source.getTask().setWindowingMode(WINDOWING_MODE_FREEFORM); // The task to be launched is a bubble task final Task bubbleTask = new TaskBuilder(mSupervisor) .setTaskDisplayArea(fullscreenDisplay.getDefaultTaskDisplayArea()) .setWindowingMode(WINDOWING_MODE_MULTI_WINDOW) .build(); bubbleTask.mLaunchNextToBubble = true; assertEquals(RESULT_CONTINUE, new CalculateRequestBuilder().setSource(source).setTask(bubbleTask).calculate()); assertEquivalentWindowingMode(WINDOWING_MODE_MULTI_WINDOW, mResult.mWindowingMode, WINDOWING_MODE_FULLSCREEN /* parentWindowingMode */); } @Test public void testInheritsSourceTaskWindowingModeWhenActivityIsInDifferentWindowingMode() { final TestDisplayContent fullscreenDisplay = createNewDisplayContent( Loading Loading
services/core/java/com/android/server/wm/TaskLaunchParamsModifier.java +20 −2 Original line number Diff line number Diff line Loading @@ -153,7 +153,7 @@ class TaskLaunchParamsModifier implements LaunchParamsModifier { // source is a freeform window in a fullscreen display launching an activity on the same // display. if (launchMode == WINDOWING_MODE_UNDEFINED && canInheritWindowingModeFromSource(display, suggestedDisplayArea, source)) { && canInheritWindowingModeFromSource(display, suggestedDisplayArea, source, task)) { // The source's windowing mode may be different from its task, e.g. activity is set // to fullscreen and its task is pinned windowing mode when the activity is entering // pip. Loading Loading @@ -411,8 +411,18 @@ class TaskLaunchParamsModifier implements LaunchParamsModifier { && launchMode != task.getRequestedOverrideWindowingMode(); } /** * Determines whether a task can inherit the windowing mode from its source activity. * * @param display the display where the task will be launched. * @param suggestedDisplayArea the suggested display area for the task. * @param source the source activity that initiated the launch, or null if none. * @param targetTask the task being launched, or null if creating a new task. * @return true if the target task can inherit the source's windowing mode, false otherwise. */ private boolean canInheritWindowingModeFromSource(@NonNull DisplayContent display, TaskDisplayArea suggestedDisplayArea, @Nullable ActivityRecord source) { TaskDisplayArea suggestedDisplayArea, @Nullable ActivityRecord source, @Nullable Task targetTask) { if (source == null) { return false; } Loading @@ -424,12 +434,20 @@ class TaskLaunchParamsModifier implements LaunchParamsModifier { return false; } // Only fullscreen and freeform sources are allowed to inherit their windowing mode. final int sourceWindowingMode = source.getTask().getWindowingMode(); if (sourceWindowingMode != WINDOWING_MODE_FULLSCREEN && sourceWindowingMode != WINDOWING_MODE_FREEFORM) { return false; } // Bubble task can only inherit from the fullscreen source task. // TODO(b/407669465): Replace mLaunchNextToBubble with property check in root task approach. if (sourceWindowingMode == WINDOWING_MODE_FREEFORM && targetTask != null && targetTask.mLaunchNextToBubble) { return false; } // Only inherit windowing mode if both source and target activities are on the same display. // Otherwise we may have unintended freeform windows showing up if an activity in freeform // window launches an activity on a fullscreen display by specifying display ID. Loading
services/tests/wmtests/src/com/android/server/wm/TaskLaunchParamsModifierTests.java +21 −0 Original line number Diff line number Diff line Loading @@ -681,6 +681,27 @@ public class TaskLaunchParamsModifierTests extends WINDOWING_MODE_FULLSCREEN); } @Test public void testBubbleTaskDoesNotInheritFreeformModeFromSource() { final TestDisplayContent fullscreenDisplay = createNewDisplayContent( WINDOWING_MODE_FULLSCREEN); // Source activity is in a freeform trampoline task. final ActivityRecord source = createSourceActivity(fullscreenDisplay); source.getTask().setWindowingMode(WINDOWING_MODE_FREEFORM); // The task to be launched is a bubble task final Task bubbleTask = new TaskBuilder(mSupervisor) .setTaskDisplayArea(fullscreenDisplay.getDefaultTaskDisplayArea()) .setWindowingMode(WINDOWING_MODE_MULTI_WINDOW) .build(); bubbleTask.mLaunchNextToBubble = true; assertEquals(RESULT_CONTINUE, new CalculateRequestBuilder().setSource(source).setTask(bubbleTask).calculate()); assertEquivalentWindowingMode(WINDOWING_MODE_MULTI_WINDOW, mResult.mWindowingMode, WINDOWING_MODE_FULLSCREEN /* parentWindowingMode */); } @Test public void testInheritsSourceTaskWindowingModeWhenActivityIsInDifferentWindowingMode() { final TestDisplayContent fullscreenDisplay = createNewDisplayContent( Loading