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

Commit 99854359 authored by Erica Chang's avatar Erica Chang Committed by Gerrit Code Review
Browse files

frameworks: display: Added automatic brightness configs

Change-Id: I71ad7e08b0be56de959bbf06851944a97a97f620
(cherry picked from commit 8ae0ee8d)
parent f3dc1ca7
Loading
Loading
Loading
Loading
+4 −0
Original line number Diff line number Diff line
@@ -300,6 +300,10 @@
    <java-symbol type="string" name="usb_ext_media_unmountable_notification_message" />
    <java-symbol type="string" name="usb_ext_media_unmountable_notification_title" />

    <!-- Automatic display brightness settings -->
    <java-symbol type="integer" name="config_brighteningLightDebounce" />
    <java-symbol type="integer" name="config_darkeningLightDebounce" />

    <!-- LiveDisplay -->
    <java-symbol type="string" name="live_display_title" />
    <java-symbol type="string" name="live_display_hint" />
+4 −0
Original line number Diff line number Diff line
@@ -971,6 +971,10 @@
    <integer-array name="config_autoBrightnessLevels">
    </integer-array>

    <!-- The debounce time value for automatic display brightness adjustment -->
    <integer name="config_brighteningLightDebounce">4000</integer>
    <integer name="config_darkeningLightDebounce">8000</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.
+10 −4
Original line number Diff line number Diff line
@@ -65,8 +65,8 @@ class AutomaticBrightnessController {
    // when adapting to brighter or darker environments.  This parameter controls how quickly
    // brightness changes occur in response to an observed change in light level that exceeds the
    // hysteresis threshold.
    private static final long BRIGHTENING_LIGHT_DEBOUNCE = 4000;
    private static final long DARKENING_LIGHT_DEBOUNCE = 8000;
    private final long mBrighteningLightDebounceConfig;
    private final long mDarkeningLightDebounceConfig;

    // Hysteresis constraints for brightening or darkening.
    // The recent lux must have changed by at least this fraction relative to the
@@ -185,6 +185,7 @@ class AutomaticBrightnessController {
            SensorManager sensorManager, Spline autoBrightnessSpline, int lightSensorWarmUpTime,
            int brightnessMin, int brightnessMax, float dozeScaleFactor,
            LiveDisplayController ldc) {
        final Resources resources = context.getResources();
        mContext = context;
        mCallbacks = callbacks;
        mTwilight = LocalServices.getService(TwilightManager.class);
@@ -196,6 +197,11 @@ class AutomaticBrightnessController {
        mDozeScaleFactor = dozeScaleFactor;
        mLiveDisplay = ldc;

        mBrighteningLightDebounceConfig = resources.getInteger(
                com.android.internal.R.integer.config_brighteningLightDebounce);
        mDarkeningLightDebounceConfig = resources.getInteger(
                com.android.internal.R.integer.config_darkeningLightDebounce);

        mHandler = new AutomaticBrightnessHandler(looper);
        mAmbientLightRingBuffer = new AmbientLightRingBuffer();

@@ -357,7 +363,7 @@ class AutomaticBrightnessController {
            }
            earliestValidTime = mAmbientLightRingBuffer.getTime(i);
        }
        return earliestValidTime + BRIGHTENING_LIGHT_DEBOUNCE;
        return earliestValidTime + mBrighteningLightDebounceConfig;
    }

    private long nextAmbientLightDarkeningTransition(long time) {
@@ -369,7 +375,7 @@ class AutomaticBrightnessController {
            }
            earliestValidTime = mAmbientLightRingBuffer.getTime(i);
        }
        return earliestValidTime + DARKENING_LIGHT_DEBOUNCE;
        return earliestValidTime + mDarkeningLightDebounceConfig;
    }

    private void updateAmbientLux() {