summaryrefslogtreecommitdiff
path: root/core/java/android
diff options
context:
space:
mode:
authorWinson Chung <winsonc@google.com>2021-02-07 15:56:45 -0800
committerWinson Chung <winsonc@google.com>2021-02-09 22:10:10 -0800
commit71718ad74877cdec81e73cf059101ae5658226e7 (patch)
tree6aed29363273eed5f5f096ba498c30293bd99475 /core/java/android
parent573555ffa8ca7689e3a7449c6641a665843f95b8 (diff)
Save and pass last snapshot data with recents task info
- Adds task & snapshot sizing info to RecentTaskInfo so that SysUI can stably layout overview when there are tasks of different sizes - Removing some unused code Bug: 179466077 Test: atest WmTests:RecentTasksTest Change-Id: Idf4c27e2d04380328413459fc537ff8bcc111a14
Diffstat (limited to 'core/java/android')
-rw-r--r--core/java/android/app/ActivityManager.java78
-rw-r--r--core/java/android/app/TaskInfo.java11
2 files changed, 78 insertions, 11 deletions
diff --git a/core/java/android/app/ActivityManager.java b/core/java/android/app/ActivityManager.java
index 43d0269beae2..e2426d116319 100644
--- a/core/java/android/app/ActivityManager.java
+++ b/core/java/android/app/ActivityManager.java
@@ -50,7 +50,9 @@ import android.graphics.Canvas;
import android.graphics.Color;
import android.graphics.Matrix;
import android.graphics.Point;
+import android.graphics.Rect;
import android.graphics.drawable.Icon;
+import android.hardware.HardwareBuffer;
import android.os.BatteryStats;
import android.os.Binder;
import android.os.Build;
@@ -76,6 +78,7 @@ import android.util.Singleton;
import android.util.Size;
import android.util.TypedXmlPullParser;
import android.util.TypedXmlSerializer;
+import android.window.TaskSnapshot;
import com.android.internal.app.LocalePicker;
import com.android.internal.app.procstats.ProcessStats;
@@ -1740,6 +1743,62 @@ public class ActivityManager {
*/
public static class RecentTaskInfo extends TaskInfo implements Parcelable {
/**
+ * @hide
+ */
+ public static class PersistedTaskSnapshotData {
+ /**
+ * The bounds of the task when the last snapshot was taken, may be null if the task is
+ * not yet attached to the hierarchy.
+ * @see {@link android.window.TaskSnapshot#mTaskSize}.
+ * @hide
+ */
+ public @Nullable Point taskSize;
+
+ /**
+ * The content insets of the task when the task snapshot was taken.
+ * @see {@link android.window.TaskSnapshot#mContentInsets}.
+ * @hide
+ */
+ public @Nullable Rect contentInsets;
+
+ /**
+ * The size of the last snapshot taken, may be null if there is no associated snapshot.
+ * @see {@link android.window.TaskSnapshot#mSnapshot}.
+ * @hide
+ */
+ public @Nullable Point bufferSize;
+
+ /**
+ * Sets the data from the other data.
+ * @hide
+ */
+ public void set(PersistedTaskSnapshotData other) {
+ taskSize = other.taskSize;
+ contentInsets = other.contentInsets;
+ bufferSize = other.bufferSize;
+ }
+
+ /**
+ * Sets the data from the provided {@param snapshot}.
+ * @hide
+ */
+ public void set(TaskSnapshot snapshot) {
+ if (snapshot == null) {
+ taskSize = null;
+ contentInsets = null;
+ bufferSize = null;
+ return;
+ }
+ final HardwareBuffer buffer = snapshot.getHardwareBuffer();
+ taskSize = new Point(snapshot.getTaskSize());
+ contentInsets = new Rect(snapshot.getContentInsets());
+ bufferSize = buffer != null
+ ? new Point(buffer.getWidth(), buffer.getHeight())
+ : null;
+ }
+ }
+
+ /**
* If this task is currently running, this is the identifier for it.
* If it is not running, this will be -1.
*
@@ -1782,6 +1841,12 @@ public class ActivityManager {
*/
public ArrayList<RecentTaskInfo> childrenTaskInfos = new ArrayList<>();
+ /**
+ * Information about the last snapshot taken for this task.
+ * @hide
+ */
+ public PersistedTaskSnapshotData lastSnapshotData = new PersistedTaskSnapshotData();
+
public RecentTaskInfo() {
}
@@ -1798,6 +1863,9 @@ public class ActivityManager {
id = source.readInt();
persistentId = source.readInt();
childrenTaskInfos = source.readArrayList(RecentTaskInfo.class.getClassLoader());
+ lastSnapshotData.taskSize = source.readTypedObject(Point.CREATOR);
+ lastSnapshotData.contentInsets = source.readTypedObject(Rect.CREATOR);
+ lastSnapshotData.bufferSize = source.readTypedObject(Point.CREATOR);
super.readFromParcel(source);
}
@@ -1806,6 +1874,9 @@ public class ActivityManager {
dest.writeInt(id);
dest.writeInt(persistentId);
dest.writeList(childrenTaskInfos);
+ dest.writeTypedObject(lastSnapshotData.taskSize, flags);
+ dest.writeTypedObject(lastSnapshotData.contentInsets, flags);
+ dest.writeTypedObject(lastSnapshotData.bufferSize, flags);
super.writeToParcel(dest, flags);
}
@@ -1825,7 +1896,6 @@ public class ActivityManager {
public void dump(PrintWriter pw, String indent) {
pw.println(); pw.print(" ");
pw.print(" id="); pw.print(persistentId);
- pw.print(" stackId="); pw.print(stackId);
pw.print(" userId="); pw.print(userId);
pw.print(" hasTask="); pw.print((id != -1));
pw.print(" lastActiveTime="); pw.println(lastActiveTime);
@@ -1872,6 +1942,12 @@ public class ActivityManager {
pw.print(Integer.toHexString(td.getBackgroundColorFloating()));
pw.println(" }");
}
+ pw.print(" ");
+ pw.print(" lastSnapshotData {");
+ pw.print(" taskSize=" + lastSnapshotData.taskSize);
+ pw.print(" contentInsets=" + lastSnapshotData.contentInsets);
+ pw.print(" bufferSize=" + lastSnapshotData.bufferSize);
+ pw.println(" }");
}
}
diff --git a/core/java/android/app/TaskInfo.java b/core/java/android/app/TaskInfo.java
index 390d9219ef2a..938ce0d56933 100644
--- a/core/java/android/app/TaskInfo.java
+++ b/core/java/android/app/TaskInfo.java
@@ -53,13 +53,6 @@ public class TaskInfo {
public int userId;
/**
- * The id of the ActivityStack that currently contains this task.
- * @hide
- */
- @UnsupportedAppUsage
- public int stackId;
-
- /**
* The identifier for this task.
*/
public int taskId;
@@ -358,7 +351,6 @@ public class TaskInfo {
*/
void readFromParcel(Parcel source) {
userId = source.readInt();
- stackId = source.readInt();
taskId = source.readInt();
displayId = source.readInt();
isRunning = source.readBoolean();
@@ -394,7 +386,6 @@ public class TaskInfo {
*/
void writeToParcel(Parcel dest, int flags) {
dest.writeInt(userId);
- dest.writeInt(stackId);
dest.writeInt(taskId);
dest.writeInt(displayId);
dest.writeBoolean(isRunning);
@@ -428,7 +419,7 @@ public class TaskInfo {
@Override
public String toString() {
- return "TaskInfo{userId=" + userId + " stackId=" + stackId + " taskId=" + taskId
+ return "TaskInfo{userId=" + userId + " taskId=" + taskId
+ " displayId=" + displayId
+ " isRunning=" + isRunning
+ " baseIntent=" + baseIntent + " baseActivity=" + baseActivity