Don't override bounds to include insets for floating activities
Insets have been decoupled from app bounds from V+. To keep the legacy
behaviour, we override the app bounds to include insets for apps
targeting older sdks. However, floating windows do not include insets
and thus the app bounds in this case should not be adjusted to include
them.
Flag: EXEMPT bugfix
Test: Manual && atest WmTests:SizeCompatTests
Fixes: 348202594
Change-Id: I2d472e4d92f5be95b448e9fed4a2cd7d2f45517e
diff --git a/services/core/java/com/android/server/wm/TaskFragment.java b/services/core/java/com/android/server/wm/TaskFragment.java
index 7f6499f..acdb66a 100644
--- a/services/core/java/com/android/server/wm/TaskFragment.java
+++ b/services/core/java/com/android/server/wm/TaskFragment.java
@@ -29,6 +29,7 @@
import static android.app.WindowConfiguration.WINDOWING_MODE_MULTI_WINDOW;
import static android.app.WindowConfiguration.WINDOWING_MODE_PINNED;
import static android.app.WindowConfiguration.WINDOWING_MODE_UNDEFINED;
+import static android.app.WindowConfiguration.isFloating;
import static android.content.pm.ActivityInfo.FLAG_ALLOW_UNTRUSTED_ACTIVITY_EMBEDDING;
import static android.content.pm.ActivityInfo.FLAG_RESUME_WHILE_PAUSING;
import static android.content.pm.ActivityInfo.SCREEN_ORIENTATION_UNSET;
@@ -2248,8 +2249,10 @@
void resolveTmpOverrides(DisplayContent dc, Configuration parentConfig,
boolean isFixedRotationTransforming) {
mParentAppBoundsOverride = new Rect(parentConfig.windowConfiguration.getAppBounds());
+ mTmpOverrideConfigOrientation = parentConfig.orientation;
final Insets insets;
- if (mUseOverrideInsetsForConfig && dc != null) {
+ if (mUseOverrideInsetsForConfig && dc != null
+ && !isFloating(parentConfig.windowConfiguration.getWindowingMode())) {
// Insets are decoupled from configuration by default from V+, use legacy
// compatibility behaviour for apps targeting SDK earlier than 35
// (see applySizeOverrideIfNeeded).
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 ac1aa20..3a85451 100644
--- a/services/tests/wmtests/src/com/android/server/wm/SizeCompatTests.java
+++ b/services/tests/wmtests/src/com/android/server/wm/SizeCompatTests.java
@@ -4271,6 +4271,27 @@
}
+ @Test
+ public void testInsetOverrideNotAppliedInFreeform() {
+ final int notchHeight = 100;
+ final DisplayContent display = new TestDisplayContent.Builder(mAtm, 1000, 2800)
+ .setNotch(notchHeight)
+ .build();
+ setUpApp(display);
+
+ // Simulate inset override for legacy app bound behaviour
+ mActivity.mResolveConfigHint.mUseOverrideInsetsForConfig = true;
+ // Set task as freeform
+ mTask.setWindowingMode(WindowConfiguration.WINDOWING_MODE_FREEFORM);
+ prepareUnresizable(mActivity, SCREEN_ORIENTATION_PORTRAIT);
+
+ Rect bounds = new Rect(mActivity.getWindowConfiguration().getBounds());
+ Rect appBounds = new Rect(mActivity.getWindowConfiguration().getAppBounds());
+ // App bounds should not include insets and should match bounds when in freeform.
+ assertEquals(new Rect(0, 0, 1000, 2800), appBounds);
+ assertEquals(new Rect(0, 0, 1000, 2800), bounds);
+ }
+
private void assertVerticalPositionForDifferentDisplayConfigsForLandscapeActivity(
float letterboxVerticalPositionMultiplier, Rect fixedOrientationLetterbox,
Rect sizeCompatUnscaled, Rect sizeCompatScaled) {