diff options
| author | 2018-03-01 02:33:54 +0000 | |
|---|---|---|
| committer | 2018-03-01 02:33:54 +0000 | |
| commit | a56e8da747b2bc0536162c079c75b9eebd6886a3 (patch) | |
| tree | 389a50079a31cb8243b4c928eb6afd28bce43314 | |
| parent | 668b5ca9aa241e654cf593db10c478d46ddf5050 (diff) | |
| parent | 65fc89acafc2c359751af4c4a7b6c6753c1b4e47 (diff) | |
Merge "Don't hold the WM lock when canceling recents animation"
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(); } } |