Skip to content

Commit 7f786b8

Browse files
Craig MautnerAndroid (Google) Code Review
authored andcommitted
Merge "Do not animate keyboard and button brightness." into jb-dev
2 parents 8325eee + 291576e commit 7f786b8

File tree

1 file changed

+30
-9
lines changed

1 file changed

+30
-9
lines changed

services/java/com/android/server/PowerManagerService.java

Lines changed: 30 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1221,6 +1221,8 @@ public void dump(FileDescriptor fd, PrintWriter pw, String[] args) {
12211221
+ " mLightSensorAdjustSetting=" + mLightSensorAdjustSetting);
12221222
pw.println(" mLightSensorValue=" + mLightSensorValue
12231223
+ " mLightSensorPendingValue=" + mLightSensorPendingValue);
1224+
pw.println(" mHighestLightSensorValue=" + mHighestLightSensorValue
1225+
+ " mWaitingForFirstLightSensor=" + mWaitingForFirstLightSensor);
12241226
pw.println(" mLightSensorPendingDecrease=" + mLightSensorPendingDecrease
12251227
+ " mLightSensorPendingIncrease=" + mLightSensorPendingIncrease);
12261228
pw.println(" mLightSensorScreenBrightness=" + mLightSensorScreenBrightness
@@ -2281,8 +2283,13 @@ private void animateInternal(int mask, boolean turningOff, int delay) {
22812283
}
22822284

22832285
public void dump(PrintWriter pw, String string) {
2284-
pw.println(prefix + "animating: " + "start:" + startValue + ", end:" + endValue
2286+
pw.println(string);
2287+
pw.println(" animating: " + "start:" + startValue + ", end:" + endValue
22852288
+ ", duration:" + duration + ", current:" + currentValue);
2289+
pw.println(" startSensorValue:" + startSensorValue
2290+
+ " endSensorValue:" + endSensorValue);
2291+
pw.println(" startSensorValue:" + startSensorValue
2292+
+ " endSensorValue:" + endSensorValue);
22862293
}
22872294

22882295
public void animateTo(int target, int mask, int animationDuration) {
@@ -2291,6 +2298,16 @@ public void animateTo(int target, int mask, int animationDuration) {
22912298

22922299
public void animateTo(int target, int sensorTarget, int mask, int animationDuration) {
22932300
synchronized(this) {
2301+
if ((mask & SCREEN_BRIGHT_BIT) == 0) {
2302+
// We only animate keyboard and button when passed in with SCREEN_BRIGHT_BIT.
2303+
if ((mask & BUTTON_BRIGHT_BIT) != 0) {
2304+
mButtonLight.setBrightness(target);
2305+
}
2306+
if ((mask & KEYBOARD_BRIGHT_BIT) != 0) {
2307+
mKeyboardLight.setBrightness(target);
2308+
}
2309+
return;
2310+
}
22942311
if (isAnimating() && (mask ^ currentMask) != 0) {
22952312
// current animation is unrelated to new animation, jump to final values
22962313
cancelAnimation();
@@ -2653,13 +2670,6 @@ private void lightSensorChangedLocked(int value, boolean immediate) {
26532670
return;
26542671
}
26552672

2656-
final int stepsToTargetLevel;
2657-
if (mHighestLightSensorValue <= value) {
2658-
stepsToTargetLevel = AUTOBRIGHTNESS_ANIM_STEPS;
2659-
} else {
2660-
stepsToTargetLevel = AUTODIMNESS_ANIM_STEPS;
2661-
}
2662-
26632673
if (mLightSensorValue != value) {
26642674
mLightSensorValue = value;
26652675
if ((mPowerState & BATTERY_LOW_BIT) == 0) {
@@ -2686,7 +2696,18 @@ private void lightSensorChangedLocked(int value, boolean immediate) {
26862696

26872697
if (mAutoBrightessEnabled && mScreenBrightnessOverride < 0) {
26882698
if (!mSkippedScreenOn && !mInitialAnimation) {
2689-
int steps = immediate ? IMMEDIATE_ANIM_STEPS : stepsToTargetLevel;
2699+
final int steps;
2700+
if (immediate) {
2701+
steps = IMMEDIATE_ANIM_STEPS;
2702+
} else {
2703+
synchronized (mScreenBrightnessAnimator) {
2704+
if (mScreenBrightnessAnimator.currentValue <= lcdValue) {
2705+
steps = AUTOBRIGHTNESS_ANIM_STEPS;
2706+
} else {
2707+
steps = AUTODIMNESS_ANIM_STEPS;
2708+
}
2709+
}
2710+
}
26902711
mScreenBrightnessAnimator.animateTo(lcdValue, value,
26912712
SCREEN_BRIGHT_BIT, steps * NOMINAL_FRAME_TIME_MS);
26922713
}

0 commit comments

Comments
 (0)