From a5dcc6c25d38fe63a15f1b5920c439696726d3da Mon Sep 17 00:00:00 2001 From: Teng-Hui Zhu Date: Wed, 30 Mar 2016 11:34:55 -0700 Subject: [PATCH] LUTInterpolator needs to have 2 frame at minimal Otherwise, it could be having invalid data, here NAN. Fix:27343522 Change-Id: I5bb17f04c62f268ec633675015ef589be2413338 --- .../internal/view/animation/FallbackLUTInterpolator.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/core/java/com/android/internal/view/animation/FallbackLUTInterpolator.java b/core/java/com/android/internal/view/animation/FallbackLUTInterpolator.java index 526e2aef4799d..9e2cbdba44d47 100644 --- a/core/java/com/android/internal/view/animation/FallbackLUTInterpolator.java +++ b/core/java/com/android/internal/view/animation/FallbackLUTInterpolator.java @@ -45,7 +45,8 @@ public class FallbackLUTInterpolator implements NativeInterpolatorFactory, TimeI private static float[] createLUT(TimeInterpolator interpolator, long duration) { long frameIntervalNanos = Choreographer.getInstance().getFrameIntervalNanos(); int animIntervalMs = (int) (frameIntervalNanos / TimeUtils.NANOS_PER_MS); - int numAnimFrames = (int) Math.ceil(((double) duration) / animIntervalMs); + // We need 2 frame values as the minimal. + int numAnimFrames = Math.max(2, (int) Math.ceil(((double) duration) / animIntervalMs)); float values[] = new float[numAnimFrames]; float lastFrame = numAnimFrames - 1; for (int i = 0; i < numAnimFrames; i++) {