OSDN Git Service

Don't hold the WM lock when canceling recents animation
authorWinson Chung <winsonc@google.com>
Wed, 28 Feb 2018 16:32:12 +0000 (08:32 -0800)
committerWinson Chung <winsonc@google.com>
Wed, 28 Feb 2018 16:32:12 +0000 (08:32 -0800)
Bug: 73968394
Test: Manual, just removing the lock into the controller, swipe up still
      works

Change-Id: Ifad09c83ca89ee48b37878a33e41b8a8dfc73e66

services/core/java/com/android/server/am/RecentsAnimation.java
services/core/java/com/android/server/wm/RecentsAnimationController.java
services/core/java/com/android/server/wm/WindowManagerService.java

index 0ef8bff..322d66b 100644 (file)
@@ -137,6 +137,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);
 
index 31b5c69..44ef247 100644 (file)
@@ -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 */);
     }
 
index 8b8a6d3..1ff87d8 100644 (file)
@@ -2701,7 +2701,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();
@@ -2726,12 +2725,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();
         }
     }