Fix rotation if the shape of display is close to square
For a close-to-square device, the user won't get reasonable benefits
when the content on display is rotated. Worse, the rotation forces the
user to turn their device into an unnatural orientation.
In this CL, if the non-decor aspect ratio of a display is less than
config_closeToSquareDisplayMaxAspectRatio, and the device is configured
to force default orientation, we will ignore all the orientation
requests on the display, and keep the orientation as the user rotation.
For the activity which has a minAspectRatio, the logic will take account
into its preferred orientation while computing its bounds. So the shape
of bounds given to the app can meet its expectation.
Bug: 123507947
Test: atest AspectRatioTests DisplayRotationTests
Test: Manual test with wm size command and simulated display cutout
Change-Id: If99a89d59c805cfc0d305a66067643ce35b3f2bd
diff --git a/services/core/java/com/android/server/wm/DisplayContent.java b/services/core/java/com/android/server/wm/DisplayContent.java
index 5cfc20b..4795555 100644
--- a/services/core/java/com/android/server/wm/DisplayContent.java
+++ b/services/core/java/com/android/server/wm/DisplayContent.java
@@ -1500,8 +1500,8 @@
final int shortSizeDp = shortSize * DisplayMetrics.DENSITY_DEFAULT / mBaseDisplayDensity;
final int longSizeDp = longSize * DisplayMetrics.DENSITY_DEFAULT / mBaseDisplayDensity;
- mDisplayRotation.configure(width, height, shortSizeDp, longSizeDp);
mDisplayPolicy.configure(width, height, shortSizeDp);
+ mDisplayRotation.configure(width, height, shortSizeDp, longSizeDp);
mDisplayFrames.onDisplayInfoUpdated(mDisplayInfo,
calculateDisplayCutoutForRotation(mDisplayInfo.rotation));