summaryrefslogtreecommitdiffstats
path: root/services/java/com/android
diff options
context:
space:
mode:
authorCraig Mautner <cmautner@google.com>2012-11-15 14:25:14 -0800
committerCraig Mautner <cmautner@google.com>2012-11-29 00:11:50 -0800
commit9dd9e0c99dcb2db98ffbcf9ad97e58fab8d38640 (patch)
tree059319290fa792cdc612ad3badb6cfc340aae2cd /services/java/com/android
parent7be52cbc33157e4700b7d04e69d1149cd80e9096 (diff)
downloadframeworks_base-9dd9e0c99dcb2db98ffbcf9ad97e58fab8d38640.zip
frameworks_base-9dd9e0c99dcb2db98ffbcf9ad97e58fab8d38640.tar.gz
frameworks_base-9dd9e0c99dcb2db98ffbcf9ad97e58fab8d38640.tar.bz2
Fix math errors causing black screen. DO NOT MERGE
Turning off animations in the Developer options creates a ValueAnimator duration scale of 0. This is used as the denominator in RampAnimator which, if the numerator is also 0, sets mAnimatedValue to NaN. Rounding NaN to the nearest int produces 0 which is then assigned to mScreenBrightness in DisplayPowerState. A copy mistake which assigned mTransitionAnimationScale as the default value for mAnimatorDurationScale in WindowManagerService is also fixed here. Bug 7515609 fixed. Change-Id: I39f8d0a7abdd5a1fe70d757fe95fbddaf7a0ed51
Diffstat (limited to 'services/java/com/android')
-rw-r--r--services/java/com/android/server/power/RampAnimator.java18
-rwxr-xr-xservices/java/com/android/server/wm/WindowManagerService.java2
2 files changed, 13 insertions, 7 deletions
diff --git a/services/java/com/android/server/power/RampAnimator.java b/services/java/com/android/server/power/RampAnimator.java
index 6f063c3..4a4f080 100644
--- a/services/java/com/android/server/power/RampAnimator.java
+++ b/services/java/com/android/server/power/RampAnimator.java
@@ -102,20 +102,26 @@ final class RampAnimator<T> {
final long frameTimeNanos = mChoreographer.getFrameTimeNanos();
final float timeDelta = (frameTimeNanos - mLastFrameTimeNanos)
* 0.000000001f;
- final float amount = timeDelta * mRate / ValueAnimator.getDurationScale();
mLastFrameTimeNanos = frameTimeNanos;
// Advance the animated value towards the target at the specified rate
// and clamp to the target. This gives us the new current value but
// we keep the animated value around to allow for fractional increments
// towards the target.
- int oldCurrentValue = mCurrentValue;
- if (mTargetValue > mCurrentValue) {
- mAnimatedValue = Math.min(mAnimatedValue + amount, mTargetValue);
+ final float scale = ValueAnimator.getDurationScale();
+ if (scale == 0) {
+ // Animation off.
+ mAnimatedValue = mTargetValue;
} else {
- mAnimatedValue = Math.max(mAnimatedValue - amount, mTargetValue);
+ final float amount = timeDelta * mRate / scale;
+ if (mTargetValue > mCurrentValue) {
+ mAnimatedValue = Math.min(mAnimatedValue + amount, mTargetValue);
+ } else {
+ mAnimatedValue = Math.max(mAnimatedValue - amount, mTargetValue);
+ }
}
- mCurrentValue = (int)Math.round(mAnimatedValue);
+ final int oldCurrentValue = mCurrentValue;
+ mCurrentValue = Math.round(mAnimatedValue);
if (oldCurrentValue != mCurrentValue) {
mProperty.setValue(mObject, mCurrentValue);
diff --git a/services/java/com/android/server/wm/WindowManagerService.java b/services/java/com/android/server/wm/WindowManagerService.java
index 51edb44..f951b64 100755
--- a/services/java/com/android/server/wm/WindowManagerService.java
+++ b/services/java/com/android/server/wm/WindowManagerService.java
@@ -821,7 +821,7 @@ public class WindowManagerService extends IWindowManager.Stub
mTransitionAnimationScale = Settings.Global.getFloat(context.getContentResolver(),
Settings.Global.TRANSITION_ANIMATION_SCALE, mTransitionAnimationScale);
setAnimatorDurationScale(Settings.Global.getFloat(context.getContentResolver(),
- Settings.Global.ANIMATOR_DURATION_SCALE, mTransitionAnimationScale));
+ Settings.Global.ANIMATOR_DURATION_SCALE, mAnimatorDurationScale));
// Track changes to DevicePolicyManager state so we can enable/disable keyguard.
IntentFilter filter = new IntentFilter();