summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--services/core/java/com/android/server/wm/DesktopModeLaunchParamsModifier.java26
-rw-r--r--services/tests/wmtests/src/com/android/server/wm/DesktopModeLaunchParamsModifierTests.java18
2 files changed, 38 insertions, 6 deletions
diff --git a/services/core/java/com/android/server/wm/DesktopModeLaunchParamsModifier.java b/services/core/java/com/android/server/wm/DesktopModeLaunchParamsModifier.java
index d466a646c7dd..3520fc0cb957 100644
--- a/services/core/java/com/android/server/wm/DesktopModeLaunchParamsModifier.java
+++ b/services/core/java/com/android/server/wm/DesktopModeLaunchParamsModifier.java
@@ -107,14 +107,23 @@ class DesktopModeLaunchParamsModifier implements LaunchParamsModifier {
// Copy over any values
outParams.set(currentParams);
- // In Proto2, trampoline task launches of an existing background task can result in the
- // previous windowing mode to be restored even if the desktop mode state has changed.
- // Let task launches inherit the windowing mode from the source task if available, which
- // should have the desired windowing mode set by WM Shell. See b/286929122.
if (source != null && source.getTask() != null) {
final Task sourceTask = source.getTask();
- outParams.mWindowingMode = sourceTask.getWindowingMode();
- appendLog("inherit-from-source=" + outParams.mWindowingMode);
+ if (DesktopModeFlags.DISABLE_DESKTOP_LAUNCH_PARAMS_OUTSIDE_DESKTOP_BUG_FIX.isTrue()
+ && isEnteringDesktopMode(sourceTask, options, currentParams)) {
+ // If trampoline source is not freeform but we are entering or in desktop mode,
+ // ignore the source windowing mode and set the windowing mode to freeform
+ outParams.mWindowingMode = WINDOWING_MODE_FREEFORM;
+ appendLog("freeform window mode applied to task trampoline");
+ } else {
+ // In Proto2, trampoline task launches of an existing background task can result in
+ // the previous windowing mode to be restored even if the desktop mode state has
+ // changed. Let task launches inherit the windowing mode from the source task if
+ // available, which should have the desired windowing mode set by WM Shell.
+ // See b/286929122.
+ outParams.mWindowingMode = sourceTask.getWindowingMode();
+ appendLog("inherit-from-source=" + outParams.mWindowingMode);
+ }
}
if (phase == PHASE_WINDOWING_MODE) {
@@ -127,6 +136,11 @@ class DesktopModeLaunchParamsModifier implements LaunchParamsModifier {
}
if ((options == null || options.getLaunchBounds() == null) && task.hasOverrideBounds()) {
+ if (DesktopModeFlags.DISABLE_DESKTOP_LAUNCH_PARAMS_OUTSIDE_DESKTOP_BUG_FIX.isTrue()) {
+ // We are in desktop, return result done to prevent other modifiers from modifying
+ // exiting task bounds or resolved windowing mode.
+ return RESULT_DONE;
+ }
appendLog("current task has bounds set, not overriding");
return RESULT_SKIP;
}
diff --git a/services/tests/wmtests/src/com/android/server/wm/DesktopModeLaunchParamsModifierTests.java b/services/tests/wmtests/src/com/android/server/wm/DesktopModeLaunchParamsModifierTests.java
index bc37496d14a7..765719c5cfc7 100644
--- a/services/tests/wmtests/src/com/android/server/wm/DesktopModeLaunchParamsModifierTests.java
+++ b/services/tests/wmtests/src/com/android/server/wm/DesktopModeLaunchParamsModifierTests.java
@@ -1450,6 +1450,24 @@ public class DesktopModeLaunchParamsModifierTests extends
assertEquals(WINDOWING_MODE_FREEFORM, mResult.mWindowingMode);
}
+ @Test
+ @EnableFlags({Flags.FLAG_ENABLE_DESKTOP_WINDOWING_MODE,
+ Flags.FLAG_DISABLE_DESKTOP_LAUNCH_PARAMS_OUTSIDE_DESKTOP_BUG_FIX})
+ public void testFreeformWindowingModeAppliedIfSourceTaskExists() {
+ setupDesktopModeLaunchParamsModifier();
+
+ final Task task = new TaskBuilder(mSupervisor).setActivityType(
+ ACTIVITY_TYPE_STANDARD).build();
+ final Task sourceTask = new TaskBuilder(mSupervisor).setActivityType(
+ ACTIVITY_TYPE_STANDARD).setWindowingMode(WINDOWING_MODE_FULLSCREEN).build();
+ final ActivityRecord sourceActivity = new ActivityBuilder(task.mAtmService)
+ .setTask(sourceTask).build();
+
+ assertEquals(RESULT_CONTINUE, new CalculateRequestBuilder().setTask(task)
+ .setSource(sourceActivity).calculate());
+ assertEquals(WINDOWING_MODE_FREEFORM, mResult.mWindowingMode);
+ }
+
private Task createTask(DisplayContent display, Boolean isResizeable) {
final int resizeMode = isResizeable ? RESIZE_MODE_RESIZEABLE
: RESIZE_MODE_UNRESIZEABLE;