summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author Riddle Hsu <riddlehsu@google.com> 2021-07-30 12:27:20 +0800
committer Riddle Hsu <riddlehsu@google.com> 2021-07-30 12:27:20 +0800
commit9d4a077de92f44ab53e705f5f02ab9743db1d5a9 (patch)
treebb9cf2a914ec60497fb47b5d5df000aadb570af9
parent23ba83b769a59a801cbeb64eea938d4886ee4322 (diff)
Use size compat bounds for window layout
When an app is in size compat mode, the configuration bounds and layout bounds are not the same such as the app keeps a larger configuration bounds and needs to be scaled when drawing on screen. The size compat bounds are the scaled bounds in screen coordinates so it should be used if available. Fix: 194820928 Test: SizeCompatTests#testFixedScreenBoundsWhenDisplaySizeChanged Change-Id: Ib97038560e65699f5275d6f5dc4b8e5881024e57
-rw-r--r--services/core/java/com/android/server/wm/WindowState.java8
-rw-r--r--services/tests/wmtests/src/com/android/server/wm/SizeCompatTests.java5
2 files changed, 13 insertions, 0 deletions
diff --git a/services/core/java/com/android/server/wm/WindowState.java b/services/core/java/com/android/server/wm/WindowState.java
index c9b15062c708..7ec6a45c0063 100644
--- a/services/core/java/com/android/server/wm/WindowState.java
+++ b/services/core/java/com/android/server/wm/WindowState.java
@@ -1441,6 +1441,14 @@ class WindowState extends WindowContainer<WindowState> implements WindowManagerP
}
}
+ @Override
+ public Rect getBounds() {
+ // The window bounds are used for layout in screen coordinates. If the token has bounds for
+ // size compatibility mode, its configuration bounds are app based coordinates which should
+ // not be used for layout.
+ return mToken.hasSizeCompatBounds() ? mToken.getBounds() : super.getBounds();
+ }
+
/** Retrieves the current frame of the window that the application sees. */
Rect getFrame() {
return mWindowFrames.mFrame;
diff --git a/services/tests/wmtests/src/com/android/server/wm/SizeCompatTests.java b/services/tests/wmtests/src/com/android/server/wm/SizeCompatTests.java
index 59894973521d..d10c006831d2 100644
--- a/services/tests/wmtests/src/com/android/server/wm/SizeCompatTests.java
+++ b/services/tests/wmtests/src/com/android/server/wm/SizeCompatTests.java
@@ -320,6 +320,11 @@ public class SizeCompatTests extends WindowTestsBase {
assertScaled();
// Activity is sandboxed due to size compat mode.
assertActivityMaxBoundsSandboxed();
+
+ final WindowState appWindow = addWindowToActivity(mActivity);
+ assertTrue(mActivity.hasSizeCompatBounds());
+ assertEquals("App window must use size compat bounds for layout in screen space",
+ mActivity.getBounds(), appWindow.getBounds());
}
@Test