From 61fe23a1bce9245e3a085550197e80ddc3228d1f Mon Sep 17 00:00:00 2001 From: Daniel Santiago Rivera Date: Tue, 5 Feb 2019 12:41:39 -0800 Subject: Restrict reflection access to ValueAnimator's sDurationScale An alternative method, areAnimatorsEnabled() can be used to determine if animations are turned off or not. Otherwise, reflection access of the value are not permitted since it is an implementation detail that can break battery saver mode or user's choice of disabling system-wide animations. Bug: 123767751 Test: n/a Change-Id: I2146613a5921e229f7db641c34732bc1044766fc --- core/java/android/animation/ValueAnimator.java | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/core/java/android/animation/ValueAnimator.java b/core/java/android/animation/ValueAnimator.java index a0464dfac1f4..ebb03e765a47 100644 --- a/core/java/android/animation/ValueAnimator.java +++ b/core/java/android/animation/ValueAnimator.java @@ -20,6 +20,7 @@ import android.annotation.CallSuper; import android.annotation.IntDef; import android.annotation.TestApi; import android.annotation.UnsupportedAppUsage; +import android.os.Build; import android.os.Looper; import android.os.Trace; import android.util.AndroidRuntimeException; @@ -76,7 +77,13 @@ public class ValueAnimator extends Animator implements AnimationHandler.Animatio /** * Internal constants */ - @UnsupportedAppUsage + + /** + * System-wide animation scale. + * + *

To check whether animations are enabled system-wise use {@link #areAnimatorsEnabled()}. + */ + @UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.P) private static float sDurationScale = 1.0f; /** -- cgit v1.2.3-59-g8ed1b