Move some logic of removeTask() into TaskRecord.
Follow up from 891146c6a6e40f40d9e9ca34378389a5aa6a53a7 to move some
logic into TaskRecord.
It removes seemingly unnecessary onActivityRemovedFromStack(), and also
encapsulates mLRUActivities into ActivityStack itself by moving stack
dump logic into ActivityStack.
Bug: 119259346
Test: Unit tests pass. go/wm-smoke. dumpsys activity activities doesn't
change.
Change-Id: Ic76fe64afd048a4fb489fd76125d072d4432da07
diff --git a/services/core/java/com/android/server/wm/TaskRecord.java b/services/core/java/com/android/server/wm/TaskRecord.java
index 8c80009..f1b0c0696 100644
--- a/services/core/java/com/android/server/wm/TaskRecord.java
+++ b/services/core/java/com/android/server/wm/TaskRecord.java
@@ -481,6 +481,32 @@
mTask = task;
}
+ void cleanUpResourcesForDestroy() {
+ if (!mActivities.isEmpty()) {
+ return;
+ }
+
+ // This task is going away, so save the last state if necessary.
+ saveLaunchingStateIfNeeded();
+
+ // TODO: VI what about activity?
+ final boolean isVoiceSession = voiceSession != null;
+ if (isVoiceSession) {
+ try {
+ voiceSession.taskFinished(intent, taskId);
+ } catch (RemoteException e) {
+ }
+ }
+ if (autoRemoveFromRecents() || isVoiceSession) {
+ // Task creator asked to remove this when done, or this task was a voice
+ // interaction, so it should not remain on the recent tasks list.
+ mService.mStackSupervisor.mRecentTasks.remove(this);
+ }
+
+ removeWindowContainer();
+ }
+
+ @VisibleForTesting
void removeWindowContainer() {
mService.getLockTaskController().clearLockedTask(this);
if (mTask == null) {