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

Commit 96eea547 authored by Chris Li's avatar Chris Li Committed by Automerger Merge Worker
Browse files

Merge "Update TaskLaunchParamsModifier.java to use DA instead DC" into sc-dev am: b53e07bc

Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/13433950

MUST ONLY BE SUBMITTED BY AUTOMERGER

Change-Id: I0761efc4385b3803d335cd09c5aebc3b7cda45bc
parents 4b7ca0cf b53e07bc
Loading
Loading
Loading
Loading
+15 −0
Original line number Diff line number Diff line
@@ -495,6 +495,21 @@ public class DisplayArea<T extends WindowContainer> extends WindowContainer<T> {
        return info;
    }

    /**
     * Gets the stable bounds of the DisplayArea, which is the bounds excluding insets for
     * navigation bar, cutout, and status bar.
     */
    void getStableRect(Rect out) {
        if (mDisplayContent == null) {
            getBounds(out);
            return;
        }

        // Intersect with the display stable bounds to get the DisplayArea stable bounds.
        mDisplayContent.getStableRect(out);
        out.intersect(getBounds());
    }

    @Override
    public boolean providesMaxBounds() {
        return true;
+1 −0
Original line number Diff line number Diff line
@@ -2677,6 +2677,7 @@ class DisplayContent extends RootDisplayArea implements WindowManagerPolicy.Disp
        mWmService.mDisplayWindowSettings.setForcedSize(this, width, height);
    }

    @Override
    void getStableRect(Rect out) {
        final InsetsState state = mDisplayContent.getInsetsStateController().getRawInsetsState();
        out.set(state.getDisplayFrame());
+119 −97

File changed.

Preview size limit exceeded, changes collapsed.

+71 −5
Original line number Diff line number Diff line
@@ -473,6 +473,68 @@ public class TaskLaunchParamsModifierTests extends WindowTestsBase {
                mDefaultDisplay.getDefaultTaskDisplayArea(), mResult.mPreferredTaskDisplayArea);
    }

    @Test
    public void testRecalculateFreeformInitialBoundsWithOverrideDisplayArea() {
        final TestDisplayContent freeformDisplay = createNewDisplayContent(
                WINDOWING_MODE_FREEFORM);
        final TaskDisplayArea secondaryDisplayArea = createTaskDisplayArea(freeformDisplay,
                mWm, "SecondaryDisplayArea", FEATURE_RUNTIME_TASK_CONTAINER_FIRST);
        secondaryDisplayArea.setBounds(DISPLAY_BOUNDS.width() / 2, 0,
                        DISPLAY_BOUNDS.width(), DISPLAY_BOUNDS.height());
        final Task launchRoot = createTaskStackOnTaskDisplayArea(WINDOWING_MODE_FULLSCREEN,
                ACTIVITY_TYPE_STANDARD, secondaryDisplayArea);
        launchRoot.mCreatedByOrganizer = true;
        secondaryDisplayArea.setLaunchRootTask(launchRoot, new int[] { WINDOWING_MODE_FREEFORM },
                new int[] { ACTIVITY_TYPE_STANDARD });
        final Rect secondaryDAStableBounds = new Rect();
        secondaryDisplayArea.getStableRect(secondaryDAStableBounds);

        // Specify the display and provide a layout so that it will be set to freeform bounds.
        final ActivityOptions options = ActivityOptions.makeBasic()
                .setLaunchDisplayId(freeformDisplay.getDisplayId());
        final ActivityInfo.WindowLayout layout = new WindowLayoutBuilder()
                .setGravity(Gravity.LEFT).build();

        assertEquals(RESULT_CONTINUE,
                new CalculateRequestBuilder().setOptions(options).setLayout(layout).calculate());

        assertEquals(secondaryDisplayArea, mResult.mPreferredTaskDisplayArea);
        assertTrue(secondaryDAStableBounds.contains(mResult.mBounds));
    }

    @Test
    public void testRecalculateFreeformInitialBoundsWithOverrideDisplayArea_unresizableApp() {
        mAtm.mSupportsNonResizableMultiWindow = true;

        final TestDisplayContent freeformDisplay = createNewDisplayContent(
                WINDOWING_MODE_FREEFORM);
        final TaskDisplayArea secondaryDisplayArea = createTaskDisplayArea(freeformDisplay,
                mWm, "SecondaryDisplayArea", FEATURE_RUNTIME_TASK_CONTAINER_FIRST);
        secondaryDisplayArea.setBounds(DISPLAY_BOUNDS.width() / 2, 0,
                DISPLAY_BOUNDS.width(), DISPLAY_BOUNDS.height());
        final Task launchRoot = createTaskStackOnTaskDisplayArea(WINDOWING_MODE_FULLSCREEN,
                ACTIVITY_TYPE_STANDARD, secondaryDisplayArea);
        launchRoot.mCreatedByOrganizer = true;
        secondaryDisplayArea.setLaunchRootTask(launchRoot, new int[] { WINDOWING_MODE_FREEFORM },
                new int[] { ACTIVITY_TYPE_STANDARD });
        final Rect secondaryDAStableBounds = new Rect();
        secondaryDisplayArea.getStableRect(secondaryDAStableBounds);

        // The bounds will get updated for unresizable with opposite orientation on freeform display
        final Rect displayBounds = new Rect(freeformDisplay.getBounds());
        mActivity.info.resizeMode = RESIZE_MODE_UNRESIZEABLE;
        mActivity.info.screenOrientation = displayBounds.width() > displayBounds.height()
                ? SCREEN_ORIENTATION_PORTRAIT : SCREEN_ORIENTATION_LANDSCAPE;
        final ActivityOptions options = ActivityOptions.makeBasic()
                .setLaunchDisplayId(freeformDisplay.getDisplayId());

        assertEquals(RESULT_CONTINUE,
                new CalculateRequestBuilder().setOptions(options).calculate());

        assertEquals(secondaryDisplayArea, mResult.mPreferredTaskDisplayArea);
        assertTrue(secondaryDAStableBounds.contains(mResult.mBounds));
    }

    // =====================================
    // Launch Windowing Mode Related Tests
    // =====================================
