[3/n] Add TaskInfo logic for user aspect ratio settings
Defines the logic for the visualization of the user aspect ratio settings button. The button should be displayed when the top activity is not in size compat mode. It must also be guarded by the related flag. Fix: 287448081 Test: Run `atest WmTests:TaskTests` Change-Id: Id4840abeaed617fed567e36a9cd37360a5cdb8ef
This commit is contained in:
@@ -241,6 +241,18 @@ public class TaskInfo {
|
||||
*/
|
||||
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.
|
||||
* @hide
|
||||
@@ -460,7 +472,8 @@ public class TaskInfo {
|
||||
public boolean hasCompatUI() {
|
||||
return hasCameraCompatControl() || topActivityInSizeCompat
|
||||
|| topActivityEligibleForLetterboxEducation
|
||||
|| isLetterboxDoubleTapEnabled;
|
||||
|| isLetterboxDoubleTapEnabled
|
||||
|| topActivityEligibleForUserAspectRatioButton;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -510,6 +523,8 @@ public class TaskInfo {
|
||||
&& supportsMultiWindow == that.supportsMultiWindow
|
||||
&& displayAreaFeatureId == that.displayAreaFeatureId
|
||||
&& isFromLetterboxDoubleTap == that.isFromLetterboxDoubleTap
|
||||
&& topActivityEligibleForUserAspectRatioButton
|
||||
== that.topActivityEligibleForUserAspectRatioButton
|
||||
&& topActivityLetterboxVerticalPosition == that.topActivityLetterboxVerticalPosition
|
||||
&& topActivityLetterboxWidth == that.topActivityLetterboxWidth
|
||||
&& topActivityLetterboxHeight == that.topActivityLetterboxHeight
|
||||
@@ -543,6 +558,8 @@ public class TaskInfo {
|
||||
&& taskId == that.taskId
|
||||
&& topActivityInSizeCompat == that.topActivityInSizeCompat
|
||||
&& isFromLetterboxDoubleTap == that.isFromLetterboxDoubleTap
|
||||
&& topActivityEligibleForUserAspectRatioButton
|
||||
== that.topActivityEligibleForUserAspectRatioButton
|
||||
&& topActivityEligibleForLetterboxEducation
|
||||
== that.topActivityEligibleForLetterboxEducation
|
||||
&& topActivityLetterboxVerticalPosition == that.topActivityLetterboxVerticalPosition
|
||||
@@ -606,6 +623,8 @@ public class TaskInfo {
|
||||
displayAreaFeatureId = source.readInt();
|
||||
cameraCompatControlState = source.readInt();
|
||||
isLetterboxDoubleTapEnabled = source.readBoolean();
|
||||
topActivityEligibleForUserAspectRatioButton = source.readBoolean();
|
||||
topActivityBoundsLetterboxed = source.readBoolean();
|
||||
isFromLetterboxDoubleTap = source.readBoolean();
|
||||
topActivityLetterboxVerticalPosition = source.readInt();
|
||||
topActivityLetterboxHorizontalPosition = source.readInt();
|
||||
@@ -660,6 +679,8 @@ public class TaskInfo {
|
||||
dest.writeInt(displayAreaFeatureId);
|
||||
dest.writeInt(cameraCompatControlState);
|
||||
dest.writeBoolean(isLetterboxDoubleTapEnabled);
|
||||
dest.writeBoolean(topActivityEligibleForUserAspectRatioButton);
|
||||
dest.writeBoolean(topActivityBoundsLetterboxed);
|
||||
dest.writeBoolean(isFromLetterboxDoubleTap);
|
||||
dest.writeInt(topActivityLetterboxVerticalPosition);
|
||||
dest.writeInt(topActivityLetterboxHorizontalPosition);
|
||||
@@ -701,8 +722,11 @@ public class TaskInfo {
|
||||
+ " topActivityInSizeCompat=" + topActivityInSizeCompat
|
||||
+ " topActivityEligibleForLetterboxEducation= "
|
||||
+ topActivityEligibleForLetterboxEducation
|
||||
+ " topActivityLetterboxed= " + isLetterboxDoubleTapEnabled
|
||||
+ " isFromDoubleTap= " + isFromLetterboxDoubleTap
|
||||
+ " isLetterboxDoubleTapEnabled= " + isLetterboxDoubleTapEnabled
|
||||
+ " topActivityEligibleForUserAspectRatioButton= "
|
||||
+ topActivityEligibleForUserAspectRatioButton
|
||||
+ " topActivityBoundsLetterboxed= " + topActivityBoundsLetterboxed
|
||||
+ " isFromLetterboxDoubleTap= " + isFromLetterboxDoubleTap
|
||||
+ " topActivityLetterboxVerticalPosition= " + topActivityLetterboxVerticalPosition
|
||||
+ " topActivityLetterboxHorizontalPosition= "
|
||||
+ topActivityLetterboxHorizontalPosition
|
||||
|
||||
@@ -3473,6 +3473,11 @@ class Task extends TaskFragment {
|
||||
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();
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -563,6 +563,36 @@ public class TaskTests extends WindowTestsBase {
|
||||
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
|
||||
* parent.
|
||||
|
||||
Reference in New Issue
Block a user