Consolidate RecentTaskInfo and RunningTaskInfo into TaskInfo class
- Remove overlapping logic for building both recent/running task infos
- Deprecate unused members of recent/running task infos
- Skip creating unnecessary recent task info when creating AppTaskImpl
Bug: 111078814
Test: Build and open Overview (ensure it still works)
Test: atest CtsAppTestCases:ActivityManagerRecentTaskInfoTest
Test: atest CtsAppTestCases:ActivityManagerRunningTaskInfoTest
Change-Id: Iaf1731002196bb89319de141a05ab92a7dcb2928
diff --git a/services/core/java/com/android/server/am/TaskRecord.java b/services/core/java/com/android/server/am/TaskRecord.java
index 05869bb..7d0672d 100644
--- a/services/core/java/com/android/server/am/TaskRecord.java
+++ b/services/core/java/com/android/server/am/TaskRecord.java
@@ -88,6 +88,7 @@
import android.app.ActivityTaskManager;
import android.app.AppGlobals;
import android.app.IActivityManager;
+import android.app.TaskInfo;
import android.content.ComponentName;
import android.content.Intent;
import android.content.pm.ActivityInfo;
@@ -1939,6 +1940,35 @@
}
}
+ /**
+ * Fills in a {@link TaskInfo} with information from this task.
+ * @param info the {@link TaskInfo} to fill in
+ * @param reuseActivitiesReport a temporary activities report that we can reuse to fetch the
+ * running activities
+ */
+ void fillTaskInfo(TaskInfo info, TaskActivitiesReport reuseActivitiesReport) {
+ getNumRunningActivities(reuseActivitiesReport);
+ info.userId = userId;
+ info.stackId = getStackId();
+ info.taskId = taskId;
+ info.isRunning = getTopActivity() != null;
+ info.baseIntent = getBaseIntent();
+ info.baseActivity = reuseActivitiesReport.base != null
+ ? reuseActivitiesReport.base.intent.getComponent()
+ : null;
+ info.topActivity = reuseActivitiesReport.top != null
+ ? reuseActivitiesReport.top.intent.getComponent()
+ : null;
+ info.origActivity = origActivity;
+ info.realActivity = realActivity;
+ info.numActivities = reuseActivitiesReport.numActivities;
+ info.lastActiveTime = lastActiveTime;
+ info.taskDescription = new ActivityManager.TaskDescription(lastTaskDescription);
+ info.supportsSplitScreenMultiWindow = supportsSplitScreenWindowingMode();
+ info.resizeMode = mResizeMode;
+ info.configuration.setTo(getConfiguration());
+ }
+
void dump(PrintWriter pw, String prefix) {
pw.print(prefix); pw.print("userId="); pw.print(userId);
pw.print(" effectiveUid="); UserHandle.formatUid(pw, effectiveUid);