summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author TreeHugger Robot <treehugger-gerrit@google.com> 2022-08-10 09:32:13 +0000
committer Android (Google) Code Review <android-gerrit@google.com> 2022-08-10 09:32:13 +0000
commit543223fd1c8f8777959f9f6fbb46c9e8c723d524 (patch)
tree29b1db1b99fb566a243804766535943af03c3eea
parentcf93bf7134ee88621ca8d1bb4f4227ba0401b05d (diff)
parent17be5b6f2643b0a656e0b0e419c5ef0e62a31b53 (diff)
Merge "Port autobrightness brightnening and darkening light debounce config from per device to per display configs" into tm-qpr-dev
-rw-r--r--services/core/java/com/android/server/display/DisplayDeviceConfig.java162
-rw-r--r--services/core/java/com/android/server/display/DisplayPowerController.java8
-rw-r--r--services/core/xsd/display-device-config/display-device-config.xsd18
-rw-r--r--services/core/xsd/display-device-config/schema/current.txt10
-rw-r--r--services/tests/servicestests/src/com/android/server/display/DisplayDeviceConfigTest.java6
5 files changed, 158 insertions, 46 deletions
diff --git a/services/core/java/com/android/server/display/DisplayDeviceConfig.java b/services/core/java/com/android/server/display/DisplayDeviceConfig.java
index b5aa7b14792b..74ee6800eb63 100644
--- a/services/core/java/com/android/server/display/DisplayDeviceConfig.java
+++ b/services/core/java/com/android/server/display/DisplayDeviceConfig.java
@@ -33,6 +33,7 @@ import android.view.DisplayAddress;
import com.android.internal.R;
import com.android.internal.annotations.VisibleForTesting;
import com.android.internal.display.BrightnessSynchronizer;
+import com.android.server.display.config.AutoBrightness;
import com.android.server.display.config.BrightnessThresholds;
import com.android.server.display.config.BrightnessThrottlingMap;
import com.android.server.display.config.BrightnessThrottlingPoint;
@@ -69,9 +70,8 @@ import java.util.List;
import javax.xml.datatype.DatatypeConfigurationException;
/**
- * Reads and stores display-specific configurations.
- * File format:
- * <pre>
+ * Reads and stores display-specific configurations. File format:
+ * <pre>
* {@code
* <displayConfiguration>
* <densityMapping>
@@ -147,6 +147,15 @@ import javax.xml.datatype.DatatypeConfigurationException;
* <quirk>canSetBrightnessViaHwc</quirk>
* </quirks>
*
+ * <autoBrightness>
+ * <brighteningLightDebounceMillis>
+ * 2000
+ * </brighteningLightDebounceMillis>
+ * <darkeningLightDebounceMillis>
+ * 1000
+ * </darkeningLightDebounceMillis>
+ * </autoBrightness>
+ *
* <screenBrightnessRampFastDecrease>0.01</screenBrightnessRampFastDecrease>
* <screenBrightnessRampFastIncrease>0.02</screenBrightnessRampFastIncrease>
* <screenBrightnessRampSlowDecrease>0.03</screenBrightnessRampSlowDecrease>
@@ -224,6 +233,9 @@ public class DisplayDeviceConfig {
// Length of the ambient light horizon used to calculate short-term estimate of ambient light.
private static final int AMBIENT_LIGHT_SHORT_HORIZON_MILLIS = 2000;
+ // Invalid value of AutoBrightness brightening and darkening light debounce
+ private static final int INVALID_AUTO_BRIGHTNESS_LIGHT_DEBOUNCE = -1;
+
@VisibleForTesting
static final float HDR_PERCENT_OF_SCREEN_REQUIRED_DEFAULT = 0.5f;
@@ -281,6 +293,14 @@ public class DisplayDeviceConfig {
private String mLoadedFrom = null;
private Spline mSdrToHdrRatioSpline;
+ // Represents the auto-brightness brightening light debounce.
+ private long mAutoBrightnessBrighteningLightDebounce =
+ INVALID_AUTO_BRIGHTNESS_LIGHT_DEBOUNCE;
+
+ // Represents the auto-brightness darkening light debounce.
+ private long mAutoBrightnessDarkeningLightDebounce =
+ INVALID_AUTO_BRIGHTNESS_LIGHT_DEBOUNCE;
+
// 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.
@@ -293,8 +313,8 @@ public class DisplayDeviceConfig {
}
/**
- * Creates an instance for the specified display.
- * Tries to find a file with identifier in the following priority order:
+ * Creates an instance for the specified display. Tries to find a file with identifier in the
+ * following priority order:
* <ol>
* <li>physicalDisplayId</li>
* <li>physicalDisplayId without a stable flag (old system)</li>
@@ -314,11 +334,12 @@ public class DisplayDeviceConfig {
}
/**
- * Creates an instance using global values since no display device config xml exists.
- * Uses values from config or PowerManager.
+ * Creates an instance using global values since no display device config xml exists. Uses
+ * values from config or PowerManager.
*
- * @param context
- * @param useConfigXml
+ * @param context The context from which the DisplayDeviceConfig is to be constructed.
+ * @param useConfigXml A flag indicating if values are to be loaded from the configuration file,
+ * or the default values.
* @return A configuration instance.
*/
public static DisplayDeviceConfig create(Context context, boolean useConfigXml) {
@@ -450,8 +471,8 @@ public class DisplayDeviceConfig {
}
/**
- * Calculates the backlight value, as recognised by the HAL, from the brightness value
- * given that the rest of the system deals with.
+ * Calculates the backlight value, as recognised by the HAL, from the brightness value given
+ * that the rest of the system deals with.
*
* @param brightness value on the framework scale of 0-1
* @return backlight value on the HAL scale of 0-1
@@ -502,13 +523,13 @@ public class DisplayDeviceConfig {
if (DEBUG) {
Slog.d(TAG, "getHdrBrightnessFromSdr: sdr brightness " + brightness
- + " backlight " + backlight
- + " nits " + nits
- + " ratio " + ratio
- + " hdrNits " + hdrNits
- + " hdrBacklight " + hdrBacklight
- + " hdrBrightness " + hdrBrightness
- );
+ + " backlight " + backlight
+ + " nits " + nits
+ + " ratio " + ratio
+ + " hdrNits " + hdrNits
+ + " hdrBacklight " + hdrBacklight
+ + " hdrBrightness " + hdrBrightness
+ );
}
return hdrBrightness;
}
@@ -590,8 +611,8 @@ public class DisplayDeviceConfig {
/**
* @param quirkValue The quirk to test.
- * @return {@code true} if the specified quirk is present in this configuration,
- * {@code false} otherwise.
+ * @return {@code true} if the specified quirk is present in this configuration, {@code false}
+ * otherwise.
*/
public boolean hasQuirk(String quirkValue) {
return mQuirks != null && mQuirks.contains(quirkValue);
@@ -625,6 +646,20 @@ public class DisplayDeviceConfig {
return BrightnessThrottlingData.create(mBrightnessThrottlingData);
}
+ /**
+ * @return Auto brightness darkening light debounce
+ */
+ public long getAutoBrightnessDarkeningLightDebounce() {
+ return mAutoBrightnessDarkeningLightDebounce;
+ }
+
+ /**
+ * @return Auto brightness brightening light debounce
+ */
+ public long getAutoBrightnessBrighteningLightDebounce() {
+ return mAutoBrightnessBrighteningLightDebounce;
+ }
+
@Override
public String toString() {
return "DisplayDeviceConfig{"
@@ -663,6 +698,10 @@ public class DisplayDeviceConfig {
+ ", mProximitySensor=" + mProximitySensor
+ ", mRefreshRateLimitations= " + Arrays.toString(mRefreshRateLimitations.toArray())
+ ", mDensityMapping= " + mDensityMapping
+ + ", mAutoBrightnessBrighteningLightDebounce= "
+ + mAutoBrightnessBrighteningLightDebounce
+ + ", mAutoBrightnessDarkeningLightDebounce= "
+ + mAutoBrightnessDarkeningLightDebounce
+ "}";
}
@@ -719,6 +758,7 @@ public class DisplayDeviceConfig {
loadProxSensorFromDdc(config);
loadAmbientHorizonFromDdc(config);
loadBrightnessChangeThresholds(config);
+ loadAutoBrightnessConfigValues(config);
} else {
Slog.w(TAG, "DisplayDeviceConfig file is null");
}
@@ -899,8 +939,8 @@ public class DisplayDeviceConfig {
if (i > 0) {
if (nits[i] < nits[i - 1]) {
Slog.e(TAG, "sdrHdrRatioMap must be non-decreasing, ignoring rest "
- + " of configuration. nits: " + nits[i] + " < "
- + nits[i - 1]);
+ + " of configuration. nits: " + nits[i] + " < "
+ + nits[i - 1]);
return null;
}
}
@@ -927,7 +967,7 @@ public class DisplayDeviceConfig {
final List<BrightnessThrottlingPoint> points = map.getBrightnessThrottlingPoint();
// At least 1 point is guaranteed by the display device config schema
List<BrightnessThrottlingData.ThrottlingLevel> throttlingLevels =
- new ArrayList<>(points.size());
+ new ArrayList<>(points.size());
boolean badConfig = false;
for (BrightnessThrottlingPoint point : points) {
@@ -938,7 +978,7 @@ public class DisplayDeviceConfig {
}
throttlingLevels.add(new BrightnessThrottlingData.ThrottlingLevel(
- convertThermalStatus(status), point.getBrightness().floatValue()));
+ convertThermalStatus(status), point.getBrightness().floatValue()));
}
if (!badConfig) {
@@ -947,6 +987,41 @@ public class DisplayDeviceConfig {
}
}
+ private void loadAutoBrightnessConfigValues(DisplayConfiguration config) {
+ loadAutoBrightnessBrighteningLightDebounce(config.getAutoBrightness());
+ loadAutoBrightnessDarkeningLightDebounce(config.getAutoBrightness());
+ }
+
+ /**
+ * Loads the auto-brightness brightening light debounce. Internally, this takes care of loading
+ * the value from the display config, and if not present, falls back to config.xml.
+ */
+ private void loadAutoBrightnessBrighteningLightDebounce(AutoBrightness autoBrightnessConfig) {
+ if (autoBrightnessConfig == null
+ || autoBrightnessConfig.getBrighteningLightDebounceMillis() == null) {
+ mAutoBrightnessBrighteningLightDebounce = mContext.getResources().getInteger(
+ com.android.internal.R.integer.config_autoBrightnessBrighteningLightDebounce);
+ } else {
+ mAutoBrightnessBrighteningLightDebounce =
+ autoBrightnessConfig.getBrighteningLightDebounceMillis().intValue();
+ }
+ }
+
+ /**
+ * Loads the auto-brightness darkening light debounce. Internally, this takes care of loading
+ * the value from the display config, and if not present, falls back to config.xml.
+ */
+ private void loadAutoBrightnessDarkeningLightDebounce(AutoBrightness autoBrightnessConfig) {
+ if (autoBrightnessConfig == null
+ || autoBrightnessConfig.getDarkeningLightDebounceMillis() == null) {
+ mAutoBrightnessDarkeningLightDebounce = mContext.getResources().getInteger(
+ com.android.internal.R.integer.config_autoBrightnessDarkeningLightDebounce);
+ } else {
+ mAutoBrightnessDarkeningLightDebounce =
+ autoBrightnessConfig.getDarkeningLightDebounceMillis().intValue();
+ }
+ }
+
private void loadBrightnessMapFromConfigXml() {
// Use the config.xml mapping
final Resources res = mContext.getResources();
@@ -1058,17 +1133,17 @@ public class DisplayDeviceConfig {
PowerManager.BRIGHTNESS_MIN, PowerManager.BRIGHTNESS_MAX, mBacklight[i]);
}
mBrightnessToBacklightSpline = mInterpolationType == INTERPOLATION_LINEAR
- ? Spline.createLinearSpline(mBrightness, mBacklight)
- : Spline.createSpline(mBrightness, mBacklight);
+ ? Spline.createLinearSpline(mBrightness, mBacklight)
+ : Spline.createSpline(mBrightness, mBacklight);
mBacklightToBrightnessSpline = mInterpolationType == INTERPOLATION_LINEAR
- ? Spline.createLinearSpline(mBacklight, mBrightness)
- : Spline.createSpline(mBacklight, mBrightness);
+ ? Spline.createLinearSpline(mBacklight, mBrightness)
+ : Spline.createSpline(mBacklight, mBrightness);
mBacklightToNitsSpline = mInterpolationType == INTERPOLATION_LINEAR
- ? Spline.createLinearSpline(mBacklight, mNits)
- : Spline.createSpline(mBacklight, mNits);
+ ? Spline.createLinearSpline(mBacklight, mNits)
+ : Spline.createSpline(mBacklight, mNits);
mNitsToBacklightSpline = mInterpolationType == INTERPOLATION_LINEAR
- ? Spline.createLinearSpline(mNits, mBacklight)
- : Spline.createSpline(mNits, mBacklight);
+ ? Spline.createLinearSpline(mNits, mBacklight)
+ : Spline.createSpline(mNits, mBacklight);
}
private void loadQuirks(DisplayConfiguration config) {
@@ -1111,7 +1186,7 @@ public class DisplayDeviceConfig {
if (mHbmData.minimumHdrPercentOfScreen > 1
|| mHbmData.minimumHdrPercentOfScreen < 0) {
Slog.w(TAG, "Invalid minimum HDR percent of screen: "
- + String.valueOf(mHbmData.minimumHdrPercentOfScreen));
+ + String.valueOf(mHbmData.minimumHdrPercentOfScreen));
mHbmData.minimumHdrPercentOfScreen = HDR_PERCENT_OF_SCREEN_REQUIRED_DEFAULT;
}
} else {
@@ -1235,7 +1310,7 @@ public class DisplayDeviceConfig {
ambientBrightnessThresholds.getDarkeningThresholds();
final BigDecimal ambientBrighteningThreshold = brighteningAmbientLux.getMinimum();
- final BigDecimal ambientDarkeningThreshold = darkeningAmbientLux.getMinimum();
+ final BigDecimal ambientDarkeningThreshold = darkeningAmbientLux.getMinimum();
if (ambientBrighteningThreshold != null) {
mAmbientLuxBrighteningMinThreshold = ambientBrighteningThreshold.floatValue();
@@ -1330,8 +1405,8 @@ public class DisplayDeviceConfig {
}
/**
- * @return True if the sensor matches both the specified name and type, or one if only
- * one is specified (not-empty). Always returns false if both parameters are null or empty.
+ * @return True if the sensor matches both the specified name and type, or one if only one
+ * is specified (not-empty). Always returns false if both parameters are null or empty.
*/
public boolean matches(String sensorName, String sensorType) {
final boolean isNameSpecified = !TextUtils.isEmpty(sensorName);
@@ -1446,6 +1521,7 @@ public class DisplayDeviceConfig {
return otherThrottlingLevel.thermalStatus == this.thermalStatus
&& otherThrottlingLevel.brightness == this.brightness;
}
+
@Override
public int hashCode() {
int result = 1;
@@ -1455,8 +1531,11 @@ public class DisplayDeviceConfig {
}
}
- static public BrightnessThrottlingData create(List<ThrottlingLevel> throttlingLevels)
- {
+
+ /**
+ * Creates multiple teperature based throttling levels of brightness
+ */
+ public static BrightnessThrottlingData create(List<ThrottlingLevel> throttlingLevels) {
if (throttlingLevels == null || throttlingLevels.size() == 0) {
Slog.e(TAG, "BrightnessThrottlingData received null or empty throttling levels");
return null;
@@ -1498,8 +1577,9 @@ public class DisplayDeviceConfig {
}
static public BrightnessThrottlingData create(BrightnessThrottlingData other) {
- if (other == null)
+ if (other == null) {
return null;
+ }
return BrightnessThrottlingData.create(other.throttlingLevels);
}
@@ -1508,8 +1588,8 @@ public class DisplayDeviceConfig {
@Override
public String toString() {
return "BrightnessThrottlingData{"
- + "throttlingLevels:" + throttlingLevels
- + "} ";
+ + "throttlingLevels:" + throttlingLevels
+ + "} ";
}
@Override
diff --git a/services/core/java/com/android/server/display/DisplayPowerController.java b/services/core/java/com/android/server/display/DisplayPowerController.java
index 8781a8d9b075..905ae1d4ca80 100644
--- a/services/core/java/com/android/server/display/DisplayPowerController.java
+++ b/services/core/java/com/android/server/display/DisplayPowerController.java
@@ -985,10 +985,10 @@ final class DisplayPowerController implements AutomaticBrightnessController.Call
screenBrighteningThresholds, screenDarkeningThresholds, screenThresholdLevels,
screenDarkeningMinThreshold, screenBrighteningMinThreshold);
- long brighteningLightDebounce = resources.getInteger(
- com.android.internal.R.integer.config_autoBrightnessBrighteningLightDebounce);
- long darkeningLightDebounce = resources.getInteger(
- com.android.internal.R.integer.config_autoBrightnessDarkeningLightDebounce);
+ long brighteningLightDebounce = mDisplayDeviceConfig
+ .getAutoBrightnessBrighteningLightDebounce();
+ long darkeningLightDebounce = mDisplayDeviceConfig
+ .getAutoBrightnessDarkeningLightDebounce();
boolean autoBrightnessResetAmbientLuxAfterWarmUp = resources.getBoolean(
com.android.internal.R.bool.config_autoBrightnessResetAmbientLuxAfterWarmUp);
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 09044e72f60b..073b131cc819 100644
--- a/services/core/xsd/display-device-config/display-device-config.xsd
+++ b/services/core/xsd/display-device-config/display-device-config.xsd
@@ -45,6 +45,8 @@
<xs:element type="highBrightnessMode" name="highBrightnessMode" minOccurs="0"
maxOccurs="1"/>
<xs:element type="displayQuirks" name="quirks" minOccurs="0" maxOccurs="1" />
+ <xs:element type="autoBrightness" name="autoBrightness" minOccurs="0"
+ maxOccurs="1" />
<xs:element type="nonNegativeDecimal" name="screenBrightnessRampFastDecrease">
<xs:annotation name="final"/>
</xs:element>
@@ -101,6 +103,21 @@
<!-- Type definitions -->
+ <xs:complexType name="autoBrightness">
+ <xs:sequence>
+ <!-- Sets the debounce for autoBrightness brightening in millis-->
+ <xs:element name="brighteningLightDebounceMillis" type="xs:nonNegativeInteger"
+ minOccurs="0" maxOccurs="1">
+ <xs:annotation name="final"/>
+ </xs:element>
+ <!-- Sets the debounce for autoBrightness darkening in millis-->
+ <xs:element name="darkeningLightDebounceMillis" type="xs:nonNegativeInteger"
+ minOccurs="0" maxOccurs="1">
+ <xs:annotation name="final"/>
+ </xs:element>
+ </xs:sequence>
+ </xs:complexType>
+
<xs:complexType name="displayQuirks">
<xs:sequence>
<xs:element name="quirk" type="xs:string" minOccurs="0" maxOccurs="unbounded" />
@@ -341,5 +358,4 @@
<xs:annotation name="final"/>
</xs:element>
</xs:complexType>
-
</xs:schema>
diff --git a/services/core/xsd/display-device-config/schema/current.txt b/services/core/xsd/display-device-config/schema/current.txt
index e8b13ca6356e..e9a926946764 100644
--- a/services/core/xsd/display-device-config/schema/current.txt
+++ b/services/core/xsd/display-device-config/schema/current.txt
@@ -1,6 +1,14 @@
// Signature format: 2.0
package com.android.server.display.config {
+ public class AutoBrightness {
+ ctor public AutoBrightness();
+ method public final java.math.BigInteger getBrighteningLightDebounceMillis();
+ method public final java.math.BigInteger getDarkeningLightDebounceMillis();
+ method public final void setBrighteningLightDebounceMillis(java.math.BigInteger);
+ method public final void setDarkeningLightDebounceMillis(java.math.BigInteger);
+ }
+
public class BrightnessThresholds {
ctor public BrightnessThresholds();
method @NonNull public final java.math.BigDecimal getMinimum();
@@ -40,6 +48,7 @@ package com.android.server.display.config {
method @NonNull public final com.android.server.display.config.Thresholds getAmbientBrightnessChangeThresholds();
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 com.android.server.display.config.HighBrightnessMode getHighBrightnessMode();
@@ -58,6 +67,7 @@ package com.android.server.display.config {
method public final void setAmbientBrightnessChangeThresholds(@NonNull 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 void setHighBrightnessMode(com.android.server.display.config.HighBrightnessMode);
diff --git a/services/tests/servicestests/src/com/android/server/display/DisplayDeviceConfigTest.java b/services/tests/servicestests/src/com/android/server/display/DisplayDeviceConfigTest.java
index 793930395daa..03ea6137074d 100644
--- a/services/tests/servicestests/src/com/android/server/display/DisplayDeviceConfigTest.java
+++ b/services/tests/servicestests/src/com/android/server/display/DisplayDeviceConfigTest.java
@@ -86,6 +86,8 @@ public final class DisplayDeviceConfigTest {
0.0f);
assertEquals(mDisplayDeviceConfig.getScreenBrighteningMinThreshold(), 0.001, 0.000001f);
assertEquals(mDisplayDeviceConfig.getScreenDarkeningMinThreshold(), 0.002, 0.000001f);
+ assertEquals(mDisplayDeviceConfig.getAutoBrightnessBrighteningLightDebounce(), 2000);
+ assertEquals(mDisplayDeviceConfig.getAutoBrightnessDarkeningLightDebounce(), 1000);
// Todo(brup): Add asserts for BrightnessThrottlingData, DensityMapping,
// HighBrightnessModeData AmbientLightSensor, RefreshRateLimitations and ProximitySensor.
@@ -109,6 +111,10 @@ public final class DisplayDeviceConfigTest {
+ "<nits>800.0</nits>\n"
+ "</point>\n"
+ "</screenBrightnessMap>\n"
+ + "<autoBrightness>\n"
+ + "<brighteningLightDebounceMillis>2000</brighteningLightDebounceMillis>\n"
+ + "<darkeningLightDebounceMillis>1000</darkeningLightDebounceMillis>\n"
+ + "</autoBrightness>\n"
+ "<highBrightnessMode enabled=\"true\">\n"
+ "<transitionPoint>0.62</transitionPoint>\n"
+ "<minimumLux>10000</minimumLux>\n"