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

Commit 1bfd0f46 authored by Jeff Brown's avatar Jeff Brown
Browse files

Improve adaptive brightness in very dark rooms.

Added config_screenBrightnessDark to configure the minimum value
that will be used for auto-brightness adjustment.  This value is
expected to be less than unadjusted minimum auto-brightness level
to provide some range for the user to make the screen dimmer
in dark rooms.

This configuration value is set to the lowest possible level
by default (1).  Individual devices may need to override this value
in their framework resource overlay depending on their backlight
characteristics.

Change-Id: I9bd3a2355c65f894dff89aeaf7661cdf38f4a6ee
parent 7d827515
Loading
Loading
Loading
Loading
+31 −22
Original line number Diff line number Diff line
@@ -673,6 +673,37 @@
    -->
    <integer name="config_doubleTapOnHomeBehavior">0</integer>

    <!-- Minimum screen brightness setting allowed by the power manager.
         The user is forbidden from setting the brightness below this level. -->
    <integer name="config_screenBrightnessSettingMinimum">10</integer>

    <!-- Maximum screen brightness allowed by the power manager.
         The user is forbidden from setting the brightness above this level. -->
    <integer name="config_screenBrightnessSettingMaximum">255</integer>

    <!-- Default screen brightness setting.
         Must be in the range specified by minimum and maximum. -->
    <integer name="config_screenBrightnessSettingDefault">102</integer>

    <!-- Screen brightness used to dim the screen while dozing in a very low power state.
         May be less than the minimum allowed brightness setting
         that can be set by the user. -->
    <integer name="config_screenBrightnessDoze">1</integer>

    <!-- Screen brightness used to dim the screen when the user activity
         timeout expires.  May be less than the minimum allowed brightness setting
         that can be set by the user. -->
    <integer name="config_screenBrightnessDim">10</integer>

    <!-- Minimum allowable screen brightness to use in a very dark room.
         This value sets the floor for the darkest possible auto-brightness
         adjustment.  It is expected to be somewhat less than the first entry in
         config_autoBrightnessLcdBacklightValues so as to allow the user to have
         some range of adjustment to dim the screen further than usual in very
         dark rooms. The contents of the screen must still be clearly visible
         in darkness (although they may not be visible in a bright room). -->
    <integer name="config_screenBrightnessDark">1</integer>

    <!-- Array of light sensor LUX values to define our levels for auto backlight brightness support.
         The N entries of this array define N + 1 control points as follows:
         (1-based arrays)
@@ -696,28 +727,6 @@
    <integer-array name="config_autoBrightnessLevels">
    </integer-array>

    <!-- Minimum screen brightness setting allowed by the power manager.
         The user is forbidden from setting the brightness below this level. -->
    <integer name="config_screenBrightnessSettingMinimum">10</integer>

    <!-- Maximum screen brightness allowed by the power manager.
         The user is forbidden from setting the brightness above this level. -->
    <integer name="config_screenBrightnessSettingMaximum">255</integer>

    <!-- Default screen brightness setting.
         Must be in the range specified by minimum and maximum. -->
    <integer name="config_screenBrightnessSettingDefault">102</integer>

    <!-- Screen brightness used to dim the screen while dozing in a very low power state.
         May be less than the minimum allowed brightness setting
         that can be set by the user. -->
    <integer name="config_screenBrightnessDoze">1</integer>

    <!-- Screen brightness used to dim the screen when the user activity
         timeout expires.  May be less than the minimum allowed brightness setting
         that can be set by the user. -->
    <integer name="config_screenBrightnessDim">10</integer>

    <!-- Array of output values for LCD backlight corresponding to the LUX values
         in the config_autoBrightnessLevels array.  This array should have size one greater
         than the size of the config_autoBrightnessLevels array.
+1 −0
Original line number Diff line number Diff line
@@ -1560,6 +1560,7 @@
  <java-symbol type="integer" name="config_screenBrightnessSettingMinimum" />
  <java-symbol type="integer" name="config_screenBrightnessSettingMaximum" />
  <java-symbol type="integer" name="config_screenBrightnessSettingDefault" />
  <java-symbol type="integer" name="config_screenBrightnessDark" />
  <java-symbol type="integer" name="config_screenBrightnessDim" />
  <java-symbol type="integer" name="config_screenBrightnessDoze" />
  <java-symbol type="integer" name="config_shutdownBatteryTemperature" />
