Merge "Adjust aspect ratio override portrait fullscreen" into tm-qpr-dev
This commit is contained in:
committed by
Android (Google) Code Review
commit
5ba309cce6
@@ -1118,6 +1118,16 @@ public class ActivityInfo extends ComponentInfo implements Parcelable {
|
||||
@Overridable
|
||||
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
|
||||
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.
|
||||
|
||||
@@ -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;
|
||||
@@ -8818,9 +8819,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();
|
||||
}
|
||||
|
||||
|
||||
@@ -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.
|
||||
|
||||
Reference in New Issue
Block a user