Merge "Support animating just the backlight when turning off." into jb-mr1-dev

This commit is contained in:
Jeff Brown
2012-10-04 20:19:35 -07:00
committed by Android (Google) Code Review
2 changed files with 26 additions and 8 deletions

View File

@@ -197,6 +197,12 @@ final class DisplayPowerController {
// May be 0 if no warm-up is required.
private int mLightSensorWarmUpTimeConfig;
// True if we should animate the backlight when turning the screen on or off, which
// tends to be efficient for LCD displays but not for OLED displays.
// False if we should play the electron beam animation instead, which is better for
// OLED displays.
private boolean mElectronBeamAnimatesBacklightConfig;
// The pending power request.
// Initially null until the first call to requestPowerState.
// Guarded by mLock.
@@ -362,6 +368,9 @@ final class DisplayPowerController {
com.android.internal.R.integer.config_lightSensorWarmupTime);
}
mElectronBeamAnimatesBacklightConfig = resources.getBoolean(
com.android.internal.R.bool.config_animateScreenLights);
if (!DEBUG_PRETEND_PROXIMITY_SENSOR_ABSENT) {
mProximitySensor = mSensorManager.getDefaultSensor(Sensor.TYPE_PROXIMITY);
if (mProximitySensor != null) {
@@ -481,7 +490,8 @@ final class DisplayPowerController {
private void initialize() {
final Executor executor = AsyncTask.THREAD_POOL_EXECUTOR;
Display display = mDisplayManager.getDisplay(Display.DEFAULT_DISPLAY);
mPowerState = new DisplayPowerState(new ElectronBeam(display),
mPowerState = new DisplayPowerState(
mElectronBeamAnimatesBacklightConfig ? null : new ElectronBeam(display),
new PhotonicModulator(executor,
mLights.getLight(LightsService.LIGHT_ID_BACKLIGHT),
mSuspendBlocker));

View File

@@ -50,7 +50,7 @@ final class DisplayPowerState {
private static final int DIRTY_BRIGHTNESS = 1 << 2;
private final Choreographer mChoreographer;
private final ElectronBeam mElectronBeam;
private final ElectronBeam mElectronBeam; // may be null if only animating backlights
private final PhotonicModulator mScreenBrightnessModulator;
private int mDirty;
@@ -134,16 +134,22 @@ final class DisplayPowerState {
* @return True if the electron beam was prepared.
*/
public boolean prepareElectronBeam(boolean warmUp) {
boolean success = mElectronBeam.prepare(warmUp);
invalidate(DIRTY_ELECTRON_BEAM);
return success;
if (mElectronBeam != null) {
boolean success = mElectronBeam.prepare(warmUp);
invalidate(DIRTY_ELECTRON_BEAM);
return success;
} else {
return true;
}
}
/**
* Dismisses the electron beam surface.
*/
public void dismissElectronBeam() {
mElectronBeam.dismiss();
if (mElectronBeam != null) {
mElectronBeam.dismiss();
}
}
/**
@@ -224,7 +230,9 @@ final class DisplayPowerState {
pw.println(" mScreenBrightness=" + mScreenBrightness);
pw.println(" mElectronBeamLevel=" + mElectronBeamLevel);
mElectronBeam.dump(pw);
if (mElectronBeam != null) {
mElectronBeam.dump(pw);
}
}
private void invalidate(int dirty) {
@@ -243,7 +251,7 @@ final class DisplayPowerState {
PowerManagerService.nativeSetScreenState(false);
}
if ((mDirty & DIRTY_ELECTRON_BEAM) != 0) {
if ((mDirty & DIRTY_ELECTRON_BEAM) != 0 && mElectronBeam != null) {
mElectronBeam.draw(mElectronBeamLevel);
}