@@ -1365,8 +1427,8 @@ public class TaskLaunchParamsModifierTests extends WindowTestsBase {
        // This test case requires a relatively big app bounds to ensure the default size calculated
        // by letterbox won't be too small to hold the minimum width/height.
        configInsetsState(
                freeformDisplay.getInsetsStateController().getRawInsetsState(),
                DISPLAY_BOUNDS, new Rect(10, 10, 1910, 1070));
                freeformDisplay.getInsetsStateController().getRawInsetsState(), freeformDisplay,
                new Rect(10, 10, 1910, 1070));

        final ActivityOptions options = ActivityOptions.makeBasic();
        options.setLaunchDisplayId(freeformDisplay.mDisplayId);
@@ -1587,15 +1649,17 @@ public class TaskLaunchParamsModifierTests extends WindowTestsBase {
        display.setBounds(DISPLAY_BOUNDS);
        display.getConfiguration().densityDpi = DENSITY_DEFAULT;
        display.getConfiguration().orientation = ORIENTATION_LANDSCAPE;
        configInsetsState(display.getInsetsStateController().getRawInsetsState(),
                DISPLAY_BOUNDS, DISPLAY_STABLE_BOUNDS);
        configInsetsState(display.getInsetsStateController().getRawInsetsState(), display,
                DISPLAY_STABLE_BOUNDS);
        return display;
    }

    /**
     * Creates insets sources so that we can get the expected stable frame.
     */
    private static void configInsetsState(InsetsState state, Rect displayFrame, Rect stableFrame) {
    private static void configInsetsState(InsetsState state, DisplayContent display,
            Rect stableFrame) {
        final Rect displayFrame = display.getBounds();
        final int dl = displayFrame.left;
        final int dt = displayFrame.top;
        final int dr = displayFrame.right;
@@ -1618,6 +1682,8 @@ public class TaskLaunchParamsModifierTests extends WindowTestsBase {
        if (sb < db) {
            state.getSource(ITYPE_NAVIGATION_BAR).setFrame(dl, sb, dr, db);
        }
        // Recompute config and push to children.
        display.onRequestedOverrideConfigurationChanged(display.getConfiguration());
    }

    private ActivityRecord createSourceActivity(TestDisplayContent display) {