Disables display content scaling for foldables
When setting folded area with changes both in width and height (set
0,0,540,1080 to a 1080x2160 device), the content of display will be
auto-scaled to physical display size. It is not an expected behavior
for foldable devices. Disable auto-scale to fix this issue.
1. LogicalDisplay.configureDisplayLocked() scales the contents according
the DisplayInfo.flags.
2. DisplayInfo.flags should not be overridden by design for a logical
display.
3. Adds disableDisplayScaling() for DisplayFoldController to bypass that.
Bug: 123245311
Test: atest WmTests
Test: adb shell wm folded-area 0,0,840,1260
Change-Id: I9a24c5d56799981b4f2cfe82fdf1898d87193681
diff --git a/services/core/java/com/android/server/display/DisplayManagerService.java b/services/core/java/com/android/server/display/DisplayManagerService.java
index b99ba7e..b2509e9 100644
--- a/services/core/java/com/android/server/display/DisplayManagerService.java
+++ b/services/core/java/com/android/server/display/DisplayManagerService.java
@@ -1222,6 +1222,22 @@
}
}
+ private void setDisplayScalingDisabledInternal(int displayId, boolean disable) {
+ synchronized (mSyncRoot) {
+ final LogicalDisplay display = mLogicalDisplays.get(displayId);
+ if (display == null) {
+ return;
+ }
+ if (display.isDisplayScalingDisabled() != disable) {
+ if (DEBUG) {
+ Slog.d(TAG, "Display " + displayId + " content scaling disabled = " + disable);
+ }
+ display.setDisplayScalingDisabledLocked(disable);
+ scheduleTraversalLocked(false);
+ }
+ }
+ }
+
// Updates the lists of UIDs that are present on displays.
private void setDisplayAccessUIDsInternal(SparseArray<IntArray> newDisplayAccessUIDs) {
synchronized (mSyncRoot) {
@@ -2359,6 +2375,11 @@
}
@Override
+ public void setDisplayScalingDisabled(int displayId, boolean disableScaling) {
+ setDisplayScalingDisabledInternal(displayId, disableScaling);
+ }
+
+ @Override
public void setDisplayAccessUIDs(SparseArray<IntArray> newDisplayAccessUIDs) {
setDisplayAccessUIDsInternal(newDisplayAccessUIDs);
}