Merge "Making Layout.Display immutable" into udc-dev
This commit is contained in:
committed by
Android (Google) Code Review
commit
608fa1fd94
@@ -121,24 +121,17 @@ class DeviceStateToLayoutMap {
|
|||||||
final Layout layout = createLayout(state);
|
final Layout layout = createLayout(state);
|
||||||
for (com.android.server.display.config.layout.Display d: l.getDisplay()) {
|
for (com.android.server.display.config.layout.Display d: l.getDisplay()) {
|
||||||
assert layout != null;
|
assert layout != null;
|
||||||
Layout.Display display = layout.createDisplayLocked(
|
int position = getPosition(d.getPosition());
|
||||||
|
layout.createDisplayLocked(
|
||||||
DisplayAddress.fromPhysicalDisplayId(d.getAddress().longValue()),
|
DisplayAddress.fromPhysicalDisplayId(d.getAddress().longValue()),
|
||||||
d.isDefaultDisplay(),
|
d.isDefaultDisplay(),
|
||||||
d.isEnabled(),
|
d.isEnabled(),
|
||||||
d.getDisplayGroup(),
|
d.getDisplayGroup(),
|
||||||
mIdProducer,
|
mIdProducer,
|
||||||
|
position,
|
||||||
|
leadDisplayId,
|
||||||
d.getBrightnessThrottlingMapId(),
|
d.getBrightnessThrottlingMapId(),
|
||||||
leadDisplayId);
|
d.getRefreshRateZoneId(),
|
||||||
|
|
||||||
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.getRefreshRateThermalThrottlingMapId());
|
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) {
|
private Layout createLayout(int state) {
|
||||||
if (mLayoutMap.contains(state)) {
|
if (mLayoutMap.contains(state)) {
|
||||||
Slog.e(TAG, "Attempted to create a second layout for state " + state);
|
Slog.e(TAG, "Attempted to create a second layout for state " + state);
|
||||||
|
|||||||
@@ -18,8 +18,6 @@ package com.android.server.display;
|
|||||||
|
|
||||||
import static android.view.Display.DEFAULT_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.NonNull;
|
||||||
import android.annotation.Nullable;
|
import android.annotation.Nullable;
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
@@ -646,10 +644,7 @@ class LogicalDisplayMapper implements DisplayDeviceRepository.Listener {
|
|||||||
if ((nextDeviceInfo.flags
|
if ((nextDeviceInfo.flags
|
||||||
& DisplayDeviceInfo.FLAG_ALLOWED_TO_BE_DEFAULT_DISPLAY) != 0
|
& DisplayDeviceInfo.FLAG_ALLOWED_TO_BE_DEFAULT_DISPLAY) != 0
|
||||||
&& !nextDeviceInfo.address.equals(deviceInfo.address)) {
|
&& !nextDeviceInfo.address.equals(deviceInfo.address)) {
|
||||||
layout.createDisplayLocked(nextDeviceInfo.address,
|
layout.createDefaultDisplayLocked(nextDeviceInfo.address, mIdProducer);
|
||||||
/* isDefault= */ true, /* isEnabled= */ true,
|
|
||||||
Layout.DEFAULT_DISPLAY_GROUP_NAME, mIdProducer,
|
|
||||||
/* brightnessThrottlingMapId= */ null, DEFAULT_DISPLAY);
|
|
||||||
applyLayoutLocked();
|
applyLayoutLocked();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -1110,9 +1105,7 @@ class LogicalDisplayMapper implements DisplayDeviceRepository.Listener {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
final DisplayDeviceInfo info = device.getDisplayDeviceInfoLocked();
|
final DisplayDeviceInfo info = device.getDisplayDeviceInfoLocked();
|
||||||
layout.createDisplayLocked(info.address, /* isDefault= */ true, /* isEnabled= */ true,
|
layout.createDefaultDisplayLocked(info.address, mIdProducer);
|
||||||
Layout.DEFAULT_DISPLAY_GROUP_NAME, mIdProducer,
|
|
||||||
/* brightnessThrottlingMapId= */ null, NO_LEAD_DISPLAY);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private int assignLayerStackLocked(int displayId) {
|
private int assignLayerStackLocked(int displayId) {
|
||||||
|
|||||||
@@ -39,7 +39,6 @@ public class Layout {
|
|||||||
public static final String DEFAULT_DISPLAY_GROUP_NAME = "";
|
public static final String DEFAULT_DISPLAY_GROUP_NAME = "";
|
||||||
|
|
||||||
private static final String TAG = "Layout";
|
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
|
// Lead display Id is set to this if this is not a follower display, and therefore
|
||||||
// has no lead.
|
// has no lead.
|
||||||
@@ -47,13 +46,6 @@ public class Layout {
|
|||||||
|
|
||||||
private final List<Display> mDisplays = new ArrayList<>(2);
|
private final List<Display> 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
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
return mDisplays.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 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 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(
|
public void createDefaultDisplayLocked(@NonNull DisplayAddress address,
|
||||||
@NonNull DisplayAddress address, boolean isDefault, boolean isEnabled,
|
DisplayIdProducer idProducer) {
|
||||||
String displayGroupName, DisplayIdProducer idProducer, String brightnessThrottlingMapId,
|
createDisplayLocked(address, /* isDefault= */ true, /* isEnabled= */ true,
|
||||||
int leadDisplayId) {
|
DEFAULT_DISPLAY_GROUP_NAME, idProducer, POSITION_UNKNOWN,
|
||||||
return createDisplayLocked(address, isDefault, isEnabled, displayGroupName, idProducer,
|
NO_LEAD_DISPLAY, /* brightnessThrottlingMapId= */ null,
|
||||||
brightnessThrottlingMapId, POSITION_UNKNOWN, leadDisplayId);
|
/* 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 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 displayGroupName Name of the display group to which the display is assigned.
|
||||||
* @param idProducer Produces the logical display id.
|
* @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 position Indicates the position this display is facing in this layout.
|
||||||
* @param leadDisplayId Display that this one follows (-1 if none).
|
* @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
|
* @exception IllegalArgumentException When a default display owns a display group other than
|
||||||
* DEFAULT_DISPLAY_GROUP.
|
* DEFAULT_DISPLAY_GROUP.
|
||||||
* @return The new Display.
|
|
||||||
*/
|
*/
|
||||||
public Display createDisplayLocked(
|
public void createDisplayLocked(
|
||||||
@NonNull DisplayAddress address, boolean isDefault, boolean isEnabled,
|
@NonNull DisplayAddress address, boolean isDefault, boolean isEnabled,
|
||||||
String displayGroupName, DisplayIdProducer idProducer, String brightnessThrottlingMapId,
|
String displayGroupName, DisplayIdProducer idProducer, int position, int leadDisplayId,
|
||||||
int position, int leadDisplayId) {
|
String brightnessThrottlingMapId, @Nullable String refreshRateZoneId,
|
||||||
|
@Nullable String refreshRateThermalThrottlingMapId) {
|
||||||
if (contains(address)) {
|
if (contains(address)) {
|
||||||
Slog.w(TAG, "Attempting to add second definition for display-device: " + 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
|
// See if we're dealing with the "default" display
|
||||||
if (isDefault && getById(DEFAULT_DISPLAY) != null) {
|
if (isDefault && getById(DEFAULT_DISPLAY) != null) {
|
||||||
Slog.w(TAG, "Ignoring attempt to add a second default display: " + address);
|
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.
|
// 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");
|
throw new IllegalArgumentException("Default display should own DEFAULT_DISPLAY_GROUP");
|
||||||
}
|
}
|
||||||
final int logicalDisplayId = idProducer.getId(isDefault);
|
final int logicalDisplayId = idProducer.getId(isDefault);
|
||||||
|
leadDisplayId = isDefault ? NO_LEAD_DISPLAY : leadDisplayId;
|
||||||
|
|
||||||
final Display display = new Display(address, logicalDisplayId, isEnabled, displayGroupName,
|
final Display display = new Display(address, logicalDisplayId, isEnabled, displayGroupName,
|
||||||
brightnessThrottlingMapId, position, leadDisplayId);
|
brightnessThrottlingMapId, position, leadDisplayId, refreshRateZoneId,
|
||||||
|
refreshRateThermalThrottlingMapId);
|
||||||
|
|
||||||
mDisplays.add(display);
|
mDisplays.add(display);
|
||||||
return display;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -242,7 +232,7 @@ public class Layout {
|
|||||||
// {@link DeviceStateToLayoutMap.POSITION_FRONT} or
|
// {@link DeviceStateToLayoutMap.POSITION_FRONT} or
|
||||||
// {@link DeviceStateToLayoutMap.POSITION_REAR}.
|
// {@link DeviceStateToLayoutMap.POSITION_REAR}.
|
||||||
// {@link DeviceStateToLayoutMap.POSITION_UNKNOWN} is unspecified.
|
// {@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
|
// 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
|
// concurrent displays mode in which a stricter brightness throttling policy might need to
|
||||||
@@ -251,33 +241,30 @@ public class Layout {
|
|||||||
private final String mBrightnessThrottlingMapId;
|
private final String mBrightnessThrottlingMapId;
|
||||||
|
|
||||||
// The ID of the lead display that this display will follow in a layout. -1 means no lead.
|
// 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
|
// Refresh rate zone id for specific layout
|
||||||
@Nullable
|
@Nullable
|
||||||
private String mRefreshRateZoneId;
|
private final String mRefreshRateZoneId;
|
||||||
|
|
||||||
@Nullable
|
@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,
|
@NonNull String displayGroupName, String brightnessThrottlingMapId, int position,
|
||||||
int leadDisplayId) {
|
int leadDisplayId, @Nullable String refreshRateZoneId,
|
||||||
|
@Nullable String refreshRateThermalThrottlingMapId) {
|
||||||
mAddress = address;
|
mAddress = address;
|
||||||
mLogicalDisplayId = logicalDisplayId;
|
mLogicalDisplayId = logicalDisplayId;
|
||||||
mIsEnabled = isEnabled;
|
mIsEnabled = isEnabled;
|
||||||
mDisplayGroupName = displayGroupName;
|
mDisplayGroupName = displayGroupName;
|
||||||
mPosition = position;
|
mPosition = position;
|
||||||
mBrightnessThrottlingMapId = brightnessThrottlingMapId;
|
mBrightnessThrottlingMapId = brightnessThrottlingMapId;
|
||||||
|
mRefreshRateZoneId = refreshRateZoneId;
|
||||||
if (leadDisplayId == mLogicalDisplayId) {
|
mRefreshRateThermalThrottlingMapId = refreshRateThermalThrottlingMapId;
|
||||||
mLeadDisplayId = NO_LEAD_DISPLAY;
|
|
||||||
} else {
|
|
||||||
mLeadDisplayId = leadDisplayId;
|
mLeadDisplayId = leadDisplayId;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
return "{"
|
return "{"
|
||||||
@@ -345,23 +332,11 @@ public class Layout {
|
|||||||
return mDisplayGroupName;
|
return mDisplayGroupName;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setRefreshRateZoneId(@Nullable String refreshRateZoneId) {
|
|
||||||
mRefreshRateZoneId = refreshRateZoneId;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Nullable
|
@Nullable
|
||||||
public String getRefreshRateZoneId() {
|
public String getRefreshRateZoneId() {
|
||||||
return mRefreshRateZoneId;
|
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.
|
* @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.
|
* @return the position that this display is facing.
|
||||||
*/
|
*/
|
||||||
public int getPosition() {
|
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.
|
* @return logical displayId of the display that this one follows.
|
||||||
*/
|
*/
|
||||||
public int getLeadDisplayId() {
|
public int getLeadDisplayId() {
|
||||||
return mLeadDisplayId;
|
return mLeadDisplayId;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setRefreshRateThermalThrottlingMapId(String refreshRateThermalThrottlingMapId) {
|
|
||||||
mRefreshRateThermalThrottlingMapId = refreshRateThermalThrottlingMapId;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getRefreshRateThermalThrottlingMapId() {
|
public String getRefreshRateThermalThrottlingMapId() {
|
||||||
return mRefreshRateThermalThrottlingMapId;
|
return mRefreshRateThermalThrottlingMapId;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -18,6 +18,7 @@ package com.android.server.display;
|
|||||||
|
|
||||||
|
|
||||||
import static org.junit.Assert.assertEquals;
|
import static org.junit.Assert.assertEquals;
|
||||||
|
import static org.junit.Assert.assertNull;
|
||||||
|
|
||||||
import android.view.Display;
|
import android.view.Display;
|
||||||
import android.view.DisplayAddress;
|
import android.view.DisplayAddress;
|
||||||
@@ -63,26 +64,10 @@ public class DeviceStateToLayoutMapTest {
|
|||||||
Layout configLayout = mDeviceStateToLayoutMap.get(0);
|
Layout configLayout = mDeviceStateToLayoutMap.get(0);
|
||||||
|
|
||||||
Layout testLayout = new Layout();
|
Layout testLayout = new Layout();
|
||||||
testLayout.createDisplayLocked(
|
createDefaultDisplay(testLayout, 123456L);
|
||||||
DisplayAddress.fromPhysicalDisplayId(123456L), /* isDefault= */ true,
|
createNonDefaultDisplay(testLayout, 78910L, /* enabled= */ false, /* group= */ null);
|
||||||
/* isEnabled= */ true, /* displayGroup= */ null, mDisplayIdProducerMock,
|
createNonDefaultDisplay(testLayout, 98765L, /* enabled= */ true, /* group= */ "group1");
|
||||||
/* brightnessThrottlingMapId= */ null,
|
createNonDefaultDisplay(testLayout, 786L, /* enabled= */ false, /* group= */ "group2");
|
||||||
/* 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);
|
|
||||||
|
|
||||||
assertEquals(testLayout, configLayout);
|
assertEquals(testLayout, configLayout);
|
||||||
}
|
}
|
||||||
@@ -92,41 +77,18 @@ public class DeviceStateToLayoutMapTest {
|
|||||||
Layout configLayout = mDeviceStateToLayoutMap.get(1);
|
Layout configLayout = mDeviceStateToLayoutMap.get(1);
|
||||||
|
|
||||||
Layout testLayout = new Layout();
|
Layout testLayout = new Layout();
|
||||||
testLayout.createDisplayLocked(
|
createDefaultDisplay(testLayout, 78910L);
|
||||||
DisplayAddress.fromPhysicalDisplayId(78910L), /* isDefault= */ true,
|
createNonDefaultDisplay(testLayout, 123456L, /* enabled= */ false, /* group= */ null);
|
||||||
/* 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);
|
|
||||||
|
|
||||||
assertEquals(testLayout, configLayout);
|
assertEquals(testLayout, configLayout);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testConcurrentState() {
|
public void testBrightnessThrottlingMapId() {
|
||||||
Layout configLayout = mDeviceStateToLayoutMap.get(2);
|
Layout configLayout = mDeviceStateToLayoutMap.get(2);
|
||||||
|
|
||||||
Layout testLayout = new Layout();
|
assertEquals("concurrent1", configLayout.getAt(0).getBrightnessThrottlingMapId());
|
||||||
|
assertEquals("concurrent2", configLayout.getAt(1).getBrightnessThrottlingMapId());
|
||||||
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);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@@ -141,38 +103,33 @@ public class DeviceStateToLayoutMapTest {
|
|||||||
public void testRefreshRateZoneId() {
|
public void testRefreshRateZoneId() {
|
||||||
Layout configLayout = mDeviceStateToLayoutMap.get(3);
|
Layout configLayout = mDeviceStateToLayoutMap.get(3);
|
||||||
|
|
||||||
Layout testLayout = new Layout();
|
assertEquals("test1", configLayout.getAt(0).getRefreshRateZoneId());
|
||||||
Layout.Display display1 = testLayout.createDisplayLocked(
|
assertNull(configLayout.getAt(1).getRefreshRateZoneId());
|
||||||
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);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testRefreshRateThermalThrottlingMapId() {
|
public void testRefreshRateThermalThrottlingMapId() {
|
||||||
Layout configLayout = mDeviceStateToLayoutMap.get(4);
|
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 testLayout = new Layout();
|
||||||
Layout.Display display1 = testLayout.createDisplayLocked(
|
testLayout.createDisplayLocked(DisplayAddress.fromPhysicalDisplayId(345L),
|
||||||
DisplayAddress.fromPhysicalDisplayId(345L), /* isDefault= */ true,
|
/* isDefault= */ true, /* isEnabled= */ true, /* displayGroupName= */ null,
|
||||||
/* isEnabled= */ true, /* displayGroup= */ null, mDisplayIdProducerMock,
|
mDisplayIdProducerMock, Layout.Display.POSITION_FRONT, Display.DEFAULT_DISPLAY,
|
||||||
/* brightnessThrottlingMapId= */ null,
|
/* brightnessThrottlingMapId= */ "brightness1",
|
||||||
/* leadDisplayId= */ Display.DEFAULT_DISPLAY);
|
/* refreshRateZoneId= */ "zone1", /* refreshRateThermalThrottlingMapId= */ "rr1");
|
||||||
display1.setRefreshRateThermalThrottlingMapId("test2");
|
testLayout.createDisplayLocked(DisplayAddress.fromPhysicalDisplayId(678L),
|
||||||
testLayout.createDisplayLocked(
|
/* isDefault= */ false, /* isEnabled= */ false, /* displayGroupName= */ "group1",
|
||||||
DisplayAddress.fromPhysicalDisplayId(678L), /* isDefault= */ false,
|
mDisplayIdProducerMock, Layout.Display.POSITION_REAR, Display.DEFAULT_DISPLAY,
|
||||||
/* isEnabled= */ true, /* displayGroup= */ null, mDisplayIdProducerMock,
|
/* brightnessThrottlingMapId= */ "brightness2",
|
||||||
/* brightnessThrottlingMapId= */ null,
|
/* refreshRateZoneId= */ "zone2", /* refreshRateThermalThrottlingMapId= */ "rr2");
|
||||||
/* leadDisplayId= */ Display.DEFAULT_DISPLAY);
|
|
||||||
|
|
||||||
assertEquals(testLayout, configLayout);
|
assertEquals(testLayout, configLayout);
|
||||||
}
|
}
|
||||||
@@ -181,6 +138,18 @@ public class DeviceStateToLayoutMapTest {
|
|||||||
// Helper Methods //
|
// 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 {
|
private void setupDeviceStateToLayoutMap() throws IOException {
|
||||||
Path tempFile = Files.createTempFile("device_state_layout_map", ".tmp");
|
Path tempFile = Files.createTempFile("device_state_layout_map", ".tmp");
|
||||||
Files.write(tempFile, getContent().getBytes(StandardCharsets.UTF_8));
|
Files.write(tempFile, getContent().getBytes(StandardCharsets.UTF_8));
|
||||||
@@ -222,12 +191,12 @@ public class DeviceStateToLayoutMapTest {
|
|||||||
+ "<display enabled=\"true\" defaultDisplay=\"true\">\n"
|
+ "<display enabled=\"true\" defaultDisplay=\"true\">\n"
|
||||||
+ "<address>345</address>\n"
|
+ "<address>345</address>\n"
|
||||||
+ "<position>front</position>\n"
|
+ "<position>front</position>\n"
|
||||||
+ "<brightnessThrottlingMapId>concurrent</brightnessThrottlingMapId>\n"
|
+ "<brightnessThrottlingMapId>concurrent1</brightnessThrottlingMapId>\n"
|
||||||
+ "</display>\n"
|
+ "</display>\n"
|
||||||
+ "<display enabled=\"true\">\n"
|
+ "<display enabled=\"true\">\n"
|
||||||
+ "<address>678</address>\n"
|
+ "<address>678</address>\n"
|
||||||
+ "<position>rear</position>\n"
|
+ "<position>rear</position>\n"
|
||||||
+ "<brightnessThrottlingMapId>concurrent</brightnessThrottlingMapId>\n"
|
+ "<brightnessThrottlingMapId>concurrent2</brightnessThrottlingMapId>\n"
|
||||||
+ "</display>\n"
|
+ "</display>\n"
|
||||||
+ "</layout>\n"
|
+ "</layout>\n"
|
||||||
|
|
||||||
@@ -254,6 +223,27 @@ public class DeviceStateToLayoutMapTest {
|
|||||||
+ "<address>678</address>\n"
|
+ "<address>678</address>\n"
|
||||||
+ "</display>\n"
|
+ "</display>\n"
|
||||||
+ "</layout>\n"
|
+ "</layout>\n"
|
||||||
|
+ "<layout>\n"
|
||||||
|
+ "<state>99</state> \n"
|
||||||
|
+ "<display enabled=\"true\" defaultDisplay=\"true\" "
|
||||||
|
+ "refreshRateZoneId=\"zone1\">\n"
|
||||||
|
+ "<address>345</address>\n"
|
||||||
|
+ "<position>front</position>\n"
|
||||||
|
+ "<brightnessThrottlingMapId>brightness1</brightnessThrottlingMapId>\n"
|
||||||
|
+ "<refreshRateThermalThrottlingMapId>"
|
||||||
|
+ "rr1"
|
||||||
|
+ "</refreshRateThermalThrottlingMapId>"
|
||||||
|
+ "</display>\n"
|
||||||
|
+ "<display enabled=\"false\" displayGroup=\"group1\" "
|
||||||
|
+ "refreshRateZoneId=\"zone2\">\n"
|
||||||
|
+ "<address>678</address>\n"
|
||||||
|
+ "<position>rear</position>\n"
|
||||||
|
+ "<brightnessThrottlingMapId>brightness2</brightnessThrottlingMapId>\n"
|
||||||
|
+ "<refreshRateThermalThrottlingMapId>"
|
||||||
|
+ "rr2"
|
||||||
|
+ "</refreshRateThermalThrottlingMapId>"
|
||||||
|
+ "</display>\n"
|
||||||
|
+ "</layout>\n"
|
||||||
+ "</layouts>\n";
|
+ "</layouts>\n";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -60,8 +60,8 @@ import android.view.Display;
|
|||||||
import android.view.DisplayAddress;
|
import android.view.DisplayAddress;
|
||||||
import android.view.DisplayInfo;
|
import android.view.DisplayInfo;
|
||||||
|
|
||||||
|
import androidx.test.ext.junit.runners.AndroidJUnit4;
|
||||||
import androidx.test.filters.SmallTest;
|
import androidx.test.filters.SmallTest;
|
||||||
import androidx.test.runner.AndroidJUnit4;
|
|
||||||
|
|
||||||
import com.android.server.display.layout.DisplayIdProducer;
|
import com.android.server.display.layout.DisplayIdProducer;
|
||||||
import com.android.server.display.layout.Layout;
|
import com.android.server.display.layout.Layout;
|
||||||
@@ -300,14 +300,8 @@ public class LogicalDisplayMapperTest {
|
|||||||
add(device2);
|
add(device2);
|
||||||
|
|
||||||
Layout layout1 = new Layout();
|
Layout layout1 = new Layout();
|
||||||
layout1.createDisplayLocked(info(device1).address, /* isDefault= */ true,
|
createDefaultDisplay(layout1, device1);
|
||||||
/* isEnabled= */ true, /* displayGroup= */ null, mIdProducer,
|
createNonDefaultDisplay(layout1, device2, /* enabled= */ true, /* group= */ null);
|
||||||
/* brightnessThrottlingMapId= */ null,
|
|
||||||
/* leadDisplayId= */ Display.DEFAULT_DISPLAY);
|
|
||||||
layout1.createDisplayLocked(info(device2).address, /* isDefault= */ false,
|
|
||||||
/* isEnabled= */ true, /* displayGroup= */ null, mIdProducer,
|
|
||||||
/* brightnessThrottlingMapId= */ null,
|
|
||||||
/* leadDisplayId= */ Display.DEFAULT_DISPLAY);
|
|
||||||
when(mDeviceStateToLayoutMapSpy.get(STATE_DEFAULT)).thenReturn(layout1);
|
when(mDeviceStateToLayoutMapSpy.get(STATE_DEFAULT)).thenReturn(layout1);
|
||||||
assertThat(layout1.size()).isEqualTo(2);
|
assertThat(layout1.size()).isEqualTo(2);
|
||||||
final int logicalId2 = layout1.getByAddress(info(device2).address).getLogicalDisplayId();
|
final int logicalId2 = layout1.getByAddress(info(device2).address).getLogicalDisplayId();
|
||||||
@@ -340,23 +334,14 @@ public class LogicalDisplayMapperTest {
|
|||||||
add(device3);
|
add(device3);
|
||||||
|
|
||||||
Layout layout1 = new Layout();
|
Layout layout1 = new Layout();
|
||||||
layout1.createDisplayLocked(info(device1).address, /* isDefault= */ true,
|
createDefaultDisplay(layout1, device1);
|
||||||
/* isEnabled= */ true, /* displayGroup= */ null, mIdProducer,
|
|
||||||
/* brightnessThrottlingMapId= */ null,
|
|
||||||
/* leadDisplayId= */ Display.DEFAULT_DISPLAY);
|
|
||||||
when(mDeviceStateToLayoutMapSpy.get(STATE_DEFAULT)).thenReturn(layout1);
|
when(mDeviceStateToLayoutMapSpy.get(STATE_DEFAULT)).thenReturn(layout1);
|
||||||
|
|
||||||
final int layoutState2 = 2;
|
final int layoutState2 = 2;
|
||||||
Layout layout2 = new Layout();
|
Layout layout2 = new Layout();
|
||||||
layout2.createDisplayLocked(info(device2).address, /* isDefault= */ false,
|
createNonDefaultDisplay(layout2, device2, /* enabled= */ true, /* group= */ null);
|
||||||
/* isEnabled= */ true, /* displayGroup= */ null, mIdProducer,
|
|
||||||
/* brightnessThrottlingMapId= */ null,
|
|
||||||
/* leadDisplayId= */ Display.DEFAULT_DISPLAY);
|
|
||||||
// Device3 is the default display.
|
// Device3 is the default display.
|
||||||
layout2.createDisplayLocked(info(device3).address, /* isDefault= */ true,
|
createDefaultDisplay(layout2, device3);
|
||||||
/* isEnabled= */ true, /* displayGroup= */ null, mIdProducer,
|
|
||||||
/* brightnessThrottlingMapId= */ null,
|
|
||||||
/* leadDisplayId= */ Display.DEFAULT_DISPLAY);
|
|
||||||
when(mDeviceStateToLayoutMapSpy.get(layoutState2)).thenReturn(layout2);
|
when(mDeviceStateToLayoutMapSpy.get(layoutState2)).thenReturn(layout2);
|
||||||
assertThat(layout2.size()).isEqualTo(2);
|
assertThat(layout2.size()).isEqualTo(2);
|
||||||
final int logicalId2 = layout2.getByAddress(info(device2).address).getLogicalDisplayId();
|
final int logicalId2 = layout2.getByAddress(info(device2).address).getLogicalDisplayId();
|
||||||
@@ -398,22 +383,11 @@ public class LogicalDisplayMapperTest {
|
|||||||
FLAG_ALLOWED_TO_BE_DEFAULT_DISPLAY);
|
FLAG_ALLOWED_TO_BE_DEFAULT_DISPLAY);
|
||||||
|
|
||||||
Layout layout = new Layout();
|
Layout layout = new Layout();
|
||||||
layout.createDisplayLocked(info(device1).address,
|
createDefaultDisplay(layout, device1);
|
||||||
/* isDefault= */ true, /* isEnabled= */ true, /* displayGroup= */ null,
|
createNonDefaultDisplay(layout, device2, /* enabled= */ true, /* group= */ "group1");
|
||||||
mIdProducer, /* brightnessThrottlingMapId= */ null,
|
createNonDefaultDisplay(layout, device3, /* enabled= */ true, /* group= */ "group1");
|
||||||
/* leadDisplayId= */ Display.DEFAULT_DISPLAY);
|
createNonDefaultDisplay(layout, device4, /* enabled= */ true, /* group= */ "group2");
|
||||||
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);
|
|
||||||
when(mDeviceStateToLayoutMapSpy.get(STATE_DEFAULT)).thenReturn(layout);
|
when(mDeviceStateToLayoutMapSpy.get(STATE_DEFAULT)).thenReturn(layout);
|
||||||
|
|
||||||
LogicalDisplay display1 = add(device1);
|
LogicalDisplay display1 = add(device1);
|
||||||
@@ -629,23 +603,21 @@ public class LogicalDisplayMapperTest {
|
|||||||
Layout layout = new Layout();
|
Layout layout = new Layout();
|
||||||
layout.createDisplayLocked(device1.getDisplayDeviceInfoLocked().address,
|
layout.createDisplayLocked(device1.getDisplayDeviceInfoLocked().address,
|
||||||
/* isDefault= */ true, /* isEnabled= */ true, /* displayGroup= */ null,
|
/* isDefault= */ true, /* isEnabled= */ true, /* displayGroup= */ null,
|
||||||
mIdProducer, /* brightnessThrottlingMapId= */ "concurrent",
|
mIdProducer, POSITION_UNKNOWN,
|
||||||
/* leadDisplayId= */ Display.DEFAULT_DISPLAY);
|
/* leadDisplayId= */ Display.DEFAULT_DISPLAY,
|
||||||
|
/* brightnessThrottlingMapId= */ "concurrent",
|
||||||
|
/* refreshRateZoneId= */ null, /* refreshRateThermalThrottlingMapId= */ null);
|
||||||
layout.createDisplayLocked(device2.getDisplayDeviceInfoLocked().address,
|
layout.createDisplayLocked(device2.getDisplayDeviceInfoLocked().address,
|
||||||
/* isDefault= */ false, /* isEnabled= */ true, /* displayGroup= */ null,
|
/* isDefault= */ false, /* isEnabled= */ true, /* displayGroup= */ null,
|
||||||
mIdProducer, /* brightnessThrottlingMapId= */ "concurrent",
|
mIdProducer, POSITION_UNKNOWN,
|
||||||
/* leadDisplayId= */ Display.DEFAULT_DISPLAY);
|
/* leadDisplayId= */ Display.DEFAULT_DISPLAY,
|
||||||
|
/* brightnessThrottlingMapId= */ "concurrent",
|
||||||
|
/* refreshRateZoneId= */ null, /* refreshRateThermalThrottlingMapId= */ null);
|
||||||
when(mDeviceStateToLayoutMapSpy.get(0)).thenReturn(layout);
|
when(mDeviceStateToLayoutMapSpy.get(0)).thenReturn(layout);
|
||||||
|
|
||||||
layout = new Layout();
|
layout = new Layout();
|
||||||
layout.createDisplayLocked(device1.getDisplayDeviceInfoLocked().address,
|
createNonDefaultDisplay(layout, device1, /* enabled= */ false, /* group= */ null);
|
||||||
/* isDefault= */ false, /* isEnabled= */ false, /* displayGroup= */ null,
|
createDefaultDisplay(layout, device2);
|
||||||
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);
|
|
||||||
when(mDeviceStateToLayoutMapSpy.get(1)).thenReturn(layout);
|
when(mDeviceStateToLayoutMapSpy.get(1)).thenReturn(layout);
|
||||||
when(mDeviceStateToLayoutMapSpy.get(2)).thenReturn(layout);
|
when(mDeviceStateToLayoutMapSpy.get(2)).thenReturn(layout);
|
||||||
|
|
||||||
@@ -722,30 +694,11 @@ public class LogicalDisplayMapperTest {
|
|||||||
TYPE_INTERNAL, 600, 900, DisplayDeviceInfo.FLAG_OWN_DISPLAY_GROUP);
|
TYPE_INTERNAL, 600, 900, DisplayDeviceInfo.FLAG_OWN_DISPLAY_GROUP);
|
||||||
|
|
||||||
Layout threeDevicesEnabledLayout = new Layout();
|
Layout threeDevicesEnabledLayout = new Layout();
|
||||||
threeDevicesEnabledLayout.createDisplayLocked(
|
createDefaultDisplay(threeDevicesEnabledLayout, displayAddressOne);
|
||||||
displayAddressOne,
|
createNonDefaultDisplay(threeDevicesEnabledLayout, displayAddressTwo,
|
||||||
/* isDefault= */ true,
|
/* enabled= */ true, /* group= */ null);
|
||||||
/* isEnabled= */ true,
|
createNonDefaultDisplay(threeDevicesEnabledLayout, displayAddressThree,
|
||||||
/* displayGroup= */ null,
|
/* enabled= */ true, /* group= */ 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);
|
|
||||||
|
|
||||||
when(mDeviceStateToLayoutMapSpy.get(STATE_DEFAULT))
|
when(mDeviceStateToLayoutMapSpy.get(STATE_DEFAULT))
|
||||||
.thenReturn(threeDevicesEnabledLayout);
|
.thenReturn(threeDevicesEnabledLayout);
|
||||||
@@ -776,30 +729,11 @@ public class LogicalDisplayMapperTest {
|
|||||||
/* includeDisabled= */ false));
|
/* includeDisabled= */ false));
|
||||||
|
|
||||||
Layout oneDeviceEnabledLayout = new Layout();
|
Layout oneDeviceEnabledLayout = new Layout();
|
||||||
oneDeviceEnabledLayout.createDisplayLocked(
|
createDefaultDisplay(oneDeviceEnabledLayout, displayAddressOne);
|
||||||
displayAddressOne,
|
createNonDefaultDisplay(oneDeviceEnabledLayout, displayAddressTwo,
|
||||||
/* isDefault= */ true,
|
/* enabled= */ false, /* group= */ null);
|
||||||
/* isEnabled= */ true,
|
createNonDefaultDisplay(oneDeviceEnabledLayout, displayAddressThree,
|
||||||
/* displayGroup= */ null,
|
/* enabled= */ false, /* group= */ 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);
|
|
||||||
|
|
||||||
when(mDeviceStateToLayoutMapSpy.get(0)).thenReturn(oneDeviceEnabledLayout);
|
when(mDeviceStateToLayoutMapSpy.get(0)).thenReturn(oneDeviceEnabledLayout);
|
||||||
when(mDeviceStateToLayoutMapSpy.get(1)).thenReturn(threeDevicesEnabledLayout);
|
when(mDeviceStateToLayoutMapSpy.get(1)).thenReturn(threeDevicesEnabledLayout);
|
||||||
@@ -873,12 +807,13 @@ public class LogicalDisplayMapperTest {
|
|||||||
FLAG_REAR);
|
FLAG_REAR);
|
||||||
|
|
||||||
Layout layout = new Layout();
|
Layout layout = new Layout();
|
||||||
layout.createDisplayLocked(device1.getDisplayDeviceInfoLocked().address,
|
layout.createDefaultDisplayLocked(device1.getDisplayDeviceInfoLocked().address,
|
||||||
true, true, null, mIdProducer, /* brightnessThrottlingMapId= */ null,
|
mIdProducer);
|
||||||
/* leadDisplayId= */ Display.DEFAULT_DISPLAY);
|
|
||||||
layout.createDisplayLocked(device2.getDisplayDeviceInfoLocked().address,
|
layout.createDisplayLocked(device2.getDisplayDeviceInfoLocked().address,
|
||||||
false, true, null, mIdProducer, /* brightnessThrottlingMapId= */ null,
|
/* isDefault= */ false, /* isEnabled= */ true, /* displayGroupName= */ null,
|
||||||
POSITION_REAR, Display.DEFAULT_DISPLAY);
|
mIdProducer, POSITION_REAR, Display.DEFAULT_DISPLAY,
|
||||||
|
/* brightnessThrottlingMapId= */ null, /* refreshRateZoneId= */ null,
|
||||||
|
/* refreshRateThermalThrottlingMapId= */null);
|
||||||
when(mDeviceStateToLayoutMapSpy.get(0)).thenReturn(layout);
|
when(mDeviceStateToLayoutMapSpy.get(0)).thenReturn(layout);
|
||||||
|
|
||||||
when(mDeviceStateToLayoutMapSpy.size()).thenReturn(1);
|
when(mDeviceStateToLayoutMapSpy.size()).thenReturn(1);
|
||||||
@@ -910,6 +845,27 @@ public class LogicalDisplayMapperTest {
|
|||||||
// Helper Methods
|
// 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) {
|
private void advanceTime(long timeMs) {
|
||||||
mLooper.moveTimeForward(1000);
|
mLooper.moveTimeForward(1000);
|
||||||
mLooper.dispatchAll();
|
mLooper.dispatchAll();
|
||||||
|
|||||||
Reference in New Issue
Block a user