From 42767054cc9e75ec29ec699fd106cfc3b1f887e1 Mon Sep 17 00:00:00 2001 From: Garfield Tan Date: Wed, 18 Nov 2020 12:26:14 -0800 Subject: [PATCH] Add task visibility to TaskInfo. Bug: 165794880 Test: Task visibility is pushed to WM shell. Change-Id: If518a72c658ffe55b60c82afadfc92b1e7bd2738 --- core/java/android/app/TaskInfo.java | 15 ++++++++++++--- .../core/java/com/android/server/wm/Task.java | 5 +++++ 2 files changed, 17 insertions(+), 3 deletions(-) diff --git a/core/java/android/app/TaskInfo.java b/core/java/android/app/TaskInfo.java index ca67dba45dd05..1a8a4b7f16da0 100644 --- a/core/java/android/app/TaskInfo.java +++ b/core/java/android/app/TaskInfo.java @@ -214,7 +214,6 @@ public class TaskInfo { */ public int parentTaskId; - /** * Parent bounds. * @hide @@ -227,6 +226,12 @@ public class TaskInfo { */ public boolean isFocused; + /** + * Whether this task is visible. + * @hide + */ + public boolean isVisible; + TaskInfo() { // Do nothing } @@ -311,7 +316,8 @@ public class TaskInfo { && pictureInPictureParams == that.pictureInPictureParams && getWindowingMode() == that.getWindowingMode() && Objects.equals(taskDescription, that.taskDescription) - && isFocused == that.isFocused; + && isFocused == that.isFocused + && isVisible == that.isVisible; } private boolean equalsLetterboxParams(TaskInfo that) { @@ -358,6 +364,7 @@ public class TaskInfo { parentTaskId = source.readInt(); parentBounds = source.readTypedObject(Rect.CREATOR); isFocused = source.readBoolean(); + isVisible = source.readBoolean(); } /** @@ -394,6 +401,7 @@ public class TaskInfo { dest.writeInt(parentTaskId); dest.writeTypedObject(parentBounds, flags); dest.writeBoolean(isFocused); + dest.writeBoolean(isVisible); } @Override @@ -413,12 +421,13 @@ public class TaskInfo { + " topActivityType=" + topActivityType + " pictureInPictureParams=" + pictureInPictureParams + " topActivityInfo=" + topActivityInfo - + " launchCookies" + launchCookies + + " launchCookies=" + launchCookies + " letterboxActivityBounds=" + letterboxActivityBounds + " positionInParent=" + positionInParent + " parentTaskId=" + parentTaskId + " parentBounds=" + parentBounds + " isFocused=" + isFocused + + " isVisible=" + isVisible + "}"; } } diff --git a/services/core/java/com/android/server/wm/Task.java b/services/core/java/com/android/server/wm/Task.java index ebf5989d6b559..bde40909d4359 100644 --- a/services/core/java/com/android/server/wm/Task.java +++ b/services/core/java/com/android/server/wm/Task.java @@ -4099,6 +4099,7 @@ class Task extends WindowContainer { ? rootTask.mTaskId : INVALID_TASK_ID; info.isFocused = isFocused(); + info.isVisible = hasVisibleChildren(); } @Nullable PictureInPictureParams getPictureInPictureParams() { @@ -5764,6 +5765,10 @@ class Task extends WindowContainer { starting, configChanges, preserveWindows, notifyClients, userLeaving), true /* traverseTopToBottom */); + // Notify WM shell that task visibilities may have changed + forAllTasks(task -> task.dispatchTaskInfoChangedIfNeeded(/* force */ false), + true /* traverseTopToBottom */); + if (mTranslucentActivityWaiting != null && mUndrawnActivitiesBelowTopTranslucent.isEmpty()) { // Nothing is getting drawn or everything was already visible, don't wait for