From f3457ca71a8a39efee848ee822846077486118ac Mon Sep 17 00:00:00 2001 From: Fiona Campbell Date: Fri, 26 Aug 2022 15:09:40 +0000 Subject: [PATCH] Implement tuning of brightness thresholds for idle Add tuning for screen brightness and ambient brightness thresholds while in idle screen brightness mode. Bug: 242267499 Test: adb shell dumpsys display Test: atest com.android.server.display Change-Id: I742ebb29545ee337161e714bdb48be10daeb7b73 --- .../AutomaticBrightnessController.java | 48 +++++- .../server/display/DisplayDeviceConfig.java | 157 ++++++++++++++++-- .../display/DisplayPowerController.java | 22 ++- .../server/display/HysteresisLevels.java | 3 - .../display-device-config.xsd | 14 +- .../display-device-config/schema/current.txt | 4 + .../AutomaticBrightnessControllerTest.java | 8 +- 7 files changed, 225 insertions(+), 31 deletions(-) diff --git a/services/core/java/com/android/server/display/AutomaticBrightnessController.java b/services/core/java/com/android/server/display/AutomaticBrightnessController.java index 31562c735f3ae..a7d372977ebbb 100644 --- a/services/core/java/com/android/server/display/AutomaticBrightnessController.java +++ b/services/core/java/com/android/server/display/AutomaticBrightnessController.java @@ -131,6 +131,8 @@ class AutomaticBrightnessController { // Configuration object for determining thresholds to change brightness dynamically private final HysteresisLevels mAmbientBrightnessThresholds; private final HysteresisLevels mScreenBrightnessThresholds; + private final HysteresisLevels mAmbientBrightnessThresholdsIdle; + private final HysteresisLevels mScreenBrightnessThresholdsIdle; private boolean mLoggingEnabled; @@ -242,7 +244,9 @@ class AutomaticBrightnessController { float dozeScaleFactor, int lightSensorRate, int initialLightSensorRate, long brighteningLightDebounceConfig, long darkeningLightDebounceConfig, boolean resetAmbientLuxAfterWarmUpConfig, HysteresisLevels ambientBrightnessThresholds, - HysteresisLevels screenBrightnessThresholds, Context context, + HysteresisLevels screenBrightnessThresholds, + HysteresisLevels ambientBrightnessThresholdsIdle, + HysteresisLevels screenBrightnessThresholdsIdle, Context context, HighBrightnessModeController hbmController, BrightnessThrottler brightnessThrottler, BrightnessMappingStrategy idleModeBrightnessMapper, int ambientLightHorizonShort, int ambientLightHorizonLong) { @@ -251,7 +255,8 @@ class AutomaticBrightnessController { lightSensorWarmUpTime, brightnessMin, brightnessMax, dozeScaleFactor, lightSensorRate, initialLightSensorRate, brighteningLightDebounceConfig, darkeningLightDebounceConfig, resetAmbientLuxAfterWarmUpConfig, - ambientBrightnessThresholds, screenBrightnessThresholds, context, + ambientBrightnessThresholds, screenBrightnessThresholds, + ambientBrightnessThresholdsIdle, screenBrightnessThresholdsIdle, context, hbmController, brightnessThrottler, idleModeBrightnessMapper, ambientLightHorizonShort, ambientLightHorizonLong ); @@ -265,7 +270,9 @@ class AutomaticBrightnessController { float dozeScaleFactor, int lightSensorRate, int initialLightSensorRate, long brighteningLightDebounceConfig, long darkeningLightDebounceConfig, boolean resetAmbientLuxAfterWarmUpConfig, HysteresisLevels ambientBrightnessThresholds, - HysteresisLevels screenBrightnessThresholds, Context context, + HysteresisLevels screenBrightnessThresholds, + HysteresisLevels ambientBrightnessThresholdsIdle, + HysteresisLevels screenBrightnessThresholdsIdle, Context context, HighBrightnessModeController hbmController, BrightnessThrottler brightnessThrottler, BrightnessMappingStrategy idleModeBrightnessMapper, int ambientLightHorizonShort, int ambientLightHorizonLong) { @@ -289,7 +296,9 @@ class AutomaticBrightnessController { mAmbientLightHorizonShort = ambientLightHorizonShort; mWeightingIntercept = ambientLightHorizonLong; mAmbientBrightnessThresholds = ambientBrightnessThresholds; + mAmbientBrightnessThresholdsIdle = ambientBrightnessThresholdsIdle; mScreenBrightnessThresholds = screenBrightnessThresholds; + mScreenBrightnessThresholdsIdle = screenBrightnessThresholdsIdle; mShortTermModelValid = true; mShortTermModelAnchor = -1; mHandler = new AutomaticBrightnessHandler(looper); @@ -585,6 +594,8 @@ class AutomaticBrightnessController { pw.println(); mAmbientBrightnessThresholds.dump(pw); mScreenBrightnessThresholds.dump(pw); + mScreenBrightnessThresholdsIdle.dump(pw); + mScreenBrightnessThresholdsIdle.dump(pw); } private String configStateToString(int state) { @@ -679,8 +690,17 @@ class AutomaticBrightnessController { lux = 0; } mAmbientLux = lux; - mAmbientBrighteningThreshold = mAmbientBrightnessThresholds.getBrighteningThreshold(lux); - mAmbientDarkeningThreshold = mAmbientBrightnessThresholds.getDarkeningThreshold(lux); + if (isInIdleMode()) { + mAmbientBrighteningThreshold = + mAmbientBrightnessThresholdsIdle.getBrighteningThreshold(lux); + mAmbientDarkeningThreshold = + mAmbientBrightnessThresholdsIdle.getDarkeningThreshold(lux); + } else { + mAmbientBrighteningThreshold = + mAmbientBrightnessThresholds.getBrighteningThreshold(lux); + mAmbientDarkeningThreshold = + mAmbientBrightnessThresholds.getDarkeningThreshold(lux); + } mHbmController.onAmbientLuxChange(mAmbientLux); // If the short term model was invalidated and the change is drastic enough, reset it. @@ -902,10 +922,20 @@ class AutomaticBrightnessController { mPreThresholdBrightness = mScreenAutoBrightness; } mScreenAutoBrightness = newScreenAutoBrightness; - mScreenBrighteningThreshold = clampScreenBrightness( - mScreenBrightnessThresholds.getBrighteningThreshold(newScreenAutoBrightness)); - mScreenDarkeningThreshold = clampScreenBrightness( - mScreenBrightnessThresholds.getDarkeningThreshold(newScreenAutoBrightness)); + if (isInIdleMode()) { + mScreenBrighteningThreshold = clampScreenBrightness( + mScreenBrightnessThresholdsIdle.getBrighteningThreshold( + newScreenAutoBrightness)); + mScreenDarkeningThreshold = clampScreenBrightness( + mScreenBrightnessThresholdsIdle.getDarkeningThreshold( + newScreenAutoBrightness)); + } else { + mScreenBrighteningThreshold = clampScreenBrightness( + mScreenBrightnessThresholds.getBrighteningThreshold( + newScreenAutoBrightness)); + mScreenDarkeningThreshold = clampScreenBrightness( + mScreenBrightnessThresholds.getDarkeningThreshold(newScreenAutoBrightness)); + } if (sendUpdate) { mCallbacks.updateBrightness(); diff --git a/services/core/java/com/android/server/display/DisplayDeviceConfig.java b/services/core/java/com/android/server/display/DisplayDeviceConfig.java index 12b2f4773387d..4165186135683 100644 --- a/services/core/java/com/android/server/display/DisplayDeviceConfig.java +++ b/services/core/java/com/android/server/display/DisplayDeviceConfig.java @@ -188,8 +188,8 @@ import javax.xml.datatype.DatatypeConfigurationException; * 10001 * 2001 * - * - * + * // Thresholds for screen changes + * // Thresholds for active mode brightness changes. * 0.001 // Minimum change needed in screen brightness to brighten. * * @@ -197,8 +197,8 @@ import javax.xml.datatype.DatatypeConfigurationException; * * * - * - * + * // Thresholds for lux changes + * // Thresholds for active mode brightness changes. * 0.003 // Minimum change needed in ambient brightness to brighten. * * @@ -206,6 +206,24 @@ import javax.xml.datatype.DatatypeConfigurationException; * * * + * // Thresholds for screen changes in idle mode + * // Thresholds for idle mode brightness changes. + * 0.001 // Minimum change needed in screen brightness to brighten. + * + * + * 0.002 // Minimum change needed in screen brightness to darken. + * + * + * + * // Thresholds for lux changes in idle mode + * // Thresholds for idle mode brightness changes. + * 0.003 // Minimum change needed in ambient brightness to brighten. + * + * + * 0.004 // Minimum change needed in ambient brightness to darken. + * + * + * * * } * @@ -319,9 +337,13 @@ public class DisplayDeviceConfig { private int mAmbientHorizonLong = AMBIENT_LIGHT_LONG_HORIZON_MILLIS; private int mAmbientHorizonShort = AMBIENT_LIGHT_SHORT_HORIZON_MILLIS; private float mScreenBrighteningMinThreshold = 0.0f; // Retain behaviour as though there is - private float mScreenDarkeningMinThreshold = 0.0f; // no minimum threshold for change in - private float mAmbientLuxBrighteningMinThreshold = 0.0f; // screen brightness or ambient - private float mAmbientLuxDarkeningMinThreshold = 0.0f; // brightness. + private float mScreenBrighteningMinThresholdIdle = 0.0f; // no minimum threshold for change in + private float mScreenDarkeningMinThreshold = 0.0f; // screen brightness or ambient + private float mScreenDarkeningMinThresholdIdle = 0.0f; // brightness. + private float mAmbientLuxBrighteningMinThreshold = 0.0f; + private float mAmbientLuxBrighteningMinThresholdIdle = 0.0f; + private float mAmbientLuxDarkeningMinThreshold = 0.0f; + private float mAmbientLuxDarkeningMinThresholdIdle = 0.0f; private Spline mBrightnessToBacklightSpline; private Spline mBacklightToBrightnessSpline; private Spline mBacklightToNitsSpline; @@ -625,22 +647,76 @@ public class DisplayDeviceConfig { return mAmbientHorizonShort; } + /** + * The minimum value for the screen brightness increase to actually occur. + * @return float value in brightness scale of 0 - 1. + */ public float getScreenBrighteningMinThreshold() { return mScreenBrighteningMinThreshold; } + /** + * The minimum value for the screen brightness decrease to actually occur. + * @return float value in brightness scale of 0 - 1. + */ public float getScreenDarkeningMinThreshold() { return mScreenDarkeningMinThreshold; } + /** + * The minimum value for the screen brightness increase to actually occur while in idle screen + * brightness mode. + * @return float value in brightness scale of 0 - 1. + */ + public float getScreenBrighteningMinThresholdIdle() { + return mScreenBrighteningMinThresholdIdle; + } + + /** + * The minimum value for the screen brightness decrease to actually occur while in idle screen + * brightness mode. + * @return float value in brightness scale of 0 - 1. + */ + public float getScreenDarkeningMinThresholdIdle() { + return mScreenDarkeningMinThresholdIdle; + } + + /** + * The minimum value for the ambient lux increase for a screen brightness change to actually + * occur. + * @return float value in brightness scale of 0 - 1. + */ public float getAmbientLuxBrighteningMinThreshold() { return mAmbientLuxBrighteningMinThreshold; } + /** + * The minimum value for the ambient lux decrease for a screen brightness change to actually + * occur. + * @return float value in brightness scale of 0 - 1. + */ public float getAmbientLuxDarkeningMinThreshold() { return mAmbientLuxDarkeningMinThreshold; } + /** + * The minimum value for the ambient lux increase for a screen brightness change to actually + * occur while in idle screen brightness mode. + * @return float value in brightness scale of 0 - 1. + */ + public float getAmbientLuxBrighteningMinThresholdIdle() { + return mAmbientLuxBrighteningMinThresholdIdle; + } + + /** + * The minimum value for the ambient lux decrease for a screen brightness change to actually + * occur while in idle screen brightness mode. + * @return float value in brightness scale of 0 - 1. + */ + public float getAmbientLuxDarkeningMinThresholdIdle() { + return mAmbientLuxDarkeningMinThresholdIdle; + } + SensorData getAmbientLightSensor() { return mAmbientLightSensor; } @@ -745,9 +821,14 @@ public class DisplayDeviceConfig { + ", mAmbientHorizonLong=" + mAmbientHorizonLong + ", mAmbientHorizonShort=" + mAmbientHorizonShort + ", mScreenDarkeningMinThreshold=" + mScreenDarkeningMinThreshold + + ", mScreenDarkeningMinThresholdIdle=" + mScreenDarkeningMinThresholdIdle + ", mScreenBrighteningMinThreshold=" + mScreenBrighteningMinThreshold + + ", mScreenBrighteningMinThresholdIdle=" + mScreenBrighteningMinThresholdIdle + ", mAmbientLuxDarkeningMinThreshold=" + mAmbientLuxDarkeningMinThreshold + + ", mAmbientLuxDarkeningMinThresholdIdle=" + mAmbientLuxDarkeningMinThresholdIdle + ", mAmbientLuxBrighteningMinThreshold=" + mAmbientLuxBrighteningMinThreshold + + ", mAmbientLuxBrighteningMinThresholdIdle=" + + mAmbientLuxBrighteningMinThresholdIdle + ", mAmbientLightSensor=" + mAmbientLightSensor + ", mProximitySensor=" + mProximitySensor + ", mRefreshRateLimitations= " + Arrays.toString(mRefreshRateLimitations.toArray()) @@ -1376,24 +1457,34 @@ public class DisplayDeviceConfig { private void loadBrightnessChangeThresholds(DisplayConfiguration config) { Thresholds displayBrightnessThresholds = config.getDisplayBrightnessChangeThresholds(); Thresholds ambientBrightnessThresholds = config.getAmbientBrightnessChangeThresholds(); + Thresholds displayBrightnessThresholdsIdle = + config.getDisplayBrightnessChangeThresholdsIdle(); + Thresholds ambientBrightnessThresholdsIdle = + config.getAmbientBrightnessChangeThresholdsIdle(); + loadDisplayBrightnessThresholds(displayBrightnessThresholds); + loadAmbientBrightnessThresholds(ambientBrightnessThresholds); + loadIdleDisplayBrightnessThresholds(displayBrightnessThresholdsIdle); + loadIdleAmbientBrightnessThresholds(ambientBrightnessThresholdsIdle); + } + + private void loadDisplayBrightnessThresholds(Thresholds displayBrightnessThresholds) { if (displayBrightnessThresholds != null) { BrightnessThresholds brighteningScreen = displayBrightnessThresholds.getBrighteningThresholds(); BrightnessThresholds darkeningScreen = displayBrightnessThresholds.getDarkeningThresholds(); - final BigDecimal screenBrighteningThreshold = brighteningScreen.getMinimum(); - final BigDecimal screenDarkeningThreshold = darkeningScreen.getMinimum(); - - if (screenBrighteningThreshold != null) { - mScreenBrighteningMinThreshold = screenBrighteningThreshold.floatValue(); + if (brighteningScreen != null && brighteningScreen.getMinimum() != null) { + mScreenBrighteningMinThreshold = brighteningScreen.getMinimum().floatValue(); } - if (screenDarkeningThreshold != null) { - mScreenDarkeningMinThreshold = screenDarkeningThreshold.floatValue(); + if (darkeningScreen != null && darkeningScreen.getMinimum() != null) { + mScreenDarkeningMinThreshold = darkeningScreen.getMinimum().floatValue(); } } + } + private void loadAmbientBrightnessThresholds(Thresholds ambientBrightnessThresholds) { if (ambientBrightnessThresholds != null) { BrightnessThresholds brighteningAmbientLux = ambientBrightnessThresholds.getBrighteningThresholds(); @@ -1412,6 +1503,44 @@ public class DisplayDeviceConfig { } } + private void loadIdleDisplayBrightnessThresholds(Thresholds idleDisplayBrightnessThresholds) { + if (idleDisplayBrightnessThresholds != null) { + BrightnessThresholds brighteningScreenIdle = + idleDisplayBrightnessThresholds.getBrighteningThresholds(); + BrightnessThresholds darkeningScreenIdle = + idleDisplayBrightnessThresholds.getDarkeningThresholds(); + + if (brighteningScreenIdle != null + && brighteningScreenIdle.getMinimum() != null) { + mScreenBrighteningMinThresholdIdle = + brighteningScreenIdle.getMinimum().floatValue(); + } + if (darkeningScreenIdle != null && darkeningScreenIdle.getMinimum() != null) { + mScreenDarkeningMinThresholdIdle = + darkeningScreenIdle.getMinimum().floatValue(); + } + } + } + + private void loadIdleAmbientBrightnessThresholds(Thresholds idleAmbientBrightnessThresholds) { + if (idleAmbientBrightnessThresholds != null) { + BrightnessThresholds brighteningAmbientLuxIdle = + idleAmbientBrightnessThresholds.getBrighteningThresholds(); + BrightnessThresholds darkeningAmbientLuxIdle = + idleAmbientBrightnessThresholds.getDarkeningThresholds(); + + if (brighteningAmbientLuxIdle != null + && brighteningAmbientLuxIdle.getMinimum() != null) { + mAmbientLuxBrighteningMinThresholdIdle = + brighteningAmbientLuxIdle.getMinimum().floatValue(); + } + if (darkeningAmbientLuxIdle != null && darkeningAmbientLuxIdle.getMinimum() != null) { + mAmbientLuxDarkeningMinThresholdIdle = + darkeningAmbientLuxIdle.getMinimum().floatValue(); + } + } + } + private boolean thermalStatusIsValid(ThermalStatus value) { if (value == null) { return false; diff --git a/services/core/java/com/android/server/display/DisplayPowerController.java b/services/core/java/com/android/server/display/DisplayPowerController.java index 2deb0565f018c..8b5c3115fce46 100644 --- a/services/core/java/com/android/server/display/DisplayPowerController.java +++ b/services/core/java/com/android/server/display/DisplayPowerController.java @@ -985,6 +985,25 @@ final class DisplayPowerController implements AutomaticBrightnessController.Call screenBrighteningThresholds, screenDarkeningThresholds, screenThresholdLevels, screenDarkeningMinThreshold, screenBrighteningMinThreshold); + // Idle screen thresholds + float screenDarkeningMinThresholdIdle = + mDisplayDeviceConfig.getScreenDarkeningMinThresholdIdle(); + float screenBrighteningMinThresholdIdle = + mDisplayDeviceConfig.getScreenBrighteningMinThresholdIdle(); + HysteresisLevels screenBrightnessThresholdsIdle = new HysteresisLevels( + screenBrighteningThresholds, screenDarkeningThresholds, screenThresholdLevels, + screenDarkeningMinThresholdIdle, screenBrighteningMinThresholdIdle); + + // Idle ambient thresholds + float ambientDarkeningMinThresholdIdle = + mDisplayDeviceConfig.getAmbientLuxDarkeningMinThresholdIdle(); + float ambientBrighteningMinThresholdIdle = + mDisplayDeviceConfig.getAmbientLuxBrighteningMinThresholdIdle(); + HysteresisLevels ambientBrightnessThresholdsIdle = new HysteresisLevels( + ambientBrighteningThresholds, ambientDarkeningThresholds, + ambientThresholdLevels, ambientDarkeningMinThresholdIdle, + ambientBrighteningMinThresholdIdle); + long brighteningLightDebounce = mDisplayDeviceConfig .getAutoBrightnessBrighteningLightDebounce(); long darkeningLightDebounce = mDisplayDeviceConfig @@ -1020,7 +1039,8 @@ final class DisplayPowerController implements AutomaticBrightnessController.Call PowerManager.BRIGHTNESS_MIN, PowerManager.BRIGHTNESS_MAX, dozeScaleFactor, lightSensorRate, initialLightSensorRate, brighteningLightDebounce, darkeningLightDebounce, autoBrightnessResetAmbientLuxAfterWarmUp, - ambientBrightnessThresholds, screenBrightnessThresholds, mContext, + ambientBrightnessThresholds, screenBrightnessThresholds, + ambientBrightnessThresholdsIdle, screenBrightnessThresholdsIdle, mContext, mHbmController, mBrightnessThrottler, mIdleModeBrightnessMapper, mDisplayDeviceConfig.getAmbientHorizonShort(), mDisplayDeviceConfig.getAmbientHorizonLong()); diff --git a/services/core/java/com/android/server/display/HysteresisLevels.java b/services/core/java/com/android/server/display/HysteresisLevels.java index 7a932ce6d7cf4..34134892552f7 100644 --- a/services/core/java/com/android/server/display/HysteresisLevels.java +++ b/services/core/java/com/android/server/display/HysteresisLevels.java @@ -18,15 +18,12 @@ package com.android.server.display; import android.util.Slog; -import com.android.internal.annotations.VisibleForTesting; - import java.io.PrintWriter; import java.util.Arrays; /** * A helper class for handling access to illuminance hysteresis level values. */ -@VisibleForTesting public class HysteresisLevels { private static final String TAG = "HysteresisLevels"; diff --git a/services/core/xsd/display-device-config/display-device-config.xsd b/services/core/xsd/display-device-config/display-device-config.xsd index 6b05d8f74a5e6..267cff6652bb1 100644 --- a/services/core/xsd/display-device-config/display-device-config.xsd +++ b/services/core/xsd/display-device-config/display-device-config.xsd @@ -97,6 +97,16 @@ + + + + + + + + @@ -319,13 +329,13 @@ - + - + diff --git a/services/core/xsd/display-device-config/schema/current.txt b/services/core/xsd/display-device-config/schema/current.txt index fb7a920f7d826..f8bff757f1ac5 100644 --- a/services/core/xsd/display-device-config/schema/current.txt +++ b/services/core/xsd/display-device-config/schema/current.txt @@ -61,11 +61,13 @@ package com.android.server.display.config { public class DisplayConfiguration { ctor public DisplayConfiguration(); method @NonNull public final com.android.server.display.config.Thresholds getAmbientBrightnessChangeThresholds(); + method public final com.android.server.display.config.Thresholds getAmbientBrightnessChangeThresholdsIdle(); method public final java.math.BigInteger getAmbientLightHorizonLong(); method public final java.math.BigInteger getAmbientLightHorizonShort(); method public com.android.server.display.config.AutoBrightness getAutoBrightness(); method @Nullable public final com.android.server.display.config.DensityMapping getDensityMapping(); method @NonNull public final com.android.server.display.config.Thresholds getDisplayBrightnessChangeThresholds(); + method public final com.android.server.display.config.Thresholds getDisplayBrightnessChangeThresholdsIdle(); method public com.android.server.display.config.HighBrightnessMode getHighBrightnessMode(); method public final com.android.server.display.config.SensorDetails getLightSensor(); method public final com.android.server.display.config.SensorDetails getProxSensor(); @@ -80,11 +82,13 @@ package com.android.server.display.config { method public final java.math.BigDecimal getScreenBrightnessRampSlowIncrease(); method @NonNull public final com.android.server.display.config.ThermalThrottling getThermalThrottling(); method public final void setAmbientBrightnessChangeThresholds(@NonNull com.android.server.display.config.Thresholds); + method public final void setAmbientBrightnessChangeThresholdsIdle(com.android.server.display.config.Thresholds); method public final void setAmbientLightHorizonLong(java.math.BigInteger); method public final void setAmbientLightHorizonShort(java.math.BigInteger); method public void setAutoBrightness(com.android.server.display.config.AutoBrightness); method public final void setDensityMapping(@Nullable com.android.server.display.config.DensityMapping); method public final void setDisplayBrightnessChangeThresholds(@NonNull com.android.server.display.config.Thresholds); + method public final void setDisplayBrightnessChangeThresholdsIdle(com.android.server.display.config.Thresholds); method public void setHighBrightnessMode(com.android.server.display.config.HighBrightnessMode); method public final void setLightSensor(com.android.server.display.config.SensorDetails); method public final void setProxSensor(com.android.server.display.config.SensorDetails); diff --git a/services/tests/servicestests/src/com/android/server/display/AutomaticBrightnessControllerTest.java b/services/tests/servicestests/src/com/android/server/display/AutomaticBrightnessControllerTest.java index 9d82f1a90c778..8280fc6c962f7 100644 --- a/services/tests/servicestests/src/com/android/server/display/AutomaticBrightnessControllerTest.java +++ b/services/tests/servicestests/src/com/android/server/display/AutomaticBrightnessControllerTest.java @@ -82,6 +82,8 @@ public class AutomaticBrightnessControllerTest { @Mock BrightnessMappingStrategy mIdleBrightnessMappingStrategy; @Mock HysteresisLevels mAmbientBrightnessThresholds; @Mock HysteresisLevels mScreenBrightnessThresholds; + @Mock HysteresisLevels mAmbientBrightnessThresholdsIdle; + @Mock HysteresisLevels mScreenBrightnessThresholdsIdle; @Mock Handler mNoOpHandler; @Mock HighBrightnessModeController mHbmController; @Mock BrightnessThrottler mBrightnessThrottler; @@ -129,6 +131,7 @@ public class AutomaticBrightnessControllerTest { INITIAL_LIGHT_SENSOR_RATE, BRIGHTENING_LIGHT_DEBOUNCE_CONFIG, DARKENING_LIGHT_DEBOUNCE_CONFIG, RESET_AMBIENT_LUX_AFTER_WARMUP_CONFIG, mAmbientBrightnessThresholds, mScreenBrightnessThresholds, + mAmbientBrightnessThresholdsIdle, mScreenBrightnessThresholdsIdle, mContext, mHbmController, mBrightnessThrottler, mIdleBrightnessMappingStrategy, AMBIENT_LIGHT_HORIZON_SHORT, AMBIENT_LIGHT_HORIZON_LONG ); @@ -314,8 +317,9 @@ public class AutomaticBrightnessControllerTest { // Now let's do the same for idle mode mController.switchToIdleMode(); - // Called once for init, and once when switching - verify(mBrightnessMappingStrategy, times(2)).isForIdleMode(); + // Called once for init, and once when switching, + // setAmbientLux() is called twice and once in updateAutoBrightness() + verify(mBrightnessMappingStrategy, times(5)).isForIdleMode(); // Ensure, after switching, original BMS is not used anymore verifyNoMoreInteractions(mBrightnessMappingStrategy);