Reset deferred task removal when app token added.
A task is scheduled for deletion after the final activity has
been removed and has animated away. But if another activity is then
added to the task the deletion flag must be reset.
Also added improved debugging.
Fixes bug 12987986.
Change-Id: I207ea6e9592a9e036d67aa5d1465b4acc5bdd120
diff --git a/services/core/java/com/android/server/wm/Task.java b/services/core/java/com/android/server/wm/Task.java
index 036804c..09c4e20 100644
--- a/services/core/java/com/android/server/wm/Task.java
+++ b/services/core/java/com/android/server/wm/Task.java
@@ -16,11 +16,12 @@
package com.android.server.wm;
+import static com.android.server.wm.WindowManagerService.TAG;
+
import android.util.EventLog;
-import com.android.server.EventLogTags;
+import android.util.Slog;
class Task {
-// private final String TAG = "TaskGroup";
TaskStack mStack;
final AppTokenList mAppTokens = new AppTokenList();
final int taskId;
@@ -39,17 +40,24 @@
}
void addAppToken(int addPos, AppWindowToken wtoken) {
+ final int lastPos = mAppTokens.size();
+ if (addPos > lastPos) {
+ // We lost an app token. Don't crash though.
+ Slog.e(TAG, "Task.addAppToken: Out of bounds attempt token=" + wtoken + " addPos="
+ + addPos + " lastPos=" + lastPos);
+ addPos = lastPos;
+ }
mAppTokens.add(addPos, wtoken);
+ mDeferRemoval = false;
}
boolean removeAppToken(AppWindowToken wtoken) {
- mAppTokens.remove(wtoken);
+ boolean removed = mAppTokens.remove(wtoken);
if (mAppTokens.size() == 0) {
EventLog.writeEvent(com.android.server.EventLogTags.WM_TASK_REMOVED, taskId,
"removeAppToken: last token");
- return true;
}
- return false;
+ return removed;
}
@Override