Merge "[2/n] Optimize user aspect ratio button heuristic" into udc-qpr-dev am: 54234feac1 am: 2b2a3ff22c
Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/24758989
Change-Id: I243ae510691716f48ea6f5f2a11dec1f554ae71a
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
diff --git a/core/java/android/app/TaskInfo.java b/core/java/android/app/TaskInfo.java
index 4957c3e..5f8b765 100644
--- a/core/java/android/app/TaskInfo.java
+++ b/core/java/android/app/TaskInfo.java
@@ -255,6 +255,12 @@
public boolean isUserFullscreenOverrideEnabled;
/**
+ * Whether the top activity fillsParent() is false
+ * @hide
+ */
+ public boolean isTopActivityTransparent;
+
+ /**
* Hint about the letterbox state of the top activity.
* @hide
*/
@@ -551,7 +557,8 @@
&& Objects.equals(mTopActivityLocusId, that.mTopActivityLocusId)
&& parentTaskId == that.parentTaskId
&& Objects.equals(topActivity, that.topActivity)
- && isUserFullscreenOverrideEnabled == that.isUserFullscreenOverrideEnabled;
+ && isUserFullscreenOverrideEnabled == that.isUserFullscreenOverrideEnabled
+ && isTopActivityTransparent == that.isTopActivityTransparent;
}
/**
@@ -584,7 +591,8 @@
&& (!hasCompatUI() || configuration.uiMode == that.configuration.uiMode)
&& (!hasCompatUI() || isVisible == that.isVisible)
&& isFocused == that.isFocused
- && isUserFullscreenOverrideEnabled == that.isUserFullscreenOverrideEnabled;
+ && isUserFullscreenOverrideEnabled == that.isUserFullscreenOverrideEnabled
+ && isTopActivityTransparent == that.isTopActivityTransparent;
}
/**
@@ -641,6 +649,7 @@
topActivityLetterboxWidth = source.readInt();
topActivityLetterboxHeight = source.readInt();
isUserFullscreenOverrideEnabled = source.readBoolean();
+ isTopActivityTransparent = source.readBoolean();
}
/**
@@ -698,6 +707,7 @@
dest.writeInt(topActivityLetterboxWidth);
dest.writeInt(topActivityLetterboxHeight);
dest.writeBoolean(isUserFullscreenOverrideEnabled);
+ dest.writeBoolean(isTopActivityTransparent);
}
@Override
@@ -745,6 +755,7 @@
+ " topActivityLetterboxWidth=" + topActivityLetterboxWidth
+ " topActivityLetterboxHeight=" + topActivityLetterboxHeight
+ " isUserFullscreenOverrideEnabled=" + isUserFullscreenOverrideEnabled
+ + " isTopActivityTransparent=" + isTopActivityTransparent
+ " locusId=" + mTopActivityLocusId
+ " displayAreaFeatureId=" + displayAreaFeatureId
+ " cameraCompatControlState="
diff --git a/libs/WindowManager/Shell/src/com/android/wm/shell/compatui/CompatUIController.java b/libs/WindowManager/Shell/src/com/android/wm/shell/compatui/CompatUIController.java
index 9760350..953efa7 100644
--- a/libs/WindowManager/Shell/src/com/android/wm/shell/compatui/CompatUIController.java
+++ b/libs/WindowManager/Shell/src/com/android/wm/shell/compatui/CompatUIController.java
@@ -348,7 +348,8 @@
// as they are still relevant. Else, if the activity is visible and focused (the one the
// user can see and is using), the user aspect ratio button can potentially be displayed so
// start tracking the buttons visibility for this task.
- if (mTopActivityTaskId != taskInfo.taskId && taskInfo.isVisible && taskInfo.isFocused) {
+ if (mTopActivityTaskId != taskInfo.taskId && !taskInfo.isTopActivityTransparent
+ && taskInfo.isVisible && taskInfo.isFocused) {
mTopActivityTaskId = taskInfo.taskId;
setHasShownUserAspectRatioSettingsButton(false);
}
diff --git a/libs/WindowManager/Shell/tests/unittest/src/com/android/wm/shell/compatui/CompatUIControllerTest.java b/libs/WindowManager/Shell/tests/unittest/src/com/android/wm/shell/compatui/CompatUIControllerTest.java
index 3e0c853..f85d707 100644
--- a/libs/WindowManager/Shell/tests/unittest/src/com/android/wm/shell/compatui/CompatUIControllerTest.java
+++ b/libs/WindowManager/Shell/tests/unittest/src/com/android/wm/shell/compatui/CompatUIControllerTest.java
@@ -633,15 +633,58 @@
Assert.assertTrue(mController.hasShownUserAspectRatioSettingsButton());
}
+ @Test
+ public void testUpdateActiveTaskInfo_transparentTask_notUpdated() {
+ // Create new task
+ final TaskInfo taskInfo = createTaskInfo(DISPLAY_ID, TASK_ID,
+ /* hasSizeCompat= */ true, CAMERA_COMPAT_CONTROL_HIDDEN, /* isVisible */ true,
+ /* isFocused */ true);
+
+ // Simulate new task being shown
+ mController.updateActiveTaskInfo(taskInfo);
+
+ // Check topActivityTaskId is updated to the taskId of the new task and
+ // hasShownUserAspectRatioSettingsButton has been reset to false
+ Assert.assertEquals(TASK_ID, mController.getTopActivityTaskId());
+ Assert.assertFalse(mController.hasShownUserAspectRatioSettingsButton());
+
+ // Simulate user aspect ratio button being shown
+ mController.setHasShownUserAspectRatioSettingsButton(true);
+ Assert.assertTrue(mController.hasShownUserAspectRatioSettingsButton());
+
+ final int newTaskId = TASK_ID + 1;
+
+ // Create transparent task
+ final TaskInfo taskInfo1 = createTaskInfo(DISPLAY_ID, newTaskId,
+ /* hasSizeCompat= */ true, CAMERA_COMPAT_CONTROL_HIDDEN, /* isVisible */ true,
+ /* isFocused */ true, /* isTopActivityTransparent */ true);
+
+ // Simulate new task being shown
+ mController.updateActiveTaskInfo(taskInfo1);
+
+ // Check topActivityTaskId is NOT updated and hasShownUserAspectRatioSettingsButton
+ // remains true
+ Assert.assertEquals(TASK_ID, mController.getTopActivityTaskId());
+ Assert.assertTrue(mController.hasShownUserAspectRatioSettingsButton());
+ }
+
private static TaskInfo createTaskInfo(int displayId, int taskId, boolean hasSizeCompat,
@CameraCompatControlState int cameraCompatControlState) {
return createTaskInfo(displayId, taskId, hasSizeCompat, cameraCompatControlState,
- /* isVisible */ false, /* isFocused */ false);
+ /* isVisible */ false, /* isFocused */ false,
+ /* isTopActivityTransparent */ false);
}
private static TaskInfo createTaskInfo(int displayId, int taskId, boolean hasSizeCompat,
@CameraCompatControlState int cameraCompatControlState, boolean isVisible,
boolean isFocused) {
+ return createTaskInfo(displayId, taskId, hasSizeCompat, cameraCompatControlState,
+ isVisible, isFocused, /* isTopActivityTransparent */ false);
+ }
+
+ private static TaskInfo createTaskInfo(int displayId, int taskId, boolean hasSizeCompat,
+ @CameraCompatControlState int cameraCompatControlState, boolean isVisible,
+ boolean isFocused, boolean isTopActivityTransparent) {
RunningTaskInfo taskInfo = new RunningTaskInfo();
taskInfo.taskId = taskId;
taskInfo.displayId = displayId;
@@ -649,6 +692,7 @@
taskInfo.cameraCompatControlState = cameraCompatControlState;
taskInfo.isVisible = isVisible;
taskInfo.isFocused = isFocused;
+ taskInfo.isTopActivityTransparent = isTopActivityTransparent;
return taskInfo;
}
}
diff --git a/services/core/java/com/android/server/wm/Task.java b/services/core/java/com/android/server/wm/Task.java
index b4b8a74..261fc2e 100644
--- a/services/core/java/com/android/server/wm/Task.java
+++ b/services/core/java/com/android/server/wm/Task.java
@@ -3494,6 +3494,7 @@
info.topActivityLetterboxHeight = TaskInfo.PROPERTY_VALUE_UNSET;
info.isUserFullscreenOverrideEnabled = top != null
&& top.mLetterboxUiController.shouldApplyUserFullscreenOverride();
+ info.isTopActivityTransparent = top != null && !top.fillsParent();
info.isFromLetterboxDoubleTap = top != null && top.mLetterboxUiController.isFromDoubleTap();
if (info.isLetterboxDoubleTapEnabled) {
info.topActivityLetterboxWidth = top.getBounds().width();