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

Commit 648ea2df authored by Michael Wright's avatar Michael Wright
Browse files

Add new bucket above high brightness for "sunlight".

Being in direct sunlight can cause the screen to look like it's
"strobing", so we want to tell the kernel when we think we're in this
state so it can configure the display to avoid this effect.

Bug: 63820596
Test: TBD
Change-Id: Ie0b7a8d45d080231748337507d1037ab45950aed
parent 3789b629
Loading
Loading
Loading
Loading
+3 −0
Original line number Diff line number Diff line
@@ -273,6 +273,9 @@
    <!-- Doze: the brightness value to use for the higher brightness AOD mode -->
    <integer name="config_doze_aod_brightness_high">27</integer>

    <!-- Doze: the brightness value to use for the sunlight AOD mode -->
    <integer name="config_doze_aod_brightness_sunlight">28</integer>

    <!-- Doze: whether the double tap sensor reports 2D touch coordinates -->
    <bool name="doze_double_tap_reports_touch_coordinates">false</bool>

+9 −3
Original line number Diff line number Diff line
@@ -39,6 +39,7 @@ public class DozeScreenBrightness implements DozeMachine.Part, SensorEventListen

    private final int mHighBrightness;
    private final int mLowBrightness;
    private final int mSunlightBrightness;

    public DozeScreenBrightness(Context context, DozeMachine.Service service,
            SensorManager sensorManager, Sensor lightSensor, Handler handler) {
@@ -52,6 +53,8 @@ public class DozeScreenBrightness implements DozeMachine.Part, SensorEventListen
                R.integer.config_doze_aod_brightness_low);
        mHighBrightness = context.getResources().getInteger(
                R.integer.config_doze_aod_brightness_high);
        mSunlightBrightness = context.getResources().getInteger(
                R.integer.config_doze_aod_brightness_sunlight);
    }

    @Override
@@ -83,9 +86,12 @@ public class DozeScreenBrightness implements DozeMachine.Part, SensorEventListen
    }

    private int computeBrightness(int sensorValue) {
        // The sensor reports 0 for off, 1 for low brightness and 2 for high brightness.
        // We currently use DozeScreenState for screen off, so we treat off as low brightness.
        if (sensorValue >= 2) {
        // The sensor reports 0 for off, 1 for low brightness, 2 for high brightness, and 3 for
        // sunlight. We currently use DozeScreenState for screen off, so we treat off as low
        // brightness.
        if (sensorValue >= 3) {
            return mSunlightBrightness;
        } else if (sensorValue == 2) {
            return mHighBrightness;
        } else {
            return mLowBrightness;