Loading core/api/test-current.txt +1 −0 Original line number Diff line number Diff line Loading @@ -793,6 +793,7 @@ package android.content.pm { field public static final long FORCE_RESIZE_APP = 174042936L; // 0xa5faf38L field public static final long NEVER_SANDBOX_DISPLAY_APIS = 184838306L; // 0xb0468a2L field public static final long OVERRIDE_MIN_ASPECT_RATIO = 174042980L; // 0xa5faf64L field public static final long OVERRIDE_MIN_ASPECT_RATIO_EXCLUDE_PORTRAIT_FULLSCREEN = 218959984L; // 0xd0d1070L field public static final long OVERRIDE_MIN_ASPECT_RATIO_LARGE = 180326787L; // 0xabf9183L field public static final float OVERRIDE_MIN_ASPECT_RATIO_LARGE_VALUE = 1.7777778f; field public static final long OVERRIDE_MIN_ASPECT_RATIO_MEDIUM = 180326845L; // 0xabf91bdL Loading core/java/android/content/pm/ActivityInfo.java +11 −0 Original line number Diff line number Diff line Loading @@ -1119,6 +1119,17 @@ public class ActivityInfo extends ComponentInfo implements Parcelable { @TestApi public static final long OVERRIDE_MIN_ASPECT_RATIO_TO_ALIGN_WITH_SPLIT_SCREEN = 208648326L; /** * Overrides the min aspect ratio restriction in portrait fullscreen in order to use all * available screen space. * @hide */ @ChangeId @Disabled @Overridable @TestApi public static final long OVERRIDE_MIN_ASPECT_RATIO_EXCLUDE_PORTRAIT_FULLSCREEN = 218959984L; /** * Compares activity window layout min width/height with require space for multi window to * determine if it can be put into multi window mode. Loading services/core/java/com/android/server/wm/ActivityRecord.java +20 −3 Original line number Diff line number Diff line Loading @@ -79,6 +79,7 @@ import static android.content.pm.ActivityInfo.LOCK_TASK_LAUNCH_MODE_DEFAULT; import static android.content.pm.ActivityInfo.LOCK_TASK_LAUNCH_MODE_IF_ALLOWLISTED; import static android.content.pm.ActivityInfo.LOCK_TASK_LAUNCH_MODE_NEVER; import static android.content.pm.ActivityInfo.OVERRIDE_MIN_ASPECT_RATIO; import static android.content.pm.ActivityInfo.OVERRIDE_MIN_ASPECT_RATIO_EXCLUDE_PORTRAIT_FULLSCREEN; import static android.content.pm.ActivityInfo.OVERRIDE_MIN_ASPECT_RATIO_LARGE; import static android.content.pm.ActivityInfo.OVERRIDE_MIN_ASPECT_RATIO_MEDIUM; import static android.content.pm.ActivityInfo.OVERRIDE_MIN_ASPECT_RATIO_PORTRAIT_ONLY; Loading Loading @@ -8809,9 +8810,25 @@ final class ActivityRecord extends WindowToken implements WindowManagerService.A * Returns the min aspect ratio of this activity. */ float getMinAspectRatio() { if (info.applicationInfo == null || !info.isChangeEnabled(OVERRIDE_MIN_ASPECT_RATIO) || ( info.isChangeEnabled(OVERRIDE_MIN_ASPECT_RATIO_PORTRAIT_ONLY) && !ActivityInfo.isFixedOrientationPortrait(getRequestedOrientation()))) { if (info.applicationInfo == null) { return info.getMinAspectRatio(); } if (!info.isChangeEnabled(OVERRIDE_MIN_ASPECT_RATIO)) { return info.getMinAspectRatio(); } if (info.isChangeEnabled(OVERRIDE_MIN_ASPECT_RATIO_PORTRAIT_ONLY) && !ActivityInfo.isFixedOrientationPortrait(getRequestedOrientation())) { return info.getMinAspectRatio(); } if (info.isChangeEnabled(OVERRIDE_MIN_ASPECT_RATIO_EXCLUDE_PORTRAIT_FULLSCREEN) && getParent().getConfiguration().orientation == ORIENTATION_PORTRAIT && getParent().getWindowConfiguration().getWindowingMode() == WINDOWING_MODE_FULLSCREEN) { // We are using the parent configuration here as this is the most recent one that gets // passed to onConfigurationChanged when a relevant change takes place return info.getMinAspectRatio(); } Loading services/tests/wmtests/src/com/android/server/wm/SizeCompatTests.java +69 −0 Original line number Diff line number Diff line Loading @@ -1639,6 +1639,75 @@ public class SizeCompatTests extends WindowTestsBase { Assert.assertEquals(expectedAspectRatio, afterAspectRatio, 0.001f); } @Test @EnableCompatChanges({ActivityInfo.OVERRIDE_MIN_ASPECT_RATIO, ActivityInfo.OVERRIDE_MIN_ASPECT_RATIO_LARGE, ActivityInfo.OVERRIDE_MIN_ASPECT_RATIO_EXCLUDE_PORTRAIT_FULLSCREEN}) public void testOverrideMinAspectRatioExcludePortraitFullscreen() { setUpDisplaySizeWithApp(2600, 1600); mActivity.mDisplayContent.setIgnoreOrientationRequest(true /* ignoreOrientationRequest */); mActivity.mWmService.mLetterboxConfiguration.setFixedOrientationLetterboxAspectRatio(1.33f); // Create a size compat activity on the same task. final ActivityRecord activity = new ActivityBuilder(mAtm) .setTask(mTask) .setComponent(ComponentName.createRelative(mContext, SizeCompatTests.class.getName())) .setUid(android.os.Process.myUid()) .build(); // Non-resizable portrait activity prepareUnresizable(activity, 0f, ActivityInfo.SCREEN_ORIENTATION_PORTRAIT); // At first, OVERRIDE_MIN_ASPECT_RATIO_PORTRAIT_FULLSCREEN does not apply, because the // display is in landscape assertEquals(1600, activity.getBounds().height()); assertEquals(1600 / ActivityInfo.OVERRIDE_MIN_ASPECT_RATIO_LARGE_VALUE, activity.getBounds().width(), 0.5); rotateDisplay(activity.mDisplayContent, ROTATION_90); prepareUnresizable(activity, /* maxAspect */ 0, SCREEN_ORIENTATION_PORTRAIT); // Now the display is in portrait fullscreen, so the override is applied making the content // fullscreen assertEquals(activity.getBounds(), activity.mDisplayContent.getBounds()); } @Test @EnableCompatChanges({ActivityInfo.OVERRIDE_MIN_ASPECT_RATIO, ActivityInfo.OVERRIDE_MIN_ASPECT_RATIO_LARGE, ActivityInfo.OVERRIDE_MIN_ASPECT_RATIO_EXCLUDE_PORTRAIT_FULLSCREEN}) public void testOverrideMinAspectRatioExcludePortraitFullscreenNotApplied() { // In this test, the activity is not in fullscreen, so the override is not applied setUpDisplaySizeWithApp(2600, 1600); mActivity.mDisplayContent.setIgnoreOrientationRequest(true /* ignoreOrientationRequest */); mActivity.mWmService.mLetterboxConfiguration.setFixedOrientationLetterboxAspectRatio(1.33f); // Create a size compat activity on the same task. final ActivityRecord activity = new ActivityBuilder(mAtm) .setTask(mTask) .setComponent(ComponentName.createRelative(mContext, SizeCompatTests.class.getName())) .setUid(android.os.Process.myUid()) .build(); final TestSplitOrganizer organizer = new TestSplitOrganizer(mAtm, activity.getDisplayContent()); // Move first activity to split screen which takes half of the screen. organizer.mPrimary.setBounds(0, 0, 1300, 1600); organizer.putTaskToPrimary(mTask, true); // Non-resizable portrait activity prepareUnresizable(activity, /* maxAspect */ 0, SCREEN_ORIENTATION_PORTRAIT); // OVERRIDE_MIN_ASPECT_RATIO_PORTRAIT_FULLSCREEN does not apply here because the // display is not in fullscreen, so OVERRIDE_MIN_ASPECT_RATIO_LARGE applies instead assertEquals(1600, activity.getBounds().height()); assertEquals(1600 / ActivityInfo.OVERRIDE_MIN_ASPECT_RATIO_LARGE_VALUE, activity.getBounds().width(), 0.5); } @Test public void testSplitAspectRatioForUnresizableLandscapeApps() { // Set up a display in portrait and ignoring orientation request. Loading Loading
core/api/test-current.txt +1 −0 Original line number Diff line number Diff line Loading @@ -793,6 +793,7 @@ package android.content.pm { field public static final long FORCE_RESIZE_APP = 174042936L; // 0xa5faf38L field public static final long NEVER_SANDBOX_DISPLAY_APIS = 184838306L; // 0xb0468a2L field public static final long OVERRIDE_MIN_ASPECT_RATIO = 174042980L; // 0xa5faf64L field public static final long OVERRIDE_MIN_ASPECT_RATIO_EXCLUDE_PORTRAIT_FULLSCREEN = 218959984L; // 0xd0d1070L field public static final long OVERRIDE_MIN_ASPECT_RATIO_LARGE = 180326787L; // 0xabf9183L field public static final float OVERRIDE_MIN_ASPECT_RATIO_LARGE_VALUE = 1.7777778f; field public static final long OVERRIDE_MIN_ASPECT_RATIO_MEDIUM = 180326845L; // 0xabf91bdL Loading
core/java/android/content/pm/ActivityInfo.java +11 −0 Original line number Diff line number Diff line Loading @@ -1119,6 +1119,17 @@ public class ActivityInfo extends ComponentInfo implements Parcelable { @TestApi public static final long OVERRIDE_MIN_ASPECT_RATIO_TO_ALIGN_WITH_SPLIT_SCREEN = 208648326L; /** * Overrides the min aspect ratio restriction in portrait fullscreen in order to use all * available screen space. * @hide */ @ChangeId @Disabled @Overridable @TestApi public static final long OVERRIDE_MIN_ASPECT_RATIO_EXCLUDE_PORTRAIT_FULLSCREEN = 218959984L; /** * Compares activity window layout min width/height with require space for multi window to * determine if it can be put into multi window mode. Loading
services/core/java/com/android/server/wm/ActivityRecord.java +20 −3 Original line number Diff line number Diff line Loading @@ -79,6 +79,7 @@ import static android.content.pm.ActivityInfo.LOCK_TASK_LAUNCH_MODE_DEFAULT; import static android.content.pm.ActivityInfo.LOCK_TASK_LAUNCH_MODE_IF_ALLOWLISTED; import static android.content.pm.ActivityInfo.LOCK_TASK_LAUNCH_MODE_NEVER; import static android.content.pm.ActivityInfo.OVERRIDE_MIN_ASPECT_RATIO; import static android.content.pm.ActivityInfo.OVERRIDE_MIN_ASPECT_RATIO_EXCLUDE_PORTRAIT_FULLSCREEN; import static android.content.pm.ActivityInfo.OVERRIDE_MIN_ASPECT_RATIO_LARGE; import static android.content.pm.ActivityInfo.OVERRIDE_MIN_ASPECT_RATIO_MEDIUM; import static android.content.pm.ActivityInfo.OVERRIDE_MIN_ASPECT_RATIO_PORTRAIT_ONLY; Loading Loading @@ -8809,9 +8810,25 @@ final class ActivityRecord extends WindowToken implements WindowManagerService.A * Returns the min aspect ratio of this activity. */ float getMinAspectRatio() { if (info.applicationInfo == null || !info.isChangeEnabled(OVERRIDE_MIN_ASPECT_RATIO) || ( info.isChangeEnabled(OVERRIDE_MIN_ASPECT_RATIO_PORTRAIT_ONLY) && !ActivityInfo.isFixedOrientationPortrait(getRequestedOrientation()))) { if (info.applicationInfo == null) { return info.getMinAspectRatio(); } if (!info.isChangeEnabled(OVERRIDE_MIN_ASPECT_RATIO)) { return info.getMinAspectRatio(); } if (info.isChangeEnabled(OVERRIDE_MIN_ASPECT_RATIO_PORTRAIT_ONLY) && !ActivityInfo.isFixedOrientationPortrait(getRequestedOrientation())) { return info.getMinAspectRatio(); } if (info.isChangeEnabled(OVERRIDE_MIN_ASPECT_RATIO_EXCLUDE_PORTRAIT_FULLSCREEN) && getParent().getConfiguration().orientation == ORIENTATION_PORTRAIT && getParent().getWindowConfiguration().getWindowingMode() == WINDOWING_MODE_FULLSCREEN) { // We are using the parent configuration here as this is the most recent one that gets // passed to onConfigurationChanged when a relevant change takes place return info.getMinAspectRatio(); } Loading
services/tests/wmtests/src/com/android/server/wm/SizeCompatTests.java +69 −0 Original line number Diff line number Diff line Loading @@ -1639,6 +1639,75 @@ public class SizeCompatTests extends WindowTestsBase { Assert.assertEquals(expectedAspectRatio, afterAspectRatio, 0.001f); } @Test @EnableCompatChanges({ActivityInfo.OVERRIDE_MIN_ASPECT_RATIO, ActivityInfo.OVERRIDE_MIN_ASPECT_RATIO_LARGE, ActivityInfo.OVERRIDE_MIN_ASPECT_RATIO_EXCLUDE_PORTRAIT_FULLSCREEN}) public void testOverrideMinAspectRatioExcludePortraitFullscreen() { setUpDisplaySizeWithApp(2600, 1600); mActivity.mDisplayContent.setIgnoreOrientationRequest(true /* ignoreOrientationRequest */); mActivity.mWmService.mLetterboxConfiguration.setFixedOrientationLetterboxAspectRatio(1.33f); // Create a size compat activity on the same task. final ActivityRecord activity = new ActivityBuilder(mAtm) .setTask(mTask) .setComponent(ComponentName.createRelative(mContext, SizeCompatTests.class.getName())) .setUid(android.os.Process.myUid()) .build(); // Non-resizable portrait activity prepareUnresizable(activity, 0f, ActivityInfo.SCREEN_ORIENTATION_PORTRAIT); // At first, OVERRIDE_MIN_ASPECT_RATIO_PORTRAIT_FULLSCREEN does not apply, because the // display is in landscape assertEquals(1600, activity.getBounds().height()); assertEquals(1600 / ActivityInfo.OVERRIDE_MIN_ASPECT_RATIO_LARGE_VALUE, activity.getBounds().width(), 0.5); rotateDisplay(activity.mDisplayContent, ROTATION_90); prepareUnresizable(activity, /* maxAspect */ 0, SCREEN_ORIENTATION_PORTRAIT); // Now the display is in portrait fullscreen, so the override is applied making the content // fullscreen assertEquals(activity.getBounds(), activity.mDisplayContent.getBounds()); } @Test @EnableCompatChanges({ActivityInfo.OVERRIDE_MIN_ASPECT_RATIO, ActivityInfo.OVERRIDE_MIN_ASPECT_RATIO_LARGE, ActivityInfo.OVERRIDE_MIN_ASPECT_RATIO_EXCLUDE_PORTRAIT_FULLSCREEN}) public void testOverrideMinAspectRatioExcludePortraitFullscreenNotApplied() { // In this test, the activity is not in fullscreen, so the override is not applied setUpDisplaySizeWithApp(2600, 1600); mActivity.mDisplayContent.setIgnoreOrientationRequest(true /* ignoreOrientationRequest */); mActivity.mWmService.mLetterboxConfiguration.setFixedOrientationLetterboxAspectRatio(1.33f); // Create a size compat activity on the same task. final ActivityRecord activity = new ActivityBuilder(mAtm) .setTask(mTask) .setComponent(ComponentName.createRelative(mContext, SizeCompatTests.class.getName())) .setUid(android.os.Process.myUid()) .build(); final TestSplitOrganizer organizer = new TestSplitOrganizer(mAtm, activity.getDisplayContent()); // Move first activity to split screen which takes half of the screen. organizer.mPrimary.setBounds(0, 0, 1300, 1600); organizer.putTaskToPrimary(mTask, true); // Non-resizable portrait activity prepareUnresizable(activity, /* maxAspect */ 0, SCREEN_ORIENTATION_PORTRAIT); // OVERRIDE_MIN_ASPECT_RATIO_PORTRAIT_FULLSCREEN does not apply here because the // display is not in fullscreen, so OVERRIDE_MIN_ASPECT_RATIO_LARGE applies instead assertEquals(1600, activity.getBounds().height()); assertEquals(1600 / ActivityInfo.OVERRIDE_MIN_ASPECT_RATIO_LARGE_VALUE, activity.getBounds().width(), 0.5); } @Test public void testSplitAspectRatioForUnresizableLandscapeApps() { // Set up a display in portrait and ignoring orientation request. Loading