Skip to content

Commit 8e306a6

Browse files
author
Jeff Brown
committed
Don't reset brightness to 0 on initial boot.
Bug: 6705012 Change-Id: I8114fda081784abbe720d5eaa637aa5234b5a947
1 parent dce5af6 commit 8e306a6

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

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

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1746,14 +1746,16 @@ private int setScreenStateLocked(boolean on) {
17461746
Slog.i(TAG, "Set screen state: " + on, e);
17471747
}
17481748
if (on) {
1749-
if ((mPowerState & SCREEN_ON_BIT) == 0 || mSkippedScreenOn) {
1749+
if (mInitialized && ((mPowerState & SCREEN_ON_BIT) == 0 || mSkippedScreenOn)) {
17501750
// If we are turning the screen state on, but the screen
17511751
// light is currently off, then make sure that we set the
17521752
// light at this point to 0. This is the case where we are
17531753
// turning on the screen and waiting for the UI to be drawn
17541754
// before showing it to the user. We want the light off
17551755
// until it is ready to be shown to the user, not it using
17561756
// whatever the last value it had.
1757+
// Skip this if the screen is being turned on for the first time
1758+
// after boot (mInitialized is false).
17571759
if (DEBUG_SCREEN_ON) {
17581760
Slog.i(TAG, "Forcing brightness 0: mPowerState=0x"
17591761
+ Integer.toHexString(mPowerState)
@@ -2325,14 +2327,20 @@ public void animateTo(int target, int sensorTarget, int mask, int animationDurat
23252327
// current animation is unrelated to new animation, jump to final values
23262328
cancelAnimation();
23272329
}
2330+
if (mInitialAnimation) {
2331+
// jump to final value in one step the first time the brightness is set
2332+
animationDuration = 0;
2333+
if (target > 0) {
2334+
mInitialAnimation = false;
2335+
}
2336+
}
23282337
startValue = currentValue;
23292338
endValue = target;
23302339
startSensorValue = mHighestLightSensorValue;
23312340
endSensorValue = sensorTarget;
23322341
currentMask = mask;
23332342
duration = (int) (mWindowScaleAnimation * animationDuration);
23342343
startTimeMillis = SystemClock.elapsedRealtime();
2335-
mInitialAnimation = mInitialAnimation && target > 0;
23362344

23372345
if (mDebugLightAnimation) {
23382346
Slog.v(TAG, "animateTo(target=" + target

0 commit comments

Comments
 (0)