Foldables: Implement emulation for folded screen
Include ag/5696684 to fix an issue where the folded state was not
properly applied if a display override was restored after boot.
Bug: 123245311
Test: adb root && adb shell setprop persist.debug.force_foldable true && adb shell stop && adb shell start; covering the proximity sensor will half the available display area.
Test: Fold, power off, unfold, power on, verify entire display is usable.
Test: atest WmTests
Change-Id: I4d1eda8e7796bf30549c1154e3e041f9520bea24
diff --git a/services/core/java/com/android/server/display/LogicalDisplay.java b/services/core/java/com/android/server/display/LogicalDisplay.java
index 9566598..7414e55 100644
--- a/services/core/java/com/android/server/display/LogicalDisplay.java
+++ b/services/core/java/com/android/server/display/LogicalDisplay.java
@@ -418,10 +418,15 @@
// Now add back the offset for the masked area.
mTempDisplayRect.offset(maskingInsets.left, maskingInsets.top);
- mTempDisplayRect.left += mDisplayOffsetX;
- mTempDisplayRect.right += mDisplayOffsetX;
- mTempDisplayRect.top += mDisplayOffsetY;
- mTempDisplayRect.bottom += mDisplayOffsetY;
+ if (orientation == Surface.ROTATION_0) {
+ mTempDisplayRect.offset(mDisplayOffsetX, mDisplayOffsetY);
+ } else if (orientation == Surface.ROTATION_90) {
+ mTempDisplayRect.offset(mDisplayOffsetY, -mDisplayOffsetX);
+ } else if (orientation == Surface.ROTATION_180) {
+ mTempDisplayRect.offset(-mDisplayOffsetX, -mDisplayOffsetY);
+ } else { // Surface.ROTATION_270
+ mTempDisplayRect.offset(-mDisplayOffsetY, mDisplayOffsetX);
+ }
device.setProjectionLocked(t, orientation, mTempLayerStackRect, mTempDisplayRect);
}