Merge "Add name to display device configuration." into udc-dev
This commit is contained in:
committed by
Android (Google) Code Review
commit
c7a54c4e51
@@ -91,6 +91,7 @@ import javax.xml.datatype.DatatypeConfigurationException;
|
||||
* <pre>
|
||||
* {@code
|
||||
* <displayConfiguration>
|
||||
* <name>Built-In Display</name>
|
||||
* <densityMapping>
|
||||
* <density>
|
||||
* <height>480</height>
|
||||
@@ -499,6 +500,10 @@ public class DisplayDeviceConfig {
|
||||
private final List<RefreshRateLimitation> mRefreshRateLimitations =
|
||||
new ArrayList<>(2 /*initialCapacity*/);
|
||||
|
||||
// Name of the display, if configured.
|
||||
@Nullable
|
||||
private String mName;
|
||||
|
||||
// Nits and backlight values that are loaded from either the display device config file, or
|
||||
// config.xml. These are the raw values and just used for the dumpsys
|
||||
private float[] mRawNits;
|
||||
@@ -832,6 +837,15 @@ public class DisplayDeviceConfig {
|
||||
return config;
|
||||
}
|
||||
|
||||
/** The name of the display.
|
||||
*
|
||||
* @return The name of the display.
|
||||
*/
|
||||
@Nullable
|
||||
public String getName() {
|
||||
return mName;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the brightness mapping nits array.
|
||||
*
|
||||
@@ -1646,6 +1660,7 @@ public class DisplayDeviceConfig {
|
||||
try (InputStream in = new BufferedInputStream(new FileInputStream(configFile))) {
|
||||
final DisplayConfiguration config = XmlParser.read(in);
|
||||
if (config != null) {
|
||||
loadName(config);
|
||||
loadDensityMapping(config);
|
||||
loadBrightnessDefaultFromDdcXml(config);
|
||||
loadBrightnessConstraintsFromConfigXml();
|
||||
@@ -1717,6 +1732,10 @@ public class DisplayDeviceConfig {
|
||||
}
|
||||
}
|
||||
|
||||
private void loadName(DisplayConfiguration config) {
|
||||
mName = config.getName();
|
||||
}
|
||||
|
||||
private void loadDensityMapping(DisplayConfiguration config) {
|
||||
if (config.getDensityMapping() == null) {
|
||||
return;
|
||||
|
||||
@@ -42,6 +42,7 @@ import android.view.DisplayShape;
|
||||
import android.view.RoundedCorners;
|
||||
import android.view.SurfaceControl;
|
||||
|
||||
import com.android.internal.R;
|
||||
import com.android.internal.annotations.VisibleForTesting;
|
||||
import com.android.internal.display.BrightnessSynchronizer;
|
||||
import com.android.internal.util.function.pooled.PooledLambda;
|
||||
@@ -675,14 +676,13 @@ final class LocalDisplayAdapter extends DisplayAdapter {
|
||||
mInfo.flags |= DisplayDeviceInfo.FLAG_ALLOWED_TO_BE_DEFAULT_DISPLAY;
|
||||
|
||||
if (mIsFirstDisplay) {
|
||||
if (res.getBoolean(com.android.internal.R.bool.config_mainBuiltInDisplayIsRound)
|
||||
if (res.getBoolean(R.bool.config_mainBuiltInDisplayIsRound)
|
||||
|| (Build.IS_EMULATOR
|
||||
&& SystemProperties.getBoolean(PROPERTY_EMULATOR_CIRCULAR, false))) {
|
||||
mInfo.flags |= DisplayDeviceInfo.FLAG_ROUND;
|
||||
}
|
||||
} else {
|
||||
if (!res.getBoolean(
|
||||
com.android.internal.R.bool.config_localDisplaysMirrorContent)) {
|
||||
if (!res.getBoolean(R.bool.config_localDisplaysMirrorContent)) {
|
||||
mInfo.flags |= DisplayDeviceInfo.FLAG_OWN_CONTENT_ONLY;
|
||||
}
|
||||
|
||||
@@ -711,18 +711,23 @@ final class LocalDisplayAdapter extends DisplayAdapter {
|
||||
mInfo.displayShape = DisplayShape.fromResources(
|
||||
res, mInfo.uniqueId, maxWidth, maxHeight, mInfo.width, mInfo.height);
|
||||
|
||||
mInfo.name = getDisplayDeviceConfig().getName();
|
||||
|
||||
if (mStaticDisplayInfo.isInternal) {
|
||||
mInfo.type = Display.TYPE_INTERNAL;
|
||||
mInfo.touch = DisplayDeviceInfo.TOUCH_INTERNAL;
|
||||
mInfo.flags |= DisplayDeviceInfo.FLAG_ROTATES_WITH_CONTENT;
|
||||
mInfo.name = res.getString(
|
||||
com.android.internal.R.string.display_manager_built_in_display_name);
|
||||
if (mInfo.name == null) {
|
||||
mInfo.name = res.getString(R.string.display_manager_built_in_display_name);
|
||||
}
|
||||
} else {
|
||||
mInfo.type = Display.TYPE_EXTERNAL;
|
||||
mInfo.touch = DisplayDeviceInfo.TOUCH_EXTERNAL;
|
||||
mInfo.flags |= DisplayDeviceInfo.FLAG_PRESENTATION;
|
||||
mInfo.name = getContext().getResources().getString(
|
||||
com.android.internal.R.string.display_manager_hdmi_display_name);
|
||||
if (mInfo.name == null) {
|
||||
mInfo.name = getContext().getResources().getString(
|
||||
R.string.display_manager_hdmi_display_name);
|
||||
}
|
||||
}
|
||||
mInfo.frameRateOverrides = mFrameRateOverrides;
|
||||
|
||||
@@ -1255,8 +1260,7 @@ final class LocalDisplayAdapter extends DisplayAdapter {
|
||||
return false;
|
||||
}
|
||||
final Resources res = getOverlayContext().getResources();
|
||||
int[] ports = res.getIntArray(
|
||||
com.android.internal.R.array.config_localPrivateDisplayPorts);
|
||||
int[] ports = res.getIntArray(R.array.config_localPrivateDisplayPorts);
|
||||
if (ports != null) {
|
||||
int port = physicalAddress.getPort();
|
||||
for (int p : ports) {
|
||||
|
||||
@@ -26,6 +26,10 @@
|
||||
<xs:element name="displayConfiguration">
|
||||
<xs:complexType>
|
||||
<xs:sequence>
|
||||
<xs:element type ="xs:string" name="name">
|
||||
<xs:annotation name="nullable"/>
|
||||
<xs:annotation name="final"/>
|
||||
</xs:element>
|
||||
<xs:element type="densityMapping" name="densityMapping" minOccurs="0" maxOccurs="1">
|
||||
<xs:annotation name="nullable"/>
|
||||
<xs:annotation name="final"/>
|
||||
|
||||
@@ -89,6 +89,7 @@ package com.android.server.display.config {
|
||||
method public final com.android.server.display.config.Thresholds getDisplayBrightnessChangeThresholdsIdle();
|
||||
method public com.android.server.display.config.HighBrightnessMode getHighBrightnessMode();
|
||||
method public final com.android.server.display.config.SensorDetails getLightSensor();
|
||||
method @Nullable public final String getName();
|
||||
method public final com.android.server.display.config.SensorDetails getProxSensor();
|
||||
method public com.android.server.display.config.DisplayQuirks getQuirks();
|
||||
method public com.android.server.display.config.RefreshRateConfigs getRefreshRate();
|
||||
@@ -114,6 +115,7 @@ package com.android.server.display.config {
|
||||
method public final void setDisplayBrightnessChangeThresholdsIdle(com.android.server.display.config.Thresholds);
|
||||
method public void setHighBrightnessMode(com.android.server.display.config.HighBrightnessMode);
|
||||
method public final void setLightSensor(com.android.server.display.config.SensorDetails);
|
||||
method public final void setName(@Nullable String);
|
||||
method public final void setProxSensor(com.android.server.display.config.SensorDetails);
|
||||
method public void setQuirks(com.android.server.display.config.DisplayQuirks);
|
||||
method public void setRefreshRate(com.android.server.display.config.RefreshRateConfigs);
|
||||
|
||||
@@ -20,6 +20,7 @@ package com.android.server.display;
|
||||
import static org.junit.Assert.assertArrayEquals;
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertNotNull;
|
||||
import static org.junit.Assert.assertNull;
|
||||
import static org.mockito.ArgumentMatchers.anyFloat;
|
||||
import static org.mockito.ArgumentMatchers.anyInt;
|
||||
import static org.mockito.Mockito.mock;
|
||||
@@ -85,6 +86,7 @@ public final class DisplayDeviceConfigTest {
|
||||
public void testConfigValuesFromDisplayConfig() throws IOException {
|
||||
setupDisplayDeviceConfigFromDisplayConfigFile();
|
||||
|
||||
assertEquals(mDisplayDeviceConfig.getName(), "Example Display");
|
||||
assertEquals(mDisplayDeviceConfig.getAmbientHorizonLong(), 5000);
|
||||
assertEquals(mDisplayDeviceConfig.getAmbientHorizonShort(), 50);
|
||||
assertEquals(mDisplayDeviceConfig.getBrightnessRampDecreaseMaxMillis(), 3000);
|
||||
@@ -240,6 +242,7 @@ public final class DisplayDeviceConfigTest {
|
||||
@Test
|
||||
public void testConfigValuesFromConfigResource() {
|
||||
setupDisplayDeviceConfigFromConfigResourceFile();
|
||||
assertNull(mDisplayDeviceConfig.getName());
|
||||
assertArrayEquals(mDisplayDeviceConfig.getAutoBrightnessBrighteningLevelsNits(), new
|
||||
float[]{2.0f, 200.0f, 600.0f}, ZERO_DELTA);
|
||||
assertArrayEquals(mDisplayDeviceConfig.getAutoBrightnessBrighteningLevelsLux(), new
|
||||
@@ -370,6 +373,7 @@ public final class DisplayDeviceConfigTest {
|
||||
private String getContent() {
|
||||
return "<?xml version='1.0' encoding='utf-8' standalone='yes' ?>\n"
|
||||
+ "<displayConfiguration>\n"
|
||||
+ "<name>Example Display</name>"
|
||||
+ "<screenBrightnessMap>\n"
|
||||
+ "<point>\n"
|
||||
+ "<value>0.0</value>\n"
|
||||
|
||||
Reference in New Issue
Block a user