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

Commit d071b252 authored by Riddle Hsu's avatar Riddle Hsu Committed by Android (Google) Code Review
Browse files

Merge "Resolve activity bounds with transformed display info" into rvc-dev

parents 502b81a8 9264a277
Loading
Loading
Loading
Loading
+7 −3
Original line number Diff line number Diff line
@@ -6190,7 +6190,9 @@ final class ActivityRecord extends WindowToken implements WindowManagerService.A
     *         density than its parent or its bounds don't fit in parent naturally.
     */
    boolean inSizeCompatMode() {
        if (mCompatDisplayInsets == null || !shouldUseSizeCompatMode()) {
        if (mCompatDisplayInsets == null || !shouldUseSizeCompatMode()
                // The orientation is different from parent when transforming.
                || isFixedRotationTransforming()) {
            return false;
        }
        final Rect appBounds = getConfiguration().windowConfiguration.getAppBounds();
@@ -6347,7 +6349,8 @@ final class ActivityRecord extends WindowToken implements WindowManagerService.A
            // can use the resolved configuration directly. Otherwise (e.g. fixed aspect ratio),
            // the rotated configuration is used as parent configuration to compute the actual
            // resolved configuration. It is like putting the activity in a rotated container.
            mTmpConfig.setTo(resolvedConfig);
            mTmpConfig.setTo(newParentConfiguration);
            mTmpConfig.updateFrom(resolvedConfig);
            newParentConfiguration = mTmpConfig;
        }
        if (mCompatDisplayInsets != null) {
@@ -6373,7 +6376,8 @@ final class ActivityRecord extends WindowToken implements WindowManagerService.A
                // Exclude the horizontal decor area because the activity will be centered
                // horizontally in parent's app bounds to balance the visual appearance.
                resolvedBounds.left = parentAppBounds.left;
                task.computeConfigResourceOverrides(resolvedConfig, newParentConfiguration);
                task.computeConfigResourceOverrides(resolvedConfig, newParentConfiguration,
                        getFixedRotationTransformDisplayInfo());
                final int offsetX = getHorizontalCenterOffset(
                        parentAppBounds.width(), resolvedBounds.width());
                if (offsetX > 0) {
+28 −5
Original line number Diff line number Diff line
@@ -2119,9 +2119,30 @@ class Task extends WindowContainer<WindowContainer> {
        intersectWithInsetsIfFits(outStableBounds, mTmpBounds, mTmpInsets);
    }

    void computeConfigResourceOverrides(@NonNull Configuration inOutConfig,
            @NonNull Configuration parentConfig, @Nullable DisplayInfo overrideDisplayInfo) {
        if (overrideDisplayInfo != null) {
            // Make sure the screen related configs can be computed by the provided display info.
            inOutConfig.windowConfiguration.setAppBounds(null);
            inOutConfig.screenLayout = Configuration.SCREENLAYOUT_UNDEFINED;
            inOutConfig.screenWidthDp = Configuration.SCREEN_WIDTH_DP_UNDEFINED;
            inOutConfig.screenHeightDp = Configuration.SCREEN_HEIGHT_DP_UNDEFINED;
        }
        computeConfigResourceOverrides(inOutConfig, parentConfig, overrideDisplayInfo,
                null /* compatInsets */);
    }

    void computeConfigResourceOverrides(@NonNull Configuration inOutConfig,
            @NonNull Configuration parentConfig) {
        computeConfigResourceOverrides(inOutConfig, parentConfig, null /* compatInsets */);
        computeConfigResourceOverrides(inOutConfig, parentConfig, null /* overrideDisplayInfo */,
                null /* compatInsets */);
    }

    void computeConfigResourceOverrides(@NonNull Configuration inOutConfig,
            @NonNull Configuration parentConfig,
            @Nullable ActivityRecord.CompatDisplayInsets compatInsets) {
        computeConfigResourceOverrides(inOutConfig, parentConfig, null /* overrideDisplayInfo */,
                compatInsets);
    }

    /**
@@ -2133,7 +2154,7 @@ class Task extends WindowContainer<WindowContainer> {
     * just be inherited from the parent configuration.
     **/
    void computeConfigResourceOverrides(@NonNull Configuration inOutConfig,
            @NonNull Configuration parentConfig,
            @NonNull Configuration parentConfig, @Nullable DisplayInfo overrideDisplayInfo,
            @Nullable ActivityRecord.CompatDisplayInsets compatInsets) {
        int windowingMode = inOutConfig.windowConfiguration.getWindowingMode();
        if (windowingMode == WINDOWING_MODE_UNDEFINED) {
@@ -2176,9 +2197,11 @@ class Task extends WindowContainer<WindowContainer> {
            if (insideParentBounds && WindowConfiguration.isFloating(windowingMode)) {
                mTmpNonDecorBounds.set(mTmpFullBounds);
                mTmpStableBounds.set(mTmpFullBounds);
            } else if (insideParentBounds && getDisplayContent() != null) {
                final DisplayInfo di = new DisplayInfo();
                getDisplayContent().mDisplay.getDisplayInfo(di);
            } else if (insideParentBounds
                    && (overrideDisplayInfo != null || getDisplayContent() != null)) {
                final DisplayInfo di = overrideDisplayInfo != null
                        ? overrideDisplayInfo
                        : getDisplayContent().getDisplayInfo();

                // For calculating screenWidthDp, screenWidthDp, we use the stable inset screen
                // area, i.e. the screen area without the system bars.
+23 −0
Original line number Diff line number Diff line
@@ -454,6 +454,29 @@ public class SizeCompatTests extends ActivityTestsBase {
        assertFalse(activity.shouldUseSizeCompatMode());
    }

    @Test
    public void testLaunchWithFixedRotationTransform() {
        mService.mWindowManager.mIsFixedRotationTransformEnabled = true;
        final int dw = 1000;
        final int dh = 2500;
        setUpDisplaySizeWithApp(dw, dh);
        mActivity.mDisplayContent.prepareAppTransition(WindowManager.TRANSIT_ACTIVITY_OPEN,
                false /* alwaysKeepCurrent */);
        mActivity.mDisplayContent.mOpeningApps.add(mActivity);
        final float maxAspect = 1.8f;
        prepareUnresizable(maxAspect, SCREEN_ORIENTATION_LANDSCAPE);

        assertFitted();
        assertTrue(mActivity.isFixedRotationTransforming());
        // Display keeps in original orientation.
        assertEquals(Configuration.ORIENTATION_PORTRAIT,
                mActivity.mDisplayContent.getConfiguration().orientation);
        // Activity bounds should be [350, 0 - 2150, 1000] in landscape. Its width=1000*1.8=1800.
        assertEquals((int) (dw * maxAspect), mActivity.getBounds().width());
        // The bounds should be horizontal centered: (2500-1900)/2=350.
        assertEquals((dh - mActivity.getBounds().width()) / 2, mActivity.getBounds().left);
    }

    /**
     * Setup {@link #mActivity} as a size-compat-mode-able activity with fixed aspect and/or
     * orientation.