Loading services/core/java/com/android/server/wm/ActivityRecord.java +15 −1 Original line number Diff line number Diff line Loading @@ -46,6 +46,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.activityTypeToString; import static android.app.WindowConfiguration.isFloating; import static android.content.Context.CONTEXT_RESTRICTED; import static android.content.Intent.ACTION_MAIN; import static android.content.Intent.CATEGORY_HOME; Loading Loading @@ -7534,8 +7535,21 @@ final class ActivityRecord extends WindowToken { final AppCompatSafeRegionPolicy safeRegionPolicy = mAppCompatController.getSafeRegionPolicy(); mAppCompatController.getLetterboxPolicy().resetFixedOrientationLetterboxEligibility(); boolean shouldApplyLegacyInsets = !isFloating(newParentConfiguration.windowConfiguration.getWindowingMode()); if (com.android.wm.shell.Flags.enableCreateAnyBubble() && com.android.wm.shell.Flags.enableBubbleAppCompatFixes()) { final Task task = getTask(); if (task != null) { // Similar to floating windows, an app bubble should not apply legacy insets. // TODO(b/407669465): Update isAppBubble usage once migrated to the new approach. shouldApplyLegacyInsets &= !task.getTaskInfo().isAppBubble; } } mResolveConfigHint.resolveTmpOverrides(mDisplayContent, newParentConfiguration, isFixedRotationTransforming(), safeRegionPolicy.getLatestSafeRegionBounds()); isFixedRotationTransforming(), safeRegionPolicy.getLatestSafeRegionBounds(), shouldApplyLegacyInsets); // Can't use resolvedConfig.windowConfiguration.getWindowingMode() because it can be // different from windowing mode of the task (PiP) during transition from fullscreen to PiP Loading services/core/java/com/android/server/wm/TaskFragment.java +3 −3 Original line number Diff line number Diff line Loading @@ -2314,7 +2314,8 @@ class TaskFragment extends WindowContainer<WindowContainer> { boolean mUseOverrideInsetsForConfig; void resolveTmpOverrides(DisplayContent dc, Configuration parentConfig, boolean isFixedRotationTransforming, @Nullable Rect safeRegionBounds) { boolean isFixedRotationTransforming, @Nullable Rect safeRegionBounds, boolean shouldApplyLegacyInsets) { mParentAppBoundsOverride = safeRegionBounds != null ? safeRegionBounds : new Rect( parentConfig.windowConfiguration.getAppBounds()); mParentBoundsOverride = safeRegionBounds != null ? safeRegionBounds : new Rect( Loading @@ -2326,8 +2327,7 @@ class TaskFragment extends WindowContainer<WindowContainer> { mTmpOverrideConfigOrientation = mParentAppBoundsOverride.height() >= mParentAppBoundsOverride.width() ? ORIENTATION_PORTRAIT : ORIENTATION_LANDSCAPE; } else if (mUseOverrideInsetsForConfig && dc != null && !isFloating(parentConfig.windowConfiguration.getWindowingMode())) { } else if (shouldApplyLegacyInsets && mUseOverrideInsetsForConfig && dc != null) { // Insets are decoupled from configuration by default from V+, use legacy // compatibility behaviour for apps targeting SDK earlier than 35 // (see applySizeOverrideIfNeeded). Loading services/tests/wmtests/src/com/android/server/wm/SizeCompatTests.java +29 −0 Original line number Diff line number Diff line Loading @@ -751,6 +751,35 @@ public class SizeCompatTests extends WindowTestsBase { assertFalse(mActivity.areBoundsLetterboxed()); } @Test @EnableFlags({com.android.wm.shell.Flags.FLAG_ENABLE_CREATE_ANY_BUBBLE, com.android.wm.shell.Flags.FLAG_ENABLE_BUBBLE_APP_COMPAT_FIXES}) // Enable to prevent any non-legacy override insets from being added. @EnableCompatChanges({ActivityInfo.INSETS_DECOUPLED_CONFIGURATION_ENFORCED}) public void testLegacyInsetOverride_isAppBubble_notApplied() { // Set up app. 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 up activity task to be in app bubble. mTask.mLaunchNextToBubble = true; mTask.setWindowingMode(WindowConfiguration.WINDOWING_MODE_MULTI_WINDOW); 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. assertEquals(new Rect(0, 0, 1000, 2800), appBounds); assertEquals(new Rect(0, 0, 1000, 2800), bounds); } @Test public void testAspectRatioMatchParentBoundsAndImeAttachable() { setUpApp(new TestDisplayContent.Builder(mAtm, 1000, 2000).build()); Loading Loading
services/core/java/com/android/server/wm/ActivityRecord.java +15 −1 Original line number Diff line number Diff line Loading @@ -46,6 +46,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.activityTypeToString; import static android.app.WindowConfiguration.isFloating; import static android.content.Context.CONTEXT_RESTRICTED; import static android.content.Intent.ACTION_MAIN; import static android.content.Intent.CATEGORY_HOME; Loading Loading @@ -7534,8 +7535,21 @@ final class ActivityRecord extends WindowToken { final AppCompatSafeRegionPolicy safeRegionPolicy = mAppCompatController.getSafeRegionPolicy(); mAppCompatController.getLetterboxPolicy().resetFixedOrientationLetterboxEligibility(); boolean shouldApplyLegacyInsets = !isFloating(newParentConfiguration.windowConfiguration.getWindowingMode()); if (com.android.wm.shell.Flags.enableCreateAnyBubble() && com.android.wm.shell.Flags.enableBubbleAppCompatFixes()) { final Task task = getTask(); if (task != null) { // Similar to floating windows, an app bubble should not apply legacy insets. // TODO(b/407669465): Update isAppBubble usage once migrated to the new approach. shouldApplyLegacyInsets &= !task.getTaskInfo().isAppBubble; } } mResolveConfigHint.resolveTmpOverrides(mDisplayContent, newParentConfiguration, isFixedRotationTransforming(), safeRegionPolicy.getLatestSafeRegionBounds()); isFixedRotationTransforming(), safeRegionPolicy.getLatestSafeRegionBounds(), shouldApplyLegacyInsets); // Can't use resolvedConfig.windowConfiguration.getWindowingMode() because it can be // different from windowing mode of the task (PiP) during transition from fullscreen to PiP Loading
services/core/java/com/android/server/wm/TaskFragment.java +3 −3 Original line number Diff line number Diff line Loading @@ -2314,7 +2314,8 @@ class TaskFragment extends WindowContainer<WindowContainer> { boolean mUseOverrideInsetsForConfig; void resolveTmpOverrides(DisplayContent dc, Configuration parentConfig, boolean isFixedRotationTransforming, @Nullable Rect safeRegionBounds) { boolean isFixedRotationTransforming, @Nullable Rect safeRegionBounds, boolean shouldApplyLegacyInsets) { mParentAppBoundsOverride = safeRegionBounds != null ? safeRegionBounds : new Rect( parentConfig.windowConfiguration.getAppBounds()); mParentBoundsOverride = safeRegionBounds != null ? safeRegionBounds : new Rect( Loading @@ -2326,8 +2327,7 @@ class TaskFragment extends WindowContainer<WindowContainer> { mTmpOverrideConfigOrientation = mParentAppBoundsOverride.height() >= mParentAppBoundsOverride.width() ? ORIENTATION_PORTRAIT : ORIENTATION_LANDSCAPE; } else if (mUseOverrideInsetsForConfig && dc != null && !isFloating(parentConfig.windowConfiguration.getWindowingMode())) { } else if (shouldApplyLegacyInsets && mUseOverrideInsetsForConfig && dc != null) { // Insets are decoupled from configuration by default from V+, use legacy // compatibility behaviour for apps targeting SDK earlier than 35 // (see applySizeOverrideIfNeeded). Loading
services/tests/wmtests/src/com/android/server/wm/SizeCompatTests.java +29 −0 Original line number Diff line number Diff line Loading @@ -751,6 +751,35 @@ public class SizeCompatTests extends WindowTestsBase { assertFalse(mActivity.areBoundsLetterboxed()); } @Test @EnableFlags({com.android.wm.shell.Flags.FLAG_ENABLE_CREATE_ANY_BUBBLE, com.android.wm.shell.Flags.FLAG_ENABLE_BUBBLE_APP_COMPAT_FIXES}) // Enable to prevent any non-legacy override insets from being added. @EnableCompatChanges({ActivityInfo.INSETS_DECOUPLED_CONFIGURATION_ENFORCED}) public void testLegacyInsetOverride_isAppBubble_notApplied() { // Set up app. 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 up activity task to be in app bubble. mTask.mLaunchNextToBubble = true; mTask.setWindowingMode(WindowConfiguration.WINDOWING_MODE_MULTI_WINDOW); 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. assertEquals(new Rect(0, 0, 1000, 2800), appBounds); assertEquals(new Rect(0, 0, 1000, 2800), bounds); } @Test public void testAspectRatioMatchParentBoundsAndImeAttachable() { setUpApp(new TestDisplayContent.Builder(mAtm, 1000, 2000).build()); Loading