diff --git a/services/core/java/com/android/server/display/DeviceStateToLayoutMap.java b/services/core/java/com/android/server/display/DeviceStateToLayoutMap.java
index 63218ee4e12da..f84a58c5b06da 100644
--- a/services/core/java/com/android/server/display/DeviceStateToLayoutMap.java
+++ b/services/core/java/com/android/server/display/DeviceStateToLayoutMap.java
@@ -121,24 +121,17 @@ class DeviceStateToLayoutMap {
final Layout layout = createLayout(state);
for (com.android.server.display.config.layout.Display d: l.getDisplay()) {
assert layout != null;
- Layout.Display display = layout.createDisplayLocked(
+ int position = getPosition(d.getPosition());
+ layout.createDisplayLocked(
DisplayAddress.fromPhysicalDisplayId(d.getAddress().longValue()),
d.isDefaultDisplay(),
d.isEnabled(),
d.getDisplayGroup(),
mIdProducer,
+ position,
+ leadDisplayId,
d.getBrightnessThrottlingMapId(),
- leadDisplayId);
-
- if (FRONT_STRING.equals(d.getPosition())) {
- display.setPosition(POSITION_FRONT);
- } else if (REAR_STRING.equals(d.getPosition())) {
- display.setPosition(POSITION_REAR);
- } else {
- display.setPosition(POSITION_UNKNOWN);
- }
- display.setRefreshRateZoneId(d.getRefreshRateZoneId());
- display.setRefreshRateThermalThrottlingMapId(
+ d.getRefreshRateZoneId(),
d.getRefreshRateThermalThrottlingMapId());
}
}
@@ -148,6 +141,16 @@ class DeviceStateToLayoutMap {
}
}
+ private int getPosition(@NonNull String position) {
+ int positionInt = POSITION_UNKNOWN;
+ if (FRONT_STRING.equals(position)) {
+ positionInt = POSITION_FRONT;
+ } else if (REAR_STRING.equals(position)) {
+ positionInt = POSITION_REAR;
+ }
+ return positionInt;
+ }
+
private Layout createLayout(int state) {
if (mLayoutMap.contains(state)) {
Slog.e(TAG, "Attempted to create a second layout for state " + state);
diff --git a/services/core/java/com/android/server/display/LogicalDisplayMapper.java b/services/core/java/com/android/server/display/LogicalDisplayMapper.java
index e290b7a8b7082..250ba4350f1d3 100644
--- a/services/core/java/com/android/server/display/LogicalDisplayMapper.java
+++ b/services/core/java/com/android/server/display/LogicalDisplayMapper.java
@@ -18,8 +18,6 @@ package com.android.server.display;
import static android.view.Display.DEFAULT_DISPLAY;
-import static com.android.server.display.layout.Layout.NO_LEAD_DISPLAY;
-
import android.annotation.NonNull;
import android.annotation.Nullable;
import android.content.Context;
@@ -646,10 +644,7 @@ class LogicalDisplayMapper implements DisplayDeviceRepository.Listener {
if ((nextDeviceInfo.flags
& DisplayDeviceInfo.FLAG_ALLOWED_TO_BE_DEFAULT_DISPLAY) != 0
&& !nextDeviceInfo.address.equals(deviceInfo.address)) {
- layout.createDisplayLocked(nextDeviceInfo.address,
- /* isDefault= */ true, /* isEnabled= */ true,
- Layout.DEFAULT_DISPLAY_GROUP_NAME, mIdProducer,
- /* brightnessThrottlingMapId= */ null, DEFAULT_DISPLAY);
+ layout.createDefaultDisplayLocked(nextDeviceInfo.address, mIdProducer);
applyLayoutLocked();
return;
}
@@ -1110,9 +1105,7 @@ class LogicalDisplayMapper implements DisplayDeviceRepository.Listener {
return;
}
final DisplayDeviceInfo info = device.getDisplayDeviceInfoLocked();
- layout.createDisplayLocked(info.address, /* isDefault= */ true, /* isEnabled= */ true,
- Layout.DEFAULT_DISPLAY_GROUP_NAME, mIdProducer,
- /* brightnessThrottlingMapId= */ null, NO_LEAD_DISPLAY);
+ layout.createDefaultDisplayLocked(info.address, mIdProducer);
}
private int assignLayerStackLocked(int displayId) {
diff --git a/services/core/java/com/android/server/display/layout/Layout.java b/services/core/java/com/android/server/display/layout/Layout.java
index 6a4d23b18763e..f86ee249408c2 100644
--- a/services/core/java/com/android/server/display/layout/Layout.java
+++ b/services/core/java/com/android/server/display/layout/Layout.java
@@ -39,7 +39,6 @@ public class Layout {
public static final String DEFAULT_DISPLAY_GROUP_NAME = "";
private static final String TAG = "Layout";
- private static int sNextNonDefaultDisplayId = DEFAULT_DISPLAY + 1;
// Lead display Id is set to this if this is not a follower display, and therefore
// has no lead.
@@ -47,13 +46,6 @@ public class Layout {
private final List mDisplays = new ArrayList<>(2);
- /**
- * @return The default display ID, or a new unique one to use.
- */
- public static int assignDisplayIdLocked(boolean isDefault) {
- return isDefault ? DEFAULT_DISPLAY : sNextNonDefaultDisplayId++;
- }
-
@Override
public String toString() {
return mDisplays.toString();
@@ -76,25 +68,17 @@ public class Layout {
}
/**
- * Creates a simple 1:1 LogicalDisplay mapping for the specified DisplayDevice.
+ * Creates the default 1:1 LogicalDisplay mapping for the specified DisplayDevice.
*
* @param address Address of the device.
- * @param isDefault Indicates if the device is meant to be the default display.
- * @param isEnabled Indicates if this display is usable and can be switched on
- * @param displayGroupName Name of the display group to which the display is assigned.
* @param idProducer Produces the logical display id.
- * @param brightnessThrottlingMapId Name of which throttling policy should be used.
- * @param leadDisplayId Display that this one follows (-1 if none).
- * @exception IllegalArgumentException When a default display owns a display group other than
- * DEFAULT_DISPLAY_GROUP.
- * @return The new Display.
*/
- public Display createDisplayLocked(
- @NonNull DisplayAddress address, boolean isDefault, boolean isEnabled,
- String displayGroupName, DisplayIdProducer idProducer, String brightnessThrottlingMapId,
- int leadDisplayId) {
- return createDisplayLocked(address, isDefault, isEnabled, displayGroupName, idProducer,
- brightnessThrottlingMapId, POSITION_UNKNOWN, leadDisplayId);
+ public void createDefaultDisplayLocked(@NonNull DisplayAddress address,
+ DisplayIdProducer idProducer) {
+ createDisplayLocked(address, /* isDefault= */ true, /* isEnabled= */ true,
+ DEFAULT_DISPLAY_GROUP_NAME, idProducer, POSITION_UNKNOWN,
+ NO_LEAD_DISPLAY, /* brightnessThrottlingMapId= */ null,
+ /* refreshRateZoneId= */ null, /* refreshRateThermalThrottlingMapId= */ null);
}
/**
@@ -105,26 +89,30 @@ public class Layout {
* @param isEnabled Indicates if this display is usable and can be switched on
* @param displayGroupName Name of the display group to which the display is assigned.
* @param idProducer Produces the logical display id.
- * @param brightnessThrottlingMapId Name of which throttling policy should be used.
* @param position Indicates the position this display is facing in this layout.
* @param leadDisplayId Display that this one follows (-1 if none).
+ * @param brightnessThrottlingMapId Name of which brightness throttling policy should be used.
+ * @param refreshRateZoneId Layout limited refresh rate zone name.
+ * @param refreshRateThermalThrottlingMapId Name of which refresh rate throttling
+ * policy should be used.
+
* @exception IllegalArgumentException When a default display owns a display group other than
* DEFAULT_DISPLAY_GROUP.
- * @return The new Display.
*/
- public Display createDisplayLocked(
+ public void createDisplayLocked(
@NonNull DisplayAddress address, boolean isDefault, boolean isEnabled,
- String displayGroupName, DisplayIdProducer idProducer, String brightnessThrottlingMapId,
- int position, int leadDisplayId) {
+ String displayGroupName, DisplayIdProducer idProducer, int position, int leadDisplayId,
+ String brightnessThrottlingMapId, @Nullable String refreshRateZoneId,
+ @Nullable String refreshRateThermalThrottlingMapId) {
if (contains(address)) {
Slog.w(TAG, "Attempting to add second definition for display-device: " + address);
- return null;
+ return;
}
// See if we're dealing with the "default" display
if (isDefault && getById(DEFAULT_DISPLAY) != null) {
Slog.w(TAG, "Ignoring attempt to add a second default display: " + address);
- return null;
+ return;
}
// Assign a logical display ID and create the new display.
@@ -138,11 +126,13 @@ public class Layout {
throw new IllegalArgumentException("Default display should own DEFAULT_DISPLAY_GROUP");
}
final int logicalDisplayId = idProducer.getId(isDefault);
+ leadDisplayId = isDefault ? NO_LEAD_DISPLAY : leadDisplayId;
+
final Display display = new Display(address, logicalDisplayId, isEnabled, displayGroupName,
- brightnessThrottlingMapId, position, leadDisplayId);
+ brightnessThrottlingMapId, position, leadDisplayId, refreshRateZoneId,
+ refreshRateThermalThrottlingMapId);
mDisplays.add(display);
- return display;
}
/**
@@ -242,7 +232,7 @@ public class Layout {
// {@link DeviceStateToLayoutMap.POSITION_FRONT} or
// {@link DeviceStateToLayoutMap.POSITION_REAR}.
// {@link DeviceStateToLayoutMap.POSITION_UNKNOWN} is unspecified.
- private int mPosition;
+ private final int mPosition;
// 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
@@ -251,31 +241,28 @@ public class Layout {
private final String mBrightnessThrottlingMapId;
// The ID of the lead display that this display will follow in a layout. -1 means no lead.
- private int mLeadDisplayId;
+ private final int mLeadDisplayId;
// Refresh rate zone id for specific layout
@Nullable
- private String mRefreshRateZoneId;
+ private final String mRefreshRateZoneId;
@Nullable
- private String mRefreshRateThermalThrottlingMapId;
+ private final String mRefreshRateThermalThrottlingMapId;
- Display(@NonNull DisplayAddress address, int logicalDisplayId, boolean isEnabled,
+ private Display(@NonNull DisplayAddress address, int logicalDisplayId, boolean isEnabled,
@NonNull String displayGroupName, String brightnessThrottlingMapId, int position,
- int leadDisplayId) {
+ int leadDisplayId, @Nullable String refreshRateZoneId,
+ @Nullable String refreshRateThermalThrottlingMapId) {
mAddress = address;
mLogicalDisplayId = logicalDisplayId;
mIsEnabled = isEnabled;
mDisplayGroupName = displayGroupName;
mPosition = position;
mBrightnessThrottlingMapId = brightnessThrottlingMapId;
-
- if (leadDisplayId == mLogicalDisplayId) {
- mLeadDisplayId = NO_LEAD_DISPLAY;
- } else {
- mLeadDisplayId = leadDisplayId;
- }
-
+ mRefreshRateZoneId = refreshRateZoneId;
+ mRefreshRateThermalThrottlingMapId = refreshRateThermalThrottlingMapId;
+ mLeadDisplayId = leadDisplayId;
}
@Override
@@ -345,23 +332,11 @@ public class Layout {
return mDisplayGroupName;
}
- public void setRefreshRateZoneId(@Nullable String refreshRateZoneId) {
- mRefreshRateZoneId = refreshRateZoneId;
- }
-
@Nullable
public String getRefreshRateZoneId() {
return mRefreshRateZoneId;
}
- /**
- * Sets the position that this display is facing.
- * @param position the display is facing.
- */
- public void setPosition(int position) {
- mPosition = position;
- }
-
/**
* @return The ID of the brightness throttling map that this display should use.
*/
@@ -370,7 +345,6 @@ public class Layout {
}
/**
- *
* @return the position that this display is facing.
*/
public int getPosition() {
@@ -378,28 +352,12 @@ public class Layout {
}
/**
- * Set the display that this display should follow certain properties of, for example,
- * brightness
- * @param displayId of the lead display.
- */
- public void setLeadDisplay(int displayId) {
- if (displayId != mLogicalDisplayId) {
- mLeadDisplayId = displayId;
- }
- }
-
- /**
- *
* @return logical displayId of the display that this one follows.
*/
public int getLeadDisplayId() {
return mLeadDisplayId;
}
- public void setRefreshRateThermalThrottlingMapId(String refreshRateThermalThrottlingMapId) {
- mRefreshRateThermalThrottlingMapId = refreshRateThermalThrottlingMapId;
- }
-
public String getRefreshRateThermalThrottlingMapId() {
return mRefreshRateThermalThrottlingMapId;
}
diff --git a/services/tests/servicestests/src/com/android/server/display/DeviceStateToLayoutMapTest.java b/services/tests/servicestests/src/com/android/server/display/DeviceStateToLayoutMapTest.java
index e74b278bd9047..a7d3df90751fa 100644
--- a/services/tests/servicestests/src/com/android/server/display/DeviceStateToLayoutMapTest.java
+++ b/services/tests/servicestests/src/com/android/server/display/DeviceStateToLayoutMapTest.java
@@ -18,6 +18,7 @@ package com.android.server.display;
import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNull;
import android.view.Display;
import android.view.DisplayAddress;
@@ -63,26 +64,10 @@ public class DeviceStateToLayoutMapTest {
Layout configLayout = mDeviceStateToLayoutMap.get(0);
Layout testLayout = new Layout();
- testLayout.createDisplayLocked(
- DisplayAddress.fromPhysicalDisplayId(123456L), /* isDefault= */ true,
- /* isEnabled= */ true, /* displayGroup= */ null, mDisplayIdProducerMock,
- /* brightnessThrottlingMapId= */ null,
- /* leadDisplayId= */ Display.DEFAULT_DISPLAY);
- testLayout.createDisplayLocked(
- DisplayAddress.fromPhysicalDisplayId(78910L), /* isDefault= */ false,
- /* isEnabled= */ false, /* displayGroup= */ null, mDisplayIdProducerMock,
- /* brightnessThrottlingMapId= */ null,
- /* leadDisplayId= */ Display.DEFAULT_DISPLAY);
- testLayout.createDisplayLocked(
- DisplayAddress.fromPhysicalDisplayId(98765L), /* isDefault= */ false,
- /* isEnabled= */ true, "group1", mDisplayIdProducerMock,
- /* brightnessThrottlingMapId= */ null,
- /* leadDisplayId= */ Display.DEFAULT_DISPLAY);
- testLayout.createDisplayLocked(
- DisplayAddress.fromPhysicalDisplayId(786L), /* isDefault= */ false,
- /* isEnabled= */ false, "group2", mDisplayIdProducerMock,
- /* brightnessThrottlingMapId= */ null,
- /* leadDisplayId= */ Display.DEFAULT_DISPLAY);
+ createDefaultDisplay(testLayout, 123456L);
+ createNonDefaultDisplay(testLayout, 78910L, /* enabled= */ false, /* group= */ null);
+ createNonDefaultDisplay(testLayout, 98765L, /* enabled= */ true, /* group= */ "group1");
+ createNonDefaultDisplay(testLayout, 786L, /* enabled= */ false, /* group= */ "group2");
assertEquals(testLayout, configLayout);
}
@@ -92,41 +77,18 @@ public class DeviceStateToLayoutMapTest {
Layout configLayout = mDeviceStateToLayoutMap.get(1);
Layout testLayout = new Layout();
- testLayout.createDisplayLocked(
- DisplayAddress.fromPhysicalDisplayId(78910L), /* isDefault= */ true,
- /* isEnabled= */ true, /* displayGroup= */ null, mDisplayIdProducerMock,
- /* brightnessThrottlingMapId= */ null,
- /* leadDisplayId= */ Display.DEFAULT_DISPLAY);
- testLayout.createDisplayLocked(
- DisplayAddress.fromPhysicalDisplayId(123456L), /* isDefault= */ false,
- /* isEnabled= */ false, /* displayGroup= */ null, mDisplayIdProducerMock,
- /* brightnessThrottlingMapId= */ null,
- /* leadDisplayId= */ Display.DEFAULT_DISPLAY);
+ createDefaultDisplay(testLayout, 78910L);
+ createNonDefaultDisplay(testLayout, 123456L, /* enabled= */ false, /* group= */ null);
assertEquals(testLayout, configLayout);
}
@Test
- public void testConcurrentState() {
+ public void testBrightnessThrottlingMapId() {
Layout configLayout = mDeviceStateToLayoutMap.get(2);
- Layout testLayout = new Layout();
-
- Layout.Display display1 = testLayout.createDisplayLocked(
- DisplayAddress.fromPhysicalDisplayId(345L), /* isDefault= */ true,
- /* isEnabled= */ true, /* displayGroup= */ null, mDisplayIdProducerMock,
- /* brightnessThrottlingMapId= */ "concurrent",
- /* leadDisplayId= */ Display.DEFAULT_DISPLAY);
- display1.setPosition(Layout.Display.POSITION_FRONT);
-
- Layout.Display display2 = testLayout.createDisplayLocked(
- DisplayAddress.fromPhysicalDisplayId(678L), /* isDefault= */ false,
- /* isEnabled= */ true, /* displayGroup= */ null, mDisplayIdProducerMock,
- /* brightnessThrottlingMapId= */ "concurrent",
- /* leadDisplayId= */ Display.DEFAULT_DISPLAY);
- display2.setPosition(Layout.Display.POSITION_REAR);
-
- assertEquals(testLayout, configLayout);
+ assertEquals("concurrent1", configLayout.getAt(0).getBrightnessThrottlingMapId());
+ assertEquals("concurrent2", configLayout.getAt(1).getBrightnessThrottlingMapId());
}
@Test
@@ -141,38 +103,33 @@ public class DeviceStateToLayoutMapTest {
public void testRefreshRateZoneId() {
Layout configLayout = mDeviceStateToLayoutMap.get(3);
- Layout testLayout = new Layout();
- Layout.Display display1 = testLayout.createDisplayLocked(
- DisplayAddress.fromPhysicalDisplayId(345L), /* isDefault= */ true,
- /* isEnabled= */ true, /* displayGroup= */ null, mDisplayIdProducerMock,
- /* brightnessThrottlingMapId= */ null,
- /* leadDisplayId= */ Display.DEFAULT_DISPLAY);
- display1.setRefreshRateZoneId("test1");
- testLayout.createDisplayLocked(
- DisplayAddress.fromPhysicalDisplayId(678L), /* isDefault= */ false,
- /* isEnabled= */ true, /* displayGroup= */ null, mDisplayIdProducerMock,
- /* brightnessThrottlingMapId= */ null,
- /* leadDisplayId= */ Display.DEFAULT_DISPLAY);
-
- assertEquals(testLayout, configLayout);
+ assertEquals("test1", configLayout.getAt(0).getRefreshRateZoneId());
+ assertNull(configLayout.getAt(1).getRefreshRateZoneId());
}
@Test
public void testRefreshRateThermalThrottlingMapId() {
Layout configLayout = mDeviceStateToLayoutMap.get(4);
+ assertEquals("test2", configLayout.getAt(0).getRefreshRateThermalThrottlingMapId());
+ assertNull(configLayout.getAt(1).getRefreshRateThermalThrottlingMapId());
+ }
+
+ @Test
+ public void testWholeStateConfig() {
+ Layout configLayout = mDeviceStateToLayoutMap.get(99);
+
Layout testLayout = new Layout();
- Layout.Display display1 = testLayout.createDisplayLocked(
- DisplayAddress.fromPhysicalDisplayId(345L), /* isDefault= */ true,
- /* isEnabled= */ true, /* displayGroup= */ null, mDisplayIdProducerMock,
- /* brightnessThrottlingMapId= */ null,
- /* leadDisplayId= */ Display.DEFAULT_DISPLAY);
- display1.setRefreshRateThermalThrottlingMapId("test2");
- testLayout.createDisplayLocked(
- DisplayAddress.fromPhysicalDisplayId(678L), /* isDefault= */ false,
- /* isEnabled= */ true, /* displayGroup= */ null, mDisplayIdProducerMock,
- /* brightnessThrottlingMapId= */ null,
- /* leadDisplayId= */ Display.DEFAULT_DISPLAY);
+ testLayout.createDisplayLocked(DisplayAddress.fromPhysicalDisplayId(345L),
+ /* isDefault= */ true, /* isEnabled= */ true, /* displayGroupName= */ null,
+ mDisplayIdProducerMock, Layout.Display.POSITION_FRONT, Display.DEFAULT_DISPLAY,
+ /* brightnessThrottlingMapId= */ "brightness1",
+ /* refreshRateZoneId= */ "zone1", /* refreshRateThermalThrottlingMapId= */ "rr1");
+ testLayout.createDisplayLocked(DisplayAddress.fromPhysicalDisplayId(678L),
+ /* isDefault= */ false, /* isEnabled= */ false, /* displayGroupName= */ "group1",
+ mDisplayIdProducerMock, Layout.Display.POSITION_REAR, Display.DEFAULT_DISPLAY,
+ /* brightnessThrottlingMapId= */ "brightness2",
+ /* refreshRateZoneId= */ "zone2", /* refreshRateThermalThrottlingMapId= */ "rr2");
assertEquals(testLayout, configLayout);
}
@@ -181,6 +138,18 @@ public class DeviceStateToLayoutMapTest {
// Helper Methods //
////////////////////
+ private void createDefaultDisplay(Layout layout, long id) {
+ layout.createDefaultDisplayLocked(DisplayAddress.fromPhysicalDisplayId(id),
+ mDisplayIdProducerMock);
+ }
+
+ private void createNonDefaultDisplay(Layout layout, long id, boolean enabled, String group) {
+ layout.createDisplayLocked(DisplayAddress.fromPhysicalDisplayId(id), /* isDefault= */ false,
+ enabled, group, mDisplayIdProducerMock, Layout.Display.POSITION_UNKNOWN,
+ Display.DEFAULT_DISPLAY, /* brightnessThrottlingMapId= */ null,
+ /* refreshRateZoneId= */ null, /* refreshRateThermalThrottlingMapId= */ null);
+ }
+
private void setupDeviceStateToLayoutMap() throws IOException {
Path tempFile = Files.createTempFile("device_state_layout_map", ".tmp");
Files.write(tempFile, getContent().getBytes(StandardCharsets.UTF_8));
@@ -222,12 +191,12 @@ public class DeviceStateToLayoutMapTest {
+ "\n"
+ "345\n"
+ "front\n"
- + "concurrent\n"
+ + "concurrent1\n"
+ "\n"
+ "\n"
+ "678\n"
+ "rear\n"
- + "concurrent\n"
+ + "concurrent2\n"
+ "\n"
+ "\n"
@@ -254,6 +223,27 @@ public class DeviceStateToLayoutMapTest {
+ "678\n"
+ "\n"
+ "\n"
- + "\n";
+ + "\n"
+ + "99 \n"
+ + "\n"
+ + "345\n"
+ + "front\n"
+ + "brightness1\n"
+ + ""
+ + "rr1"
+ + ""
+ + "\n"
+ + "\n"
+ + "678\n"
+ + "rear\n"
+ + "brightness2\n"
+ + ""
+ + "rr2"
+ + ""
+ + "\n"
+ + "\n"
+ + "\n";
}
}
diff --git a/services/tests/servicestests/src/com/android/server/display/LogicalDisplayMapperTest.java b/services/tests/servicestests/src/com/android/server/display/LogicalDisplayMapperTest.java
index 9eb600304f981..567548e83dc8b 100644
--- a/services/tests/servicestests/src/com/android/server/display/LogicalDisplayMapperTest.java
+++ b/services/tests/servicestests/src/com/android/server/display/LogicalDisplayMapperTest.java
@@ -60,8 +60,8 @@ import android.view.Display;
import android.view.DisplayAddress;
import android.view.DisplayInfo;
+import androidx.test.ext.junit.runners.AndroidJUnit4;
import androidx.test.filters.SmallTest;
-import androidx.test.runner.AndroidJUnit4;
import com.android.server.display.layout.DisplayIdProducer;
import com.android.server.display.layout.Layout;
@@ -300,14 +300,8 @@ public class LogicalDisplayMapperTest {
add(device2);
Layout layout1 = new Layout();
- layout1.createDisplayLocked(info(device1).address, /* isDefault= */ true,
- /* isEnabled= */ true, /* displayGroup= */ null, mIdProducer,
- /* brightnessThrottlingMapId= */ null,
- /* leadDisplayId= */ Display.DEFAULT_DISPLAY);
- layout1.createDisplayLocked(info(device2).address, /* isDefault= */ false,
- /* isEnabled= */ true, /* displayGroup= */ null, mIdProducer,
- /* brightnessThrottlingMapId= */ null,
- /* leadDisplayId= */ Display.DEFAULT_DISPLAY);
+ createDefaultDisplay(layout1, device1);
+ createNonDefaultDisplay(layout1, device2, /* enabled= */ true, /* group= */ null);
when(mDeviceStateToLayoutMapSpy.get(STATE_DEFAULT)).thenReturn(layout1);
assertThat(layout1.size()).isEqualTo(2);
final int logicalId2 = layout1.getByAddress(info(device2).address).getLogicalDisplayId();
@@ -340,23 +334,14 @@ public class LogicalDisplayMapperTest {
add(device3);
Layout layout1 = new Layout();
- layout1.createDisplayLocked(info(device1).address, /* isDefault= */ true,
- /* isEnabled= */ true, /* displayGroup= */ null, mIdProducer,
- /* brightnessThrottlingMapId= */ null,
- /* leadDisplayId= */ Display.DEFAULT_DISPLAY);
+ createDefaultDisplay(layout1, device1);
when(mDeviceStateToLayoutMapSpy.get(STATE_DEFAULT)).thenReturn(layout1);
final int layoutState2 = 2;
Layout layout2 = new Layout();
- layout2.createDisplayLocked(info(device2).address, /* isDefault= */ false,
- /* isEnabled= */ true, /* displayGroup= */ null, mIdProducer,
- /* brightnessThrottlingMapId= */ null,
- /* leadDisplayId= */ Display.DEFAULT_DISPLAY);
+ createNonDefaultDisplay(layout2, device2, /* enabled= */ true, /* group= */ null);
// Device3 is the default display.
- layout2.createDisplayLocked(info(device3).address, /* isDefault= */ true,
- /* isEnabled= */ true, /* displayGroup= */ null, mIdProducer,
- /* brightnessThrottlingMapId= */ null,
- /* leadDisplayId= */ Display.DEFAULT_DISPLAY);
+ createDefaultDisplay(layout2, device3);
when(mDeviceStateToLayoutMapSpy.get(layoutState2)).thenReturn(layout2);
assertThat(layout2.size()).isEqualTo(2);
final int logicalId2 = layout2.getByAddress(info(device2).address).getLogicalDisplayId();
@@ -398,22 +383,11 @@ public class LogicalDisplayMapperTest {
FLAG_ALLOWED_TO_BE_DEFAULT_DISPLAY);
Layout layout = new Layout();
- layout.createDisplayLocked(info(device1).address,
- /* isDefault= */ true, /* isEnabled= */ true, /* displayGroup= */ null,
- mIdProducer, /* brightnessThrottlingMapId= */ null,
- /* leadDisplayId= */ Display.DEFAULT_DISPLAY);
- layout.createDisplayLocked(info(device2).address,
- /* isDefault= */ false, /* isEnabled= */ true, "group1", mIdProducer,
- /* brightnessThrottlingMapId= */ null,
- /* leadDisplayId= */ Display.DEFAULT_DISPLAY);
- layout.createDisplayLocked(info(device3).address,
- /* isDefault= */ false, /* isEnabled= */ true, "group1", mIdProducer,
- /* brightnessThrottlingMapId= */ null,
- /* leadDisplayId= */ Display.DEFAULT_DISPLAY);
- layout.createDisplayLocked(info(device4).address,
- /* isDefault= */ false, /* isEnabled= */ true, "group2", mIdProducer,
- /* brightnessThrottlingMapId= */ null,
- /* leadDisplayId= */ Display.DEFAULT_DISPLAY);
+ createDefaultDisplay(layout, device1);
+ createNonDefaultDisplay(layout, device2, /* enabled= */ true, /* group= */ "group1");
+ createNonDefaultDisplay(layout, device3, /* enabled= */ true, /* group= */ "group1");
+ createNonDefaultDisplay(layout, device4, /* enabled= */ true, /* group= */ "group2");
+
when(mDeviceStateToLayoutMapSpy.get(STATE_DEFAULT)).thenReturn(layout);
LogicalDisplay display1 = add(device1);
@@ -629,23 +603,21 @@ public class LogicalDisplayMapperTest {
Layout layout = new Layout();
layout.createDisplayLocked(device1.getDisplayDeviceInfoLocked().address,
/* isDefault= */ true, /* isEnabled= */ true, /* displayGroup= */ null,
- mIdProducer, /* brightnessThrottlingMapId= */ "concurrent",
- /* leadDisplayId= */ Display.DEFAULT_DISPLAY);
+ mIdProducer, POSITION_UNKNOWN,
+ /* leadDisplayId= */ Display.DEFAULT_DISPLAY,
+ /* brightnessThrottlingMapId= */ "concurrent",
+ /* refreshRateZoneId= */ null, /* refreshRateThermalThrottlingMapId= */ null);
layout.createDisplayLocked(device2.getDisplayDeviceInfoLocked().address,
/* isDefault= */ false, /* isEnabled= */ true, /* displayGroup= */ null,
- mIdProducer, /* brightnessThrottlingMapId= */ "concurrent",
- /* leadDisplayId= */ Display.DEFAULT_DISPLAY);
+ mIdProducer, POSITION_UNKNOWN,
+ /* leadDisplayId= */ Display.DEFAULT_DISPLAY,
+ /* brightnessThrottlingMapId= */ "concurrent",
+ /* refreshRateZoneId= */ null, /* refreshRateThermalThrottlingMapId= */ null);
when(mDeviceStateToLayoutMapSpy.get(0)).thenReturn(layout);
layout = new Layout();
- layout.createDisplayLocked(device1.getDisplayDeviceInfoLocked().address,
- /* isDefault= */ false, /* isEnabled= */ false, /* displayGroup= */ null,
- mIdProducer, /* brightnessThrottlingMapId= */ null,
- /* leadDisplayId= */ Display.DEFAULT_DISPLAY);
- layout.createDisplayLocked(device2.getDisplayDeviceInfoLocked().address,
- /* isDefault= */ true, /* isEnabled= */ true, /* displayGroup= */ null,
- mIdProducer, /* brightnessThrottlingMapId= */ null,
- /* leadDisplayId= */ Display.DEFAULT_DISPLAY);
+ createNonDefaultDisplay(layout, device1, /* enabled= */ false, /* group= */ null);
+ createDefaultDisplay(layout, device2);
when(mDeviceStateToLayoutMapSpy.get(1)).thenReturn(layout);
when(mDeviceStateToLayoutMapSpy.get(2)).thenReturn(layout);
@@ -722,30 +694,11 @@ public class LogicalDisplayMapperTest {
TYPE_INTERNAL, 600, 900, DisplayDeviceInfo.FLAG_OWN_DISPLAY_GROUP);
Layout threeDevicesEnabledLayout = new Layout();
- threeDevicesEnabledLayout.createDisplayLocked(
- displayAddressOne,
- /* isDefault= */ true,
- /* isEnabled= */ true,
- /* displayGroup= */ null,
- mIdProducer,
- /* brightnessThrottlingMapId= */ null,
- /* leadDisplayId= */ Display.DEFAULT_DISPLAY);
- threeDevicesEnabledLayout.createDisplayLocked(
- displayAddressTwo,
- /* isDefault= */ false,
- /* isEnabled= */ true,
- /* displayGroup= */ null,
- mIdProducer,
- /* brightnessThrottlingMapId= */ null,
- /* leadDisplayId= */ Display.DEFAULT_DISPLAY);
- threeDevicesEnabledLayout.createDisplayLocked(
- displayAddressThree,
- /* isDefault= */ false,
- /* isEnabled= */ true,
- /* displayGroup= */ null,
- mIdProducer,
- /* brightnessThrottlingMapId= */ null,
- /* leadDisplayId= */ Display.DEFAULT_DISPLAY);
+ createDefaultDisplay(threeDevicesEnabledLayout, displayAddressOne);
+ createNonDefaultDisplay(threeDevicesEnabledLayout, displayAddressTwo,
+ /* enabled= */ true, /* group= */ null);
+ createNonDefaultDisplay(threeDevicesEnabledLayout, displayAddressThree,
+ /* enabled= */ true, /* group= */ null);
when(mDeviceStateToLayoutMapSpy.get(STATE_DEFAULT))
.thenReturn(threeDevicesEnabledLayout);
@@ -776,30 +729,11 @@ public class LogicalDisplayMapperTest {
/* includeDisabled= */ false));
Layout oneDeviceEnabledLayout = new Layout();
- oneDeviceEnabledLayout.createDisplayLocked(
- displayAddressOne,
- /* isDefault= */ true,
- /* isEnabled= */ true,
- /* displayGroup= */ null,
- mIdProducer,
- /* brightnessThrottlingMapId= */ null,
- /* leadDisplayId= */ Display.DEFAULT_DISPLAY);
- oneDeviceEnabledLayout.createDisplayLocked(
- displayAddressTwo,
- /* isDefault= */ false,
- /* isEnabled= */ false,
- /* displayGroup= */ null,
- mIdProducer,
- /* brightnessThrottlingMapId= */ null,
- /* leadDisplayId= */ Display.DEFAULT_DISPLAY);
- oneDeviceEnabledLayout.createDisplayLocked(
- displayAddressThree,
- /* isDefault= */ false,
- /* isEnabled= */ false,
- /* displayGroup= */ null,
- mIdProducer,
- /* brightnessThrottlingMapId= */ null,
- /* leadDisplayId= */ Display.DEFAULT_DISPLAY);
+ createDefaultDisplay(oneDeviceEnabledLayout, displayAddressOne);
+ createNonDefaultDisplay(oneDeviceEnabledLayout, displayAddressTwo,
+ /* enabled= */ false, /* group= */ null);
+ createNonDefaultDisplay(oneDeviceEnabledLayout, displayAddressThree,
+ /* enabled= */ false, /* group= */ null);
when(mDeviceStateToLayoutMapSpy.get(0)).thenReturn(oneDeviceEnabledLayout);
when(mDeviceStateToLayoutMapSpy.get(1)).thenReturn(threeDevicesEnabledLayout);
@@ -873,12 +807,13 @@ public class LogicalDisplayMapperTest {
FLAG_REAR);
Layout layout = new Layout();
- layout.createDisplayLocked(device1.getDisplayDeviceInfoLocked().address,
- true, true, null, mIdProducer, /* brightnessThrottlingMapId= */ null,
- /* leadDisplayId= */ Display.DEFAULT_DISPLAY);
+ layout.createDefaultDisplayLocked(device1.getDisplayDeviceInfoLocked().address,
+ mIdProducer);
layout.createDisplayLocked(device2.getDisplayDeviceInfoLocked().address,
- false, true, null, mIdProducer, /* brightnessThrottlingMapId= */ null,
- POSITION_REAR, Display.DEFAULT_DISPLAY);
+ /* isDefault= */ false, /* isEnabled= */ true, /* displayGroupName= */ null,
+ mIdProducer, POSITION_REAR, Display.DEFAULT_DISPLAY,
+ /* brightnessThrottlingMapId= */ null, /* refreshRateZoneId= */ null,
+ /* refreshRateThermalThrottlingMapId= */null);
when(mDeviceStateToLayoutMapSpy.get(0)).thenReturn(layout);
when(mDeviceStateToLayoutMapSpy.size()).thenReturn(1);
@@ -910,6 +845,27 @@ public class LogicalDisplayMapperTest {
// Helper Methods
/////////////////
+ private void createDefaultDisplay(Layout layout, DisplayDevice device) {
+ createDefaultDisplay(layout, info(device).address);
+ }
+
+ private void createDefaultDisplay(Layout layout, DisplayAddress address) {
+ layout.createDefaultDisplayLocked(address, mIdProducer);
+ }
+
+ private void createNonDefaultDisplay(Layout layout, DisplayDevice device, boolean enabled,
+ String group) {
+ createNonDefaultDisplay(layout, info(device).address, enabled, group);
+ }
+
+ private void createNonDefaultDisplay(Layout layout, DisplayAddress address, boolean enabled,
+ String group) {
+ layout.createDisplayLocked(address, /* isDefault= */ false, enabled, group, mIdProducer,
+ Layout.Display.POSITION_UNKNOWN, Display.DEFAULT_DISPLAY,
+ /* brightnessThrottlingMapId= */ null, /* refreshRateZoneId= */ null,
+ /* refreshRateThrottlingMapId= */ null);
+ }
+
private void advanceTime(long timeMs) {
mLooper.moveTimeForward(1000);
mLooper.dispatchAll();