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

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

Merge "Return natural orientation according to available screen size" into main

parents 3963ce0a 51afcf8b
Loading
Loading
Loading
Loading
+7 −2
Original line number Diff line number Diff line
@@ -5149,8 +5149,13 @@ class DisplayContent extends RootDisplayArea implements WindowManagerPolicy.Disp

    /** @return the orientation of the display when it's rotation is ROTATION_0. */
    int getNaturalOrientation() {
        return mBaseDisplayWidth < mBaseDisplayHeight
                ? ORIENTATION_PORTRAIT : ORIENTATION_LANDSCAPE;
        final Configuration config = getConfiguration();
        if (config.windowConfiguration.getDisplayRotation() == ROTATION_0) {
            return config.orientation;
        }
        final Rect frame = mDisplayPolicy.getDecorInsetsInfo(
                ROTATION_0, mBaseDisplayWidth, mBaseDisplayHeight).mConfigFrame;
        return frame.width() <= frame.height() ? ORIENTATION_PORTRAIT : ORIENTATION_LANDSCAPE;
    }

    void performLayout(boolean initial, boolean updateInputWindows) {
+2 −0
Original line number Diff line number Diff line
@@ -993,7 +993,9 @@ public class DisplayContentTests extends WindowTestsBase {
        dc.getDisplayPolicy().getDecorInsetsInfo(ROTATION_0, dc.mBaseDisplayHeight,
                dc.mBaseDisplayWidth).mConfigFrame.set(0, 0, 1000, 990);
        dc.computeScreenConfiguration(config, ROTATION_0);
        dc.onRequestedOverrideConfigurationChanged(config);
        assertEquals(Configuration.ORIENTATION_LANDSCAPE, config.orientation);
        assertEquals(Configuration.ORIENTATION_LANDSCAPE, dc.getNaturalOrientation());
    }

    @Test