Reapply animation duration scale each time it is started.

When Battery Saver mode is enabled, we set the animation duration
scale factor to 0 to effectively disable all animations.  Later
when it is disabled, we reset the animation duration scale
factor to 1.

This change ensures that we reapply the duration scale factor
whenever the animation is started instead of only applying it
once when the duration is set (usually when the animation is
created).  This ensures that the correct scale factor is applied
even when it changes after the animation has been initialized.

Previously, certain animations would continue to be suppressed
even after Battery Saver mode was disengaged.  This wasn't much
of an issue when the duration scale was initially implemented as
a developer setting but now that it is exposed via Battery Saver
the artifacts caused by this bug have become visible to users.

Bug: 17887431
Change-Id: I91ba5ca0505d02ac389a31d067e38886112fa0c8
diff --git a/core/java/android/animation/ValueAnimator.java b/core/java/android/animation/ValueAnimator.java
index 9435dfb..0d17d67 100644
--- a/core/java/android/animation/ValueAnimator.java
+++ b/core/java/android/animation/ValueAnimator.java
@@ -508,10 +508,14 @@
                     duration);
         }
         mUnscaledDuration = duration;
-        mDuration = (long)(duration * sDurationScale);
+        updateScaledDuration();
         return this;
     }
 
+    private void updateScaledDuration() {
+        mDuration = (long)(mUnscaledDuration * sDurationScale);
+    }
+
     /**
      * Gets the length of the animation. The default duration is 300 milliseconds.
      *
@@ -947,6 +951,7 @@
         mStarted = true;
         mStartedDelay = false;
         mPaused = false;
+        updateScaledDuration(); // in case the scale factor has changed since creation time
         AnimationHandler animationHandler = getOrCreateAnimationHandler();
         animationHandler.mPendingAnimations.add(this);
         if (mStartDelay == 0) {