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

Commit e6707b8a authored by TreeHugger Robot's avatar TreeHugger Robot Committed by Android (Google) Code Review
Browse files

Merge "Made short term model timeout configurable."

parents 455b60fe 825cc07a
Loading
Loading
Loading
Loading
+7 −0
Original line number Diff line number Diff line
@@ -1404,6 +1404,13 @@
    <integer-array name="config_autoBrightnessLevels">
    </integer-array>

    <!-- Timeout (in milliseconds) after which we remove the effects any user interactions might've
         had on the brightness mapping. This timeout doesn't start until we transition to a
         non-interactive display policy so that we don't reset while users are using their devices,
         but also so that we don't erroneously keep the short-term model if the device is dozing
         but the display is fully on. -->
    <integer name="config_autoBrightnessShortTermModelTimeout">300000</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
@@ -1964,6 +1964,7 @@
  <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_autoBrightnessShortTermModelTimeout" />
  <java-symbol type="integer" name="config_shutdownBatteryTemperature" />
  <java-symbol type="integer" name="config_undockedHdmiRotation" />
  <java-symbol type="integer" name="config_virtualKeyQuietTimeMillis" />
+11 −10
Original line number Diff line number Diff line
@@ -56,13 +56,6 @@ class AutomaticBrightnessController {
    // the user is satisfied with the result before storing the sample.
    private static final int BRIGHTNESS_ADJUSTMENT_SAMPLE_DEBOUNCE_MILLIS = 10000;

    // Timeout after which we remove the effects any user interactions might've had on the
    // brightness mapping. This timeout doesn't start until we transition to a non-interactive
    // display policy so that we don't reset while users are using their devices, but also so that
    // we don't erroneously keep the short-term model if the device is dozing but the display is
    // fully on.
    private static final int SHORT_TERM_MODEL_TIMEOUT_MILLIS = 30000;

    private static final int MSG_UPDATE_AMBIENT_LUX = 1;
    private static final int MSG_BRIGHTNESS_ADJUSTMENT_SAMPLE = 2;
    private static final int MSG_INVALIDATE_SHORT_TERM_MODEL = 3;
@@ -126,6 +119,13 @@ class AutomaticBrightnessController {
    private final HysteresisLevels mAmbientBrightnessThresholds;
    private final HysteresisLevels mScreenBrightnessThresholds;

    // Timeout after which we remove the effects any user interactions might've had on the
    // brightness mapping. This timeout doesn't start until we transition to a non-interactive
    // display policy so that we don't reset while users are using their devices, but also so that
    // we don't erroneously keep the short-term model if the device is dozing but the display is
    // fully on.
    private long mShortTermModelTimeout;

    // Amount of time to delay auto-brightness after screen on while waiting for
    // the light sensor to warm-up in milliseconds.
    // May be 0 if no warm-up is required.
@@ -198,7 +198,7 @@ class AutomaticBrightnessController {
            int lightSensorRate, int initialLightSensorRate, long brighteningLightDebounceConfig,
            long darkeningLightDebounceConfig, boolean resetAmbientLuxAfterWarmUpConfig,
            HysteresisLevels ambientBrightnessThresholds,
            HysteresisLevels screenBrightnessThresholds) {
            HysteresisLevels screenBrightnessThresholds, long shortTermModelTimeout) {
        mCallbacks = callbacks;
        mSensorManager = sensorManager;
        mBrightnessMapper = mapper;
@@ -216,6 +216,7 @@ class AutomaticBrightnessController {
        mWeightingIntercept = AMBIENT_LIGHT_LONG_HORIZON_MILLIS;
        mAmbientBrightnessThresholds = ambientBrightnessThresholds;
        mScreenBrightnessThresholds = screenBrightnessThresholds;
        mShortTermModelTimeout = shortTermModelTimeout;
        mShortTermModelValid = true;
        mShortTermModelAnchor = -1;

@@ -295,7 +296,7 @@ class AutomaticBrightnessController {
        }
        if (!isInteractivePolicy(policy) && isInteractivePolicy(oldPolicy)) {
            mHandler.sendEmptyMessageDelayed(MSG_INVALIDATE_SHORT_TERM_MODEL,
                    SHORT_TERM_MODEL_TIMEOUT_MILLIS);
                    mShortTermModelTimeout);
        } else if (isInteractivePolicy(policy) && !isInteractivePolicy(oldPolicy)) {
            mHandler.removeMessages(MSG_INVALIDATE_SHORT_TERM_MODEL);
        }
@@ -377,13 +378,13 @@ class AutomaticBrightnessController {
        pw.println("  mAmbientLightRingBuffer=" + mAmbientLightRingBuffer);
        pw.println("  mScreenAutoBrightness=" + mScreenAutoBrightness);
        pw.println("  mDisplayPolicy=" + DisplayPowerRequest.policyToString(mDisplayPolicy));
        pw.println("  mShortTermModelTimeout=" + mShortTermModelTimeout);
        pw.println("  mShortTermModelAnchor=" + mShortTermModelAnchor);
        pw.println("  mShortTermModelValid=" + mShortTermModelValid);
        pw.println("  mBrightnessAdjustmentSamplePending=" + mBrightnessAdjustmentSamplePending);
        pw.println("  mBrightnessAdjustmentSampleOldLux=" + mBrightnessAdjustmentSampleOldLux);
        pw.println("  mBrightnessAdjustmentSampleOldBrightness="
                + mBrightnessAdjustmentSampleOldBrightness);
        pw.println("  mShortTermModelValid=" + mShortTermModelValid);

        pw.println();
        mBrightnessMapper.dump(pw);
+3 −1
Original line number Diff line number Diff line
@@ -461,6 +461,8 @@ final class DisplayPowerController implements AutomaticBrightnessController.Call
                        + initialLightSensorRate + ") to be less than or equal to "
                        + "config_autoBrightnessLightSensorRate (" + lightSensorRate + ").");
            }
            int shortTermModelTimeout = resources.getInteger(
                    com.android.internal.R.integer.config_autoBrightnessShortTermModelTimeout);

            mBrightnessMapper = BrightnessMappingStrategy.create(resources);
            if (mBrightnessMapper != null) {
@@ -470,7 +472,7 @@ final class DisplayPowerController implements AutomaticBrightnessController.Call
                        mScreenBrightnessRangeMaximum, dozeScaleFactor, lightSensorRate,
                        initialLightSensorRate, brighteningLightDebounce, darkeningLightDebounce,
                        autoBrightnessResetAmbientLuxAfterWarmUp, ambientBrightnessThresholds,
                        screenBrightnessThresholds);
                        screenBrightnessThresholds, shortTermModelTimeout);
            } else {
                mUseSoftwareAutoBrightnessConfig = false;
            }