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

Commit f974cc87 authored by Ruchi Kandoi's avatar Ruchi Kandoi
Browse files

Display: Brightness: Low power mode scales the brightness to 50 percent.



When the device is in low power mode all changes to brightness will be
scaled to half of the brightness that would be normally set when not in
low power mode.

Change-Id: I03be820ef64c1d5631ded35f7dfc2799e807226b
Signed-off-by: default avatarRuchi Kandoi <kandoiruchi@google.com>
parent 07bb4c30
Loading
Loading
Loading
Loading
+8 −2
Original line number Diff line number Diff line
@@ -156,6 +156,9 @@ public abstract class DisplayManagerInternal {
        // If true, enables automatic brightness control.
        public boolean useAutoBrightness;

        //If true, scales the brightness to half of desired.
        public boolean lowPowerMode;

        // If true, prevents the screen from completely turning on if it is currently off.
        // The display does not enter a "ready" state if this flag is true and screen on is
        // blocked.  The window manager policy blocks screen on while it prepares the keyguard to
@@ -203,6 +206,7 @@ public abstract class DisplayManagerInternal {
            screenAutoBrightnessAdjustment = other.screenAutoBrightnessAdjustment;
            useAutoBrightness = other.useAutoBrightness;
            blockScreenOn = other.blockScreenOn;
            lowPowerMode = other.lowPowerMode;
        }

        @Override
@@ -218,7 +222,8 @@ public abstract class DisplayManagerInternal {
                    && screenBrightness == other.screenBrightness
                    && screenAutoBrightnessAdjustment == other.screenAutoBrightnessAdjustment
                    && useAutoBrightness == other.useAutoBrightness
                    && blockScreenOn == other.blockScreenOn;
                    && blockScreenOn == other.blockScreenOn
                    && lowPowerMode == other.lowPowerMode;
        }

        @Override
@@ -233,7 +238,8 @@ public abstract class DisplayManagerInternal {
                    + ", screenBrightness=" + screenBrightness
                    + ", screenAutoBrightnessAdjustment=" + screenAutoBrightnessAdjustment
                    + ", useAutoBrightness=" + useAutoBrightness
                    + ", blockScreenOn=" + blockScreenOn;
                    + ", blockScreenOn=" + blockScreenOn
                    + ", lowPowerMode=" + lowPowerMode;
        }
    }

+5 −0
Original line number Diff line number Diff line
@@ -518,6 +518,11 @@ final class DisplayPowerController implements AutomaticBrightnessController.Call
                // Brighten quickly.
                slow = false;
            }
            // If low power mode is enabled, brightness level
            // would be scaled down to half
            if (mPowerRequest.lowPowerMode) {
                target = target/2;
            }
            animateScreenBrightness(clampScreenBrightness(target),
                    slow ? BRIGHTNESS_RAMP_RATE_SLOW : BRIGHTNESS_RAMP_RATE_FAST);
        } else {
+2 −0
Original line number Diff line number Diff line
@@ -1634,6 +1634,8 @@ public final class PowerManagerService extends com.android.server.SystemService

            mDisplayPowerRequest.blockScreenOn = mScreenOnBlocker.isHeld();

            mDisplayPowerRequest.lowPowerMode = mLowPowerModeEnabled;

            mDisplayReady = mDisplayManagerInternal.requestPowerState(mDisplayPowerRequest,
                    mRequestWaitForNegativeProximity);
            mRequestWaitForNegativeProximity = false;