+32 −5
Original line number Diff line number Diff line
@@ -139,6 +139,9 @@ final class DisplayPowerController implements AutomaticBrightnessController.Call
    // The dim screen brightness.
    private final int mScreenBrightnessDimConfig;

    // The minimum screen brightness to use in a very dark room.
    private final int mScreenBrightnessDarkConfig;

    // The minimum allowed brightness.
    private final int mScreenBrightnessRangeMinimum;

@@ -247,6 +250,8 @@ final class DisplayPowerController implements AutomaticBrightnessController.Call
        mContext = context;

        final Resources resources = context.getResources();
        final int screenBrightnessSettingMinimum = clampAbsoluteBrightness(resources.getInteger(
                com.android.internal.R.integer.config_screenBrightnessSettingMinimum));

        mScreenBrightnessDozeConfig = clampAbsoluteBrightness(resources.getInteger(
                com.android.internal.R.integer.config_screenBrightnessDoze));
@@ -254,9 +259,23 @@ final class DisplayPowerController implements AutomaticBrightnessController.Call
        mScreenBrightnessDimConfig = clampAbsoluteBrightness(resources.getInteger(
                com.android.internal.R.integer.config_screenBrightnessDim));

        int screenBrightnessRangeMinimum = clampAbsoluteBrightness(Math.min(resources.getInteger(
                com.android.internal.R.integer.config_screenBrightnessSettingMinimum),
                mScreenBrightnessDimConfig));
        mScreenBrightnessDarkConfig = clampAbsoluteBrightness(resources.getInteger(
                com.android.internal.R.integer.config_screenBrightnessDark));
        if (mScreenBrightnessDarkConfig > mScreenBrightnessDimConfig) {
            Slog.w(TAG, "Expected config_screenBrightnessDark ("
                    + mScreenBrightnessDarkConfig + ") to be less than or equal to "
                    + "config_screenBrightnessDim (" + mScreenBrightnessDimConfig + ").");
        }
        if (mScreenBrightnessDarkConfig > mScreenBrightnessDimConfig) {
            Slog.w(TAG, "Expected config_screenBrightnessDark ("
                    + mScreenBrightnessDarkConfig + ") to be less than or equal to "
                    + "config_screenBrightnessSettingMinimum ("
                    + screenBrightnessSettingMinimum + ").");
        }

        int screenBrightnessRangeMinimum = Math.min(Math.min(
                screenBrightnessSettingMinimum, mScreenBrightnessDimConfig),
                mScreenBrightnessDarkConfig);

        mScreenBrightnessRangeMaximum = PowerManager.BRIGHTNESS_ON;

@@ -280,8 +299,15 @@ final class DisplayPowerController implements AutomaticBrightnessController.Call
                        + "Auto-brightness will be disabled.");
                mUseSoftwareAutoBrightnessConfig = false;
            } else {
                if (screenBrightness[0] < screenBrightnessRangeMinimum) {
                    screenBrightnessRangeMinimum = clampAbsoluteBrightness(screenBrightness[0]);
                int bottom = clampAbsoluteBrightness(screenBrightness[0]);
                if (mScreenBrightnessDarkConfig > bottom) {
                    Slog.w(TAG, "config_screenBrightnessDark (" + mScreenBrightnessDarkConfig
                            + ") should be less than or equal to the first value of "
                            + "config_autoBrightnessLcdBacklightValues ("
                            + bottom + ").");
                }
                if (bottom < screenBrightnessRangeMinimum) {
                    screenBrightnessRangeMinimum = bottom;
                }
                mAutomaticBrightnessController = new AutomaticBrightnessController(this,
                        handler.getLooper(), sensorManager, screenAutoBrightnessSpline,
@@ -905,6 +931,7 @@ final class DisplayPowerController implements AutomaticBrightnessController.Call
        pw.println("Display Power Controller Configuration:");
        pw.println("  mScreenBrightnessDozeConfig=" + mScreenBrightnessDozeConfig);
        pw.println("  mScreenBrightnessDimConfig=" + mScreenBrightnessDimConfig);
        pw.println("  mScreenBrightnessDarkConfig=" + mScreenBrightnessDarkConfig);
        pw.println("  mScreenBrightnessRangeMinimum=" + mScreenBrightnessRangeMinimum);
        pw.println("  mScreenBrightnessRangeMaximum=" + mScreenBrightnessRangeMaximum);
        pw.println("  mUseSoftwareAutoBrightnessConfig="