Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit cb95d68c authored by Eghosa Ewansiha-Vlachavas's avatar Eghosa Ewansiha-Vlachavas
Browse files

Set launch param window mode to freeform for task trampolines in desktop

Trampoline launches do not always get handled by Shell and thus can have
the wrong window mode when in desktop. To prevent this, apply freeform
window mode to task trampolines if we are in or entering desktop mode.

Flag: com.android.window.flags.disable_desktop_launch_params_outside_desktop_bug_fix
Test: atest WmTests:DesktopModeLaunchParamsModifierTests
Fixes: 371220641
Fixes: 400983021
Change-Id: I3d8203754ea79c5ab54c529ed4f2aa9f9b31e991
parent 166bb0dc
Loading
Loading
Loading
Loading
+20 −6
Original line number Diff line number Diff line
@@ -107,15 +107,24 @@ 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();
            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) {
            return RESULT_CONTINUE;
@@ -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;
        }
+18 −0
Original line number Diff line number Diff line
@@ -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;