Merge "Implement tuning of brightness thresholds for idle" into tm-qpr-dev
This commit is contained in:
committed by
Android (Google) Code Review
commit
84e2c20b42
@@ -131,6 +131,8 @@ class AutomaticBrightnessController {
|
|||||||
// Configuration object for determining thresholds to change brightness dynamically
|
// Configuration object for determining thresholds to change brightness dynamically
|
||||||
private final HysteresisLevels mAmbientBrightnessThresholds;
|
private final HysteresisLevels mAmbientBrightnessThresholds;
|
||||||
private final HysteresisLevels mScreenBrightnessThresholds;
|
private final HysteresisLevels mScreenBrightnessThresholds;
|
||||||
|
private final HysteresisLevels mAmbientBrightnessThresholdsIdle;
|
||||||
|
private final HysteresisLevels mScreenBrightnessThresholdsIdle;
|
||||||
|
|
||||||
private boolean mLoggingEnabled;
|
private boolean mLoggingEnabled;
|
||||||
|
|
||||||
@@ -242,7 +244,9 @@ class AutomaticBrightnessController {
|
|||||||
float dozeScaleFactor, int lightSensorRate, int initialLightSensorRate,
|
float dozeScaleFactor, int lightSensorRate, int initialLightSensorRate,
|
||||||
long brighteningLightDebounceConfig, long darkeningLightDebounceConfig,
|
long brighteningLightDebounceConfig, long darkeningLightDebounceConfig,
|
||||||
boolean resetAmbientLuxAfterWarmUpConfig, HysteresisLevels ambientBrightnessThresholds,
|
boolean resetAmbientLuxAfterWarmUpConfig, HysteresisLevels ambientBrightnessThresholds,
|
||||||
HysteresisLevels screenBrightnessThresholds, Context context,
|
HysteresisLevels screenBrightnessThresholds,
|
||||||
|
HysteresisLevels ambientBrightnessThresholdsIdle,
|
||||||
|
HysteresisLevels screenBrightnessThresholdsIdle, Context context,
|
||||||
HighBrightnessModeController hbmController, BrightnessThrottler brightnessThrottler,
|
HighBrightnessModeController hbmController, BrightnessThrottler brightnessThrottler,
|
||||||
BrightnessMappingStrategy idleModeBrightnessMapper, int ambientLightHorizonShort,
|
BrightnessMappingStrategy idleModeBrightnessMapper, int ambientLightHorizonShort,
|
||||||
int ambientLightHorizonLong) {
|
int ambientLightHorizonLong) {
|
||||||
@@ -251,7 +255,8 @@ class AutomaticBrightnessController {
|
|||||||
lightSensorWarmUpTime, brightnessMin, brightnessMax, dozeScaleFactor,
|
lightSensorWarmUpTime, brightnessMin, brightnessMax, dozeScaleFactor,
|
||||||
lightSensorRate, initialLightSensorRate, brighteningLightDebounceConfig,
|
lightSensorRate, initialLightSensorRate, brighteningLightDebounceConfig,
|
||||||
darkeningLightDebounceConfig, resetAmbientLuxAfterWarmUpConfig,
|
darkeningLightDebounceConfig, resetAmbientLuxAfterWarmUpConfig,
|
||||||
ambientBrightnessThresholds, screenBrightnessThresholds, context,
|
ambientBrightnessThresholds, screenBrightnessThresholds,
|
||||||
|
ambientBrightnessThresholdsIdle, screenBrightnessThresholdsIdle, context,
|
||||||
hbmController, brightnessThrottler, idleModeBrightnessMapper,
|
hbmController, brightnessThrottler, idleModeBrightnessMapper,
|
||||||
ambientLightHorizonShort, ambientLightHorizonLong
|
ambientLightHorizonShort, ambientLightHorizonLong
|
||||||
);
|
);
|
||||||
@@ -265,7 +270,9 @@ class AutomaticBrightnessController {
|
|||||||
float dozeScaleFactor, int lightSensorRate, int initialLightSensorRate,
|
float dozeScaleFactor, int lightSensorRate, int initialLightSensorRate,
|
||||||
long brighteningLightDebounceConfig, long darkeningLightDebounceConfig,
|
long brighteningLightDebounceConfig, long darkeningLightDebounceConfig,
|
||||||
boolean resetAmbientLuxAfterWarmUpConfig, HysteresisLevels ambientBrightnessThresholds,
|
boolean resetAmbientLuxAfterWarmUpConfig, HysteresisLevels ambientBrightnessThresholds,
|
||||||
HysteresisLevels screenBrightnessThresholds, Context context,
|
HysteresisLevels screenBrightnessThresholds,
|
||||||
|
HysteresisLevels ambientBrightnessThresholdsIdle,
|
||||||
|
HysteresisLevels screenBrightnessThresholdsIdle, Context context,
|
||||||
HighBrightnessModeController hbmController, BrightnessThrottler brightnessThrottler,
|
HighBrightnessModeController hbmController, BrightnessThrottler brightnessThrottler,
|
||||||
BrightnessMappingStrategy idleModeBrightnessMapper, int ambientLightHorizonShort,
|
BrightnessMappingStrategy idleModeBrightnessMapper, int ambientLightHorizonShort,
|
||||||
int ambientLightHorizonLong) {
|
int ambientLightHorizonLong) {
|
||||||
@@ -289,7 +296,9 @@ class AutomaticBrightnessController {
|
|||||||
mAmbientLightHorizonShort = ambientLightHorizonShort;
|
mAmbientLightHorizonShort = ambientLightHorizonShort;
|
||||||
mWeightingIntercept = ambientLightHorizonLong;
|
mWeightingIntercept = ambientLightHorizonLong;
|
||||||
mAmbientBrightnessThresholds = ambientBrightnessThresholds;
|
mAmbientBrightnessThresholds = ambientBrightnessThresholds;
|
||||||
|
mAmbientBrightnessThresholdsIdle = ambientBrightnessThresholdsIdle;
|
||||||
mScreenBrightnessThresholds = screenBrightnessThresholds;
|
mScreenBrightnessThresholds = screenBrightnessThresholds;
|
||||||
|
mScreenBrightnessThresholdsIdle = screenBrightnessThresholdsIdle;
|
||||||
mShortTermModelValid = true;
|
mShortTermModelValid = true;
|
||||||
mShortTermModelAnchor = -1;
|
mShortTermModelAnchor = -1;
|
||||||
mHandler = new AutomaticBrightnessHandler(looper);
|
mHandler = new AutomaticBrightnessHandler(looper);
|
||||||
@@ -585,6 +594,8 @@ class AutomaticBrightnessController {
|
|||||||
pw.println();
|
pw.println();
|
||||||
mAmbientBrightnessThresholds.dump(pw);
|
mAmbientBrightnessThresholds.dump(pw);
|
||||||
mScreenBrightnessThresholds.dump(pw);
|
mScreenBrightnessThresholds.dump(pw);
|
||||||
|
mScreenBrightnessThresholdsIdle.dump(pw);
|
||||||
|
mScreenBrightnessThresholdsIdle.dump(pw);
|
||||||
}
|
}
|
||||||
|
|
||||||
private String configStateToString(int state) {
|
private String configStateToString(int state) {
|
||||||
@@ -679,8 +690,17 @@ class AutomaticBrightnessController {
|
|||||||
lux = 0;
|
lux = 0;
|
||||||
}
|
}
|
||||||
mAmbientLux = lux;
|
mAmbientLux = lux;
|
||||||
mAmbientBrighteningThreshold = mAmbientBrightnessThresholds.getBrighteningThreshold(lux);
|
if (isInIdleMode()) {
|
||||||
mAmbientDarkeningThreshold = mAmbientBrightnessThresholds.getDarkeningThreshold(lux);
|
mAmbientBrighteningThreshold =
|
||||||
|
mAmbientBrightnessThresholdsIdle.getBrighteningThreshold(lux);
|
||||||
|
mAmbientDarkeningThreshold =
|
||||||
|
mAmbientBrightnessThresholdsIdle.getDarkeningThreshold(lux);
|
||||||
|
} else {
|
||||||
|
mAmbientBrighteningThreshold =
|
||||||
|
mAmbientBrightnessThresholds.getBrighteningThreshold(lux);
|
||||||
|
mAmbientDarkeningThreshold =
|
||||||
|
mAmbientBrightnessThresholds.getDarkeningThreshold(lux);
|
||||||
|
}
|
||||||
mHbmController.onAmbientLuxChange(mAmbientLux);
|
mHbmController.onAmbientLuxChange(mAmbientLux);
|
||||||
|
|
||||||
// If the short term model was invalidated and the change is drastic enough, reset it.
|
// If the short term model was invalidated and the change is drastic enough, reset it.
|
||||||
@@ -902,10 +922,20 @@ class AutomaticBrightnessController {
|
|||||||
mPreThresholdBrightness = mScreenAutoBrightness;
|
mPreThresholdBrightness = mScreenAutoBrightness;
|
||||||
}
|
}
|
||||||
mScreenAutoBrightness = newScreenAutoBrightness;
|
mScreenAutoBrightness = newScreenAutoBrightness;
|
||||||
mScreenBrighteningThreshold = clampScreenBrightness(
|
if (isInIdleMode()) {
|
||||||
mScreenBrightnessThresholds.getBrighteningThreshold(newScreenAutoBrightness));
|
mScreenBrighteningThreshold = clampScreenBrightness(
|
||||||
mScreenDarkeningThreshold = clampScreenBrightness(
|
mScreenBrightnessThresholdsIdle.getBrighteningThreshold(
|
||||||
mScreenBrightnessThresholds.getDarkeningThreshold(newScreenAutoBrightness));
|
newScreenAutoBrightness));
|
||||||
|
mScreenDarkeningThreshold = clampScreenBrightness(
|
||||||
|
mScreenBrightnessThresholdsIdle.getDarkeningThreshold(
|
||||||
|
newScreenAutoBrightness));
|
||||||
|
} else {
|
||||||
|
mScreenBrighteningThreshold = clampScreenBrightness(
|
||||||
|
mScreenBrightnessThresholds.getBrighteningThreshold(
|
||||||
|
newScreenAutoBrightness));
|
||||||
|
mScreenDarkeningThreshold = clampScreenBrightness(
|
||||||
|
mScreenBrightnessThresholds.getDarkeningThreshold(newScreenAutoBrightness));
|
||||||
|
}
|
||||||
|
|
||||||
if (sendUpdate) {
|
if (sendUpdate) {
|
||||||
mCallbacks.updateBrightness();
|
mCallbacks.updateBrightness();
|
||||||
|
|||||||
@@ -188,8 +188,8 @@ import javax.xml.datatype.DatatypeConfigurationException;
|
|||||||
* <ambientLightHorizonLong>10001</ambientLightHorizonLong>
|
* <ambientLightHorizonLong>10001</ambientLightHorizonLong>
|
||||||
* <ambientLightHorizonShort>2001</ambientLightHorizonShort>
|
* <ambientLightHorizonShort>2001</ambientLightHorizonShort>
|
||||||
*
|
*
|
||||||
* <displayBrightnessChangeThresholds>
|
* <displayBrightnessChangeThresholds> // Thresholds for screen changes
|
||||||
* <brighteningThresholds>
|
* <brighteningThresholds> // Thresholds for active mode brightness changes.
|
||||||
* <minimum>0.001</minimum> // Minimum change needed in screen brightness to brighten.
|
* <minimum>0.001</minimum> // Minimum change needed in screen brightness to brighten.
|
||||||
* </brighteningThresholds>
|
* </brighteningThresholds>
|
||||||
* <darkeningThresholds>
|
* <darkeningThresholds>
|
||||||
@@ -197,8 +197,8 @@ import javax.xml.datatype.DatatypeConfigurationException;
|
|||||||
* </darkeningThresholds>
|
* </darkeningThresholds>
|
||||||
* </displayBrightnessChangeThresholds>
|
* </displayBrightnessChangeThresholds>
|
||||||
*
|
*
|
||||||
* <ambientBrightnessChangeThresholds>
|
* <ambientBrightnessChangeThresholds> // Thresholds for lux changes
|
||||||
* <brighteningThresholds>
|
* <brighteningThresholds> // Thresholds for active mode brightness changes.
|
||||||
* <minimum>0.003</minimum> // Minimum change needed in ambient brightness to brighten.
|
* <minimum>0.003</minimum> // Minimum change needed in ambient brightness to brighten.
|
||||||
* </brighteningThresholds>
|
* </brighteningThresholds>
|
||||||
* <darkeningThresholds>
|
* <darkeningThresholds>
|
||||||
@@ -206,6 +206,24 @@ import javax.xml.datatype.DatatypeConfigurationException;
|
|||||||
* </darkeningThresholds>
|
* </darkeningThresholds>
|
||||||
* </ambientBrightnessChangeThresholds>
|
* </ambientBrightnessChangeThresholds>
|
||||||
*
|
*
|
||||||
|
* <displayBrightnessChangeThresholdsIdle> // Thresholds for screen changes in idle mode
|
||||||
|
* <brighteningThresholds> // Thresholds for idle mode brightness changes.
|
||||||
|
* <minimum>0.001</minimum> // Minimum change needed in screen brightness to brighten.
|
||||||
|
* </brighteningThresholds>
|
||||||
|
* <darkeningThresholds>
|
||||||
|
* <minimum>0.002</minimum> // Minimum change needed in screen brightness to darken.
|
||||||
|
* </darkeningThresholds>
|
||||||
|
* </displayBrightnessChangeThresholdsIdle>
|
||||||
|
*
|
||||||
|
* <ambientBrightnessChangeThresholdsIdle> // Thresholds for lux changes in idle mode
|
||||||
|
* <brighteningThresholds> // Thresholds for idle mode brightness changes.
|
||||||
|
* <minimum>0.003</minimum> // Minimum change needed in ambient brightness to brighten.
|
||||||
|
* </brighteningThresholds>
|
||||||
|
* <darkeningThresholds>
|
||||||
|
* <minimum>0.004</minimum> // Minimum change needed in ambient brightness to darken.
|
||||||
|
* </darkeningThresholds>
|
||||||
|
* </ambientBrightnessChangeThresholdsIdle>
|
||||||
|
*
|
||||||
* </displayConfiguration>
|
* </displayConfiguration>
|
||||||
* }
|
* }
|
||||||
* </pre>
|
* </pre>
|
||||||
@@ -319,9 +337,13 @@ public class DisplayDeviceConfig {
|
|||||||
private int mAmbientHorizonLong = AMBIENT_LIGHT_LONG_HORIZON_MILLIS;
|
private int mAmbientHorizonLong = AMBIENT_LIGHT_LONG_HORIZON_MILLIS;
|
||||||
private int mAmbientHorizonShort = AMBIENT_LIGHT_SHORT_HORIZON_MILLIS;
|
private int mAmbientHorizonShort = AMBIENT_LIGHT_SHORT_HORIZON_MILLIS;
|
||||||
private float mScreenBrighteningMinThreshold = 0.0f; // Retain behaviour as though there is
|
private float mScreenBrighteningMinThreshold = 0.0f; // Retain behaviour as though there is
|
||||||
private float mScreenDarkeningMinThreshold = 0.0f; // no minimum threshold for change in
|
private float mScreenBrighteningMinThresholdIdle = 0.0f; // no minimum threshold for change in
|
||||||
private float mAmbientLuxBrighteningMinThreshold = 0.0f; // screen brightness or ambient
|
private float mScreenDarkeningMinThreshold = 0.0f; // screen brightness or ambient
|
||||||
private float mAmbientLuxDarkeningMinThreshold = 0.0f; // brightness.
|
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 mBrightnessToBacklightSpline;
|
||||||
private Spline mBacklightToBrightnessSpline;
|
private Spline mBacklightToBrightnessSpline;
|
||||||
private Spline mBacklightToNitsSpline;
|
private Spline mBacklightToNitsSpline;
|
||||||
@@ -625,22 +647,76 @@ public class DisplayDeviceConfig {
|
|||||||
return mAmbientHorizonShort;
|
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() {
|
public float getScreenBrighteningMinThreshold() {
|
||||||
return mScreenBrighteningMinThreshold;
|
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() {
|
public float getScreenDarkeningMinThreshold() {
|
||||||
return mScreenDarkeningMinThreshold;
|
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() {
|
public float getAmbientLuxBrighteningMinThreshold() {
|
||||||
return mAmbientLuxBrighteningMinThreshold;
|
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() {
|
public float getAmbientLuxDarkeningMinThreshold() {
|
||||||
return mAmbientLuxDarkeningMinThreshold;
|
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() {
|
SensorData getAmbientLightSensor() {
|
||||||
return mAmbientLightSensor;
|
return mAmbientLightSensor;
|
||||||
}
|
}
|
||||||
@@ -745,9 +821,14 @@ public class DisplayDeviceConfig {
|
|||||||
+ ", mAmbientHorizonLong=" + mAmbientHorizonLong
|
+ ", mAmbientHorizonLong=" + mAmbientHorizonLong
|
||||||
+ ", mAmbientHorizonShort=" + mAmbientHorizonShort
|
+ ", mAmbientHorizonShort=" + mAmbientHorizonShort
|
||||||
+ ", mScreenDarkeningMinThreshold=" + mScreenDarkeningMinThreshold
|
+ ", mScreenDarkeningMinThreshold=" + mScreenDarkeningMinThreshold
|
||||||
|
+ ", mScreenDarkeningMinThresholdIdle=" + mScreenDarkeningMinThresholdIdle
|
||||||
+ ", mScreenBrighteningMinThreshold=" + mScreenBrighteningMinThreshold
|
+ ", mScreenBrighteningMinThreshold=" + mScreenBrighteningMinThreshold
|
||||||
|
+ ", mScreenBrighteningMinThresholdIdle=" + mScreenBrighteningMinThresholdIdle
|
||||||
+ ", mAmbientLuxDarkeningMinThreshold=" + mAmbientLuxDarkeningMinThreshold
|
+ ", mAmbientLuxDarkeningMinThreshold=" + mAmbientLuxDarkeningMinThreshold
|
||||||
|
+ ", mAmbientLuxDarkeningMinThresholdIdle=" + mAmbientLuxDarkeningMinThresholdIdle
|
||||||
+ ", mAmbientLuxBrighteningMinThreshold=" + mAmbientLuxBrighteningMinThreshold
|
+ ", mAmbientLuxBrighteningMinThreshold=" + mAmbientLuxBrighteningMinThreshold
|
||||||
|
+ ", mAmbientLuxBrighteningMinThresholdIdle="
|
||||||
|
+ mAmbientLuxBrighteningMinThresholdIdle
|
||||||
+ ", mAmbientLightSensor=" + mAmbientLightSensor
|
+ ", mAmbientLightSensor=" + mAmbientLightSensor
|
||||||
+ ", mProximitySensor=" + mProximitySensor
|
+ ", mProximitySensor=" + mProximitySensor
|
||||||
+ ", mRefreshRateLimitations= " + Arrays.toString(mRefreshRateLimitations.toArray())
|
+ ", mRefreshRateLimitations= " + Arrays.toString(mRefreshRateLimitations.toArray())
|
||||||
@@ -1376,24 +1457,34 @@ public class DisplayDeviceConfig {
|
|||||||
private void loadBrightnessChangeThresholds(DisplayConfiguration config) {
|
private void loadBrightnessChangeThresholds(DisplayConfiguration config) {
|
||||||
Thresholds displayBrightnessThresholds = config.getDisplayBrightnessChangeThresholds();
|
Thresholds displayBrightnessThresholds = config.getDisplayBrightnessChangeThresholds();
|
||||||
Thresholds ambientBrightnessThresholds = config.getAmbientBrightnessChangeThresholds();
|
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) {
|
if (displayBrightnessThresholds != null) {
|
||||||
BrightnessThresholds brighteningScreen =
|
BrightnessThresholds brighteningScreen =
|
||||||
displayBrightnessThresholds.getBrighteningThresholds();
|
displayBrightnessThresholds.getBrighteningThresholds();
|
||||||
BrightnessThresholds darkeningScreen =
|
BrightnessThresholds darkeningScreen =
|
||||||
displayBrightnessThresholds.getDarkeningThresholds();
|
displayBrightnessThresholds.getDarkeningThresholds();
|
||||||
|
|
||||||
final BigDecimal screenBrighteningThreshold = brighteningScreen.getMinimum();
|
if (brighteningScreen != null && brighteningScreen.getMinimum() != null) {
|
||||||
final BigDecimal screenDarkeningThreshold = darkeningScreen.getMinimum();
|
mScreenBrighteningMinThreshold = brighteningScreen.getMinimum().floatValue();
|
||||||
|
|
||||||
if (screenBrighteningThreshold != null) {
|
|
||||||
mScreenBrighteningMinThreshold = screenBrighteningThreshold.floatValue();
|
|
||||||
}
|
}
|
||||||
if (screenDarkeningThreshold != null) {
|
if (darkeningScreen != null && darkeningScreen.getMinimum() != null) {
|
||||||
mScreenDarkeningMinThreshold = screenDarkeningThreshold.floatValue();
|
mScreenDarkeningMinThreshold = darkeningScreen.getMinimum().floatValue();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void loadAmbientBrightnessThresholds(Thresholds ambientBrightnessThresholds) {
|
||||||
if (ambientBrightnessThresholds != null) {
|
if (ambientBrightnessThresholds != null) {
|
||||||
BrightnessThresholds brighteningAmbientLux =
|
BrightnessThresholds brighteningAmbientLux =
|
||||||
ambientBrightnessThresholds.getBrighteningThresholds();
|
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) {
|
private boolean thermalStatusIsValid(ThermalStatus value) {
|
||||||
if (value == null) {
|
if (value == null) {
|
||||||
return false;
|
return false;
|
||||||
|
|||||||
@@ -985,6 +985,25 @@ final class DisplayPowerController implements AutomaticBrightnessController.Call
|
|||||||
screenBrighteningThresholds, screenDarkeningThresholds, screenThresholdLevels,
|
screenBrighteningThresholds, screenDarkeningThresholds, screenThresholdLevels,
|
||||||
screenDarkeningMinThreshold, screenBrighteningMinThreshold);
|
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
|
long brighteningLightDebounce = mDisplayDeviceConfig
|
||||||
.getAutoBrightnessBrighteningLightDebounce();
|
.getAutoBrightnessBrighteningLightDebounce();
|
||||||
long darkeningLightDebounce = mDisplayDeviceConfig
|
long darkeningLightDebounce = mDisplayDeviceConfig
|
||||||
@@ -1020,7 +1039,8 @@ final class DisplayPowerController implements AutomaticBrightnessController.Call
|
|||||||
PowerManager.BRIGHTNESS_MIN, PowerManager.BRIGHTNESS_MAX, dozeScaleFactor,
|
PowerManager.BRIGHTNESS_MIN, PowerManager.BRIGHTNESS_MAX, dozeScaleFactor,
|
||||||
lightSensorRate, initialLightSensorRate, brighteningLightDebounce,
|
lightSensorRate, initialLightSensorRate, brighteningLightDebounce,
|
||||||
darkeningLightDebounce, autoBrightnessResetAmbientLuxAfterWarmUp,
|
darkeningLightDebounce, autoBrightnessResetAmbientLuxAfterWarmUp,
|
||||||
ambientBrightnessThresholds, screenBrightnessThresholds, mContext,
|
ambientBrightnessThresholds, screenBrightnessThresholds,
|
||||||
|
ambientBrightnessThresholdsIdle, screenBrightnessThresholdsIdle, mContext,
|
||||||
mHbmController, mBrightnessThrottler, mIdleModeBrightnessMapper,
|
mHbmController, mBrightnessThrottler, mIdleModeBrightnessMapper,
|
||||||
mDisplayDeviceConfig.getAmbientHorizonShort(),
|
mDisplayDeviceConfig.getAmbientHorizonShort(),
|
||||||
mDisplayDeviceConfig.getAmbientHorizonLong());
|
mDisplayDeviceConfig.getAmbientHorizonLong());
|
||||||
|
|||||||
@@ -18,15 +18,12 @@ package com.android.server.display;
|
|||||||
|
|
||||||
import android.util.Slog;
|
import android.util.Slog;
|
||||||
|
|
||||||
import com.android.internal.annotations.VisibleForTesting;
|
|
||||||
|
|
||||||
import java.io.PrintWriter;
|
import java.io.PrintWriter;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A helper class for handling access to illuminance hysteresis level values.
|
* A helper class for handling access to illuminance hysteresis level values.
|
||||||
*/
|
*/
|
||||||
@VisibleForTesting
|
|
||||||
public class HysteresisLevels {
|
public class HysteresisLevels {
|
||||||
private static final String TAG = "HysteresisLevels";
|
private static final String TAG = "HysteresisLevels";
|
||||||
|
|
||||||
|
|||||||
@@ -97,6 +97,16 @@
|
|||||||
<xs:annotation name="nonnull"/>
|
<xs:annotation name="nonnull"/>
|
||||||
<xs:annotation name="final"/>
|
<xs:annotation name="final"/>
|
||||||
</xs:element>
|
</xs:element>
|
||||||
|
<!-- Set of thresholds that dictate the change needed for screen brightness
|
||||||
|
adaptations while in idle mode -->
|
||||||
|
<xs:element type="thresholds" name="displayBrightnessChangeThresholdsIdle" minOccurs="0" maxOccurs="1">
|
||||||
|
<xs:annotation name="final"/>
|
||||||
|
</xs:element>
|
||||||
|
<!-- Set of thresholds that dictate the change needed for ambient brightness
|
||||||
|
adaptations while in idle mode -->
|
||||||
|
<xs:element type="thresholds" name="ambientBrightnessChangeThresholdsIdle" minOccurs="0" maxOccurs="1">
|
||||||
|
<xs:annotation name="final"/>
|
||||||
|
</xs:element>
|
||||||
</xs:sequence>
|
</xs:sequence>
|
||||||
</xs:complexType>
|
</xs:complexType>
|
||||||
</xs:element>
|
</xs:element>
|
||||||
@@ -319,13 +329,13 @@
|
|||||||
<!-- Thresholds for brightness changes. -->
|
<!-- Thresholds for brightness changes. -->
|
||||||
<xs:complexType name="thresholds">
|
<xs:complexType name="thresholds">
|
||||||
<xs:sequence>
|
<xs:sequence>
|
||||||
<!-- Brightening thresholds. -->
|
<!-- Brightening thresholds for active screen brightness mode. -->
|
||||||
<xs:element name="brighteningThresholds" type="brightnessThresholds" minOccurs="0"
|
<xs:element name="brighteningThresholds" type="brightnessThresholds" minOccurs="0"
|
||||||
maxOccurs="1" >
|
maxOccurs="1" >
|
||||||
<xs:annotation name="nonnull"/>
|
<xs:annotation name="nonnull"/>
|
||||||
<xs:annotation name="final"/>
|
<xs:annotation name="final"/>
|
||||||
</xs:element>
|
</xs:element>
|
||||||
<!-- Darkening thresholds. -->
|
<!-- Darkening thresholds for active screen brightness mode. -->
|
||||||
<xs:element name="darkeningThresholds" type="brightnessThresholds" minOccurs="0"
|
<xs:element name="darkeningThresholds" type="brightnessThresholds" minOccurs="0"
|
||||||
maxOccurs="1" >
|
maxOccurs="1" >
|
||||||
<xs:annotation name="nonnull"/>
|
<xs:annotation name="nonnull"/>
|
||||||
|
|||||||
@@ -61,11 +61,13 @@ package com.android.server.display.config {
|
|||||||
public class DisplayConfiguration {
|
public class DisplayConfiguration {
|
||||||
ctor public DisplayConfiguration();
|
ctor public DisplayConfiguration();
|
||||||
method @NonNull public final com.android.server.display.config.Thresholds getAmbientBrightnessChangeThresholds();
|
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 getAmbientLightHorizonLong();
|
||||||
method public final java.math.BigInteger getAmbientLightHorizonShort();
|
method public final java.math.BigInteger getAmbientLightHorizonShort();
|
||||||
method public com.android.server.display.config.AutoBrightness getAutoBrightness();
|
method public com.android.server.display.config.AutoBrightness getAutoBrightness();
|
||||||
method @Nullable public final com.android.server.display.config.DensityMapping getDensityMapping();
|
method @Nullable public final com.android.server.display.config.DensityMapping getDensityMapping();
|
||||||
method @NonNull public final com.android.server.display.config.Thresholds getDisplayBrightnessChangeThresholds();
|
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 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 getLightSensor();
|
||||||
method public final com.android.server.display.config.SensorDetails getProxSensor();
|
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 public final java.math.BigDecimal getScreenBrightnessRampSlowIncrease();
|
||||||
method @NonNull public final com.android.server.display.config.ThermalThrottling getThermalThrottling();
|
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 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 setAmbientLightHorizonLong(java.math.BigInteger);
|
||||||
method public final void setAmbientLightHorizonShort(java.math.BigInteger);
|
method public final void setAmbientLightHorizonShort(java.math.BigInteger);
|
||||||
method public void setAutoBrightness(com.android.server.display.config.AutoBrightness);
|
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 setDensityMapping(@Nullable com.android.server.display.config.DensityMapping);
|
||||||
method public final void setDisplayBrightnessChangeThresholds(@NonNull com.android.server.display.config.Thresholds);
|
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 void setHighBrightnessMode(com.android.server.display.config.HighBrightnessMode);
|
||||||
method public final void setLightSensor(com.android.server.display.config.SensorDetails);
|
method public final void setLightSensor(com.android.server.display.config.SensorDetails);
|
||||||
method public final void setProxSensor(com.android.server.display.config.SensorDetails);
|
method public final void setProxSensor(com.android.server.display.config.SensorDetails);
|
||||||
|
|||||||
@@ -82,6 +82,8 @@ public class AutomaticBrightnessControllerTest {
|
|||||||
@Mock BrightnessMappingStrategy mIdleBrightnessMappingStrategy;
|
@Mock BrightnessMappingStrategy mIdleBrightnessMappingStrategy;
|
||||||
@Mock HysteresisLevels mAmbientBrightnessThresholds;
|
@Mock HysteresisLevels mAmbientBrightnessThresholds;
|
||||||
@Mock HysteresisLevels mScreenBrightnessThresholds;
|
@Mock HysteresisLevels mScreenBrightnessThresholds;
|
||||||
|
@Mock HysteresisLevels mAmbientBrightnessThresholdsIdle;
|
||||||
|
@Mock HysteresisLevels mScreenBrightnessThresholdsIdle;
|
||||||
@Mock Handler mNoOpHandler;
|
@Mock Handler mNoOpHandler;
|
||||||
@Mock HighBrightnessModeController mHbmController;
|
@Mock HighBrightnessModeController mHbmController;
|
||||||
@Mock BrightnessThrottler mBrightnessThrottler;
|
@Mock BrightnessThrottler mBrightnessThrottler;
|
||||||
@@ -129,6 +131,7 @@ public class AutomaticBrightnessControllerTest {
|
|||||||
INITIAL_LIGHT_SENSOR_RATE, BRIGHTENING_LIGHT_DEBOUNCE_CONFIG,
|
INITIAL_LIGHT_SENSOR_RATE, BRIGHTENING_LIGHT_DEBOUNCE_CONFIG,
|
||||||
DARKENING_LIGHT_DEBOUNCE_CONFIG, RESET_AMBIENT_LUX_AFTER_WARMUP_CONFIG,
|
DARKENING_LIGHT_DEBOUNCE_CONFIG, RESET_AMBIENT_LUX_AFTER_WARMUP_CONFIG,
|
||||||
mAmbientBrightnessThresholds, mScreenBrightnessThresholds,
|
mAmbientBrightnessThresholds, mScreenBrightnessThresholds,
|
||||||
|
mAmbientBrightnessThresholdsIdle, mScreenBrightnessThresholdsIdle,
|
||||||
mContext, mHbmController, mBrightnessThrottler, mIdleBrightnessMappingStrategy,
|
mContext, mHbmController, mBrightnessThrottler, mIdleBrightnessMappingStrategy,
|
||||||
AMBIENT_LIGHT_HORIZON_SHORT, AMBIENT_LIGHT_HORIZON_LONG
|
AMBIENT_LIGHT_HORIZON_SHORT, AMBIENT_LIGHT_HORIZON_LONG
|
||||||
);
|
);
|
||||||
@@ -314,8 +317,9 @@ public class AutomaticBrightnessControllerTest {
|
|||||||
|
|
||||||
// Now let's do the same for idle mode
|
// Now let's do the same for idle mode
|
||||||
mController.switchToIdleMode();
|
mController.switchToIdleMode();
|
||||||
// Called once for init, and once when switching
|
// Called once for init, and once when switching,
|
||||||
verify(mBrightnessMappingStrategy, times(2)).isForIdleMode();
|
// setAmbientLux() is called twice and once in updateAutoBrightness()
|
||||||
|
verify(mBrightnessMappingStrategy, times(5)).isForIdleMode();
|
||||||
// Ensure, after switching, original BMS is not used anymore
|
// Ensure, after switching, original BMS is not used anymore
|
||||||
verifyNoMoreInteractions(mBrightnessMappingStrategy);
|
verifyNoMoreInteractions(mBrightnessMappingStrategy);
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user