Merge "Add Developer Option setting for Animator scaling."
diff --git a/api/current.txt b/api/current.txt
index 051ea66..9e94a0d 100644
--- a/api/current.txt
+++ b/api/current.txt
@@ -17583,6 +17583,7 @@
field public static final java.lang.String ALARM_ALERT = "alarm_alert";
field public static final java.lang.String ALWAYS_FINISH_ACTIVITIES = "always_finish_activities";
field public static final deprecated java.lang.String ANDROID_ID = "android_id";
+ field public static final java.lang.String ANIMATOR_DURATION_SCALE = "animator_duration_scale";
field public static final java.lang.String APPEND_FOR_LAST_AUDIBLE = "_last_audible";
field public static final java.lang.String AUTO_TIME = "auto_time";
field public static final java.lang.String AUTO_TIME_ZONE = "auto_time_zone";
diff --git a/core/java/android/animation/ValueAnimator.java b/core/java/android/animation/ValueAnimator.java
index 3f28e67..cc1efb9 100755
--- a/core/java/android/animation/ValueAnimator.java
+++ b/core/java/android/animation/ValueAnimator.java
@@ -54,7 +54,6 @@
* Internal constants
*/
private static float sDurationScale = 1.0f;
- private static boolean sDurationScaleInitialized = false;
/**
* Messages sent to timing handler: START is sent when an animation first begins.
@@ -161,7 +160,7 @@
//
// How long the animation should last in ms
- private long mDuration = 300;
+ private long mDuration = (long)(300 * sDurationScale);
private long mUnscaledDuration = 300;
// The amount of time in ms to delay starting the animation after start() is called
@@ -222,21 +221,20 @@
*/
public static final int INFINITE = -1;
+
+ /**
+ * @hide
+ */
+ public static void setDurationScale(float durationScale) {
+ sDurationScale = durationScale;
+ }
+
/**
* Creates a new ValueAnimator object. This default constructor is primarily for
* use internally; the factory methods which take parameters are more generally
* useful.
*/
public ValueAnimator() {
- if (!sDurationScaleInitialized) {
- // Scale value initialized per-process when first animator is constructed
- String scaleString = SystemProperties.get("persist.sys.ui.animation");
- if (!scaleString.isEmpty()) {
- sDurationScale = Float.parseFloat(scaleString);
- }
- sDurationScaleInitialized = true;
- }
- mDuration *= sDurationScale;
}
/**
diff --git a/core/java/android/provider/Settings.java b/core/java/android/provider/Settings.java
index f14d27e..207810c 100644
--- a/core/java/android/provider/Settings.java
+++ b/core/java/android/provider/Settings.java
@@ -1678,6 +1678,13 @@
public static final String TRANSITION_ANIMATION_SCALE = "transition_animation_scale";
/**
+ * Scaling factor for Animator-based animations. This affects both the start delay and
+ * duration of all such animations. Setting to 0 will cause animations to end immediately.
+ * The default value is 1.
+ */
+ public static final String ANIMATOR_DURATION_SCALE = "animator_duration_scale";
+
+ /**
* Scaling factor for normal window animations. Setting to 0 will disable window
* animations.
* @hide
diff --git a/core/java/android/view/ViewRootImpl.java b/core/java/android/view/ViewRootImpl.java
index eefebd5..cbf4b5a 100644
--- a/core/java/android/view/ViewRootImpl.java
+++ b/core/java/android/view/ViewRootImpl.java
@@ -18,6 +18,7 @@
import android.Manifest;
import android.animation.LayoutTransition;
+import android.animation.ValueAnimator;
import android.app.ActivityManagerNative;
import android.content.ClipDescription;
import android.content.ComponentCallbacks;
@@ -323,8 +324,11 @@
if (!mInitialized) {
try {
InputMethodManager imm = InputMethodManager.getInstance(mainLooper);
- sWindowSession = Display.getWindowManager().openSession(
+ IWindowManager windowManager = Display.getWindowManager();
+ sWindowSession = windowManager.openSession(
imm.getClient(), imm.getInputContext());
+ float animatorScale = windowManager.getAnimationScale(2);
+ ValueAnimator.setDurationScale(animatorScale);
mInitialized = true;
} catch (RemoteException e) {
}
diff --git a/services/java/com/android/server/wm/WindowManagerService.java b/services/java/com/android/server/wm/WindowManagerService.java
index 5178af5..620d74c 100644
--- a/services/java/com/android/server/wm/WindowManagerService.java
+++ b/services/java/com/android/server/wm/WindowManagerService.java
@@ -563,6 +563,7 @@
float mWindowAnimationScale = 1.0f;
float mTransitionAnimationScale = 1.0f;
+ float mAnimatorDurationScale = 1.0f;
final InputManager mInputManager;
@@ -779,6 +780,8 @@
Settings.System.WINDOW_ANIMATION_SCALE, mWindowAnimationScale);
mTransitionAnimationScale = Settings.System.getFloat(context.getContentResolver(),
Settings.System.TRANSITION_ANIMATION_SCALE, mTransitionAnimationScale);
+ mAnimatorDurationScale = Settings.System.getFloat(context.getContentResolver(),
+ Settings.System.ANIMATOR_DURATION_SCALE, mTransitionAnimationScale);
// Track changes to DevicePolicyManager state so we can enable/disable keyguard.
IntentFilter filter = new IntentFilter();
@@ -4662,6 +4665,7 @@
switch (which) {
case 0: mWindowAnimationScale = fixScale(scale); break;
case 1: mTransitionAnimationScale = fixScale(scale); break;
+ case 2: mAnimatorDurationScale = fixScale(scale); break;
}
// Persist setting
@@ -4681,6 +4685,9 @@
if (scales.length >= 2) {
mTransitionAnimationScale = fixScale(scales[1]);
}
+ if (scales.length >= 3) {
+ mAnimatorDurationScale = fixScale(scales[2]);
+ }
}
// Persist setting
@@ -4691,12 +4698,14 @@
switch (which) {
case 0: return mWindowAnimationScale;
case 1: return mTransitionAnimationScale;
+ case 2: return mAnimatorDurationScale;
}
return 0;
}
public float[] getAnimationScales() {
- return new float[] { mWindowAnimationScale, mTransitionAnimationScale };
+ return new float[] { mWindowAnimationScale, mTransitionAnimationScale,
+ mAnimatorDurationScale };
}
public int getSwitchState(int sw) {
@@ -6830,6 +6839,8 @@
Settings.System.WINDOW_ANIMATION_SCALE, mWindowAnimationScale);
Settings.System.putFloat(mContext.getContentResolver(),
Settings.System.TRANSITION_ANIMATION_SCALE, mTransitionAnimationScale);
+ Settings.System.putFloat(mContext.getContentResolver(),
+ Settings.System.ANIMATOR_DURATION_SCALE, mAnimatorDurationScale);
break;
}
@@ -9773,6 +9784,7 @@
pw.print(" mTraversalScheduled="); pw.print(mTraversalScheduled);
pw.print(" mWindowAnimationScale="); pw.print(mWindowAnimationScale);
pw.print(" mTransitionWindowAnimationScale="); pw.println(mTransitionAnimationScale);
+ pw.print(" mAnimatorDurationScale="); pw.println(mAnimatorDurationScale);
pw.print(" mNextAppTransition=0x");
pw.print(Integer.toHexString(mNextAppTransition));
pw.print(" mAppTransitionReady="); pw.println(mAppTransitionReady);