Merge "[3/n] Add TaskInfo logic for user aspect ratio settings" into udc-qpr-dev

This commit is contained in:
Massimo Carli
2023-06-27 13:16:16 +00:00
committed by Android (Google) Code Review
3 changed files with 62 additions and 3 deletions

View File

@@ -241,6 +241,18 @@ public class TaskInfo {
*/ */
public boolean isLetterboxDoubleTapEnabled; public boolean isLetterboxDoubleTapEnabled;
/**
* Whether the user aspect ratio settings button is enabled
* @hide
*/
public boolean topActivityEligibleForUserAspectRatioButton;
/**
* Hint about the letterbox state of the top activity.
* @hide
*/
public boolean topActivityBoundsLetterboxed;
/** /**
* Whether the update comes from a letterbox double-tap action from the user or not. * Whether the update comes from a letterbox double-tap action from the user or not.
* @hide * @hide
@@ -460,7 +472,8 @@ public class TaskInfo {
public boolean hasCompatUI() { public boolean hasCompatUI() {
return hasCameraCompatControl() || topActivityInSizeCompat return hasCameraCompatControl() || topActivityInSizeCompat
|| topActivityEligibleForLetterboxEducation || topActivityEligibleForLetterboxEducation
|| isLetterboxDoubleTapEnabled; || isLetterboxDoubleTapEnabled
|| topActivityEligibleForUserAspectRatioButton;
} }
/** /**
@@ -510,6 +523,8 @@ public class TaskInfo {
&& supportsMultiWindow == that.supportsMultiWindow && supportsMultiWindow == that.supportsMultiWindow
&& displayAreaFeatureId == that.displayAreaFeatureId && displayAreaFeatureId == that.displayAreaFeatureId
&& isFromLetterboxDoubleTap == that.isFromLetterboxDoubleTap && isFromLetterboxDoubleTap == that.isFromLetterboxDoubleTap
&& topActivityEligibleForUserAspectRatioButton
== that.topActivityEligibleForUserAspectRatioButton
&& topActivityLetterboxVerticalPosition == that.topActivityLetterboxVerticalPosition && topActivityLetterboxVerticalPosition == that.topActivityLetterboxVerticalPosition
&& topActivityLetterboxWidth == that.topActivityLetterboxWidth && topActivityLetterboxWidth == that.topActivityLetterboxWidth
&& topActivityLetterboxHeight == that.topActivityLetterboxHeight && topActivityLetterboxHeight == that.topActivityLetterboxHeight
@@ -543,6 +558,8 @@ public class TaskInfo {
&& taskId == that.taskId && taskId == that.taskId
&& topActivityInSizeCompat == that.topActivityInSizeCompat && topActivityInSizeCompat == that.topActivityInSizeCompat
&& isFromLetterboxDoubleTap == that.isFromLetterboxDoubleTap && isFromLetterboxDoubleTap == that.isFromLetterboxDoubleTap
&& topActivityEligibleForUserAspectRatioButton
== that.topActivityEligibleForUserAspectRatioButton
&& topActivityEligibleForLetterboxEducation && topActivityEligibleForLetterboxEducation
== that.topActivityEligibleForLetterboxEducation == that.topActivityEligibleForLetterboxEducation
&& topActivityLetterboxVerticalPosition == that.topActivityLetterboxVerticalPosition && topActivityLetterboxVerticalPosition == that.topActivityLetterboxVerticalPosition
@@ -606,6 +623,8 @@ public class TaskInfo {
displayAreaFeatureId = source.readInt(); displayAreaFeatureId = source.readInt();
cameraCompatControlState = source.readInt(); cameraCompatControlState = source.readInt();
isLetterboxDoubleTapEnabled = source.readBoolean(); isLetterboxDoubleTapEnabled = source.readBoolean();
topActivityEligibleForUserAspectRatioButton = source.readBoolean();
topActivityBoundsLetterboxed = source.readBoolean();
isFromLetterboxDoubleTap = source.readBoolean(); isFromLetterboxDoubleTap = source.readBoolean();
topActivityLetterboxVerticalPosition = source.readInt(); topActivityLetterboxVerticalPosition = source.readInt();
topActivityLetterboxHorizontalPosition = source.readInt(); topActivityLetterboxHorizontalPosition = source.readInt();
@@ -660,6 +679,8 @@ public class TaskInfo {
dest.writeInt(displayAreaFeatureId); dest.writeInt(displayAreaFeatureId);
dest.writeInt(cameraCompatControlState); dest.writeInt(cameraCompatControlState);
dest.writeBoolean(isLetterboxDoubleTapEnabled); dest.writeBoolean(isLetterboxDoubleTapEnabled);
dest.writeBoolean(topActivityEligibleForUserAspectRatioButton);
dest.writeBoolean(topActivityBoundsLetterboxed);
dest.writeBoolean(isFromLetterboxDoubleTap); dest.writeBoolean(isFromLetterboxDoubleTap);
dest.writeInt(topActivityLetterboxVerticalPosition); dest.writeInt(topActivityLetterboxVerticalPosition);
dest.writeInt(topActivityLetterboxHorizontalPosition); dest.writeInt(topActivityLetterboxHorizontalPosition);
@@ -701,8 +722,11 @@ public class TaskInfo {
+ " topActivityInSizeCompat=" + topActivityInSizeCompat + " topActivityInSizeCompat=" + topActivityInSizeCompat
+ " topActivityEligibleForLetterboxEducation= " + " topActivityEligibleForLetterboxEducation= "
+ topActivityEligibleForLetterboxEducation + topActivityEligibleForLetterboxEducation
+ " topActivityLetterboxed= " + isLetterboxDoubleTapEnabled + " isLetterboxDoubleTapEnabled= " + isLetterboxDoubleTapEnabled
+ " isFromDoubleTap= " + isFromLetterboxDoubleTap + " topActivityEligibleForUserAspectRatioButton= "
+ topActivityEligibleForUserAspectRatioButton
+ " topActivityBoundsLetterboxed= " + topActivityBoundsLetterboxed
+ " isFromLetterboxDoubleTap= " + isFromLetterboxDoubleTap
+ " topActivityLetterboxVerticalPosition= " + topActivityLetterboxVerticalPosition + " topActivityLetterboxVerticalPosition= " + topActivityLetterboxVerticalPosition
+ " topActivityLetterboxHorizontalPosition= " + " topActivityLetterboxHorizontalPosition= "
+ topActivityLetterboxHorizontalPosition + topActivityLetterboxHorizontalPosition

View File

@@ -3473,6 +3473,11 @@ class Task extends TaskFragment {
top.mLetterboxUiController.getLetterboxPositionForVerticalReachability(); top.mLetterboxUiController.getLetterboxPositionForVerticalReachability();
} }
} }
// User Aspect Ratio Settings is enabled if the app is not in SCM
info.topActivityEligibleForUserAspectRatioButton =
mWmService.mLetterboxConfiguration.isUserAppAspectRatioSettingsEnabled()
&& top != null && !info.topActivityInSizeCompat;
info.topActivityBoundsLetterboxed = top != null && top.areBoundsLetterboxed();
} }
/** /**

View File

@@ -563,6 +563,36 @@ public class TaskTests extends WindowTestsBase {
assertEquals(freeformBounds, task.getBounds()); assertEquals(freeformBounds, task.getBounds());
} }
@Test
public void testTopActivityEligibleForUserAspectRatioButton() {
DisplayContent display = mAtm.mRootWindowContainer.getDefaultDisplay();
final Task rootTask = new TaskBuilder(mSupervisor).setCreateActivity(true)
.setWindowingMode(WINDOWING_MODE_FULLSCREEN).setDisplay(display).build();
final Task task = rootTask.getBottomMostTask();
final ActivityRecord root = task.getTopNonFinishingActivity();
spyOn(mWm.mLetterboxConfiguration);
// When device config flag is disabled the button is not enabled
doReturn(false).when(mWm.mLetterboxConfiguration)
.isUserAppAspectRatioSettingsEnabled();
doReturn(false).when(mWm.mLetterboxConfiguration)
.isTranslucentLetterboxingEnabled();
assertFalse(task.getTaskInfo().topActivityEligibleForUserAspectRatioButton);
// The flag is enabled
doReturn(true).when(mWm.mLetterboxConfiguration)
.isUserAppAspectRatioSettingsEnabled();
spyOn(root);
doReturn(task).when(root).getOrganizedTask();
// When the flag is enabled and the top activity is not in size compat mode.
doReturn(false).when(root).inSizeCompatMode();
assertTrue(task.getTaskInfo().topActivityEligibleForUserAspectRatioButton);
// When in size compat mode the button is not enabled
doReturn(true).when(root).inSizeCompatMode();
assertFalse(task.getTaskInfo().topActivityEligibleForUserAspectRatioButton);
}
/** /**
* Tests that a task with forced orientation has orientation-consistent bounds within the * Tests that a task with forced orientation has orientation-consistent bounds within the
* parent. * parent.