Retain stacks even if they are empty.
Previously stacks would be removed when the last ActivityRecord was
removed. This causes problems for ActivityContainers which persist and
permit activities to be launched into an empty stack.
Change-Id: Ia79ac65d17c42eff3a7b1321980c21b29996001b
diff --git a/services/core/java/com/android/server/am/ActivityStack.java b/services/core/java/com/android/server/am/ActivityStack.java
index 5cb0b31..114fe34 100644
--- a/services/core/java/com/android/server/am/ActivityStack.java
+++ b/services/core/java/com/android/server/am/ActivityStack.java
@@ -2674,7 +2674,7 @@
r.finishLaunchTickingLocked();
}
- final void removeActivityFromHistoryLocked(ActivityRecord r) {
+ private void removeActivityFromHistoryLocked(ActivityRecord r) {
finishActivityResultsLocked(r, Activity.RESULT_CANCELED, null);
r.makeFinishing();
if (DEBUG_ADD_REMOVE) {
@@ -2689,7 +2689,7 @@
if (mStackSupervisor.isFrontStack(this) && task == topTask() && task.mOnTopOfHome) {
mStackSupervisor.moveHomeToTop();
}
- mStackSupervisor.removeTask(task);
+ removeTask(task);
}
r.takeFromHistory();
removeTimeoutsForActivityLocked(r);
@@ -3596,14 +3596,28 @@
return starting;
}
- boolean removeTask(TaskRecord task) {
+ void removeTask(TaskRecord task) {
+ mWindowManager.removeTask(task.taskId);
+ final ActivityRecord r = mResumedActivity;
+ if (r != null && r.task == task) {
+ mResumedActivity = null;
+ }
+
final int taskNdx = mTaskHistory.indexOf(task);
final int topTaskNdx = mTaskHistory.size() - 1;
if (task.mOnTopOfHome && taskNdx < topTaskNdx) {
mTaskHistory.get(taskNdx + 1).mOnTopOfHome = true;
}
mTaskHistory.remove(task);
- return mTaskHistory.isEmpty();
+
+ if (mTaskHistory.isEmpty()) {
+ if (DEBUG_STACK) Slog.i(TAG, "removeTask: moving to back stack=" + this);
+ if (isOnHomeDisplay()) {
+ mStackSupervisor.moveHomeStack(!isHomeStack());
+ }
+ mStacks.remove(this);
+ mStacks.add(0, this);
+ }
}
TaskRecord createTaskRecord(int taskId, ActivityInfo info, Intent intent, boolean toTop) {