Don't remove active stacks from window manager
Background:
In ag/406771 we stopped deleting empty stacks in activity manager
and window manager. This fixed a problem where dormant tasks were
being added back to stacks later.
In ag/476888 we introduced a callback to inform the ActivityView
holder that the embedded task was complete. This callback was made
from the new method ActivityContainer.onTaskListEmpty().
In ag/483035 onTaskListEmpty() was expanded to detach the stack of the
ActivityView and also removed the stack from window manager. There
was a mistake in that CL that causes it to remove any non-home stacks,
not just ones in ActivityViews.
That mistake left us with an empty stack in activity manager and no
corresponding stack in window manager. As a result, when trying to
bring back a task that used to be in this stack window manager threw
up an exception.
This fix limits the stacks detached by onTaskListEmpty() to those
on VirtualDisplays.
Fixes bug 17469145.
Change-Id: I85a4452e8e85625e657d88e4cb9f366fd4026441
diff --git a/services/core/java/com/android/server/am/ActivityStackSupervisor.java b/services/core/java/com/android/server/am/ActivityStackSupervisor.java
index 4940493..c8b8b92 100644
--- a/services/core/java/com/android/server/am/ActivityStackSupervisor.java
+++ b/services/core/java/com/android/server/am/ActivityStackSupervisor.java
@@ -3673,7 +3673,7 @@
}
}
- private void detachLocked() {
+ protected void detachLocked() {
if (DEBUG_STACK) Slog.d(TAG, "detachLocked: " + this + " from display="
+ mActivityDisplay + " Callers=" + Debug.getCallers(2));
if (mActivityDisplay != null) {
@@ -3797,12 +3797,6 @@
}
void onTaskListEmptyLocked() {
- mHandler.removeMessages(CONTAINER_TASK_LIST_EMPTY_TIMEOUT, this);
- if (!mStack.isHomeStack()) {
- detachLocked();
- deleteActivityContainer(this);
- }
- mHandler.obtainMessage(CONTAINER_CALLBACK_TASK_LIST_EMPTY, this).sendToTarget();
}
@Override
@@ -3891,6 +3885,13 @@
return false;
}
+ void onTaskListEmptyLocked() {
+ mHandler.removeMessages(CONTAINER_TASK_LIST_EMPTY_TIMEOUT, this);
+ detachLocked();
+ deleteActivityContainer(this);
+ mHandler.obtainMessage(CONTAINER_CALLBACK_TASK_LIST_EMPTY, this).sendToTarget();
+ }
+
private void setSurfaceIfReadyLocked() {
if (DEBUG_STACK) Slog.v(TAG, "setSurfaceIfReadyLocked: mDrawn=" + mDrawn +
" mContainerState=" + mContainerState + " mSurface=" + mSurface);