summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorCraig Mautner <cmautner@google.com>2013-02-21 20:00:58 -0800
committerCraig Mautner <cmautner@google.com>2013-02-21 20:00:58 -0800
commitb44de0d910a3ec22b9963e538117e257f621de47 (patch)
treec144d5debdc96bfb3826dec18b1f932b24c16c18
parent7a7360ad528576d560aa13fbb4e81740b2c425b2 (diff)
downloadframeworks_base-b44de0d910a3ec22b9963e538117e257f621de47.zip
frameworks_base-b44de0d910a3ec22b9963e538117e257f621de47.tar.gz
frameworks_base-b44de0d910a3ec22b9963e538117e257f621de47.tar.bz2
Update histories simultaneously.
In moveTaskToBackLocked calls that used mHistory were being made between the times that mTaskHistory and mHistory were modified. This caused an inconsistent state that led to Windows arranged out of order. Updating both history stacks at the same time fixes this. Fixes bug 8244261. Change-Id: I9669762ad39b06ab6d401122702b74969d4dc658
-rw-r--r--services/java/com/android/server/am/ActivityStack.java69
-rw-r--r--services/java/com/android/server/wm/WindowManagerService.java1
2 files changed, 33 insertions, 37 deletions
diff --git a/services/java/com/android/server/am/ActivityStack.java b/services/java/com/android/server/am/ActivityStack.java
index 30a7e23..e0b8015 100644
--- a/services/java/com/android/server/am/ActivityStack.java
+++ b/services/java/com/android/server/am/ActivityStack.java
@@ -4850,44 +4850,8 @@ final class ActivityStack {
* @return Returns true if the move completed, false if not.
*/
final boolean moveTaskToBackLocked(int task, ActivityRecord reason) {
- if (!newMoveTaskToBackLocked(task, reason)) {
- return false;
- }
-
- final int N = mHistory.size();
- int bottom = 0;
- int pos = 0;
-
- // Shift all activities with this task down to the bottom
- // of the stack, keeping them in the same internal order.
- while (pos < N) {
- ActivityRecord r = mHistory.get(pos);
- if (localLOGV) Slog.v(
- TAG, "At " + pos + " ckp " + r.task + ": " + r);
- if (r.task.taskId == task) {
- if (localLOGV) Slog.v(TAG, "Removing and adding at " + (N-1));
- if (DEBUG_ADD_REMOVE) {
- RuntimeException here = new RuntimeException("here");
- here.fillInStackTrace();
- Slog.i(TAG, "Removing and adding activity " + r + " to stack at "
- + bottom, here);
- }
- mHistory.remove(pos);
- mHistory.add(bottom, r);
- bottom++;
- }
- pos++;
- }
- if (VALIDATE_TASK_REPLACE) {
- verifyActivityRecords(true);
- }
-
- return true;
- }
-
- final boolean newMoveTaskToBackLocked(int task, ActivityRecord reason) {
Slog.i(TAG, "moveTaskToBack: " + task);
-
+
// If we have a watcher, preflight the move before committing to it. First check
// for *other* available tasks, but if none are available, then try again allowing the
// current task to be selected.
@@ -4917,6 +4881,36 @@ final class ActivityStack {
mTaskHistory.remove(tr);
mTaskHistory.add(0, tr);
+ // BEGIN REGION TO REMOVE.
+ final int N = mHistory.size();
+ int bottom = 0;
+ int pos = 0;
+
+ // Shift all activities with this task down to the bottom
+ // of the stack, keeping them in the same internal order.
+ while (pos < N) {
+ ActivityRecord r = mHistory.get(pos);
+ if (localLOGV) Slog.v(
+ TAG, "At " + pos + " ckp " + r.task + ": " + r);
+ if (r.task.taskId == task) {
+ if (localLOGV) Slog.v(TAG, "Removing and adding at " + (N-1));
+ if (DEBUG_ADD_REMOVE) {
+ RuntimeException here = new RuntimeException("here");
+ here.fillInStackTrace();
+ Slog.i(TAG, "Removing and adding activity " + r + " to stack at "
+ + bottom, here);
+ }
+ mHistory.remove(pos);
+ mHistory.add(bottom, r);
+ bottom++;
+ }
+ pos++;
+ }
+ if (VALIDATE_TASK_REPLACE) {
+ verifyActivityRecords(true);
+ }
+ // END REGION TO REMOVE
+
if (reason != null &&
(reason.intent.getFlags()&Intent.FLAG_ACTIVITY_NO_ANIMATION) != 0) {
mService.mWindowManager.prepareAppTransition(AppTransition.TRANSIT_NONE, false);
@@ -4929,6 +4923,7 @@ final class ActivityStack {
AppTransition.TRANSIT_TASK_TO_BACK, false);
}
mService.mWindowManager.moveTaskToBottom(task);
+
if (VALIDATE_TOKENS) {
validateAppTokensLocked();
}
diff --git a/services/java/com/android/server/wm/WindowManagerService.java b/services/java/com/android/server/wm/WindowManagerService.java
index c2213b3..6a5ded0 100644
--- a/services/java/com/android/server/wm/WindowManagerService.java
+++ b/services/java/com/android/server/wm/WindowManagerService.java
@@ -3158,6 +3158,7 @@ public class WindowManagerService extends IWindowManager.Stub
if (mismatch || iterator.hasNext()) {
Slog.w(TAG, "validateAppTokens: Mismatch! ActivityManager=" + tasks);
Slog.w(TAG, "validateAppTokens: Mismatch! WindowManager=" + iterator);
+ Slog.w(TAG, "validateAppTokens: Mismatch! Callers=" + Debug.getCallers(4));
}
}
}