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

Commit d5972d10 authored by Garfield Tan's avatar Garfield Tan
Browse files

Set bounds from previous modifiers for fullscreen

Bounds in LaunchParams are still used to restore
TaskRecord#mLastNonFullscreenBounds if windowing mode is not freeform.
Therefore still pass it along if previous modifiers or
LaunchParamsController has that.

Fixes: 121166721
Test: Manual test and WmTests:TaskLaunchParamsModifierTests.
Change-Id: I7a554ff38478594a032bc0123beeffead7c152b4
parent 76e986a2
Loading
Loading
Loading
Loading
+9 −3
Original line number Diff line number Diff line
@@ -219,12 +219,18 @@ class TaskLaunchParamsModifier implements LaunchParamsModifier {
                }
            }

            if (launchMode == WINDOWING_MODE_FREEFORM && !currentParams.mBounds.isEmpty()) {
            if (!currentParams.mBounds.isEmpty()) {
                // Carry over bounds from callers regardless of launch mode because bounds is still
                // used to restore last non-fullscreen bounds when launch mode is not freeform.
                // Therefore it's not a resolution step for non-freeform launch mode and only
                // consider it fully resolved only when launch mode is freeform.
                outParams.mBounds.set(currentParams.mBounds);
                if (launchMode == WINDOWING_MODE_FREEFORM) {
                    fullyResolvedCurrentParam = true;
                    if (DEBUG) appendLog("inherit-bounds=" + outParams.mBounds);
                }
            }
        }

        // STEP 2.3: Adjust launch parameters as needed for freeform display. We enforce the policy
        // that legacy (pre-D) apps and those apps that can't handle multiple screen density well
+15 −0
Original line number Diff line number Diff line
@@ -767,6 +767,21 @@ public class TaskLaunchParamsModifierTests extends ActivityTestsBase {
        assertEquals(new Rect(0, 0, 200, 100), mResult.mBounds);
    }

    @Test
    public void testReturnBoundsForFullscreenWindowingMode() {
        final TestActivityDisplay freeformDisplay = createNewActivityDisplay(
                WINDOWING_MODE_FREEFORM);

        mCurrent.mPreferredDisplayId = freeformDisplay.mDisplayId;
        mCurrent.mWindowingMode = WINDOWING_MODE_FULLSCREEN;
        mCurrent.mBounds.set(0, 0, 200, 100);

        assertEquals(RESULT_CONTINUE, mTarget.onCalculate(/* task */ null, /* layout */ null,
                mActivity, /* source */ null, /* options */ null, mCurrent, mResult));

        assertEquals(new Rect(0, 0, 200, 100), mResult.mBounds);
    }

    @Test
    public void testUsesDisplayOrientationForNoSensorOrientation() {
        final TestActivityDisplay freeformDisplay = createNewActivityDisplay(