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

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

frameworks: display: Added automatic brightness debounce configs

Change-Id: I047936c098c2f0ddb0d5e258d28f1b7cc7169c79
parent b36bbedb
Loading
Loading
Loading
Loading
+4 −0
Original line number Diff line number Diff line
@@ -276,6 +276,10 @@
    <java-symbol type="string" name="usb_media_removed" />
    <java-symbol type="string" name="usb_media_shared" />

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

    <java-symbol type="string" name="lock_to_app_toast_no_navbar" />
    <java-symbol type="string" name="lock_to_app_description_no_navbar" />
</resources>
+4 −0
Original line number Diff line number Diff line
@@ -871,6 +871,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.
+15 −5
Original line number Diff line number Diff line
@@ -21,6 +21,7 @@ import com.android.server.twilight.TwilightListener;
import com.android.server.twilight.TwilightManager;
import com.android.server.twilight.TwilightState;

import android.content.Context;
import android.content.res.Resources;
import android.hardware.Sensor;
import android.hardware.SensorEvent;
@@ -64,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
@@ -171,9 +172,13 @@ class AutomaticBrightnessController {
    // The last screen auto-brightness gamma.  (For printing in dump() only.)
    private float mLastScreenAutoBrightnessGamma = 1.0f;

    public AutomaticBrightnessController(Callbacks callbacks, Looper looper,
    private final Context mContext;

    public AutomaticBrightnessController(Context context, Callbacks callbacks, Looper looper,
            SensorManager sensorManager, Spline autoBrightnessSpline,
            int lightSensorWarmUpTime, int brightnessMin, int brightnessMax) {
        final Resources resources = context.getResources();
        mContext = context;
        mCallbacks = callbacks;
        mTwilight = LocalServices.getService(TwilightManager.class);
        mSensorManager = sensorManager;
@@ -182,6 +187,11 @@ class AutomaticBrightnessController {
        mScreenBrightnessRangeMaximum = brightnessMax;
        mLightSensorWarmUpTimeConfig = lightSensorWarmUpTime;

        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();

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

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

    private void updateAmbientLux() {
+1 −1
Original line number Diff line number Diff line
@@ -323,7 +323,7 @@ final class DisplayPowerController implements AutomaticBrightnessController.Call
                if (bottom < screenBrightnessRangeMinimum) {
                    screenBrightnessRangeMinimum = bottom;
                }
                mAutomaticBrightnessController = new AutomaticBrightnessController(this,
                mAutomaticBrightnessController = new AutomaticBrightnessController(mContext, this,
                        handler.getLooper(), sensorManager, screenAutoBrightnessSpline,
                        lightSensorWarmUpTimeConfig, screenBrightnessRangeMinimum,
                        mScreenBrightnessRangeMaximum);