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

Commit 825cc07a authored by Dan Gittik's avatar Dan Gittik
Browse files

Made short term model timeout configurable.

Test: manual.
      Apply user adjustment (i.e. set brightness manually), let
      screen go idle, and check that the user adjustment persists
      up to 5 minutes and is cancelled afterwards.

Change-Id: I5916d8d2749a682daf172ed799ade1a33f4e5da7
Fixes: 122350002
parent 70a5fa70
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;
            }