summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author TreeHugger Robot <treehugger-gerrit@google.com> 2023-01-25 11:41:43 +0000
committer Android (Google) Code Review <android-gerrit@google.com> 2023-01-25 11:41:43 +0000
commita95c39d602ccb8c63ed188720777a8dca435a65d (patch)
treeee7e4415c26978444323df43df7b184ca5b0448e
parent0401d48b731bea4343254cf7052081740b804e4d (diff)
parent27403ad421d1373de8143ae5204bd18e34872dbd (diff)
Merge "Add brightness throttling map for concurrent displays"
-rw-r--r--services/core/java/com/android/server/display/DisplayDeviceConfig.java70
-rw-r--r--services/core/java/com/android/server/display/DisplayPowerController.java7
-rw-r--r--services/core/java/com/android/server/display/DisplayPowerController2.java7
-rw-r--r--services/core/xsd/display-device-config/display-device-config.xsd7
-rw-r--r--services/core/xsd/display-device-config/schema/current.txt2
-rw-r--r--services/tests/servicestests/src/com/android/server/display/DisplayDeviceConfigTest.java100
6 files changed, 182 insertions, 11 deletions
diff --git a/services/core/java/com/android/server/display/DisplayDeviceConfig.java b/services/core/java/com/android/server/display/DisplayDeviceConfig.java
index e557b50d8a20..535129c9fda3 100644
--- a/services/core/java/com/android/server/display/DisplayDeviceConfig.java
+++ b/services/core/java/com/android/server/display/DisplayDeviceConfig.java
@@ -132,6 +132,16 @@ import javax.xml.datatype.DatatypeConfigurationException;
* <brightness>0.01</brightness>
* </brightnessThrottlingPoint>
* </brightnessThrottlingMap>
+ * <concurrentDisplaysBrightnessThrottlingMap>
+ * <brightnessThrottlingPoint>
+ * <thermalStatus>severe</thermalStatus>
+ * <brightness>0.07</brightness>
+ * </brightnessThrottlingPoint>
+ * <brightnessThrottlingPoint>
+ * <thermalStatus>critical</thermalStatus>
+ * <brightness>0.005</brightness>
+ * </brightnessThrottlingPoint>
+ * </concurrentDisplaysBrightnessThrottlingMap>
* </thermalThrottling>
*
* <refreshRate>
@@ -613,6 +623,8 @@ public class DisplayDeviceConfig {
// overwritten value.
private BrightnessThrottlingData mBrightnessThrottlingData;
private BrightnessThrottlingData mOriginalBrightnessThrottlingData;
+ // The concurrent displays mode might need a stricter throttling policy
+ private BrightnessThrottlingData mConcurrentDisplaysBrightnessThrottlingData;
@VisibleForTesting
DisplayDeviceConfig(Context context) {
@@ -1258,13 +1270,21 @@ public class DisplayDeviceConfig {
}
/**
- * @return brightness throttling data configuration data for the display.
+ * @return brightness throttling configuration data for the display.
*/
public BrightnessThrottlingData getBrightnessThrottlingData() {
return BrightnessThrottlingData.create(mBrightnessThrottlingData);
}
/**
+ * @return brightness throttling configuration data for the display for the concurrent
+ * displays mode.
+ */
+ public BrightnessThrottlingData getConcurrentDisplaysBrightnessThrottlingData() {
+ return BrightnessThrottlingData.create(mConcurrentDisplaysBrightnessThrottlingData);
+ }
+
+ /**
* @return Auto brightness darkening light debounce
*/
public long getAutoBrightnessDarkeningLightDebounce() {
@@ -1503,6 +1523,7 @@ public class DisplayDeviceConfig {
loadBrightnessConstraintsFromConfigXml();
loadBrightnessMap(config);
loadBrightnessThrottlingMap(config);
+ loadConcurrentDisplaysBrightnessThrottlingMap(config);
loadHighBrightnessModeData(config);
loadQuirks(config);
loadBrightnessRamps(config);
@@ -1714,13 +1735,13 @@ public class DisplayDeviceConfig {
private void loadBrightnessThrottlingMap(DisplayConfiguration config) {
final ThermalThrottling throttlingConfig = config.getThermalThrottling();
if (throttlingConfig == null) {
- Slog.i(TAG, "no thermal throttling config found");
+ Slog.i(TAG, "No thermal throttling config found");
return;
}
final BrightnessThrottlingMap map = throttlingConfig.getBrightnessThrottlingMap();
if (map == null) {
- Slog.i(TAG, "no brightness throttling map found");
+ Slog.i(TAG, "No brightness throttling map found");
return;
}
@@ -1747,6 +1768,43 @@ public class DisplayDeviceConfig {
}
}
+ private void loadConcurrentDisplaysBrightnessThrottlingMap(DisplayConfiguration config) {
+ final ThermalThrottling throttlingConfig = config.getThermalThrottling();
+ if (throttlingConfig == null) {
+ Slog.i(TAG, "No concurrent displays thermal throttling config found");
+ return;
+ }
+
+ final BrightnessThrottlingMap map =
+ throttlingConfig.getConcurrentDisplaysBrightnessThrottlingMap();
+ if (map == null) {
+ Slog.i(TAG, "No concurrent displays brightness throttling map found");
+ return;
+ }
+
+ 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());
+
+ boolean badConfig = false;
+ for (BrightnessThrottlingPoint point : points) {
+ ThermalStatus status = point.getThermalStatus();
+ if (!thermalStatusIsValid(status)) {
+ badConfig = true;
+ break;
+ }
+
+ throttlingLevels.add(new BrightnessThrottlingData.ThrottlingLevel(
+ convertThermalStatus(status), point.getBrightness().floatValue()));
+ }
+
+ if (!badConfig) {
+ mConcurrentDisplaysBrightnessThrottlingData =
+ BrightnessThrottlingData.create(throttlingLevels);
+ }
+ }
+
private void loadRefreshRateSetting(DisplayConfiguration config) {
final RefreshRateConfigs refreshRateConfigs =
(config == null) ? null : config.getRefreshRate();
@@ -2529,7 +2587,8 @@ public class DisplayDeviceConfig {
}
}
- private @PowerManager.ThermalStatus int convertThermalStatus(ThermalStatus value) {
+ @VisibleForTesting
+ static @PowerManager.ThermalStatus int convertThermalStatus(ThermalStatus value) {
if (value == null) {
return PowerManager.THERMAL_STATUS_NONE;
}
@@ -2855,7 +2914,8 @@ public class DisplayDeviceConfig {
return throttlingLevels.hashCode();
}
- private BrightnessThrottlingData(List<ThrottlingLevel> inLevels) {
+ @VisibleForTesting
+ BrightnessThrottlingData(List<ThrottlingLevel> inLevels) {
throttlingLevels = new ArrayList<>(inLevels.size());
for (ThrottlingLevel level : inLevels) {
throttlingLevels.add(new ThrottlingLevel(level.thermalStatus, level.brightness));
diff --git a/services/core/java/com/android/server/display/DisplayPowerController.java b/services/core/java/com/android/server/display/DisplayPowerController.java
index 23ece9928eb5..dbd2ab0cbe60 100644
--- a/services/core/java/com/android/server/display/DisplayPowerController.java
+++ b/services/core/java/com/android/server/display/DisplayPowerController.java
@@ -885,6 +885,9 @@ final class DisplayPowerController implements AutomaticBrightnessController.Call
updatePowerState();
}
});
+
+ // TODO (b/265793751): Re-create BrightnessTracker if we're enetering/exiting concurrent
+ // displays mode
}
/**
@@ -943,6 +946,8 @@ final class DisplayPowerController implements AutomaticBrightnessController.Call
return mDisplayDeviceConfig.getHdrBrightnessFromSdr(sdrBrightness);
}
});
+ // TODO (b/265793751): Use the appropriate throttling data if we're in concurrent displays
+ // mode
mBrightnessThrottler.resetThrottlingData(
mDisplayDeviceConfig.getBrightnessThrottlingData(), mUniqueDisplayId);
}
@@ -2048,6 +2053,8 @@ final class DisplayPowerController implements AutomaticBrightnessController.Call
private BrightnessThrottler createBrightnessThrottlerLocked() {
final DisplayDevice device = mLogicalDisplay.getPrimaryDisplayDeviceLocked();
final DisplayDeviceConfig ddConfig = device.getDisplayDeviceConfig();
+ // TODO (b/265793751): Use the appropriate throttling data if we're in concurrent displays
+ // mode
final DisplayDeviceConfig.BrightnessThrottlingData data =
ddConfig != null ? ddConfig.getBrightnessThrottlingData() : null;
return new BrightnessThrottler(mHandler, data,
diff --git a/services/core/java/com/android/server/display/DisplayPowerController2.java b/services/core/java/com/android/server/display/DisplayPowerController2.java
index 3ac85a70f13c..103a1dac4ecb 100644
--- a/services/core/java/com/android/server/display/DisplayPowerController2.java
+++ b/services/core/java/com/android/server/display/DisplayPowerController2.java
@@ -732,6 +732,9 @@ final class DisplayPowerController2 implements AutomaticBrightnessController.Cal
updatePowerState();
}
});
+
+ // TODO (b/265793751): Re-create BrightnessTracker if we're enetering/exiting concurrent
+ // displays mode
}
/**
@@ -783,6 +786,8 @@ final class DisplayPowerController2 implements AutomaticBrightnessController.Cal
return mDisplayDeviceConfig.getHdrBrightnessFromSdr(sdrBrightness);
}
});
+ // TODO (b/265793751): Use the appropriate throttling data if we're in concurrent displays
+ // mode
mBrightnessThrottler.resetThrottlingData(
mDisplayDeviceConfig.getBrightnessThrottlingData(), mUniqueDisplayId);
}
@@ -1755,6 +1760,8 @@ final class DisplayPowerController2 implements AutomaticBrightnessController.Cal
private BrightnessThrottler createBrightnessThrottlerLocked() {
final DisplayDevice device = mLogicalDisplay.getPrimaryDisplayDeviceLocked();
final DisplayDeviceConfig ddConfig = device.getDisplayDeviceConfig();
+ // TODO (b/265793751): Use the appropriate throttling data if we're in concurrent displays
+ // mode
final DisplayDeviceConfig.BrightnessThrottlingData data =
ddConfig != null ? ddConfig.getBrightnessThrottlingData() : null;
return new BrightnessThrottler(mHandler, data,
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 7f85347b6731..a27eb7f5f0c3 100644
--- a/services/core/xsd/display-device-config/display-device-config.xsd
+++ b/services/core/xsd/display-device-config/display-device-config.xsd
@@ -202,12 +202,15 @@
</xs:simpleType>
<xs:complexType name="thermalThrottling">
- <xs:complexType>
+ <xs:sequence>
<xs:element type="brightnessThrottlingMap" name="brightnessThrottlingMap">
<xs:annotation name="nonnull"/>
<xs:annotation name="final"/>
</xs:element>
- </xs:complexType>
+ <xs:element type="brightnessThrottlingMap" name="concurrentDisplaysBrightnessThrottlingMap">
+ <xs:annotation name="final"/>
+ </xs:element>
+ </xs:sequence>
</xs:complexType>
<xs:complexType name="brightnessThrottlingMap">
diff --git a/services/core/xsd/display-device-config/schema/current.txt b/services/core/xsd/display-device-config/schema/current.txt
index cb081791ffce..6c66d0dee0c0 100644
--- a/services/core/xsd/display-device-config/schema/current.txt
+++ b/services/core/xsd/display-device-config/schema/current.txt
@@ -237,7 +237,9 @@ package com.android.server.display.config {
public class ThermalThrottling {
ctor public ThermalThrottling();
method @NonNull public final com.android.server.display.config.BrightnessThrottlingMap getBrightnessThrottlingMap();
+ method public final com.android.server.display.config.BrightnessThrottlingMap getConcurrentDisplaysBrightnessThrottlingMap();
method public final void setBrightnessThrottlingMap(@NonNull com.android.server.display.config.BrightnessThrottlingMap);
+ method public final void setConcurrentDisplaysBrightnessThrottlingMap(com.android.server.display.config.BrightnessThrottlingMap);
}
public class ThresholdPoint {
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 91fd76ec4b70..4bc8242836e7 100644
--- a/services/tests/servicestests/src/com/android/server/display/DisplayDeviceConfigTest.java
+++ b/services/tests/servicestests/src/com/android/server/display/DisplayDeviceConfigTest.java
@@ -32,6 +32,7 @@ import androidx.test.filters.SmallTest;
import androidx.test.runner.AndroidJUnit4;
import com.android.internal.R;
+import com.android.server.display.config.ThermalStatus;
import org.junit.Before;
import org.junit.Test;
@@ -43,6 +44,8 @@ import java.io.IOException;
import java.nio.charset.StandardCharsets;
import java.nio.file.Files;
import java.nio.file.Path;
+import java.util.ArrayList;
+import java.util.List;
@SmallTest
@RunWith(AndroidJUnit4.class)
@@ -164,6 +167,51 @@ public final class DisplayDeviceConfigTest {
assertArrayEquals(new int[]{-1, 10, 20, 30, 40},
mDisplayDeviceConfig.getScreenOffBrightnessSensorValueToLux());
+ List<DisplayDeviceConfig.BrightnessThrottlingData.ThrottlingLevel> throttlingLevels =
+ new ArrayList();
+ throttlingLevels.add(new DisplayDeviceConfig.BrightnessThrottlingData.ThrottlingLevel(
+ DisplayDeviceConfig.convertThermalStatus(ThermalStatus.light), 0.4f
+ ));
+ throttlingLevels.add(new DisplayDeviceConfig.BrightnessThrottlingData.ThrottlingLevel(
+ DisplayDeviceConfig.convertThermalStatus(ThermalStatus.moderate), 0.3f
+ ));
+ throttlingLevels.add(new DisplayDeviceConfig.BrightnessThrottlingData.ThrottlingLevel(
+ DisplayDeviceConfig.convertThermalStatus(ThermalStatus.severe), 0.2f
+ ));
+ throttlingLevels.add(new DisplayDeviceConfig.BrightnessThrottlingData.ThrottlingLevel(
+ DisplayDeviceConfig.convertThermalStatus(ThermalStatus.critical), 0.1f
+ ));
+ throttlingLevels.add(new DisplayDeviceConfig.BrightnessThrottlingData.ThrottlingLevel(
+ DisplayDeviceConfig.convertThermalStatus(ThermalStatus.emergency), 0.05f
+ ));
+ throttlingLevels.add(new DisplayDeviceConfig.BrightnessThrottlingData.ThrottlingLevel(
+ DisplayDeviceConfig.convertThermalStatus(ThermalStatus.shutdown), 0.025f
+ ));
+ assertEquals(new DisplayDeviceConfig.BrightnessThrottlingData(throttlingLevels),
+ mDisplayDeviceConfig.getBrightnessThrottlingData());
+
+ throttlingLevels.clear();
+ throttlingLevels.add(new DisplayDeviceConfig.BrightnessThrottlingData.ThrottlingLevel(
+ DisplayDeviceConfig.convertThermalStatus(ThermalStatus.light), 0.2f
+ ));
+ throttlingLevels.add(new DisplayDeviceConfig.BrightnessThrottlingData.ThrottlingLevel(
+ DisplayDeviceConfig.convertThermalStatus(ThermalStatus.moderate), 0.15f
+ ));
+ throttlingLevels.add(new DisplayDeviceConfig.BrightnessThrottlingData.ThrottlingLevel(
+ DisplayDeviceConfig.convertThermalStatus(ThermalStatus.severe), 0.1f
+ ));
+ throttlingLevels.add(new DisplayDeviceConfig.BrightnessThrottlingData.ThrottlingLevel(
+ DisplayDeviceConfig.convertThermalStatus(ThermalStatus.critical), 0.05f
+ ));
+ throttlingLevels.add(new DisplayDeviceConfig.BrightnessThrottlingData.ThrottlingLevel(
+ DisplayDeviceConfig.convertThermalStatus(ThermalStatus.emergency), 0.025f
+ ));
+ throttlingLevels.add(new DisplayDeviceConfig.BrightnessThrottlingData.ThrottlingLevel(
+ DisplayDeviceConfig.convertThermalStatus(ThermalStatus.shutdown), 0.0125f
+ ));
+ assertEquals(new DisplayDeviceConfig.BrightnessThrottlingData(throttlingLevels),
+ mDisplayDeviceConfig.getConcurrentDisplaysBrightnessThrottlingData());
+
// Todo: Add asserts for BrightnessThrottlingData, DensityMapping,
// HighBrightnessModeData AmbientLightSensor, RefreshRateLimitations and ProximitySensor.
}
@@ -428,16 +476,60 @@ public final class DisplayDeviceConfigTest {
+ "<ambientLightHorizonShort>50</ambientLightHorizonShort>\n"
+ "<screenBrightnessRampIncreaseMaxMillis>"
+ "2000"
- + "</screenBrightnessRampIncreaseMaxMillis>\n"
+ + "</screenBrightnessRampIncreaseMaxMillis>\n"
+ "<thermalThrottling>\n"
+ "<brightnessThrottlingMap>\n"
+ "<brightnessThrottlingPoint>\n"
+ + "<thermalStatus>light</thermalStatus>\n"
+ + "<brightness>0.4</brightness>\n"
+ + "</brightnessThrottlingPoint>\n"
+ + "<brightnessThrottlingPoint>\n"
+ + "<thermalStatus>moderate</thermalStatus>\n"
+ + "<brightness>0.3</brightness>\n"
+ + "</brightnessThrottlingPoint>\n"
+ + "<brightnessThrottlingPoint>\n"
+ + "<thermalStatus>severe</thermalStatus>\n"
+ + "<brightness>0.2</brightness>\n"
+ + "</brightnessThrottlingPoint>\n"
+ + "<brightnessThrottlingPoint>\n"
+ + "<thermalStatus>critical</thermalStatus>\n"
+ + "<brightness>0.1</brightness>\n"
+ + "</brightnessThrottlingPoint>\n"
+ + "<brightnessThrottlingPoint>\n"
+ "<thermalStatus>emergency</thermalStatus>\n"
- + "<!-- Throttling to 250 nits: (250-2.0)/(500-2.0)*(0.62-0.0)+0"
- + ".0 = 0.30875502 -->\n"
- + "<brightness>0.30875502</brightness>\n"
+ + "<brightness>0.05</brightness>\n"
+ + "</brightnessThrottlingPoint>\n"
+ + "<brightnessThrottlingPoint>\n"
+ + "<thermalStatus>shutdown</thermalStatus>\n"
+ + "<brightness>0.025</brightness>\n"
+ "</brightnessThrottlingPoint>\n"
+ "</brightnessThrottlingMap>\n"
+ + "<concurrentDisplaysBrightnessThrottlingMap>\n"
+ + "<brightnessThrottlingPoint>\n"
+ + "<thermalStatus>light</thermalStatus>\n"
+ + "<brightness>0.2</brightness>\n"
+ + "</brightnessThrottlingPoint>\n"
+ + "<brightnessThrottlingPoint>\n"
+ + "<thermalStatus>moderate</thermalStatus>\n"
+ + "<brightness>0.15</brightness>\n"
+ + "</brightnessThrottlingPoint>\n"
+ + "<brightnessThrottlingPoint>\n"
+ + "<thermalStatus>severe</thermalStatus>\n"
+ + "<brightness>0.1</brightness>\n"
+ + "</brightnessThrottlingPoint>\n"
+ + "<brightnessThrottlingPoint>\n"
+ + "<thermalStatus>critical</thermalStatus>\n"
+ + "<brightness>0.05</brightness>\n"
+ + "</brightnessThrottlingPoint>\n"
+ + "<brightnessThrottlingPoint>\n"
+ + "<thermalStatus>emergency</thermalStatus>\n"
+ + "<brightness>0.025</brightness>\n"
+ + "</brightnessThrottlingPoint>\n"
+ + "<brightnessThrottlingPoint>\n"
+ + "<thermalStatus>shutdown</thermalStatus>\n"
+ + "<brightness>0.0125</brightness>\n"
+ + "</brightnessThrottlingPoint>\n"
+ + "</concurrentDisplaysBrightnessThrottlingMap>\n"
+ "</thermalThrottling>\n"
+ "<refreshRate>\n"
+ "<lowerBlockingZoneConfigs>\n"