Add flag for immersive app repositioning
Flag: com.android.window.flags.immersive_app_repositioning
Fix: 334076352
Test: atest SizeCompatTests
Change-Id: Ib25360573f0adf32c37ea0e6fb27af2d8f76c78a
Merged-In: Ib25360573f0adf32c37ea0e6fb27af2d8f76c78a
diff --git a/core/java/android/window/flags/large_screen_experiences_app_compat.aconfig b/core/java/android/window/flags/large_screen_experiences_app_compat.aconfig
index 0ef4fa3..cad3cc7 100644
--- a/core/java/android/window/flags/large_screen_experiences_app_compat.aconfig
+++ b/core/java/android/window/flags/large_screen_experiences_app_compat.aconfig
@@ -77,6 +77,16 @@
}
flag {
+ name: "immersive_app_repositioning"
+ namespace: "large_screen_experiences_app_compat"
+ description: "Fix immersive apps changing size when repositioning"
+ bug: "334076352"
+ metadata {
+ purpose: PURPOSE_BUGFIX
+ }
+}
+
+flag {
name: "camera_compat_for_freeform"
namespace: "large_screen_experiences_app_compat"
description: "Whether to apply Camera Compat treatment to fixed-orientation apps in freeform windowing mode"
diff --git a/services/core/java/com/android/server/wm/ActivityRecord.java b/services/core/java/com/android/server/wm/ActivityRecord.java
index 78cb8d0..3422e21 100644
--- a/services/core/java/com/android/server/wm/ActivityRecord.java
+++ b/services/core/java/com/android/server/wm/ActivityRecord.java
@@ -8538,7 +8538,7 @@
// If activity in fullscreen mode is letterboxed because of fixed orientation then bounds
// are already calculated in resolveFixedOrientationConfiguration.
// Don't apply aspect ratio if app is overridden to fullscreen by device user/manufacturer.
- if (!isLetterboxedForFixedOrientationAndAspectRatio()
+ if (Flags.immersiveAppRepositioning() && !isLetterboxedForFixedOrientationAndAspectRatio()
&& !mLetterboxUiController.hasFullscreenOverride()) {
resolveAspectRatioRestriction(newParentConfiguration);
}
@@ -8555,6 +8555,14 @@
computeConfigByResolveHint(resolvedConfig, newParentConfiguration);
}
}
+ // If activity in fullscreen mode is letterboxed because of fixed orientation then bounds
+ // are already calculated in resolveFixedOrientationConfiguration, or if in size compat
+ // mode, it should already be calculated in resolveSizeCompatModeConfiguration.
+ // Don't apply aspect ratio if app is overridden to fullscreen by device user/manufacturer.
+ if (!Flags.immersiveAppRepositioning() && !isLetterboxedForFixedOrientationAndAspectRatio()
+ && !mInSizeCompatModeForBounds && !mLetterboxUiController.hasFullscreenOverride()) {
+ resolveAspectRatioRestriction(newParentConfiguration);
+ }
if (isFixedOrientationLetterboxAllowed || compatDisplayInsets != null
// In fullscreen, can be letterboxed for aspect ratio.
@@ -8880,7 +8888,11 @@
}
boolean isImmersiveMode(@NonNull Rect parentBounds) {
- if (!mResolveConfigHint.mUseOverrideInsetsForStableBounds) {
+ if (!Flags.immersiveAppRepositioning()) {
+ return false;
+ }
+ if (!mResolveConfigHint.mUseOverrideInsetsForStableBounds
+ && mWmService.mFlags.mInsetsDecoupledConfiguration) {
return false;
}
final Insets navBarInsets = mDisplayContent.getInsetsStateController()
@@ -9229,10 +9241,12 @@
// orientation bounds (stored in resolved bounds) instead of parent bounds since the
// activity will be displayed within them even if it is in size compat mode. They should be
// saved here before resolved bounds are overridden below.
- final Rect containerBounds = isAspectRatioApplied()
+ final boolean useResolvedBounds = Flags.immersiveAppRepositioning()
+ ? isAspectRatioApplied() : isLetterboxedForFixedOrientationAndAspectRatio();
+ final Rect containerBounds = useResolvedBounds
? new Rect(resolvedBounds)
: newParentConfiguration.windowConfiguration.getBounds();
- final Rect containerAppBounds = isAspectRatioApplied()
+ final Rect containerAppBounds = useResolvedBounds
? new Rect(resolvedConfig.windowConfiguration.getAppBounds())
: newParentConfiguration.windowConfiguration.getAppBounds();
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 c6476df..f2390c0 100644
--- a/services/tests/wmtests/src/com/android/server/wm/SizeCompatTests.java
+++ b/services/tests/wmtests/src/com/android/server/wm/SizeCompatTests.java
@@ -107,6 +107,7 @@
import android.os.Binder;
import android.os.RemoteException;
import android.os.UserHandle;
+import android.platform.test.annotations.EnableFlags;
import android.platform.test.annotations.Presubmit;
import android.platform.test.annotations.RequiresFlagsDisabled;
import android.provider.DeviceConfig;
@@ -401,6 +402,7 @@
// TODO(b/333663877): Enable test after fix
@Test
@RequiresFlagsDisabled({Flags.FLAG_INSETS_DECOUPLED_CONFIGURATION})
+ @EnableFlags(Flags.FLAG_IMMERSIVE_APP_REPOSITIONING)
public void testRepositionLandscapeImmersiveAppWithDisplayCutout() {
final int dw = 2100;
final int dh = 2000;
@@ -4020,6 +4022,7 @@
}
@Test
+ @EnableFlags(Flags.FLAG_IMMERSIVE_APP_REPOSITIONING)
public void testImmersiveLetterboxAlignedToBottom_OverlappingNavbar() {
assertLandscapeActivityAlignedToBottomWithNavbar(true /* immersive */);
}