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

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

Don't update flexible option bounds if fullscreen override applied

Currently if option bounds are marked as flexible, the desired size of
an application is recalculated and the option bounds size is updated.
However, if the fullscreen override is applied, there is no need to
recalculate the desired size or the cascaded position so we can simply
just inherit the existing option bounds:

Flag: com.android.window.flags.enable_shell_initial_bounds_regression_bug_fix
Fixes: 400851216
Test: atest WmTests:DesktopModeLaunchParamsModifierTests
Change-Id: I03d83d14f8727050b9dfa10773498ddc7211838e
parent 55d8b4bf
Loading
Loading
Loading
Loading
+5 −2
Original line number Diff line number Diff line
@@ -70,9 +70,12 @@ public final class DesktopModeBoundsCalculator {
        final Rect stableBounds = new Rect();
        task.getDisplayArea().getStableRect(stableBounds);

        // If the options bounds size is flexible, update size with calculated desired size.
        final boolean hasFullscreenOverride = activity != null
                && activity.mAppCompatController.getAspectRatioOverrides().hasFullscreenOverride();
        // If the options bounds size is flexible and no fullscreen override has been applied,
        // update size with calculated desired size.
        final boolean updateOptionBoundsSize = options != null
                && options.getFlexibleLaunchSize();
                && options.getFlexibleLaunchSize() && !hasFullscreenOverride;
        // If cascading is also enabled, the position of the options bounds must be respected
        // during the size update.
        final boolean shouldRespectOptionPosition =
+28 −2
Original line number Diff line number Diff line
@@ -382,7 +382,7 @@ public class DesktopModeLaunchParamsModifierTests extends
        spyOn(mActivity.mAppCompatController.getAspectRatioOverrides());
        doReturn(true).when(
                        mActivity.mAppCompatController.getAspectRatioOverrides())
                .isUserFullscreenOverrideEnabled();
                .hasFullscreenOverride();

        final int desiredWidth =
                (int) (LANDSCAPE_DISPLAY_BOUNDS.width() * DESKTOP_MODE_INITIAL_BOUNDS_SCALE);
@@ -410,7 +410,7 @@ public class DesktopModeLaunchParamsModifierTests extends
        spyOn(mActivity.mAppCompatController.getAspectRatioOverrides());
        doReturn(true).when(
                        mActivity.mAppCompatController.getAspectRatioOverrides())
                .isSystemOverrideToFullscreenEnabled();
                .hasFullscreenOverride();

        final int desiredWidth =
                (int) (LANDSCAPE_DISPLAY_BOUNDS.width() * DESKTOP_MODE_INITIAL_BOUNDS_SCALE);
@@ -1157,6 +1157,32 @@ public class DesktopModeLaunchParamsModifierTests extends
        assertEquals(WINDOWING_MODE_FREEFORM, mResult.mWindowingMode);
    }

    @Test
    @EnableFlags({Flags.FLAG_ENABLE_DESKTOP_WINDOWING_MODE,
            Flags.FLAG_ENABLE_SHELL_INITIAL_BOUNDS_REGRESSION_BUG_FIX})
    public void testOptionsBoundsSet_flexibleLaunchSizeWithFullscreenOverride_noModifications() {
        setupDesktopModeLaunchParamsModifier();

        final TestDisplayContent display = createNewDisplayContent(WINDOWING_MODE_FULLSCREEN);
        final Task task = new TaskBuilder(mSupervisor).setActivityType(
                ACTIVITY_TYPE_STANDARD).setDisplay(display).build();
        final ActivityOptions options = ActivityOptions.makeBasic()
                .setLaunchBounds(new Rect(
                        DISPLAY_STABLE_BOUNDS.left,
                        DISPLAY_STABLE_BOUNDS.top,
                        /* right = */ 500,
                        /* bottom = */ 500))
                .setFlexibleLaunchSize(true);
        spyOn(mActivity.mAppCompatController.getAspectRatioOverrides());
        doReturn(true).when(
                        mActivity.mAppCompatController.getAspectRatioOverrides())
                .hasFullscreenOverride();

        assertEquals(RESULT_DONE,
                new CalculateRequestBuilder().setTask(task).setOptions(options).calculate());
        assertEquals(options.getLaunchBounds(), mResult.mBounds);
    }

    @Test
    @EnableFlags({Flags.FLAG_ENABLE_DESKTOP_WINDOWING_MODE,
            Flags.FLAG_ENABLE_SHELL_INITIAL_BOUNDS_REGRESSION_BUG_FIX})