diff --git a/services/core/java/com/android/server/display/DisplayDeviceConfig.java b/services/core/java/com/android/server/display/DisplayDeviceConfig.java
index e557b50d8a200..535129c9fda39 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;
* 0.01
*
*
+ *
+ *
+ * severe
+ * 0.07
+ *
+ *
+ * critical
+ * 0.005
+ *
+ *
*
*
*
@@ -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,12 +1270,20 @@ 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
*/
@@ -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 points = map.getBrightnessThrottlingPoint();
+ // At least 1 point is guaranteed by the display device config schema
+ List 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 inLevels) {
+ @VisibleForTesting
+ BrightnessThrottlingData(List 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 23ece9928eb55..dbd2ab0cbe60d 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 3ac85a70f13c7..103a1dac4ecb1 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 7f85347b67318..a27eb7f5f0c32 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 @@
-
+
-
+
+
+
+
diff --git a/services/core/xsd/display-device-config/schema/current.txt b/services/core/xsd/display-device-config/schema/current.txt
index cb081791ffce0..6c66d0dee0c06 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 91fd76ec4b704..4bc8242836e7b 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 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 {
+ "50\n"
+ ""
+ "2000"
- + "\n"
+ + "\n"
+ "\n"
+ "\n"
+ "\n"
+ + "light\n"
+ + "0.4\n"
+ + "\n"
+ + "\n"
+ + "moderate\n"
+ + "0.3\n"
+ + "\n"
+ + "\n"
+ + "severe\n"
+ + "0.2\n"
+ + "\n"
+ + "\n"
+ + "critical\n"
+ + "0.1\n"
+ + "\n"
+ + "\n"
+ "emergency\n"
- + "\n"
- + "0.30875502\n"
+ + "0.05\n"
+ + "\n"
+ + "\n"
+ + "shutdown\n"
+ + "0.025\n"
+ "\n"
+ "\n"
+ + "\n"
+ + "\n"
+ + "light\n"
+ + "0.2\n"
+ + "\n"
+ + "\n"
+ + "moderate\n"
+ + "0.15\n"
+ + "\n"
+ + "\n"
+ + "severe\n"
+ + "0.1\n"
+ + "\n"
+ + "\n"
+ + "critical\n"
+ + "0.05\n"
+ + "\n"
+ + "\n"
+ + "emergency\n"
+ + "0.025\n"
+ + "\n"
+ + "\n"
+ + "shutdown\n"
+ + "0.0125\n"
+ + "\n"
+ + "\n"
+ "\n"
+ "\n"
+ "\n"