Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit a52772ff authored by Jeff Brown's avatar Jeff Brown
Browse files

Support animating just the backlight when turning off.

Bug: 7224614
Change-Id: Ic9fa7a9e458c89d347b03bce6829f952bdf3b6a5
parent 54308359
Loading
Loading
Loading
Loading
+11 −1
Original line number Diff line number Diff line
@@ -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));
+15 −7
Original line number Diff line number Diff line
@@ -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,17 +134,23 @@ final class DisplayPowerState {
     * @return True if the electron beam was prepared.
     */
    public boolean prepareElectronBeam(boolean warmUp) {
        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() {
        if (mElectronBeam != null) {
            mElectronBeam.dismiss();
        }
    }

    /**
     * Sets the level of the electron beam steering current.
@@ -224,8 +230,10 @@ final class DisplayPowerState {
        pw.println("  mScreenBrightness=" + mScreenBrightness);
        pw.println("  mElectronBeamLevel=" + mElectronBeamLevel);

        if (mElectronBeam != null) {
            mElectronBeam.dump(pw);
        }
    }

    private void invalidate(int dirty) {
        if (mDirty == 0) {
@@ -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);
            }