Merge "Fix replacing window timeouts" into nyc-dev
am: a63e1325b5
* commit 'a63e1325b595d84dea7d33cb2e2c149acb326204':
Fix replacing window timeouts
Change-Id: I78463da8421ae1a039b0b22f2e44739e3199f166
diff --git a/services/core/java/com/android/server/wm/AppWindowToken.java b/services/core/java/com/android/server/wm/AppWindowToken.java
index a234241..e490a40 100644
--- a/services/core/java/com/android/server/wm/AppWindowToken.java
+++ b/services/core/java/com/android/server/wm/AppWindowToken.java
@@ -582,10 +582,7 @@
w.mSkipEnterAnimationForSeamlessReplacement = !candidate.mAnimateReplacingWindow;
// if we got a replacement window, reset the timeout to give drawing more time
- service.mH.removeMessages(H.WINDOW_REPLACEMENT_TIMEOUT);
- service.mH.sendMessageDelayed(
- service.mH.obtainMessage(H.WINDOW_REPLACEMENT_TIMEOUT, this),
- WINDOW_REPLACEMENT_TIMEOUT_DURATION);
+ service.scheduleReplacingWindowTimeouts(this);
}
}
allAppWindows.add(w);
diff --git a/services/core/java/com/android/server/wm/WindowManagerService.java b/services/core/java/com/android/server/wm/WindowManagerService.java
index 8b1d2a0..defd513 100644
--- a/services/core/java/com/android/server/wm/WindowManagerService.java
+++ b/services/core/java/com/android/server/wm/WindowManagerService.java
@@ -415,6 +415,12 @@
final ArrayList<AppWindowToken> mFinishedStarting = new ArrayList<>();
/**
+ * List of app window tokens that are waiting for replacing windows. If the
+ * replacement doesn't come in time the stale windows needs to be disposed of.
+ */
+ final ArrayList<AppWindowToken> mReplacingWindowTimeouts = new ArrayList<>();
+
+ /**
* The input consumer added to the window manager which consumes input events to windows below
* it.
*/
@@ -8497,9 +8503,12 @@
}
break;
case WINDOW_REPLACEMENT_TIMEOUT: {
- final AppWindowToken token = (AppWindowToken) msg.obj;
synchronized (mWindowMap) {
- token.clearTimedoutReplacesLocked();
+ for (int i = mReplacingWindowTimeouts.size() - 1; i >= 0; i--) {
+ final AppWindowToken token = mReplacingWindowTimeouts.get(i);
+ token.clearTimedoutReplacesLocked();
+ }
+ mReplacingWindowTimeouts.clear();
}
}
case NOTIFY_APP_TRANSITION_STARTING: {
@@ -10769,16 +10778,22 @@
return;
}
if (replacing) {
- mH.removeMessages(H.WINDOW_REPLACEMENT_TIMEOUT);
- mH.sendMessageDelayed(
- mH.obtainMessage(H.WINDOW_REPLACEMENT_TIMEOUT, appWindowToken),
- WINDOW_REPLACEMENT_TIMEOUT_DURATION);
+ scheduleReplacingWindowTimeouts(appWindowToken);
} else {
appWindowToken.resetReplacingWindows();
}
}
}
+ void scheduleReplacingWindowTimeouts(AppWindowToken appWindowToken) {
+ if (!mReplacingWindowTimeouts.contains(appWindowToken)) {
+ mReplacingWindowTimeouts.add(appWindowToken);
+ }
+ mH.removeMessages(H.WINDOW_REPLACEMENT_TIMEOUT);
+ mH.sendEmptyMessageDelayed(
+ H.WINDOW_REPLACEMENT_TIMEOUT, WINDOW_REPLACEMENT_TIMEOUT_DURATION);
+ }
+
@Override
public int getDockedStackSide() {
synchronized (mWindowMap) {