Loading services/core/java/com/android/server/wm/ActivityRecord.java +16 −0 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.app.admin.DevicePolicyResources.Drawables.Source.PROFILE_SWITCH_ANIMATION; import static android.app.admin.DevicePolicyResources.Drawables.Style.OUTLINE; import static android.app.admin.DevicePolicyResources.Drawables.WORK_PROFILE_ICON; Loading Loading @@ -8376,6 +8377,7 @@ final class ActivityRecord extends WindowToken { mConfigurationSeq = Math.max(++mConfigurationSeq, 1); getResolvedOverrideConfiguration().seq = mConfigurationSeq; // TODO(b/392069771): Move to AppCompatSandboxingPolicy. // Sandbox max bounds by setting it to the activity bounds, if activity is letterboxed, or // has or will have mAppCompatDisplayInsets for size compat. Also forces an activity to be // sandboxed or not depending upon the configuration settings. Loading Loading @@ -8404,6 +8406,20 @@ final class ActivityRecord extends WindowToken { resolvedConfig.windowConfiguration.setMaxBounds(mTmpBounds); } // Sandbox activity bounds in freeform to app bounds to force app to display within the // container. This prevents UI cropping when activities can draw below insets which are // normally excluded from appBounds before targetSDK < 35 // (see ConfigurationContainer#applySizeOverrideIfNeeded). if (isFloating(parentWindowingMode)) { Rect appBounds = resolvedConfig.windowConfiguration.getAppBounds(); if (appBounds == null || appBounds.isEmpty()) { // When there is no override bounds, the activity will inherit the bounds from // parent. appBounds = mResolveConfigHint.mParentAppBoundsOverride; } resolvedConfig.windowConfiguration.setBounds(appBounds); } applySizeOverrideIfNeeded( mDisplayContent, info.applicationInfo, Loading services/tests/wmtests/src/com/android/server/wm/SizeCompatTests.java +39 −0 Original line number Diff line number Diff line Loading @@ -4461,7 +4461,46 @@ public class SizeCompatTests extends WindowTestsBase { // are aligned to the top of the parentAppBounds assertEquals(new Rect(0, notchHeight, 1000, 1200), appBounds); assertEquals(new Rect(0, 0, 1000, 1200), bounds); } @Test @DisableCompatChanges({ActivityInfo.INSETS_DECOUPLED_CONFIGURATION_ENFORCED}) public void testInFreeform_boundsSandboxedToAppBounds() { final int dw = 2800; final int dh = 1400; final int notchHeight = 100; final DisplayContent display = new TestDisplayContent.Builder(mAtm, dw, dh) .setNotch(notchHeight) .build(); setUpApp(display); prepareUnresizable(mActivity, SCREEN_ORIENTATION_PORTRAIT); mTask.mDisplayContent.getDefaultTaskDisplayArea() .setWindowingMode(WindowConfiguration.WINDOWING_MODE_FREEFORM); mTask.setWindowingMode(WINDOWING_MODE_FREEFORM); Rect appBounds = new Rect(0, 0, 1000, 500); Rect bounds = new Rect(0, 0, 1000, 600); mTask.getWindowConfiguration().setAppBounds(appBounds); mTask.getWindowConfiguration().setBounds(bounds); mActivity.onConfigurationChanged(mTask.getConfiguration()); // Bounds are sandboxed to appBounds in freeform. assertDownScaled(); assertEquals(mActivity.getWindowConfiguration().getAppBounds(), mActivity.getWindowConfiguration().getBounds()); // Exit freeform. mTask.mDisplayContent.getDefaultTaskDisplayArea() .setWindowingMode(WindowConfiguration.WINDOWING_MODE_FULLSCREEN); mTask.setWindowingMode(WINDOWING_MODE_FULLSCREEN); mTask.getWindowConfiguration().setBounds(new Rect(0, 0, dw, dh)); mActivity.onConfigurationChanged(mTask.getConfiguration()); assertFitted(); appBounds = mActivity.getWindowConfiguration().getAppBounds(); bounds = mActivity.getWindowConfiguration().getBounds(); // Bounds are not sandboxed to appBounds. assertNotEquals(appBounds, bounds); assertEquals(notchHeight, appBounds.top - bounds.top); } @Test Loading Loading
services/core/java/com/android/server/wm/ActivityRecord.java +16 −0 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.app.admin.DevicePolicyResources.Drawables.Source.PROFILE_SWITCH_ANIMATION; import static android.app.admin.DevicePolicyResources.Drawables.Style.OUTLINE; import static android.app.admin.DevicePolicyResources.Drawables.WORK_PROFILE_ICON; Loading Loading @@ -8376,6 +8377,7 @@ final class ActivityRecord extends WindowToken { mConfigurationSeq = Math.max(++mConfigurationSeq, 1); getResolvedOverrideConfiguration().seq = mConfigurationSeq; // TODO(b/392069771): Move to AppCompatSandboxingPolicy. // Sandbox max bounds by setting it to the activity bounds, if activity is letterboxed, or // has or will have mAppCompatDisplayInsets for size compat. Also forces an activity to be // sandboxed or not depending upon the configuration settings. Loading Loading @@ -8404,6 +8406,20 @@ final class ActivityRecord extends WindowToken { resolvedConfig.windowConfiguration.setMaxBounds(mTmpBounds); } // Sandbox activity bounds in freeform to app bounds to force app to display within the // container. This prevents UI cropping when activities can draw below insets which are // normally excluded from appBounds before targetSDK < 35 // (see ConfigurationContainer#applySizeOverrideIfNeeded). if (isFloating(parentWindowingMode)) { Rect appBounds = resolvedConfig.windowConfiguration.getAppBounds(); if (appBounds == null || appBounds.isEmpty()) { // When there is no override bounds, the activity will inherit the bounds from // parent. appBounds = mResolveConfigHint.mParentAppBoundsOverride; } resolvedConfig.windowConfiguration.setBounds(appBounds); } applySizeOverrideIfNeeded( mDisplayContent, info.applicationInfo, Loading
services/tests/wmtests/src/com/android/server/wm/SizeCompatTests.java +39 −0 Original line number Diff line number Diff line Loading @@ -4461,7 +4461,46 @@ public class SizeCompatTests extends WindowTestsBase { // are aligned to the top of the parentAppBounds assertEquals(new Rect(0, notchHeight, 1000, 1200), appBounds); assertEquals(new Rect(0, 0, 1000, 1200), bounds); } @Test @DisableCompatChanges({ActivityInfo.INSETS_DECOUPLED_CONFIGURATION_ENFORCED}) public void testInFreeform_boundsSandboxedToAppBounds() { final int dw = 2800; final int dh = 1400; final int notchHeight = 100; final DisplayContent display = new TestDisplayContent.Builder(mAtm, dw, dh) .setNotch(notchHeight) .build(); setUpApp(display); prepareUnresizable(mActivity, SCREEN_ORIENTATION_PORTRAIT); mTask.mDisplayContent.getDefaultTaskDisplayArea() .setWindowingMode(WindowConfiguration.WINDOWING_MODE_FREEFORM); mTask.setWindowingMode(WINDOWING_MODE_FREEFORM); Rect appBounds = new Rect(0, 0, 1000, 500); Rect bounds = new Rect(0, 0, 1000, 600); mTask.getWindowConfiguration().setAppBounds(appBounds); mTask.getWindowConfiguration().setBounds(bounds); mActivity.onConfigurationChanged(mTask.getConfiguration()); // Bounds are sandboxed to appBounds in freeform. assertDownScaled(); assertEquals(mActivity.getWindowConfiguration().getAppBounds(), mActivity.getWindowConfiguration().getBounds()); // Exit freeform. mTask.mDisplayContent.getDefaultTaskDisplayArea() .setWindowingMode(WindowConfiguration.WINDOWING_MODE_FULLSCREEN); mTask.setWindowingMode(WINDOWING_MODE_FULLSCREEN); mTask.getWindowConfiguration().setBounds(new Rect(0, 0, dw, dh)); mActivity.onConfigurationChanged(mTask.getConfiguration()); assertFitted(); appBounds = mActivity.getWindowConfiguration().getAppBounds(); bounds = mActivity.getWindowConfiguration().getBounds(); // Bounds are not sandboxed to appBounds. assertNotEquals(appBounds, bounds); assertEquals(notchHeight, appBounds.top - bounds.top); } @Test Loading