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

Commit 7f4d456d authored by Eghosa Ewansiha-Vlachavas's avatar Eghosa Ewansiha-Vlachavas Committed by Android (Google) Code Review
Browse files

Merge "Set launch param window mode to freeform for task trampolines in desktop" into main

parents 5255bfc7 cb95d68c
Loading
Loading
Loading
Loading
+20 −6
Original line number Diff line number Diff line
@@ -113,15 +113,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;
@@ -133,6 +142,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
@@ -1493,6 +1493,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;