Skip to content

Commit 9f4021d

Browse files
Dianne HackbornAndroid (Google) Code Review
authored andcommitted
Merge "Keep screen brightness at 0 while waiting for the UI to be displayed."
2 parents 5f9532f + 474fd74 commit 9f4021d

1 file changed

Lines changed: 21 additions & 2 deletions

File tree

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

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1677,6 +1677,18 @@ private int setScreenStateLocked(boolean on) {
16771677
e.fillInStackTrace();
16781678
Slog.i(TAG, "Set screen state: " + on, e);
16791679
}
1680+
if (on) {
1681+
if ((mPowerState & SCREEN_ON_BIT) == 0 || mSkippedScreenOn) {
1682+
// If we are turning the screen state on, but the screen
1683+
// light is currently off, then make sure that we set the
1684+
// light at this point to 0. This is the case where we are
1685+
// turning on the screen and waiting for the UI to be drawn
1686+
// before showing it to the user. We want the light off
1687+
// until it is ready to be shown to the user, not it using
1688+
// whatever the last value it had.
1689+
mScreenBrightness.forceValueLocked(Power.BRIGHTNESS_OFF);
1690+
}
1691+
}
16801692
int err = Power.setScreenState(on);
16811693
if (err == 0) {
16821694
mLastScreenOnTime = (on ? SystemClock.elapsedRealtime() : 0);
@@ -2029,8 +2041,6 @@ private void updateLightsLocked(int newState, int forceState) {
20292041
RuntimeException e = new RuntimeException("here");
20302042
e.fillInStackTrace();
20312043
Slog.i(TAG, "Setting screen brightness: " + brightness, e);
2032-
mScreenBrightness.setTargetLocked(brightness, steps,
2033-
INITIAL_SCREEN_BRIGHTNESS, nominalCurrentValue);
20342044
}
20352045
}
20362046

@@ -2103,6 +2113,15 @@ public void dump(PrintWriter pw, String prefix) {
21032113
+ " delta=" + delta);
21042114
}
21052115

2116+
void forceValueLocked(int value) {
2117+
targetValue = -1;
2118+
curValue = value;
2119+
setLightBrightness(mask, value);
2120+
if (animating) {
2121+
finishAnimationLocked(false, value);
2122+
}
2123+
}
2124+
21062125
void setTargetLocked(int target, int stepsToTarget, int initialValue,
21072126
int nominalCurrentValue) {
21082127
if (!initialized) {

0 commit comments

Comments
 (0)