Merge "Use concurrent displays brightness throttling map if needed"

This commit is contained in:
Piotr Wilczyński
2023-02-01 16:21:22 +00:00
committed by Android (Google) Code Review
14 changed files with 207 additions and 152 deletions

View File

@@ -122,7 +122,8 @@ class DeviceStateToLayoutMap {
DisplayAddress.fromPhysicalDisplayId(d.getAddress().longValue()),
d.isDefaultDisplay(),
d.isEnabled(),
mIdProducer);
mIdProducer,
d.getBrightnessThrottlingMapId());
if (FRONT_STRING.equals(d.getPosition())) {
display.setPosition(POSITION_FRONT);

View File

@@ -74,8 +74,10 @@ import java.math.BigInteger;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
import java.util.HashMap;
import java.util.List;
import java.util.Locale;
import java.util.Map;
import javax.xml.datatype.DatatypeConfigurationException;
@@ -411,6 +413,8 @@ public class DisplayDeviceConfig {
public static final String QUIRK_CAN_SET_BRIGHTNESS_VIA_HWC = "canSetBrightnessViaHwc";
static final String DEFAULT_BRIGHTNESS_THROTTLING_DATA_ID = "default";
private static final float BRIGHTNESS_DEFAULT = 0.5f;
private static final String ETC_DIR = "etc";
private static final String DISPLAY_CONFIG_DIR = "displayconfig";
@@ -627,13 +631,7 @@ public class DisplayDeviceConfig {
private int[] mHighDisplayBrightnessThresholds = DEFAULT_BRIGHTNESS_THRESHOLDS;
private int[] mHighAmbientBrightnessThresholds = DEFAULT_BRIGHTNESS_THRESHOLDS;
// 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.
private BrightnessThrottlingData mBrightnessThrottlingData;
private BrightnessThrottlingData mOriginalBrightnessThrottlingData;
// The concurrent displays mode might need a stricter throttling policy
private BrightnessThrottlingData mConcurrentDisplaysBrightnessThrottlingData;
private Map<String, BrightnessThrottlingData> mBrightnessThrottlingDataMap = new HashMap();
@Nullable
private HostUsiVersion mHostUsiVersion;
@@ -779,10 +777,6 @@ public class DisplayDeviceConfig {
return config;
}
void setBrightnessThrottlingData(BrightnessThrottlingData brightnessThrottlingData) {
mBrightnessThrottlingData = brightnessThrottlingData;
}
/**
* Return the brightness mapping nits array.
*
@@ -1282,18 +1276,11 @@ public class DisplayDeviceConfig {
}
/**
* @param id The ID of the throttling data
* @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);
public BrightnessThrottlingData getBrightnessThrottlingData(String id) {
return BrightnessThrottlingData.create(mBrightnessThrottlingDataMap.get(id));
}
/**
@@ -1411,8 +1398,7 @@ public class DisplayDeviceConfig {
+ ", isHbmEnabled=" + mIsHighBrightnessModeEnabled
+ ", mHbmData=" + mHbmData
+ ", mSdrToHdrRatioSpline=" + mSdrToHdrRatioSpline
+ ", mBrightnessThrottlingData=" + mBrightnessThrottlingData
+ ", mOriginalBrightnessThrottlingData=" + mOriginalBrightnessThrottlingData
+ ", mBrightnessThrottlingData=" + mBrightnessThrottlingDataMap
+ "\n"
+ ", mBrightnessRampFastDecrease=" + mBrightnessRampFastDecrease
+ ", mBrightnessRampFastIncrease=" + mBrightnessRampFastIncrease
@@ -1545,8 +1531,7 @@ public class DisplayDeviceConfig {
loadBrightnessDefaultFromDdcXml(config);
loadBrightnessConstraintsFromConfigXml();
loadBrightnessMap(config);
loadBrightnessThrottlingMap(config);
loadConcurrentDisplaysBrightnessThrottlingMap(config);
loadBrightnessThrottlingMaps(config);
loadHighBrightnessModeData(config);
loadQuirks(config);
loadBrightnessRamps(config);
@@ -1756,76 +1741,47 @@ public class DisplayDeviceConfig {
return Spline.createSpline(nits, ratios);
}
private void loadBrightnessThrottlingMap(DisplayConfiguration config) {
private void loadBrightnessThrottlingMaps(DisplayConfiguration config) {
final ThermalThrottling throttlingConfig = config.getThermalThrottling();
if (throttlingConfig == null) {
Slog.i(TAG, "No thermal throttling config found");
return;
}
final BrightnessThrottlingMap map = throttlingConfig.getBrightnessThrottlingMap();
if (map == null) {
final List<BrightnessThrottlingMap> maps = throttlingConfig.getBrightnessThrottlingMap();
if (maps == null || maps.isEmpty()) {
Slog.i(TAG, "No 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());
for (BrightnessThrottlingMap map : maps) {
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;
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()));
}
throttlingLevels.add(new BrightnessThrottlingData.ThrottlingLevel(
convertThermalStatus(status), point.getBrightness().floatValue()));
}
if (!badConfig) {
mBrightnessThrottlingData = BrightnessThrottlingData.create(throttlingLevels);
mOriginalBrightnessThrottlingData = mBrightnessThrottlingData;
}
}
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;
if (!badConfig) {
String id = map.getId() == null ? DEFAULT_BRIGHTNESS_THROTTLING_DATA_ID
: map.getId();
if (mBrightnessThrottlingDataMap.containsKey(id)) {
throw new RuntimeException("Brightness throttling data with ID " + id
+ " already exists");
}
mBrightnessThrottlingDataMap.put(id,
BrightnessThrottlingData.create(throttlingLevels));
}
throttlingLevels.add(new BrightnessThrottlingData.ThrottlingLevel(
convertThermalStatus(status), point.getBrightness().floatValue()));
}
if (!badConfig) {
mConcurrentDisplaysBrightnessThrottlingData =
BrightnessThrottlingData.create(throttlingLevels);
}
}

View File

@@ -504,6 +504,8 @@ final class DisplayPowerController implements AutomaticBrightnessController.Call
private boolean mIsEnabled;
private boolean mIsInTransition;
private String mBrightnessThrottlingDataId;
// DPCs following the brightness of this DPC. This is used in concurrent displays mode - there
// is one lead display, the additional displays follow the brightness value of the lead display.
@GuardedBy("mLock")
@@ -539,6 +541,7 @@ final class DisplayPowerController implements AutomaticBrightnessController.Call
mHandler = new DisplayControllerHandler(handler.getLooper());
mLastBrightnessEvent = new BrightnessEvent(mDisplayId);
mTempBrightnessEvent = new BrightnessEvent(mDisplayId);
mBrightnessThrottlingDataId = logicalDisplay.getBrightnessThrottlingDataIdLocked();
if (mDisplayId == Display.DEFAULT_DISPLAY) {
mBatteryStats = BatteryStatsService.getService();
@@ -862,6 +865,8 @@ final class DisplayPowerController implements AutomaticBrightnessController.Call
final DisplayDeviceInfo info = device.getDisplayDeviceInfoLocked();
final boolean isEnabled = mLogicalDisplay.isEnabledLocked();
final boolean isInTransition = mLogicalDisplay.isInTransitionLocked();
final String brightnessThrottlingDataId =
mLogicalDisplay.getBrightnessThrottlingDataIdLocked();
mHandler.post(() -> {
boolean changed = false;
if (mDisplayDevice != device) {
@@ -870,12 +875,19 @@ final class DisplayPowerController implements AutomaticBrightnessController.Call
mUniqueDisplayId = uniqueId;
mDisplayStatsId = mUniqueDisplayId.hashCode();
mDisplayDeviceConfig = config;
mBrightnessThrottlingDataId = brightnessThrottlingDataId;
loadFromDisplayDeviceConfig(token, info, hbmMetadata);
/// Since the underlying display-device changed, we really don't know the
// last command that was sent to change it's state. Lets assume it is unknown so
// that we trigger a change immediately.
mPowerState.resetScreenState();
} else if (!mBrightnessThrottlingDataId.equals(brightnessThrottlingDataId)) {
changed = true;
mBrightnessThrottlingDataId = brightnessThrottlingDataId;
mBrightnessThrottler.resetThrottlingData(
config.getBrightnessThrottlingData(mBrightnessThrottlingDataId),
mUniqueDisplayId);
}
if (mIsEnabled != isEnabled || mIsInTransition != isInTransition) {
changed = true;
@@ -887,9 +899,6 @@ final class DisplayPowerController implements AutomaticBrightnessController.Call
updatePowerState();
}
});
// TODO (b/265793751): Re-create BrightnessTracker if we're enetering/exiting concurrent
// displays mode
}
/**
@@ -926,7 +935,7 @@ final class DisplayPowerController implements AutomaticBrightnessController.Call
}
private void loadFromDisplayDeviceConfig(IBinder token, DisplayDeviceInfo info,
HighBrightnessModeMetadata hbmMetadata) {
HighBrightnessModeMetadata hbmMetadata) {
// All properties that depend on the associated DisplayDevice and the DDC must be
// updated here.
loadBrightnessRampRates();
@@ -948,10 +957,9 @@ 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);
mDisplayDeviceConfig.getBrightnessThrottlingData(mBrightnessThrottlingDataId),
mUniqueDisplayId);
}
private void sendUpdatePowerState() {
@@ -2061,11 +2069,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,
return new BrightnessThrottler(mHandler,
ddConfig.getBrightnessThrottlingData(mBrightnessThrottlingDataId),
() -> {
sendUpdatePowerState();
postBrightnessChangeRunnable();

View File

@@ -411,6 +411,8 @@ final class DisplayPowerController2 implements AutomaticBrightnessController.Cal
private boolean mIsEnabled;
private boolean mIsInTransition;
private String mBrightnessThrottlingDataId;
// DPCs following the brightness of this DPC. This is used in concurrent displays mode - there
// is one lead display, the additional displays follow the brightness value of the lead display.
@GuardedBy("mLock")
@@ -443,6 +445,7 @@ final class DisplayPowerController2 implements AutomaticBrightnessController.Cal
mHighBrightnessModeMetadata = hbmMetadata;
mDisplayStateController = new DisplayStateController(mDisplayPowerProximityStateController);
mTag = "DisplayPowerController2[" + mDisplayId + "]";
mBrightnessThrottlingDataId = logicalDisplay.getBrightnessThrottlingDataIdLocked();
mDisplayDevice = mLogicalDisplay.getPrimaryDisplayDeviceLocked();
mUniqueDisplayId = logicalDisplay.getPrimaryDisplayDeviceLocked().getUniqueId();
@@ -705,6 +708,8 @@ final class DisplayPowerController2 implements AutomaticBrightnessController.Cal
final DisplayDeviceInfo info = device.getDisplayDeviceInfoLocked();
final boolean isEnabled = mLogicalDisplay.isEnabledLocked();
final boolean isInTransition = mLogicalDisplay.isInTransitionLocked();
final String brightnessThrottlingDataId =
mLogicalDisplay.getBrightnessThrottlingDataIdLocked();
mHandler.post(() -> {
boolean changed = false;
@@ -714,6 +719,7 @@ final class DisplayPowerController2 implements AutomaticBrightnessController.Cal
mUniqueDisplayId = uniqueId;
mDisplayStatsId = mUniqueDisplayId.hashCode();
mDisplayDeviceConfig = config;
mBrightnessThrottlingDataId = brightnessThrottlingDataId;
loadFromDisplayDeviceConfig(token, info, hbmMetadata);
mDisplayPowerProximityStateController.notifyDisplayDeviceChanged(config);
@@ -721,6 +727,12 @@ final class DisplayPowerController2 implements AutomaticBrightnessController.Cal
// last command that was sent to change it's state. Lets assume it is unknown so
// that we trigger a change immediately.
mPowerState.resetScreenState();
} else if (!mBrightnessThrottlingDataId.equals(brightnessThrottlingDataId)) {
changed = true;
mBrightnessThrottlingDataId = brightnessThrottlingDataId;
mBrightnessThrottler.resetThrottlingData(
config.getBrightnessThrottlingData(mBrightnessThrottlingDataId),
mUniqueDisplayId);
}
if (mIsEnabled != isEnabled || mIsInTransition != isInTransition) {
changed = true;
@@ -732,9 +744,6 @@ final class DisplayPowerController2 implements AutomaticBrightnessController.Cal
updatePowerState();
}
});
// TODO (b/265793751): Re-create BrightnessTracker if we're enetering/exiting concurrent
// displays mode
}
/**
@@ -765,7 +774,7 @@ final class DisplayPowerController2 implements AutomaticBrightnessController.Cal
}
private void loadFromDisplayDeviceConfig(IBinder token, DisplayDeviceInfo info,
HighBrightnessModeMetadata hbmMetadata) {
HighBrightnessModeMetadata hbmMetadata) {
// All properties that depend on the associated DisplayDevice and the DDC must be
// updated here.
loadBrightnessRampRates();
@@ -786,10 +795,9 @@ 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);
mDisplayDeviceConfig.getBrightnessThrottlingData(mBrightnessThrottlingDataId),
mUniqueDisplayId);
}
private void sendUpdatePowerState() {
@@ -1768,11 +1776,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,
return new BrightnessThrottler(mHandler,
ddConfig.getBrightnessThrottlingData(mBrightnessThrottlingDataId),
() -> {
sendUpdatePowerState();
postBrightnessChangeRunnable();

View File

@@ -152,6 +152,13 @@ final class LogicalDisplay {
// the {@link mIsEnabled} is changing, or the underlying mPrimiaryDisplayDevice is changing.
private boolean mIsInTransition;
/**
* The ID of the brightness throttling data that should be used. This can change e.g. in
* concurrent displays mode in which a stricter brightness throttling policy might need to be
* used.
*/
private String mBrightnessThrottlingDataId;
public LogicalDisplay(int displayId, int layerStack, DisplayDevice primaryDisplayDevice) {
mDisplayId = displayId;
mLayerStack = layerStack;
@@ -160,6 +167,7 @@ final class LogicalDisplay {
mTempFrameRateOverride = new SparseArray<>();
mIsEnabled = true;
mIsInTransition = false;
mBrightnessThrottlingDataId = DisplayDeviceConfig.DEFAULT_BRIGHTNESS_THROTTLING_DATA_ID;
}
/**
@@ -762,7 +770,7 @@ final class LogicalDisplay {
/**
* Sets the display as enabled.
*
* @param enable True if enabled, false otherwise.
* @param enabled True if enabled, false otherwise.
*/
public void setEnabledLocked(boolean enabled) {
mIsEnabled = enabled;
@@ -785,6 +793,22 @@ final class LogicalDisplay {
mIsInTransition = isInTransition;
}
/**
* @return The ID of the brightness throttling data that this display should use.
*/
public String getBrightnessThrottlingDataIdLocked() {
return mBrightnessThrottlingDataId;
}
/**
* @param brightnessThrottlingDataId The ID of the brightness throttling data that this
* display should use.
*/
public void setBrightnessThrottlingDataIdLocked(String brightnessThrottlingDataId) {
mBrightnessThrottlingDataId =
brightnessThrottlingDataId;
}
public void dumpLocked(PrintWriter pw) {
pw.println("mDisplayId=" + mDisplayId);
pw.println("mIsEnabled=" + mIsEnabled);
@@ -802,6 +826,7 @@ final class LogicalDisplay {
pw.println("mRequestedMinimalPostProcessing=" + mRequestedMinimalPostProcessing);
pw.println("mFrameRateOverrides=" + Arrays.toString(mFrameRateOverrides));
pw.println("mPendingFrameRateOverrideUids=" + mPendingFrameRateOverrideUids);
pw.println("mBrightnessThrottlingDataId=" + mBrightnessThrottlingDataId);
}
@Override

View File

@@ -638,7 +638,8 @@ class LogicalDisplayMapper implements DisplayDeviceRepository.Listener {
& DisplayDeviceInfo.FLAG_ALLOWED_TO_BE_DEFAULT_DISPLAY) != 0
&& !nextDeviceInfo.address.equals(deviceInfo.address)) {
layout.createDisplayLocked(nextDeviceInfo.address,
/* isDefault= */ true, /* isEnabled= */ true, mIdProducer);
/* isDefault= */ true, /* isEnabled= */ true, mIdProducer,
/* brightnessThrottlingMapId= */ null);
applyLayoutLocked();
return;
}
@@ -989,6 +990,10 @@ class LogicalDisplayMapper implements DisplayDeviceRepository.Listener {
}
setEnabledLocked(newDisplay, displayLayout.isEnabled());
newDisplay.setBrightnessThrottlingDataIdLocked(
displayLayout.getBrightnessThrottlingMapId() == null
? DisplayDeviceConfig.DEFAULT_BRIGHTNESS_THROTTLING_DATA_ID
: displayLayout.getBrightnessThrottlingMapId());
}
}
@@ -1063,7 +1068,7 @@ class LogicalDisplayMapper implements DisplayDeviceRepository.Listener {
}
final DisplayDeviceInfo info = device.getDisplayDeviceInfoLocked();
layout.createDisplayLocked(info.address, /* isDefault= */ true, /* isEnabled= */ true,
mIdProducer);
mIdProducer, /* brightnessThrottlingMapId= */ null);
}
private int assignLayerStackLocked(int displayId) {

View File

@@ -25,6 +25,7 @@ import android.view.DisplayAddress;
import java.util.ArrayList;
import java.util.List;
import java.util.Objects;
/**
* Holds a collection of {@link Display}s. A single instance of this class describes
@@ -76,7 +77,7 @@ public class Layout {
*/
public Display createDisplayLocked(
@NonNull DisplayAddress address, boolean isDefault, boolean isEnabled,
DisplayIdProducer idProducer) {
DisplayIdProducer idProducer, String brightnessThrottlingMapId) {
if (contains(address)) {
Slog.w(TAG, "Attempting to add second definition for display-device: " + address);
return null;
@@ -93,7 +94,8 @@ public class Layout {
// different layouts, a logical display can be destroyed and later recreated with the
// same logical display ID.
final int logicalDisplayId = idProducer.getId(isDefault);
final Display display = new Display(address, logicalDisplayId, isEnabled);
final Display display = new Display(address, logicalDisplayId, isEnabled,
brightnessThrottlingMapId);
mDisplays.add(display);
return display;
@@ -195,11 +197,19 @@ public class Layout {
// {@link DeviceStateToLayoutMap.POSITION_UNKNOWN} is unspecified.
private int mPosition;
Display(@NonNull DisplayAddress address, int logicalDisplayId, boolean isEnabled) {
// The ID of the brightness throttling map that should be used. This can change e.g. in
// concurrent displays mode in which a stricter brightness throttling policy might need to
// be used.
@Nullable
private final String mBrightnessThrottlingMapId;
Display(@NonNull DisplayAddress address, int logicalDisplayId, boolean isEnabled,
String brightnessThrottlingMapId) {
mAddress = address;
mLogicalDisplayId = logicalDisplayId;
mIsEnabled = isEnabled;
mPosition = POSITION_UNKNOWN;
mBrightnessThrottlingMapId = brightnessThrottlingMapId;
}
@Override
@@ -209,6 +219,7 @@ public class Layout {
+ "(" + (mIsEnabled ? "ON" : "OFF") + ")"
+ ", addr: " + mAddress
+ ((mPosition == POSITION_UNKNOWN) ? "" : ", position: " + mPosition)
+ ", brightnessThrottlingMapId: " + mBrightnessThrottlingMapId
+ "}";
}
@@ -223,7 +234,9 @@ public class Layout {
return otherDisplay.mIsEnabled == this.mIsEnabled
&& otherDisplay.mPosition == this.mPosition
&& otherDisplay.mLogicalDisplayId == this.mLogicalDisplayId
&& this.mAddress.equals(otherDisplay.mAddress);
&& this.mAddress.equals(otherDisplay.mAddress)
&& Objects.equals(mBrightnessThrottlingMapId,
otherDisplay.mBrightnessThrottlingMapId);
}
@Override
@@ -233,6 +246,7 @@ public class Layout {
result = 31 * result + mPosition;
result = 31 * result + mLogicalDisplayId;
result = 31 * result + mAddress.hashCode();
result = 31 * result + mBrightnessThrottlingMapId.hashCode();
return result;
}
@@ -251,5 +265,12 @@ public class Layout {
public void setPosition(int position) {
mPosition = position;
}
/**
* @return The ID of the brightness throttling map that this display should use.
*/
public String getBrightnessThrottlingMapId() {
return mBrightnessThrottlingMapId;
}
}
}

View File

@@ -208,11 +208,7 @@
<xs:complexType name="thermalThrottling">
<xs:sequence>
<xs:element type="brightnessThrottlingMap" name="brightnessThrottlingMap">
<xs:annotation name="nonnull"/>
<xs:annotation name="final"/>
</xs:element>
<xs:element type="brightnessThrottlingMap" name="concurrentDisplaysBrightnessThrottlingMap">
<xs:element type="brightnessThrottlingMap" name="brightnessThrottlingMap" maxOccurs="unbounded">
<xs:annotation name="final"/>
</xs:element>
</xs:sequence>
@@ -225,6 +221,7 @@
<xs:annotation name="final"/>
</xs:element>
</xs:sequence>
<xs:attribute name="id" type="xs:string"/>
</xs:complexType>
<xs:complexType name="brightnessThrottlingPoint">

View File

@@ -37,6 +37,8 @@ package com.android.server.display.config {
public class BrightnessThrottlingMap {
ctor public BrightnessThrottlingMap();
method @NonNull public final java.util.List<com.android.server.display.config.BrightnessThrottlingPoint> getBrightnessThrottlingPoint();
method public String getId();
method public void setId(String);
}
public class BrightnessThrottlingPoint {
@@ -238,10 +240,7 @@ 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);
method public final java.util.List<com.android.server.display.config.BrightnessThrottlingMap> getBrightnessThrottlingMap();
}
public class ThresholdPoint {

View File

@@ -51,6 +51,7 @@
<xs:sequence>
<xs:element name="address" type="xs:nonNegativeInteger"/>
<xs:element name="position" type="xs:string" minOccurs="0" maxOccurs="1" />
<xs:element name="brightnessThrottlingMapId" type="xs:string" minOccurs="0" maxOccurs="1" />
</xs:sequence>
<xs:attribute name="enabled" type="xs:boolean" use="optional" />
<xs:attribute name="defaultDisplay" type="xs:boolean" use="optional" />

View File

@@ -4,10 +4,12 @@ package com.android.server.display.config.layout {
public class Display {
ctor public Display();
method public java.math.BigInteger getAddress();
method public String getBrightnessThrottlingMapId();
method public String getPosition();
method public boolean isDefaultDisplay();
method public boolean isEnabled();
method public void setAddress(java.math.BigInteger);
method public void setBrightnessThrottlingMapId(String);
method public void setDefaultDisplay(boolean);
method public void setEnabled(boolean);
method public void setPosition(String);

View File

@@ -64,10 +64,12 @@ public class DeviceStateToLayoutMapTest {
Layout testLayout = new Layout();
testLayout.createDisplayLocked(
DisplayAddress.fromPhysicalDisplayId(123456L), /* isDefault= */ true,
/* isEnabled= */ true, mDisplayIdProducerMock);
/* isEnabled= */ true, mDisplayIdProducerMock,
/* brightnessThrottlingMapId= */ null);
testLayout.createDisplayLocked(
DisplayAddress.fromPhysicalDisplayId(78910L), /* isDefault= */ false,
/* isEnabled= */ false, mDisplayIdProducerMock);
/* isEnabled= */ false, mDisplayIdProducerMock,
/* brightnessThrottlingMapId= */ null);
assertEquals(testLayout, configLayout);
}
@@ -78,10 +80,12 @@ public class DeviceStateToLayoutMapTest {
Layout testLayout = new Layout();
testLayout.createDisplayLocked(
DisplayAddress.fromPhysicalDisplayId(78910L), /* isDefault= */ true,
/* isEnabled= */ true, mDisplayIdProducerMock);
/* isEnabled= */ true, mDisplayIdProducerMock,
/* brightnessThrottlingMapId= */ null);
testLayout.createDisplayLocked(
DisplayAddress.fromPhysicalDisplayId(123456L), /* isDefault= */ false,
/* isEnabled= */ false, mDisplayIdProducerMock);
/* isEnabled= */ false, mDisplayIdProducerMock,
/* brightnessThrottlingMapId= */ null);
assertEquals(testLayout, configLayout);
}
@@ -91,12 +95,18 @@ public class DeviceStateToLayoutMapTest {
Layout configLayout = mDeviceStateToLayoutMap.get(2);
Layout testLayout = new Layout();
testLayout.createDisplayLocked(
Layout.Display display1 = testLayout.createDisplayLocked(
DisplayAddress.fromPhysicalDisplayId(345L), /* isDefault= */ true,
/* isEnabled= */ true, mDisplayIdProducerMock);
testLayout.createDisplayLocked(
/* isEnabled= */ true, mDisplayIdProducerMock,
/* brightnessThrottlingMapId= */ "concurrent");
display1.setPosition(Layout.Display.POSITION_FRONT);
Layout.Display display2 = testLayout.createDisplayLocked(
DisplayAddress.fromPhysicalDisplayId(678L), /* isDefault= */ false,
/* isEnabled= */ true, mDisplayIdProducerMock);
/* isEnabled= */ true, mDisplayIdProducerMock,
/* brightnessThrottlingMapId= */ "concurrent");
display2.setPosition(Layout.Display.POSITION_REAR);
assertEquals(testLayout, configLayout);
}
@@ -139,9 +149,13 @@ public class DeviceStateToLayoutMapTest {
+ "<state>2</state> \n"
+ "<display enabled=\"true\" defaultDisplay=\"true\">\n"
+ "<address>345</address>\n"
+ "<position>front</position>\n"
+ "<brightnessThrottlingMapId>concurrent</brightnessThrottlingMapId>\n"
+ "</display>\n"
+ "<display enabled=\"true\">\n"
+ "<address>678</address>\n"
+ "<position>rear</position>\n"
+ "<brightnessThrottlingMapId>concurrent</brightnessThrottlingMapId>\n"
+ "</display>\n"
+ "</layout>\n"
+ "</layouts>\n";

View File

@@ -189,7 +189,7 @@ public final class DisplayDeviceConfigTest {
DisplayDeviceConfig.convertThermalStatus(ThermalStatus.shutdown), 0.025f
));
assertEquals(new DisplayDeviceConfig.BrightnessThrottlingData(throttlingLevels),
mDisplayDeviceConfig.getBrightnessThrottlingData());
mDisplayDeviceConfig.getBrightnessThrottlingData("default"));
throttlingLevels.clear();
throttlingLevels.add(new DisplayDeviceConfig.BrightnessThrottlingData.ThrottlingLevel(
@@ -211,7 +211,7 @@ public final class DisplayDeviceConfigTest {
DisplayDeviceConfig.convertThermalStatus(ThermalStatus.shutdown), 0.0125f
));
assertEquals(new DisplayDeviceConfig.BrightnessThrottlingData(throttlingLevels),
mDisplayDeviceConfig.getConcurrentDisplaysBrightnessThrottlingData());
mDisplayDeviceConfig.getBrightnessThrottlingData("concurrent"));
assertNotNull(mDisplayDeviceConfig.getHostUsiVersion());
assertEquals(mDisplayDeviceConfig.getHostUsiVersion().getMajorVersion(), 2);
@@ -509,7 +509,7 @@ public final class DisplayDeviceConfigTest {
+ "<brightness>0.025</brightness>\n"
+ "</brightnessThrottlingPoint>\n"
+ "</brightnessThrottlingMap>\n"
+ "<concurrentDisplaysBrightnessThrottlingMap>\n"
+ "<brightnessThrottlingMap id=\"concurrent\">\n"
+ "<brightnessThrottlingPoint>\n"
+ "<thermalStatus>light</thermalStatus>\n"
+ "<brightness>0.2</brightness>\n"
@@ -534,7 +534,7 @@ public final class DisplayDeviceConfigTest {
+ "<thermalStatus>shutdown</thermalStatus>\n"
+ "<brightness>0.0125</brightness>\n"
+ "</brightnessThrottlingPoint>\n"
+ "</concurrentDisplaysBrightnessThrottlingMap>\n"
+ "</brightnessThrottlingMap>\n"
+ "</thermalThrottling>\n"
+ "<refreshRate>\n"
+ "<lowerBlockingZoneConfigs>\n"

View File

@@ -296,9 +296,9 @@ public class LogicalDisplayMapperTest {
Layout layout1 = new Layout();
layout1.createDisplayLocked(info(device1).address, /* isDefault= */ true,
/* isEnabled= */ true, mIdProducer);
/* isEnabled= */ true, mIdProducer, /* brightnessThrottlingMapId= */ null);
layout1.createDisplayLocked(info(device2).address, /* isDefault= */ false,
/* isEnabled= */ true, mIdProducer);
/* isEnabled= */ true, mIdProducer, /* brightnessThrottlingMapId= */ null);
when(mDeviceStateToLayoutMapSpy.get(STATE_DEFAULT)).thenReturn(layout1);
assertThat(layout1.size()).isEqualTo(2);
final int logicalId2 = layout1.getByAddress(info(device2).address).getLogicalDisplayId();
@@ -331,17 +331,17 @@ public class LogicalDisplayMapperTest {
add(device3);
Layout layout1 = new Layout();
layout1.createDisplayLocked(info(device1).address,
/* isDefault= */ true, /* isEnabled= */ true, mIdProducer);
layout1.createDisplayLocked(info(device1).address, /* isDefault= */ true,
/* isEnabled= */ true, mIdProducer, /* brightnessThrottlingMapId= */ null);
when(mDeviceStateToLayoutMapSpy.get(STATE_DEFAULT)).thenReturn(layout1);
final int layoutState2 = 2;
Layout layout2 = new Layout();
layout2.createDisplayLocked(info(device2).address,
/* isDefault= */ false, /* isEnabled= */ true, mIdProducer);
layout2.createDisplayLocked(info(device2).address, /* isDefault= */ false,
/* isEnabled= */ true, mIdProducer, /* brightnessThrottlingMapId= */ null);
// Device3 is the default display.
layout2.createDisplayLocked(info(device3).address,
/* isDefault= */ true, /* isEnabled= */ true, mIdProducer);
layout2.createDisplayLocked(info(device3).address, /* isDefault= */ true,
/* isEnabled= */ true, mIdProducer, /* brightnessThrottlingMapId= */ null);
when(mDeviceStateToLayoutMapSpy.get(layoutState2)).thenReturn(layout2);
assertThat(layout2.size()).isEqualTo(2);
final int logicalId2 = layout2.getByAddress(info(device2).address).getLogicalDisplayId();
@@ -563,16 +563,18 @@ public class LogicalDisplayMapperTest {
Layout layout = new Layout();
layout.createDisplayLocked(device1.getDisplayDeviceInfoLocked().address,
true, true, mIdProducer);
true, true, mIdProducer,
/* brightnessThrottlingMapId= */ "concurrent");
layout.createDisplayLocked(device2.getDisplayDeviceInfoLocked().address,
false, true, mIdProducer);
false, true, mIdProducer,
/* brightnessThrottlingMapId= */ "concurrent");
when(mDeviceStateToLayoutMapSpy.get(0)).thenReturn(layout);
layout = new Layout();
layout.createDisplayLocked(device1.getDisplayDeviceInfoLocked().address,
false, false, mIdProducer);
false, false, mIdProducer, /* brightnessThrottlingMapId= */ null);
layout.createDisplayLocked(device2.getDisplayDeviceInfoLocked().address,
true, true, mIdProducer);
true, true, mIdProducer, /* brightnessThrottlingMapId= */ null);
when(mDeviceStateToLayoutMapSpy.get(1)).thenReturn(layout);
when(mDeviceStateToLayoutMapSpy.get(2)).thenReturn(layout);
@@ -599,6 +601,10 @@ public class LogicalDisplayMapperTest {
assertTrue(mLogicalDisplayMapper.getDisplayLocked(device2).isEnabledLocked());
assertFalse(mLogicalDisplayMapper.getDisplayLocked(device1).isInTransitionLocked());
assertFalse(mLogicalDisplayMapper.getDisplayLocked(device2).isInTransitionLocked());
assertEquals("concurrent", mLogicalDisplayMapper.getDisplayLocked(device1)
.getBrightnessThrottlingDataIdLocked());
assertEquals("concurrent", mLogicalDisplayMapper.getDisplayLocked(device2)
.getBrightnessThrottlingDataIdLocked());
mLogicalDisplayMapper.setDeviceStateLocked(1, false);
advanceTime(1000);
@@ -606,6 +612,12 @@ public class LogicalDisplayMapperTest {
assertTrue(mLogicalDisplayMapper.getDisplayLocked(device2).isEnabledLocked());
assertFalse(mLogicalDisplayMapper.getDisplayLocked(device1).isInTransitionLocked());
assertFalse(mLogicalDisplayMapper.getDisplayLocked(device2).isInTransitionLocked());
assertEquals(DisplayDeviceConfig.DEFAULT_BRIGHTNESS_THROTTLING_DATA_ID,
mLogicalDisplayMapper.getDisplayLocked(device1)
.getBrightnessThrottlingDataIdLocked());
assertEquals(DisplayDeviceConfig.DEFAULT_BRIGHTNESS_THROTTLING_DATA_ID,
mLogicalDisplayMapper.getDisplayLocked(device2)
.getBrightnessThrottlingDataIdLocked());
mLogicalDisplayMapper.setDeviceStateLocked(2, false);
advanceTime(1000);
@@ -613,6 +625,12 @@ public class LogicalDisplayMapperTest {
assertTrue(mLogicalDisplayMapper.getDisplayLocked(device2).isEnabledLocked());
assertFalse(mLogicalDisplayMapper.getDisplayLocked(device1).isInTransitionLocked());
assertFalse(mLogicalDisplayMapper.getDisplayLocked(device2).isInTransitionLocked());
assertEquals(DisplayDeviceConfig.DEFAULT_BRIGHTNESS_THROTTLING_DATA_ID,
mLogicalDisplayMapper.getDisplayLocked(device1)
.getBrightnessThrottlingDataIdLocked());
assertEquals(DisplayDeviceConfig.DEFAULT_BRIGHTNESS_THROTTLING_DATA_ID,
mLogicalDisplayMapper.getDisplayLocked(device2)
.getBrightnessThrottlingDataIdLocked());
}
@Test
@@ -633,17 +651,20 @@ public class LogicalDisplayMapperTest {
displayAddressOne,
/* isDefault= */ true,
/* isEnabled= */ true,
mIdProducer);
mIdProducer,
/* brightnessThrottlingMapId= */ null);
threeDevicesEnabledLayout.createDisplayLocked(
displayAddressTwo,
/* isDefault= */ false,
/* isEnabled= */ true,
mIdProducer);
mIdProducer,
/* brightnessThrottlingMapId= */ null);
threeDevicesEnabledLayout.createDisplayLocked(
displayAddressThree,
/* isDefault= */ false,
/* isEnabled= */ true,
mIdProducer);
mIdProducer,
/* brightnessThrottlingMapId= */ null);
when(mDeviceStateToLayoutMapSpy.get(STATE_DEFAULT))
.thenReturn(threeDevicesEnabledLayout);
@@ -678,17 +699,20 @@ public class LogicalDisplayMapperTest {
displayAddressOne,
/* isDefault= */ true,
/* isEnabled= */ true,
mIdProducer);
mIdProducer,
/* brightnessThrottlingMapId= */ null);
oneDeviceEnabledLayout.createDisplayLocked(
displayAddressTwo,
/* isDefault= */ false,
/* isEnabled= */ false,
mIdProducer);
mIdProducer,
/* brightnessThrottlingMapId= */ null);
oneDeviceEnabledLayout.createDisplayLocked(
displayAddressThree,
/* isDefault= */ false,
/* isEnabled= */ false,
mIdProducer);
mIdProducer,
/* brightnessThrottlingMapId= */ null);
when(mDeviceStateToLayoutMapSpy.get(0)).thenReturn(oneDeviceEnabledLayout);
when(mDeviceStateToLayoutMapSpy.get(1)).thenReturn(threeDevicesEnabledLayout);