Loading services/core/java/com/android/server/wm/ActivityRecord.java +14 −7 Original line number Diff line number Diff line Loading @@ -7729,13 +7729,20 @@ final class ActivityRecord extends WindowToken implements WindowManagerService.A return false; } // Compute configuration based on max supported width and height. // Also account for the left / top insets (e.g. from display cutouts), which will be clipped // away later in {@link Task#computeConfigResourceOverrides()}. Otherwise, the app // bounds would end up too small. outBounds.set(containingBounds.left, containingBounds.top, activityWidth + containingAppBounds.left, activityHeight + containingAppBounds.top); // Compute configuration based on max or min supported width and height. // Also account for the insets (e.g. display cutouts, navigation bar), which will be // clipped away later in {@link Task#computeConfigResourceOverrides()}, i.e., the out // bounds are the app bounds restricted by aspect ratio + clippable insets. Otherwise, // the app bounds would end up too small. int right = activityWidth + containingAppBounds.left; if (right >= containingAppBounds.right) { right += containingBounds.right - containingAppBounds.right; } int bottom = activityHeight + containingAppBounds.top; if (bottom >= containingAppBounds.bottom) { bottom += containingBounds.bottom - containingAppBounds.bottom; } outBounds.set(containingBounds.left, containingBounds.top, right, bottom); return true; } Loading services/tests/wmtests/src/com/android/server/wm/SizeCompatTests.java +10 −3 Original line number Diff line number Diff line Loading @@ -982,7 +982,9 @@ public class SizeCompatTests extends WindowTestsBase { @EnableCompatChanges({ActivityInfo.OVERRIDE_MIN_ASPECT_RATIO, ActivityInfo.OVERRIDE_MIN_ASPECT_RATIO_MEDIUM}) public void testOverrideMinAspectRatioLowerThanManifest() { setUpDisplaySizeWithApp(1400, 1600); final DisplayContent display = new TestDisplayContent.Builder(mAtm, 1400, 1800) .setNotch(200).setSystemDecorations(true).build(); mTask = new TaskBuilder(mSupervisor).setDisplay(display).build(); // Create a size compat activity on the same task. final ActivityRecord activity = new ActivityBuilder(mAtm) Loading @@ -996,8 +998,13 @@ public class SizeCompatTests extends WindowTestsBase { // The per-package override should have no effect, because the manifest aspect ratio is // larger (2:1) assertEquals(1600, activity.getBounds().height()); assertEquals(800, activity.getBounds().width()); final Rect appBounds = activity.getWindowConfiguration().getAppBounds(); assertEquals("App bounds must have min aspect ratio", 2f, (float) appBounds.height() / appBounds.width(), 0.0001f /* delta */); assertEquals("Long side must fit task", mTask.getWindowConfiguration().getAppBounds().height(), appBounds.height()); assertEquals("Bounds can include insets", mTask.getBounds().height(), activity.getBounds().height()); } @Test Loading Loading
services/core/java/com/android/server/wm/ActivityRecord.java +14 −7 Original line number Diff line number Diff line Loading @@ -7729,13 +7729,20 @@ final class ActivityRecord extends WindowToken implements WindowManagerService.A return false; } // Compute configuration based on max supported width and height. // Also account for the left / top insets (e.g. from display cutouts), which will be clipped // away later in {@link Task#computeConfigResourceOverrides()}. Otherwise, the app // bounds would end up too small. outBounds.set(containingBounds.left, containingBounds.top, activityWidth + containingAppBounds.left, activityHeight + containingAppBounds.top); // Compute configuration based on max or min supported width and height. // Also account for the insets (e.g. display cutouts, navigation bar), which will be // clipped away later in {@link Task#computeConfigResourceOverrides()}, i.e., the out // bounds are the app bounds restricted by aspect ratio + clippable insets. Otherwise, // the app bounds would end up too small. int right = activityWidth + containingAppBounds.left; if (right >= containingAppBounds.right) { right += containingBounds.right - containingAppBounds.right; } int bottom = activityHeight + containingAppBounds.top; if (bottom >= containingAppBounds.bottom) { bottom += containingBounds.bottom - containingAppBounds.bottom; } outBounds.set(containingBounds.left, containingBounds.top, right, bottom); return true; } Loading
services/tests/wmtests/src/com/android/server/wm/SizeCompatTests.java +10 −3 Original line number Diff line number Diff line Loading @@ -982,7 +982,9 @@ public class SizeCompatTests extends WindowTestsBase { @EnableCompatChanges({ActivityInfo.OVERRIDE_MIN_ASPECT_RATIO, ActivityInfo.OVERRIDE_MIN_ASPECT_RATIO_MEDIUM}) public void testOverrideMinAspectRatioLowerThanManifest() { setUpDisplaySizeWithApp(1400, 1600); final DisplayContent display = new TestDisplayContent.Builder(mAtm, 1400, 1800) .setNotch(200).setSystemDecorations(true).build(); mTask = new TaskBuilder(mSupervisor).setDisplay(display).build(); // Create a size compat activity on the same task. final ActivityRecord activity = new ActivityBuilder(mAtm) Loading @@ -996,8 +998,13 @@ public class SizeCompatTests extends WindowTestsBase { // The per-package override should have no effect, because the manifest aspect ratio is // larger (2:1) assertEquals(1600, activity.getBounds().height()); assertEquals(800, activity.getBounds().width()); final Rect appBounds = activity.getWindowConfiguration().getAppBounds(); assertEquals("App bounds must have min aspect ratio", 2f, (float) appBounds.height() / appBounds.width(), 0.0001f /* delta */); assertEquals("Long side must fit task", mTask.getWindowConfiguration().getAppBounds().height(), appBounds.height()); assertEquals("Bounds can include insets", mTask.getBounds().height(), activity.getBounds().height()); } @Test Loading