diff options
| author | 2018-02-01 15:03:59 +0100 | |
|---|---|---|
| committer | 2018-02-01 15:03:59 +0100 | |
| commit | a19d781a8a03757334a4dd1be8cfe2bc5e0299a7 (patch) | |
| tree | 27a5252291c53ba56bdad3e7864a0b0f4060665b | |
| parent | 9d3986bdc3b9fe5a85a54bf6a4f787e198eade40 (diff) | |
Scale timeout with animation scale
So slowed down animations still work
Test: RemoteAnimationControllerTest
Test: go/wm-smoke-auto
Change-Id: I23116fdd0f2e75e4320bd77aee704d1e2a9de5e7
| -rw-r--r-- | services/core/java/com/android/server/wm/RemoteAnimationController.java | 5 | ||||
| -rw-r--r-- | services/tests/servicestests/src/com/android/server/wm/RemoteAnimationControllerTest.java | 28 |
2 files changed, 31 insertions, 2 deletions
diff --git a/services/core/java/com/android/server/wm/RemoteAnimationController.java b/services/core/java/com/android/server/wm/RemoteAnimationController.java index 8269a3b783c4..925199358b4e 100644 --- a/services/core/java/com/android/server/wm/RemoteAnimationController.java +++ b/services/core/java/com/android/server/wm/RemoteAnimationController.java @@ -92,7 +92,10 @@ class RemoteAnimationController { onAnimationFinished(); return; } - mHandler.postDelayed(mTimeoutRunnable, TIMEOUT_MS); + + // Scale the timeout with the animator scale the controlling app is using. + mHandler.postDelayed(mTimeoutRunnable, + (long) (TIMEOUT_MS * mService.getCurrentAnimatorScale())); try { mRemoteAnimationAdapter.getRunner().onAnimationStart(createAnimations(), mFinishedCallback); diff --git a/services/tests/servicestests/src/com/android/server/wm/RemoteAnimationControllerTest.java b/services/tests/servicestests/src/com/android/server/wm/RemoteAnimationControllerTest.java index f860195bd6ea..26a7313b71d8 100644 --- a/services/tests/servicestests/src/com/android/server/wm/RemoteAnimationControllerTest.java +++ b/services/tests/servicestests/src/com/android/server/wm/RemoteAnimationControllerTest.java @@ -19,12 +19,12 @@ package com.android.server.wm; 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.never; import static org.mockito.Mockito.verify; import static org.mockito.Mockito.verifyZeroInteractions; import android.graphics.Point; import android.graphics.Rect; -import android.platform.test.annotations.Postsubmit; import android.support.test.filters.FlakyTest; import android.support.test.filters.SmallTest; import android.support.test.runner.AndroidJUnit4; @@ -137,6 +137,32 @@ public class RemoteAnimationControllerTest extends WindowTestsBase { } @Test + public void testTimeout_scaled() throws Exception { + sWm.setAnimationScale(2, 5.0f); + try{ + final WindowState win = createWindow(null /* parent */, TYPE_BASE_APPLICATION, "testWin"); + final AnimationAdapter adapter = mController.createAnimationAdapter(win.mAppToken, + new Point(50, 100), new Rect(50, 100, 150, 150)); + adapter.startAnimation(mMockLeash, mMockTransaction, mFinishedCallback); + mController.goodToGo(); + + mClock.fastForward(2500); + mHandler.timeAdvance(); + + verify(mMockRunner, never()).onAnimationCancelled(); + + mClock.fastForward(10000); + mHandler.timeAdvance(); + + verify(mMockRunner).onAnimationCancelled(); + verify(mFinishedCallback).onAnimationFinished(eq(adapter)); + } finally { + sWm.setAnimationScale(2, 1.0f); + } + + } + + @Test public void testZeroAnimations() throws Exception { mController.goodToGo(); verifyZeroInteractions(mMockRunner); |