1919import android .os .Handler ;
2020import android .os .Looper ;
2121import android .os .Message ;
22+ import android .os .SystemProperties ;
2223import android .util .AndroidRuntimeException ;
2324import android .view .Choreographer ;
2425import android .view .animation .AccelerateDecelerateInterpolator ;
@@ -52,6 +53,8 @@ public class ValueAnimator extends Animator {
5253 /**
5354 * Internal constants
5455 */
56+ private static float sDurationScale = 1.0f ;
57+ private static boolean sDurationScaleInitialized = false ;
5558
5659 /**
5760 * Messages sent to timing handler: START is sent when an animation first begins.
@@ -159,9 +162,11 @@ public class ValueAnimator extends Animator {
159162
160163 // How long the animation should last in ms
161164 private long mDuration = 300 ;
165+ private long mUnscaledDuration = 300 ;
162166
163167 // The amount of time in ms to delay starting the animation after start() is called
164168 private long mStartDelay = 0 ;
169+ private long mUnscaledStartDelay = 0 ;
165170
166171 // The number of times the animation will repeat. The default is 0, which means the animation
167172 // will play only once
@@ -223,6 +228,15 @@ public class ValueAnimator extends Animator {
223228 * useful.
224229 */
225230 public ValueAnimator () {
231+ if (!sDurationScaleInitialized ) {
232+ // Scale value initialized per-process when first animator is constructed
233+ String scaleString = SystemProperties .get ("persist.sys.ui.animation" );
234+ if (!scaleString .isEmpty ()) {
235+ sDurationScale = Float .parseFloat (scaleString );
236+ }
237+ sDurationScaleInitialized = true ;
238+ }
239+ mDuration *= sDurationScale ;
226240 }
227241
228242 /**
@@ -453,7 +467,8 @@ public ValueAnimator setDuration(long duration) {
453467 throw new IllegalArgumentException ("Animators cannot have negative duration: " +
454468 duration );
455469 }
456- mDuration = duration ;
470+ mUnscaledDuration = duration ;
471+ mDuration = (long )(duration * sDurationScale );
457472 return this ;
458473 }
459474
@@ -463,7 +478,7 @@ public ValueAnimator setDuration(long duration) {
463478 * @return The length of the animation, in milliseconds.
464479 */
465480 public long getDuration () {
466- return mDuration ;
481+ return mUnscaledDuration ;
467482 }
468483
469484 /**
@@ -658,7 +673,7 @@ public void onAnimate() {
658673 * @return the number of milliseconds to delay running the animation
659674 */
660675 public long getStartDelay () {
661- return mStartDelay ;
676+ return mUnscaledStartDelay ;
662677 }
663678
664679 /**
@@ -668,7 +683,8 @@ public long getStartDelay() {
668683 * @param startDelay The amount of the delay, in milliseconds
669684 */
670685 public void setStartDelay (long startDelay ) {
671- this .mStartDelay = startDelay ;
686+ this .mStartDelay = (long )(startDelay * sDurationScale );
687+ mUnscaledStartDelay = startDelay ;
672688 }
673689
674690 /**
0 commit comments