Skip to content

Commit a07b1ff

Browse files
Jeff BrownAndroid (Google) Code Review
authored andcommitted
Merge "Support animating just the backlight when turning off." into jb-mr1-dev
2 parents 29126cf + a52772f commit a07b1ff

File tree

2 files changed

+26
-8
lines changed

2 files changed

+26
-8
lines changed

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

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -197,6 +197,12 @@ final class DisplayPowerController {
197197
// May be 0 if no warm-up is required.
198198
private int mLightSensorWarmUpTimeConfig;
199199

200+
// True if we should animate the backlight when turning the screen on or off, which
201+
// tends to be efficient for LCD displays but not for OLED displays.
202+
// False if we should play the electron beam animation instead, which is better for
203+
// OLED displays.
204+
private boolean mElectronBeamAnimatesBacklightConfig;
205+
200206
// The pending power request.
201207
// Initially null until the first call to requestPowerState.
202208
// Guarded by mLock.
@@ -362,6 +368,9 @@ public DisplayPowerController(Looper looper, Context context, Notifier notifier,
362368
com.android.internal.R.integer.config_lightSensorWarmupTime);
363369
}
364370

371+
mElectronBeamAnimatesBacklightConfig = resources.getBoolean(
372+
com.android.internal.R.bool.config_animateScreenLights);
373+
365374
if (!DEBUG_PRETEND_PROXIMITY_SENSOR_ABSENT) {
366375
mProximitySensor = mSensorManager.getDefaultSensor(Sensor.TYPE_PROXIMITY);
367376
if (mProximitySensor != null) {
@@ -481,7 +490,8 @@ private void sendUpdatePowerStateLocked() {
481490
private void initialize() {
482491
final Executor executor = AsyncTask.THREAD_POOL_EXECUTOR;
483492
Display display = mDisplayManager.getDisplay(Display.DEFAULT_DISPLAY);
484-
mPowerState = new DisplayPowerState(new ElectronBeam(display),
493+
mPowerState = new DisplayPowerState(
494+
mElectronBeamAnimatesBacklightConfig ? null : new ElectronBeam(display),
485495
new PhotonicModulator(executor,
486496
mLights.getLight(LightsService.LIGHT_ID_BACKLIGHT),
487497
mSuspendBlocker));

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

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ final class DisplayPowerState {
5050
private static final int DIRTY_BRIGHTNESS = 1 << 2;
5151

5252
private final Choreographer mChoreographer;
53-
private final ElectronBeam mElectronBeam;
53+
private final ElectronBeam mElectronBeam; // may be null if only animating backlights
5454
private final PhotonicModulator mScreenBrightnessModulator;
5555

5656
private int mDirty;
@@ -134,16 +134,22 @@ public boolean isScreenOn() {
134134
* @return True if the electron beam was prepared.
135135
*/
136136
public boolean prepareElectronBeam(boolean warmUp) {
137-
boolean success = mElectronBeam.prepare(warmUp);
138-
invalidate(DIRTY_ELECTRON_BEAM);
139-
return success;
137+
if (mElectronBeam != null) {
138+
boolean success = mElectronBeam.prepare(warmUp);
139+
invalidate(DIRTY_ELECTRON_BEAM);
140+
return success;
141+
} else {
142+
return true;
143+
}
140144
}
141145

142146
/**
143147
* Dismisses the electron beam surface.
144148
*/
145149
public void dismissElectronBeam() {
146-
mElectronBeam.dismiss();
150+
if (mElectronBeam != null) {
151+
mElectronBeam.dismiss();
152+
}
147153
}
148154

149155
/**
@@ -224,7 +230,9 @@ public void dump(PrintWriter pw) {
224230
pw.println(" mScreenBrightness=" + mScreenBrightness);
225231
pw.println(" mElectronBeamLevel=" + mElectronBeamLevel);
226232

227-
mElectronBeam.dump(pw);
233+
if (mElectronBeam != null) {
234+
mElectronBeam.dump(pw);
235+
}
228236
}
229237

230238
private void invalidate(int dirty) {
@@ -243,7 +251,7 @@ private void apply() {
243251
PowerManagerService.nativeSetScreenState(false);
244252
}
245253

246-
if ((mDirty & DIRTY_ELECTRON_BEAM) != 0) {
254+
if ((mDirty & DIRTY_ELECTRON_BEAM) != 0 && mElectronBeam != null) {
247255
mElectronBeam.draw(mElectronBeamLevel);
248256
}
249257

0 commit comments

Comments
 (0)