Merge "DO NOT MERGE: Remove continuous sampling logic. This was added for dogfooding purposes in order to determine power usage. However, this feature has since been moved to the G release." into cw-f-dev
This commit is contained in:
committed by
Android (Google) Code Review
commit
fef074ad29
@@ -1110,28 +1110,18 @@
|
||||
If this flag is false, then the ambient light level estimate will be adjusted more
|
||||
gradually in the same manner that normally happens when the screen is on according to the
|
||||
brightening or dimming debounce thresholds. As a result, it may take somewhat longer to
|
||||
adapt to the environment. This mode may be better suited for watches. -->
|
||||
adapt to the environment. This mode may be better suited for watches. -->
|
||||
<bool name="config_autoBrightnessResetAmbientLuxAfterWarmUp">true</bool>
|
||||
|
||||
<!-- Period of time in which to consider light samples in milliseconds. -->
|
||||
<integer name="config_autoBrightnessAmbientLightHorizon">10000</integer>
|
||||
|
||||
<!-- This flag enables light sensor sampling while dozing. A single sample is taken upon
|
||||
entering doze mode, and another sample is taken every time the display enters STATE_DOZE
|
||||
or STATE_DOZE_SUSPEND. It is recommended that config_dozeSensorLuxLevels and
|
||||
config_dozeBrightnessBacklightValues have entries so that the doze mode brightness can be
|
||||
determined dynamically.
|
||||
-->
|
||||
<bool name="config_allowAutoBrightnessActiveDozeLightSensor">false</bool>
|
||||
|
||||
<!-- This flag should be used with config_allowAutoBrightnessActiveDozeLightSensor set to true.
|
||||
|
||||
The screen brightness of a device is based off of a ring buffer of the last n seconds of
|
||||
<!-- The screen brightness of a device is based off of a ring buffer of the last n seconds of
|
||||
ambient light sensor sample readings.
|
||||
|
||||
If this flag is true, then this buffer is cleared every time a new sample is taken in doze
|
||||
mode and the screen brightness is based off the new reading. This mode may be better suited
|
||||
for watches.
|
||||
If this flag is true, then this buffer is cleared and the screen brightness is based off of
|
||||
ambient light sensor readings that are obtained while the device is dozing. This mode may
|
||||
be better suited for watches.
|
||||
|
||||
If this flag is false, then this buffer is untouched. -->
|
||||
<bool name="config_useNewSensorSamplesForDoze">false</bool>
|
||||
|
||||
@@ -1669,7 +1669,6 @@
|
||||
<java-symbol type="array" name="config_notificationFallbackVibePattern" />
|
||||
<java-symbol type="array" name="config_onlySingleDcAllowed" />
|
||||
<java-symbol type="bool" name="config_useNewSensorSamplesForDoze" />
|
||||
<java-symbol type="bool" name="config_allowAutoBrightnessActiveDozeLightSensor" />
|
||||
<java-symbol type="bool" name="config_useAttentionLight" />
|
||||
<java-symbol type="bool" name="config_animateScreenLights" />
|
||||
<java-symbol type="bool" name="config_automatic_brightness_available" />
|
||||
|
||||
@@ -120,7 +120,7 @@ class AutomaticBrightnessController {
|
||||
// weighting values positive.
|
||||
private final int mWeightingIntercept;
|
||||
|
||||
// accessor object for determining lux levels
|
||||
// Accessor object for determining lux levels.
|
||||
private final LuxLevels mLuxLevels;
|
||||
|
||||
// Amount of time to delay auto-brightness after screen on while waiting for
|
||||
@@ -195,10 +195,8 @@ class AutomaticBrightnessController {
|
||||
// Are we going to adjust brightness while dozing.
|
||||
private boolean mDozing;
|
||||
|
||||
// True if we are collecting light samples when dozing to set the screen brightness. A single
|
||||
// light sample is collected when entering doze mode. If autobrightness is enabled, calls to
|
||||
// DisplayPowerController#updatePowerState in doze mode will also collect light samples.
|
||||
private final boolean mUseActiveDozeLightSensorConfig;
|
||||
// True if we are collecting one last light sample when dozing to set the screen brightness.
|
||||
private boolean mActiveDozeLightSensor = false;
|
||||
|
||||
// True if the ambient light sensor ring buffer should be cleared when entering doze mode.
|
||||
private final boolean mUseNewSensorSamplesForDoze;
|
||||
@@ -219,8 +217,8 @@ class AutomaticBrightnessController {
|
||||
int lightSensorRate, int initialLightSensorRate, long brighteningLightDebounceConfig,
|
||||
long darkeningLightDebounceConfig, boolean resetAmbientLuxAfterWarmUpConfig,
|
||||
int ambientLightHorizon, float autoBrightnessAdjustmentMaxGamma,
|
||||
boolean activeDozeLightSensor, boolean useNewSensorSamplesForDoze,
|
||||
float darkHorizonThresholdFactor, int darkAmbientLightHorizon, LuxLevels luxLevels) {
|
||||
boolean useNewSensorSamplesForDoze, float darkHorizonThresholdFactor,
|
||||
int darkAmbientLightHorizon, LuxLevels luxLevels) {
|
||||
mCallbacks = callbacks;
|
||||
mTwilight = LocalServices.getService(TwilightManager.class);
|
||||
mSensorManager = sensorManager;
|
||||
@@ -239,10 +237,10 @@ class AutomaticBrightnessController {
|
||||
mWeightingIntercept = ambientLightHorizon;
|
||||
mScreenAutoBrightnessAdjustmentMaxGamma = autoBrightnessAdjustmentMaxGamma;
|
||||
mUseNewSensorSamplesForDoze = useNewSensorSamplesForDoze;
|
||||
mUseActiveDozeLightSensorConfig = activeDozeLightSensor;
|
||||
mDarkHorizonThresholdFactor = darkHorizonThresholdFactor;
|
||||
mDarkAmbientLightHorizon = darkAmbientLightHorizon;
|
||||
mLuxLevels = luxLevels;
|
||||
mActiveDozeLightSensor = mLuxLevels.hasDynamicDozeBrightness();
|
||||
|
||||
mHandler = new AutomaticBrightnessHandler(looper);
|
||||
mAmbientLightRingBuffer =
|
||||
@@ -273,18 +271,21 @@ class AutomaticBrightnessController {
|
||||
// switch to a wake-up light sensor instead but for now we will simply disable the sensor
|
||||
// and hold onto the last computed screen auto brightness. We save the dozing flag for
|
||||
// debugging purposes.
|
||||
boolean enableSensor = enable && (dozing ? mUseActiveDozeLightSensorConfig : true);
|
||||
if (enableSensor && dozing && !mDozing && mLightSensorEnabled
|
||||
&& mUseNewSensorSamplesForDoze) {
|
||||
mAmbientLightRingBuffer.clear();
|
||||
mInitialHorizonAmbientLightRingBuffer.clear();
|
||||
if (DEBUG) {
|
||||
Slog.d(TAG, "configure: Clearing ambient light ring buffers when entering doze.");
|
||||
}
|
||||
mAmbientLuxValid = false;
|
||||
adjustLightSensorRate(mInitialLightSensorRate);
|
||||
}
|
||||
mDozing = dozing;
|
||||
boolean enableSensor = enable && !dozing;
|
||||
if (enableSensor && !mLightSensorEnabled && mActiveDozeLightSensor) {
|
||||
mActiveDozeLightSensor = false;
|
||||
} else if (!enableSensor && mLightSensorEnabled) {
|
||||
// keep the light sensor active until another light sample is taken while dozing
|
||||
mActiveDozeLightSensor = true;
|
||||
adjustLightSensorRate(mInitialLightSensorRate);
|
||||
if (mUseNewSensorSamplesForDoze) {
|
||||
mAmbientLightRingBuffer.clear();
|
||||
mInitialHorizonAmbientLightRingBuffer.clear();
|
||||
mAmbientLuxValid = false;
|
||||
return;
|
||||
}
|
||||
}
|
||||
boolean changed = setLightSensorEnabled(enableSensor);
|
||||
changed |= setScreenAutoBrightnessAdjustment(adjustment);
|
||||
changed |= setUseTwilight(useTwilight);
|
||||
@@ -382,7 +383,7 @@ class AutomaticBrightnessController {
|
||||
}
|
||||
applyLightSensorMeasurement(time, lux);
|
||||
updateAmbientLux(time);
|
||||
if (mUseActiveDozeLightSensorConfig && mDozing) {
|
||||
if (mActiveDozeLightSensor) {
|
||||
// disable the ambient light sensor and update the screen brightness
|
||||
if (DEBUG) {
|
||||
Slog.d(TAG, "handleLightSensorEvent: doze ambient light sensor reading: " + lux);
|
||||
@@ -634,7 +635,7 @@ class AutomaticBrightnessController {
|
||||
}
|
||||
|
||||
int newScreenAutoBrightness;
|
||||
if (mUseActiveDozeLightSensorConfig && mDozing) {
|
||||
if (mActiveDozeLightSensor) {
|
||||
newScreenAutoBrightness = mLuxLevels.getDozeBrightness(mAmbientLux);
|
||||
} else {
|
||||
newScreenAutoBrightness =
|
||||
|
||||
@@ -158,9 +158,6 @@ final class DisplayPowerController implements AutomaticBrightnessController.Call
|
||||
// True if should use light sensor to automatically determine doze screen brightness.
|
||||
private final boolean mAllowAutoBrightnessWhileDozingConfig;
|
||||
|
||||
// True if collecting light sensor samples in doze mode.
|
||||
private boolean mUseActiveDozeLightSensorConfig;
|
||||
|
||||
// True if we should fade the screen while turning it off, false if we should play
|
||||
// a stylish color fade animation instead.
|
||||
private boolean mColorFadeFadesConfig;
|
||||
@@ -264,6 +261,9 @@ final class DisplayPowerController implements AutomaticBrightnessController.Call
|
||||
// The first autobrightness value set when entering RAMP_STATE_SKIP_INITIAL.
|
||||
private int mInitialAutoBrightness;
|
||||
|
||||
// Accessor object for determining lux levels.
|
||||
private LuxLevels mLuxLevels;
|
||||
|
||||
// The controller for the automatic brightness level.
|
||||
private AutomaticBrightnessController mAutomaticBrightnessController;
|
||||
|
||||
@@ -383,9 +383,7 @@ final class DisplayPowerController implements AutomaticBrightnessController.Call
|
||||
com.android.internal.R.array.config_dozeBrightnessBacklightValues);
|
||||
boolean useNewSensorSamplesForDoze = resources.getBoolean(
|
||||
com.android.internal.R.bool.config_useNewSensorSamplesForDoze);
|
||||
mUseActiveDozeLightSensorConfig = resources.getBoolean(
|
||||
com.android.internal.R.bool.config_allowAutoBrightnessActiveDozeLightSensor);
|
||||
LuxLevels luxLevels = new LuxLevels(brightHysteresisLevels, darkHysteresisLevels,
|
||||
mLuxLevels = new LuxLevels(brightHysteresisLevels, darkHysteresisLevels,
|
||||
luxHysteresisLevels, dozeSensorLuxLevels, dozeBrightnessBacklightValues);
|
||||
|
||||
Spline screenAutoBrightnessSpline = createAutoBrightnessSpline(lux, screenBrightness);
|
||||
@@ -414,9 +412,8 @@ final class DisplayPowerController implements AutomaticBrightnessController.Call
|
||||
mScreenBrightnessRangeMaximum, dozeScaleFactor, lightSensorRate,
|
||||
initialLightSensorRate, brighteningLightDebounce, darkeningLightDebounce,
|
||||
autoBrightnessResetAmbientLuxAfterWarmUp, ambientLightHorizon,
|
||||
autoBrightnessAdjustmentMaxGamma, mUseActiveDozeLightSensorConfig,
|
||||
useNewSensorSamplesForDoze, darkHorizonThresholdFactor,
|
||||
darkAmbientLightHorizon, luxLevels);
|
||||
autoBrightnessAdjustmentMaxGamma, useNewSensorSamplesForDoze,
|
||||
darkHorizonThresholdFactor, darkAmbientLightHorizon, mLuxLevels);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -670,9 +667,8 @@ final class DisplayPowerController implements AutomaticBrightnessController.Call
|
||||
if (mAutomaticBrightnessController != null) {
|
||||
final boolean autoBrightnessEnabledInDoze = mAllowAutoBrightnessWhileDozingConfig
|
||||
&& (state == Display.STATE_DOZE || state == Display.STATE_DOZE_SUSPEND);
|
||||
autoBrightnessEnabled = (mPowerRequest.useAutoBrightness
|
||||
autoBrightnessEnabled = mPowerRequest.useAutoBrightness
|
||||
&& (state == Display.STATE_ON || autoBrightnessEnabledInDoze)
|
||||
|| mUseActiveDozeLightSensorConfig && autoBrightnessEnabledInDoze)
|
||||
&& brightness < 0;
|
||||
final boolean userInitiatedChange = autoBrightnessAdjustmentChanged
|
||||
&& mPowerRequest.brightnessSetByUser;
|
||||
@@ -711,11 +707,13 @@ final class DisplayPowerController implements AutomaticBrightnessController.Call
|
||||
mAppliedAutoBrightness = false;
|
||||
}
|
||||
|
||||
// Use default brightness when dozing unless overridden or if collecting sensor samples.
|
||||
// Use default brightness when dozing unless overridden or if using dynamic doze brightness.
|
||||
if (state == Display.STATE_DOZE || state == Display.STATE_DOZE_SUSPEND) {
|
||||
if (brightness < 0) {
|
||||
brightness = mScreenBrightnessDozeConfig;
|
||||
} else if (mUseActiveDozeLightSensorConfig) {
|
||||
} else if (autoBrightnessEnabled && mLuxLevels.hasDynamicDozeBrightness()) {
|
||||
brightness = mAutomaticBrightnessController.getAutomaticScreenBrightness();
|
||||
} else {
|
||||
brightness = Math.min(brightness, mScreenBrightnessDozeConfig);
|
||||
if (DEBUG) {
|
||||
Slog.d(TAG, "updatePowerState: ALS-based doze brightness: " + brightness);
|
||||
|
||||
@@ -29,7 +29,7 @@ final class LuxLevels {
|
||||
private final float[] mBrightLevels;
|
||||
private final float[] mDarkLevels;
|
||||
private final float[] mLuxHysteresisLevels;
|
||||
private final float[] mDozeBrightnessBacklightValues;
|
||||
private final float[] mDozeBacklightLevels;
|
||||
private final float[] mDozeSensorLuxLevels;
|
||||
|
||||
/**
|
||||
@@ -39,29 +39,29 @@ final class LuxLevels {
|
||||
* {@code luxLevels} has length n+1.
|
||||
*
|
||||
* {@code dozeSensorLuxLevels} has length r.
|
||||
* {@code dozeBrightnessBacklightValues} has length r+1.
|
||||
* {@code dozeBacklightLevels} has length r+1.
|
||||
*
|
||||
* @param brightLevels an array of brightening hysteresis constraint constants
|
||||
* @param darkLevels an array of darkening hysteresis constraint constants
|
||||
* @param luxHysteresisLevels a monotonically increasing array of illuminance thresholds in lux
|
||||
* @param dozeSensorLuxLevels a monotonically increasing array of ALS thresholds in lux
|
||||
* @param dozeBrightnessBacklightValues an array of screen brightness values for doze mode in lux
|
||||
* @param dozeBacklightLevels an array of screen brightness values for doze mode in lux
|
||||
*/
|
||||
public LuxLevels(int[] brightLevels, int[] darkLevels, int[] luxHysteresisLevels,
|
||||
int[] dozeSensorLuxLevels, int[] dozeBrightnessBacklightValues) {
|
||||
int[] dozeSensorLuxLevels, int[] dozeBacklightLevels) {
|
||||
if (brightLevels.length != darkLevels.length ||
|
||||
darkLevels.length !=luxHysteresisLevels.length + 1) {
|
||||
throw new IllegalArgumentException("Mismatch between hysteresis array lengths.");
|
||||
}
|
||||
if (dozeBrightnessBacklightValues.length > 0 && dozeSensorLuxLevels.length > 0
|
||||
&& dozeBrightnessBacklightValues.length != dozeSensorLuxLevels.length + 1) {
|
||||
if (dozeBacklightLevels.length > 0 && dozeSensorLuxLevels.length > 0
|
||||
&& dozeBacklightLevels.length != dozeSensorLuxLevels.length + 1) {
|
||||
throw new IllegalArgumentException("Mismatch between doze lux array lengths.");
|
||||
}
|
||||
mBrightLevels = setArrayFormat(brightLevels, 1000.0f);
|
||||
mDarkLevels = setArrayFormat(darkLevels, 1000.0f);
|
||||
mLuxHysteresisLevels = setArrayFormat(luxHysteresisLevels, 1.0f);
|
||||
mDozeSensorLuxLevels = setArrayFormat(dozeSensorLuxLevels, 1.0f);
|
||||
mDozeBrightnessBacklightValues = setArrayFormat(dozeBrightnessBacklightValues, 1.0f);
|
||||
mDozeBacklightLevels = setArrayFormat(dozeBacklightLevels, 1.0f);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -94,7 +94,7 @@ final class LuxLevels {
|
||||
* Return the doze backlight brightness level for the given ambient sensor lux level.
|
||||
*/
|
||||
public int getDozeBrightness(float lux) {
|
||||
int dozeBrightness = (int) getReferenceLevel(lux, mDozeBrightnessBacklightValues,
|
||||
int dozeBrightness = (int) getReferenceLevel(lux, mDozeBacklightLevels,
|
||||
mDozeSensorLuxLevels);
|
||||
if (DEBUG) {
|
||||
Slog.d(TAG, "doze brightness: " + dozeBrightness + ", lux=" + lux);
|
||||
|
||||
Reference in New Issue
Block a user