OSDN Git Service

If nothing to animate, don't call remote animator
authorJorim Jaggi <jjaggi@google.com>
Thu, 25 Jan 2018 14:06:13 +0000 (15:06 +0100)
committerJorim Jaggi <jjaggi@google.com>
Mon, 29 Jan 2018 18:16:34 +0000 (19:16 +0100)
Otherwise we'll end up with weird transitions when just switching
focus because focus switch causes an app transition to run.

Test: go/wm-smoke
Test: Enter PIP, click on PIP window, click on launcher window
to execute an empty app transition.

Change-Id: Ie42ad808ff4d4646570c122fd3b964e3255a57bc

services/core/java/com/android/server/wm/RemoteAnimationController.java
services/tests/servicestests/src/com/android/server/wm/RemoteAnimationControllerTest.java

index 8515dcb..0048983 100644 (file)
@@ -88,6 +88,10 @@ class RemoteAnimationController {
      * Called when the transition is ready to be started, and all leashes have been set up.
      */
     void goodToGo() {
+        if (mPendingAnimations.isEmpty()) {
+            onAnimationFinished();
+            return;
+        }
         mHandler.postDelayed(mTimeoutRunnable, TIMEOUT_MS);
         try {
             mRemoteAnimationAdapter.getRunner().onAnimationStart(createAnimations(),
index 897be34..f860195 100644 (file)
@@ -20,6 +20,7 @@ import static android.view.WindowManager.LayoutParams.TYPE_BASE_APPLICATION;
 import static org.junit.Assert.assertEquals;
 import static org.mockito.ArgumentMatchers.eq;
 import static org.mockito.Mockito.verify;
+import static org.mockito.Mockito.verifyZeroInteractions;
 
 import android.graphics.Point;
 import android.graphics.Rect;
@@ -134,4 +135,10 @@ public class RemoteAnimationControllerTest extends WindowTestsBase {
         verify(mMockRunner).onAnimationCancelled();
         verify(mFinishedCallback).onAnimationFinished(eq(adapter));
     }
+
+    @Test
+    public void testZeroAnimations() throws Exception {
+        mController.goodToGo();
+        verifyZeroInteractions(mMockRunner);
+    }
 }