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

Commit ecb82d9f authored by TreeHugger Robot's avatar TreeHugger Robot Committed by Android (Google) Code Review
Browse files

Merge "Pass in window layout when setting initial state."

parents 6c47c99a 706dbcbb
Loading
Loading
Loading
Loading
+2 −2
Original line number Diff line number Diff line
@@ -1606,8 +1606,8 @@ class ActivityStarter {

        mLaunchParams.reset();

        mSupervisor.getLaunchParamsController().calculate(inTask, null /*layout*/, r, sourceRecord,
                options, mLaunchParams);
        mSupervisor.getLaunchParamsController().calculate(inTask, r.info.windowLayout, r,
                sourceRecord, options, mLaunchParams);

        if (mLaunchParams.hasPreferredDisplay()) {
            mPreferredDisplayId = mLaunchParams.mPreferredDisplayId;
+12 −8
Original line number Diff line number Diff line
@@ -131,16 +131,16 @@ class TaskLaunchParamsModifier implements LaunchParamsModifier {
        }
        // STEP 2: Resolve launch windowing mode.
        // STEP 2.1: Determine if any parameter has specified initial bounds. That might be the
        // launch bounds from activity options, or size/gravity passed in layout. It also treat the
        // launch bounds from activity options, or size/gravity passed in layout. It also treats the
        // launch windowing mode in options as a suggestion for future resolution.
        int launchMode = options != null ? options.getLaunchWindowingMode()
                : WINDOWING_MODE_UNDEFINED;
        // hasInitialBounds is set if either activity options or layout has specified bounds. If
        // that's set we'll skip some adjustments later to avoid overriding the initial bounds.
        boolean hasInitialBounds = false;
        final boolean canApplyFreeformPolicy =
                canApplyFreeformWindowPolicy(display, root, launchMode);
        if (mSupervisor.canUseActivityOptionsLaunchBounds(options) && canApplyFreeformPolicy) {
        final boolean canApplyFreeformPolicy = canApplyFreeformWindowPolicy(display, launchMode);
        if (mSupervisor.canUseActivityOptionsLaunchBounds(options)
                && (canApplyFreeformPolicy || canApplyPipWindowPolicy(launchMode))) {
            hasInitialBounds = true;
            launchMode = launchMode == WINDOWING_MODE_UNDEFINED
                    ? WINDOWING_MODE_FREEFORM
@@ -279,10 +279,14 @@ class TaskLaunchParamsModifier implements LaunchParamsModifier {
        return displayId;
    }

    private boolean canApplyFreeformWindowPolicy(@NonNull ActivityDisplay display,
            @NonNull ActivityRecord root, int launchMode) {
        return display.inFreeformWindowingMode() || launchMode == WINDOWING_MODE_FREEFORM
                || root.isResizeable();
    private boolean canApplyFreeformWindowPolicy(@NonNull ActivityDisplay display, int launchMode) {
        return mSupervisor.mService.mSupportsFreeformWindowManagement
                && (display.inFreeformWindowingMode() || launchMode == WINDOWING_MODE_FREEFORM);
    }

    private boolean canApplyPipWindowPolicy(int launchMode) {
        return mSupervisor.mService.mSupportsPictureInPicture
                && launchMode == WINDOWING_MODE_PINNED;
    }

    private void getLayoutBounds(@NonNull ActivityDisplay display, @NonNull ActivityRecord root,
+3 −2
Original line number Diff line number Diff line
@@ -411,8 +411,9 @@ public class ActivityStarterTests extends ActivityTestsBase {
                .setActivityOptions(new SafeActivityOptions(options))
                .execute();

        // verify that values are passed to the modifier.
        verify(modifier, times(1)).onCalculate(any(), eq(windowLayout), any(), any(), eq(options),
        // verify that values are passed to the modifier. Values are passed twice -- once for
        // setting initial state, another when task is created.
        verify(modifier, times(2)).onCalculate(any(), eq(windowLayout), any(), any(), eq(options),
                any(), any());
    }

+3 −18
Original line number Diff line number Diff line
@@ -189,7 +189,7 @@ public class TaskLaunchParamsModifierTests extends ActivityTestsBase {
        assertEquals(RESULT_CONTINUE, mTarget.onCalculate(/* task */ null, /* layout */ null,
                mActivity, /* source */ null, options, mCurrent, mResult));

        assertEquivalentWindowingMode(WINDOWING_MODE_FREEFORM, mResult.mWindowingMode,
        assertEquivalentWindowingMode(WINDOWING_MODE_FULLSCREEN, mResult.mWindowingMode,
                WINDOWING_MODE_FULLSCREEN);
    }

@@ -277,7 +277,7 @@ public class TaskLaunchParamsModifierTests extends ActivityTestsBase {
    }

    @Test
    public void testNonEmptyLayoutInfersFreeformWithResizeableActivity() {
    public void testNonEmptyLayoutUsesFullscreenWithResizeableActivity() {
        final ActivityInfo.WindowLayout layout = new WindowLayoutBuilder()
                .setWidth(120).setHeight(80).build();

@@ -286,7 +286,7 @@ public class TaskLaunchParamsModifierTests extends ActivityTestsBase {
        assertEquals(RESULT_CONTINUE, mTarget.onCalculate(/* task */ null, layout, mActivity,
                /* source */ null, /* options */ null, mCurrent, mResult));

        assertEquivalentWindowingMode(WINDOWING_MODE_FREEFORM, mResult.mWindowingMode,
        assertEquivalentWindowingMode(WINDOWING_MODE_FULLSCREEN, mResult.mWindowingMode,
                WINDOWING_MODE_FULLSCREEN);
    }

@@ -712,21 +712,6 @@ public class TaskLaunchParamsModifierTests extends ActivityTestsBase {
        assertEquals(new Rect(900, 486, 1020, 594), mResult.mBounds);
    }

    @Test
    public void testNonEmptyLayoutBoundsWithResizeableActivity() {
        final ActivityDisplay display = mSupervisor.getActivityDisplay(DEFAULT_DISPLAY);
        display.setBounds(new Rect(0, 0, 1920, 1080));
        final ActivityInfo.WindowLayout layout = new WindowLayoutBuilder()
                .setWidth(120).setHeight(80).build();

        mCurrent.mPreferredDisplayId = DEFAULT_DISPLAY;

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

        assertEquals(new Rect(900, 500, 1020, 580), mResult.mBounds);
    }

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