Skip to content

Commit 24d966a

Browse files
Craig MautnerAndroid (Google) Code Review
authored andcommitted
Merge "Fix math errors causing black screen. DO NOT MERGE" into jb-mr1.1-dev
2 parents 652678a + 9dd9e0c commit 24d966a

File tree

2 files changed

+13
-7
lines changed

2 files changed

+13
-7
lines changed

services/java/com/android/server/power/RampAnimator.java

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -102,20 +102,26 @@ public void run() {
102102
final long frameTimeNanos = mChoreographer.getFrameTimeNanos();
103103
final float timeDelta = (frameTimeNanos - mLastFrameTimeNanos)
104104
* 0.000000001f;
105-
final float amount = timeDelta * mRate / ValueAnimator.getDurationScale();
106105
mLastFrameTimeNanos = frameTimeNanos;
107106

108107
// Advance the animated value towards the target at the specified rate
109108
// and clamp to the target. This gives us the new current value but
110109
// we keep the animated value around to allow for fractional increments
111110
// towards the target.
112-
int oldCurrentValue = mCurrentValue;
113-
if (mTargetValue > mCurrentValue) {
114-
mAnimatedValue = Math.min(mAnimatedValue + amount, mTargetValue);
111+
final float scale = ValueAnimator.getDurationScale();
112+
if (scale == 0) {
113+
// Animation off.
114+
mAnimatedValue = mTargetValue;
115115
} else {
116-
mAnimatedValue = Math.max(mAnimatedValue - amount, mTargetValue);
116+
final float amount = timeDelta * mRate / scale;
117+
if (mTargetValue > mCurrentValue) {
118+
mAnimatedValue = Math.min(mAnimatedValue + amount, mTargetValue);
119+
} else {
120+
mAnimatedValue = Math.max(mAnimatedValue - amount, mTargetValue);
121+
}
117122
}
118-
mCurrentValue = (int)Math.round(mAnimatedValue);
123+
final int oldCurrentValue = mCurrentValue;
124+
mCurrentValue = Math.round(mAnimatedValue);
119125

120126
if (oldCurrentValue != mCurrentValue) {
121127
mProperty.setValue(mObject, mCurrentValue);

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -821,7 +821,7 @@ private WindowManagerService(Context context, PowerManagerService pm,
821821
mTransitionAnimationScale = Settings.Global.getFloat(context.getContentResolver(),
822822
Settings.Global.TRANSITION_ANIMATION_SCALE, mTransitionAnimationScale);
823823
setAnimatorDurationScale(Settings.Global.getFloat(context.getContentResolver(),
824-
Settings.Global.ANIMATOR_DURATION_SCALE, mTransitionAnimationScale));
824+
Settings.Global.ANIMATOR_DURATION_SCALE, mAnimatorDurationScale));
825825

826826
// Track changes to DevicePolicyManager state so we can enable/disable keyguard.
827827
IntentFilter filter = new IntentFilter();

0 commit comments

Comments
 (0)