Merge "Enable AutoBrightness per display"
This commit is contained in:
committed by
Android (Google) Code Review
commit
ed2e1a50b8
@@ -150,7 +150,7 @@ import javax.xml.datatype.DatatypeConfigurationException;
|
||||
* <quirk>canSetBrightnessViaHwc</quirk>
|
||||
* </quirks>
|
||||
*
|
||||
* <autoBrightness>
|
||||
* <autoBrightness enable="true">
|
||||
* <brighteningLightDebounceMillis>
|
||||
* 2000
|
||||
* </brighteningLightDebounceMillis>
|
||||
@@ -507,6 +507,11 @@ public class DisplayDeviceConfig {
|
||||
private long mAutoBrightnessDarkeningLightDebounce =
|
||||
INVALID_AUTO_BRIGHTNESS_LIGHT_DEBOUNCE;
|
||||
|
||||
// This setting allows non-default displays to have autobrightness enabled.
|
||||
private boolean mAutoBrightnessAvailable = false;
|
||||
// This stores the raw value loaded from the config file - true if not written.
|
||||
private boolean mDdcAutoBrightnessAvailable = true;
|
||||
|
||||
// Brightness Throttling data may be updated via the DeviceConfig. Here we store the original
|
||||
// data, which comes from the ddc, and the current one, which may be the DeviceConfig
|
||||
// overwritten value.
|
||||
@@ -1119,6 +1124,10 @@ public class DisplayDeviceConfig {
|
||||
return mProximitySensor;
|
||||
}
|
||||
|
||||
boolean isAutoBrightnessAvailable() {
|
||||
return mAutoBrightnessAvailable;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param quirkValue The quirk to test.
|
||||
* @return {@code true} if the specified quirk is present in this configuration, {@code false}
|
||||
@@ -1271,6 +1280,8 @@ public class DisplayDeviceConfig {
|
||||
+ mAutoBrightnessDarkeningLightDebounce
|
||||
+ ", mBrightnessLevelsLux= " + Arrays.toString(mBrightnessLevelsLux)
|
||||
+ ", mBrightnessLevelsNits= " + Arrays.toString(mBrightnessLevelsNits)
|
||||
+ ", mDdcAutoBrightnessAvailable= " + mDdcAutoBrightnessAvailable
|
||||
+ ", mAutoBrightnessAvailable= " + mAutoBrightnessAvailable
|
||||
+ "}";
|
||||
}
|
||||
|
||||
@@ -1349,6 +1360,7 @@ public class DisplayDeviceConfig {
|
||||
loadBrightnessChangeThresholdsFromXml();
|
||||
setProxSensorUnspecified();
|
||||
loadAutoBrightnessConfigsFromConfigXml();
|
||||
loadAutoBrightnessAvailableFromConfigXml();
|
||||
mLoadedFrom = "<config.xml>";
|
||||
}
|
||||
|
||||
@@ -1367,6 +1379,7 @@ public class DisplayDeviceConfig {
|
||||
setSimpleMappingStrategyValues();
|
||||
loadAmbientLightSensorFromConfigXml();
|
||||
setProxSensorUnspecified();
|
||||
loadAutoBrightnessAvailableFromConfigXml();
|
||||
}
|
||||
|
||||
private void copyUninitializedValuesFromSecondaryConfig(DisplayConfiguration defaultConfig) {
|
||||
@@ -1559,9 +1572,11 @@ public class DisplayDeviceConfig {
|
||||
}
|
||||
|
||||
private void loadAutoBrightnessConfigValues(DisplayConfiguration config) {
|
||||
loadAutoBrightnessBrighteningLightDebounce(config.getAutoBrightness());
|
||||
loadAutoBrightnessDarkeningLightDebounce(config.getAutoBrightness());
|
||||
loadAutoBrightnessDisplayBrightnessMapping(config.getAutoBrightness());
|
||||
final AutoBrightness autoBrightness = config.getAutoBrightness();
|
||||
loadAutoBrightnessBrighteningLightDebounce(autoBrightness);
|
||||
loadAutoBrightnessDarkeningLightDebounce(autoBrightness);
|
||||
loadAutoBrightnessDisplayBrightnessMapping(autoBrightness);
|
||||
loadEnableAutoBrightness(autoBrightness);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -1623,6 +1638,11 @@ public class DisplayDeviceConfig {
|
||||
}
|
||||
}
|
||||
|
||||
private void loadAutoBrightnessAvailableFromConfigXml() {
|
||||
mAutoBrightnessAvailable = mContext.getResources().getBoolean(
|
||||
R.bool.config_automatic_brightness_available);
|
||||
}
|
||||
|
||||
private void loadBrightnessMapFromConfigXml() {
|
||||
// Use the config.xml mapping
|
||||
final Resources res = mContext.getResources();
|
||||
@@ -2262,6 +2282,20 @@ public class DisplayDeviceConfig {
|
||||
return levels;
|
||||
}
|
||||
|
||||
private void loadEnableAutoBrightness(AutoBrightness autobrightness) {
|
||||
// mDdcAutoBrightnessAvailable is initialised to true, so that we fallback to using the
|
||||
// config.xml values if the autobrightness tag is not defined in the ddc file.
|
||||
// Autobrightness can still be turned off globally via config_automatic_brightness_available
|
||||
mDdcAutoBrightnessAvailable = true;
|
||||
if (autobrightness != null) {
|
||||
mDdcAutoBrightnessAvailable = autobrightness.getEnabled();
|
||||
}
|
||||
|
||||
mAutoBrightnessAvailable = mContext.getResources().getBoolean(
|
||||
com.android.internal.R.bool.config_automatic_brightness_available)
|
||||
&& mDdcAutoBrightnessAvailable;
|
||||
}
|
||||
|
||||
static class SensorData {
|
||||
public String type;
|
||||
public String name;
|
||||
|
||||
@@ -566,13 +566,6 @@ final class DisplayPowerController implements AutomaticBrightnessController.Call
|
||||
mScreenBrightnessForVrRangeMinimum = clampAbsoluteBrightness(
|
||||
pm.getBrightnessConstraint(PowerManager.BRIGHTNESS_CONSTRAINT_TYPE_MINIMUM_VR));
|
||||
|
||||
// Check the setting, but also verify that it is the default display. Only the default
|
||||
// display has an automatic brightness controller running.
|
||||
// TODO: b/179021925 - Fix to work with multiple displays
|
||||
mUseSoftwareAutoBrightnessConfig = resources.getBoolean(
|
||||
com.android.internal.R.bool.config_automatic_brightness_available)
|
||||
&& mDisplayId == Display.DEFAULT_DISPLAY;
|
||||
|
||||
mAllowAutoBrightnessWhileDozingConfig = resources.getBoolean(
|
||||
com.android.internal.R.bool.config_allowAutoBrightnessWhileDozing);
|
||||
|
||||
@@ -952,6 +945,8 @@ final class DisplayPowerController implements AutomaticBrightnessController.Call
|
||||
}
|
||||
|
||||
private void setUpAutoBrightness(Resources resources, Handler handler) {
|
||||
mUseSoftwareAutoBrightnessConfig = mDisplayDeviceConfig.isAutoBrightnessAvailable();
|
||||
|
||||
if (!mUseSoftwareAutoBrightnessConfig) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -542,13 +542,6 @@ final class DisplayPowerController2 implements AutomaticBrightnessController.Cal
|
||||
mScreenBrightnessForVrRangeMinimum = clampAbsoluteBrightness(
|
||||
pm.getBrightnessConstraint(PowerManager.BRIGHTNESS_CONSTRAINT_TYPE_MINIMUM_VR));
|
||||
|
||||
// Check the setting, but also verify that it is the default display. Only the default
|
||||
// display has an automatic brightness controller running.
|
||||
// TODO: b/179021925 - Fix to work with multiple displays
|
||||
mUseSoftwareAutoBrightnessConfig = resources.getBoolean(
|
||||
R.bool.config_automatic_brightness_available)
|
||||
&& mDisplayId == Display.DEFAULT_DISPLAY;
|
||||
|
||||
mAllowAutoBrightnessWhileDozingConfig = resources.getBoolean(
|
||||
R.bool.config_allowAutoBrightnessWhileDozing);
|
||||
|
||||
@@ -928,6 +921,8 @@ final class DisplayPowerController2 implements AutomaticBrightnessController.Cal
|
||||
}
|
||||
|
||||
private void setUpAutoBrightness(Resources resources, Handler handler) {
|
||||
mUseSoftwareAutoBrightnessConfig = mDisplayDeviceConfig.isAutoBrightnessAvailable();
|
||||
|
||||
if (!mUseSoftwareAutoBrightnessConfig) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -383,6 +383,7 @@
|
||||
</xs:complexType>
|
||||
|
||||
<xs:complexType name="autoBrightness">
|
||||
<xs:attribute name="enabled" type="xs:boolean" use="optional" default="true"/>
|
||||
<xs:sequence>
|
||||
<!-- Sets the debounce for autoBrightness brightening in millis-->
|
||||
<xs:element name="brighteningLightDebounceMillis" type="xs:nonNegativeInteger"
|
||||
|
||||
@@ -6,9 +6,11 @@ package com.android.server.display.config {
|
||||
method public final java.math.BigInteger getBrighteningLightDebounceMillis();
|
||||
method public final java.math.BigInteger getDarkeningLightDebounceMillis();
|
||||
method public final com.android.server.display.config.DisplayBrightnessMapping getDisplayBrightnessMapping();
|
||||
method public boolean getEnabled();
|
||||
method public final void setBrighteningLightDebounceMillis(java.math.BigInteger);
|
||||
method public final void setDarkeningLightDebounceMillis(java.math.BigInteger);
|
||||
method public final void setDisplayBrightnessMapping(com.android.server.display.config.DisplayBrightnessMapping);
|
||||
method public void setEnabled(boolean);
|
||||
}
|
||||
|
||||
public class BrightnessThresholds {
|
||||
|
||||
Reference in New Issue
Block a user