Skip to content

Commit ff7e6ef

Browse files
author
Jeff Brown
committed
Apply ValueAnimator scale factor immediately in WM.
Normally the ValueAnimator scale factor is applied the first time a ViewRootImpl window session is created but that may be too late for animators created by system services that start early in the boot process. So set the scale factor immediately whenever the setting changes. Also make ValueAnimator.getDurationScale() accessible (but @hide) for custom animators that want to apply the same scale to their animations. Change-Id: I0f5a750ab5b014f63848445435d8dca86f2a7ada
1 parent 109025d commit ff7e6ef

File tree

2 files changed

+16
-3
lines changed

2 files changed

+16
-3
lines changed

core/java/android/animation/ValueAnimator.java

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -231,6 +231,13 @@ public static void setDurationScale(float durationScale) {
231231
sDurationScale = durationScale;
232232
}
233233

234+
/**
235+
* @hide
236+
*/
237+
public static float getDurationScale() {
238+
return sDurationScale;
239+
}
240+
234241
/**
235242
* Creates a new ValueAnimator object. This default constructor is primarily for
236243
* use internally; the factory methods which take parameters are more generally

services/java/com/android/server/wm/WindowManagerService.java

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@
5757
import android.app.IActivityManager;
5858
import android.app.StatusBarManager;
5959
import android.app.admin.DevicePolicyManager;
60+
import android.animation.ValueAnimator;
6061
import android.content.BroadcastReceiver;
6162
import android.content.Context;
6263
import android.content.Intent;
@@ -900,8 +901,8 @@ private WindowManagerService(Context context, PowerManagerService pm,
900901
Settings.System.WINDOW_ANIMATION_SCALE, mWindowAnimationScale);
901902
mTransitionAnimationScale = Settings.System.getFloat(context.getContentResolver(),
902903
Settings.System.TRANSITION_ANIMATION_SCALE, mTransitionAnimationScale);
903-
mAnimatorDurationScale = Settings.System.getFloat(context.getContentResolver(),
904-
Settings.System.ANIMATOR_DURATION_SCALE, mTransitionAnimationScale);
904+
setAnimatorDurationScale(Settings.System.getFloat(context.getContentResolver(),
905+
Settings.System.ANIMATOR_DURATION_SCALE, mTransitionAnimationScale));
905906

906907
// Track changes to DevicePolicyManager state so we can enable/disable keyguard.
907908
IntentFilter filter = new IntentFilter();
@@ -5160,14 +5161,19 @@ public void setAnimationScales(float[] scales) {
51605161
mTransitionAnimationScale = fixScale(scales[1]);
51615162
}
51625163
if (scales.length >= 3) {
5163-
mAnimatorDurationScale = fixScale(scales[2]);
5164+
setAnimatorDurationScale(fixScale(scales[2]));
51645165
}
51655166
}
51665167

51675168
// Persist setting
51685169
mH.obtainMessage(H.PERSIST_ANIMATION_SCALE).sendToTarget();
51695170
}
51705171

5172+
private void setAnimatorDurationScale(float scale) {
5173+
mAnimatorDurationScale = scale;
5174+
ValueAnimator.setDurationScale(scale);
5175+
}
5176+
51715177
public float getAnimationScale(int which) {
51725178
switch (which) {
51735179
case 0: return mWindowAnimationScale;

0 commit comments

Comments
 (0)