summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author Winson Chung <winsonc@google.com> 2018-03-01 02:33:54 +0000
committer Android (Google) Code Review <android-gerrit@google.com> 2018-03-01 02:33:54 +0000
commita56e8da747b2bc0536162c079c75b9eebd6886a3 (patch)
tree389a50079a31cb8243b4c928eb6afd28bce43314
parent668b5ca9aa241e654cf593db10c478d46ddf5050 (diff)
parent65fc89acafc2c359751af4c4a7b6c6753c1b4e47 (diff)
Merge "Don't hold the WM lock when canceling recents animation"
-rw-r--r--services/core/java/com/android/server/am/RecentsAnimation.java1
-rw-r--r--services/core/java/com/android/server/wm/RecentsAnimationController.java22
-rw-r--r--services/core/java/com/android/server/wm/WindowManagerService.java13
3 files changed, 19 insertions, 17 deletions
diff --git a/services/core/java/com/android/server/am/RecentsAnimation.java b/services/core/java/com/android/server/am/RecentsAnimation.java
index 6dcf04193c8e..4b1594c60073 100644
--- a/services/core/java/com/android/server/am/RecentsAnimation.java
+++ b/services/core/java/com/android/server/am/RecentsAnimation.java
@@ -134,6 +134,7 @@ class RecentsAnimation implements RecentsAnimationCallbacks {
// Fetch all the surface controls and pass them to the client to get the animation
// started
+ mWindowManager.cancelRecentsAnimation();
mWindowManager.initializeRecentsAnimation(recentsAnimationRunner, this,
display.mDisplayId);
diff --git a/services/core/java/com/android/server/wm/RecentsAnimationController.java b/services/core/java/com/android/server/wm/RecentsAnimationController.java
index 31b5c698dc5e..44ef247f9aba 100644
--- a/services/core/java/com/android/server/wm/RecentsAnimationController.java
+++ b/services/core/java/com/android/server/wm/RecentsAnimationController.java
@@ -256,18 +256,20 @@ public class RecentsAnimationController {
void cancelAnimation() {
if (DEBUG) Log.d(TAG, "cancelAnimation()");
- if (mCanceled) {
- // We've already canceled the animation
- return;
- }
- mCanceled = true;
- try {
- mRunner.onAnimationCanceled();
- } catch (RemoteException e) {
- Slog.e(TAG, "Failed to cancel recents animation", e);
+ synchronized (mService.getWindowManagerLock()) {
+ if (mCanceled) {
+ // We've already canceled the animation
+ return;
+ }
+ mCanceled = true;
+ try {
+ mRunner.onAnimationCanceled();
+ } catch (RemoteException e) {
+ Slog.e(TAG, "Failed to cancel recents animation", e);
+ }
}
-
// Clean up and return to the previous app
+ // Don't hold the WM lock here as it calls back to AM/RecentsAnimation
mCallbacks.onAnimationFinished(false /* moveHomeToTop */);
}
diff --git a/services/core/java/com/android/server/wm/WindowManagerService.java b/services/core/java/com/android/server/wm/WindowManagerService.java
index 696eef1ac6ca..d12eee36b771 100644
--- a/services/core/java/com/android/server/wm/WindowManagerService.java
+++ b/services/core/java/com/android/server/wm/WindowManagerService.java
@@ -2694,7 +2694,6 @@ public class WindowManagerService extends IWindowManager.Stub
IRecentsAnimationRunner recentsAnimationRunner,
RecentsAnimationController.RecentsAnimationCallbacks callbacks, int displayId) {
synchronized (mWindowMap) {
- cancelRecentsAnimation();
mRecentsAnimationController = new RecentsAnimationController(this,
recentsAnimationRunner, callbacks, displayId);
mRecentsAnimationController.initialize();
@@ -2719,12 +2718,12 @@ public class WindowManagerService extends IWindowManager.Stub
}
public void cancelRecentsAnimation() {
- synchronized (mWindowMap) {
- if (mRecentsAnimationController != null) {
- // This call will call through to cleanupAnimation() below after the animation is
- // canceled
- mRecentsAnimationController.cancelAnimation();
- }
+ // Note: Do not hold the WM lock, this will lock appropriately in the call which also
+ // calls through to AM/RecentsAnimation.onAnimationFinished()
+ if (mRecentsAnimationController != null) {
+ // This call will call through to cleanupAnimation() below after the animation is
+ // canceled
+ mRecentsAnimationController.cancelAnimation();
}
}