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

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

Merge "Compute configuration orientation by available screen size" into main

parents e35a7ead c545ce99
Loading
Loading
Loading
Loading
+2 −1
Original line number Diff line number Diff line
@@ -2436,13 +2436,14 @@ class DisplayContent extends RootDisplayArea implements WindowManagerPolicy.Disp
        // AppBounds at the root level should mirror the app screen size.
        outConfig.windowConfiguration.setAppBounds(info.mNonDecorFrame);
        outConfig.windowConfiguration.setRotation(rotation);
        outConfig.orientation = (dw <= dh) ? ORIENTATION_PORTRAIT : ORIENTATION_LANDSCAPE;

        final float density = mDisplayMetrics.density;
        outConfig.screenWidthDp = (int) (info.mConfigFrame.width() / density + 0.5f);
        outConfig.screenHeightDp = (int) (info.mConfigFrame.height() / density + 0.5f);
        outConfig.compatScreenWidthDp = (int) (outConfig.screenWidthDp / mCompatibleScreenScale);
        outConfig.compatScreenHeightDp = (int) (outConfig.screenHeightDp / mCompatibleScreenScale);
        outConfig.orientation = (outConfig.screenWidthDp <= outConfig.screenHeightDp)
                ? ORIENTATION_PORTRAIT : ORIENTATION_LANDSCAPE;
        outConfig.screenLayout = computeScreenLayout(
                Configuration.resetScreenLayout(outConfig.screenLayout),
                outConfig.screenWidthDp, outConfig.screenHeightDp);
+7 −0
Original line number Diff line number Diff line
@@ -970,6 +970,13 @@ public class DisplayContentTests extends WindowTestsBase {
        assertEquals(
                "Screen orientation must be defined by the window even on close-to-square display.",
                window.mAttrs.screenOrientation, dc.getOrientation());

        // Assume that a decor window occupies the display height, so the configuration orientation
        // should be landscape.
        dc.getDisplayPolicy().getDecorInsetsInfo(ROTATION_0, dc.mBaseDisplayHeight,
                dc.mBaseDisplayWidth).mConfigFrame.set(0, 0, 1000, 990);
        dc.computeScreenConfiguration(config, ROTATION_0);
        assertEquals(Configuration.ORIENTATION_LANDSCAPE, config.orientation);
    }

    @Test