summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author Massimo Carli <mcarli@google.com> 2023-06-27 13:16:16 +0000
committer Android (Google) Code Review <android-gerrit@google.com> 2023-06-27 13:16:16 +0000
commita5130e3803cc68805e98045bc14d59e173f66326 (patch)
treecca26696a5df677b2c1d19c92f2b4efb3f6d07a0
parent0bc973eb333f7766e0a5c9a994390b4261228c99 (diff)
parent6763dc84810a864dab8e308b098a168e0da90738 (diff)
Merge "[3/n] Add TaskInfo logic for user aspect ratio settings" into udc-qpr-dev
-rw-r--r--core/java/android/app/TaskInfo.java30
-rw-r--r--services/core/java/com/android/server/wm/Task.java5
-rw-r--r--services/tests/wmtests/src/com/android/server/wm/TaskTests.java30
3 files changed, 62 insertions, 3 deletions
diff --git a/core/java/android/app/TaskInfo.java b/core/java/android/app/TaskInfo.java
index c4e49954f745..2b5175ca6659 100644
--- a/core/java/android/app/TaskInfo.java
+++ b/core/java/android/app/TaskInfo.java
@@ -242,6 +242,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
diff --git a/services/core/java/com/android/server/wm/Task.java b/services/core/java/com/android/server/wm/Task.java
index 39772dda4792..9c23beb21a92 100644
--- a/services/core/java/com/android/server/wm/Task.java
+++ b/services/core/java/com/android/server/wm/Task.java
@@ -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();
}
/**
diff --git a/services/tests/wmtests/src/com/android/server/wm/TaskTests.java b/services/tests/wmtests/src/com/android/server/wm/TaskTests.java
index 28241d30e168..f332b6988da0 100644
--- a/services/tests/wmtests/src/com/android/server/wm/TaskTests.java
+++ b/services/tests/wmtests/src/com/android/server/wm/TaskTests.java
@@ -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.