Merge "WindowManager#getPossibleMaximumWindowMetrics for disabled displays" into tm-qpr-dev
This commit is contained in:
committed by
Android (Google) Code Review
commit
99970b1959
@@ -3652,44 +3652,21 @@ public final class DisplayManagerService extends SystemService {
|
||||
@Override
|
||||
public Set<DisplayInfo> getPossibleDisplayInfo(int displayId) {
|
||||
synchronized (mSyncRoot) {
|
||||
// Retrieve the group associated with this display id.
|
||||
final int displayGroupId =
|
||||
mLogicalDisplayMapper.getDisplayGroupIdFromDisplayIdLocked(displayId);
|
||||
if (displayGroupId == Display.INVALID_DISPLAY_GROUP) {
|
||||
Slog.w(TAG,
|
||||
"Can't get possible display info since display group for " + displayId
|
||||
+ " does not exist");
|
||||
return new ArraySet<>();
|
||||
}
|
||||
|
||||
// Assume any display in this group can be swapped out for the given display id.
|
||||
Set<DisplayInfo> possibleInfo = new ArraySet<>();
|
||||
final DisplayGroup group = mLogicalDisplayMapper.getDisplayGroupLocked(
|
||||
displayGroupId);
|
||||
for (int i = 0; i < group.getSizeLocked(); i++) {
|
||||
final int id = group.getIdLocked(i);
|
||||
final LogicalDisplay logical = mLogicalDisplayMapper.getDisplayLocked(id);
|
||||
if (logical == null) {
|
||||
Slog.w(TAG,
|
||||
"Can't get possible display info since logical display for "
|
||||
+ "display id " + id + " does not exist, as part of group "
|
||||
+ displayGroupId);
|
||||
} else {
|
||||
possibleInfo.add(logical.getDisplayInfoLocked());
|
||||
}
|
||||
}
|
||||
|
||||
// For the supported device states, retrieve the DisplayInfos for the logical
|
||||
// display layout.
|
||||
// For each of supported device states, retrieve the display layout of that state,
|
||||
// and return all of the DisplayInfos (one per state) for the given display id.
|
||||
if (mDeviceStateManager == null) {
|
||||
Slog.w(TAG, "Can't get supported states since DeviceStateManager not ready");
|
||||
} else {
|
||||
final int[] supportedStates =
|
||||
mDeviceStateManager.getSupportedStateIdentifiers();
|
||||
for (int state : supportedStates) {
|
||||
possibleInfo.addAll(
|
||||
mLogicalDisplayMapper.getDisplayInfoForStateLocked(state, displayId,
|
||||
displayGroupId));
|
||||
return possibleInfo;
|
||||
}
|
||||
final int[] supportedStates =
|
||||
mDeviceStateManager.getSupportedStateIdentifiers();
|
||||
DisplayInfo displayInfo;
|
||||
for (int state : supportedStates) {
|
||||
displayInfo = mLogicalDisplayMapper.getDisplayInfoForStateLocked(state,
|
||||
displayId);
|
||||
if (displayInfo != null) {
|
||||
possibleInfo.add(displayInfo);
|
||||
}
|
||||
}
|
||||
return possibleInfo;
|
||||
|
||||
@@ -19,6 +19,7 @@ package com.android.server.display;
|
||||
import static android.view.Display.DEFAULT_DISPLAY;
|
||||
|
||||
import android.annotation.NonNull;
|
||||
import android.annotation.Nullable;
|
||||
import android.content.Context;
|
||||
import android.hardware.devicestate.DeviceStateManager;
|
||||
import android.os.Handler;
|
||||
@@ -28,7 +29,6 @@ import android.os.PowerManager;
|
||||
import android.os.SystemClock;
|
||||
import android.os.SystemProperties;
|
||||
import android.text.TextUtils;
|
||||
import android.util.ArraySet;
|
||||
import android.util.IndentingPrintWriter;
|
||||
import android.util.Slog;
|
||||
import android.util.SparseArray;
|
||||
@@ -43,7 +43,6 @@ import com.android.server.display.layout.Layout;
|
||||
|
||||
import java.io.PrintWriter;
|
||||
import java.util.Arrays;
|
||||
import java.util.Set;
|
||||
import java.util.function.Consumer;
|
||||
|
||||
/**
|
||||
@@ -304,58 +303,44 @@ class LogicalDisplayMapper implements DisplayDeviceRepository.Listener {
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the set of {@link DisplayInfo} for this device state, only fetching the info that is
|
||||
* part of the same display group as the provided display id. The DisplayInfo represent the
|
||||
* logical display layouts possible for the given device state.
|
||||
* Returns the {@link DisplayInfo} for this device state, indicated by the given display id. The
|
||||
* DisplayInfo represents the attributes of the indicated display in the layout associated with
|
||||
* this state. This is used to get display information for various displays in various states;
|
||||
* e.g. to help apps preload resources for the possible display states.
|
||||
*
|
||||
* @param deviceState the state to query possible layouts for
|
||||
* @param displayId the display id to apply to all displays within the group
|
||||
* @param groupId the display group to filter display info for. Must be the same group as
|
||||
* the display with the provided display id.
|
||||
* @param displayId the display id to retrieve
|
||||
* @return {@code null} if no corresponding {@link DisplayInfo} could be found, or the
|
||||
* {@link DisplayInfo} with a matching display id.
|
||||
*/
|
||||
public Set<DisplayInfo> getDisplayInfoForStateLocked(int deviceState, int displayId,
|
||||
int groupId) {
|
||||
Set<DisplayInfo> displayInfos = new ArraySet<>();
|
||||
@Nullable
|
||||
public DisplayInfo getDisplayInfoForStateLocked(int deviceState, int displayId) {
|
||||
// Retrieve the layout for this particular state.
|
||||
final Layout layout = mDeviceStateToLayoutMap.get(deviceState);
|
||||
final int layoutSize = layout.size();
|
||||
for (int i = 0; i < layoutSize; i++) {
|
||||
Layout.Display displayLayout = layout.getAt(i);
|
||||
if (displayLayout == null) {
|
||||
continue;
|
||||
}
|
||||
|
||||
// If the underlying display-device we want to use for this display
|
||||
// doesn't exist, then skip it. This can happen at startup as display-devices
|
||||
// trickle in one at a time. When the new display finally shows up, the layout is
|
||||
// recalculated so that the display is properly added to the current layout.
|
||||
final DisplayAddress address = displayLayout.getAddress();
|
||||
final DisplayDevice device = mDisplayDeviceRepo.getByAddressLocked(address);
|
||||
if (device == null) {
|
||||
Slog.w(TAG, "The display device (" + address + "), is not available"
|
||||
+ " for the display state " + deviceState);
|
||||
continue;
|
||||
}
|
||||
|
||||
// Find or create the LogicalDisplay to map the DisplayDevice to.
|
||||
final int logicalDisplayId = displayLayout.getLogicalDisplayId();
|
||||
final LogicalDisplay logicalDisplay = getDisplayLocked(logicalDisplayId);
|
||||
if (logicalDisplay == null) {
|
||||
Slog.w(TAG, "The logical display (" + address + "), is not available"
|
||||
+ " for the display state " + deviceState);
|
||||
continue;
|
||||
}
|
||||
final DisplayInfo temp = logicalDisplay.getDisplayInfoLocked();
|
||||
DisplayInfo displayInfo = new DisplayInfo(temp);
|
||||
if (displayInfo.displayGroupId != groupId) {
|
||||
// Ignore any displays not in the provided group.
|
||||
continue;
|
||||
}
|
||||
// A display in the same group can be swapped out at any point, so set the display id
|
||||
// for all results to the provided display id.
|
||||
displayInfo.displayId = displayId;
|
||||
displayInfos.add(displayInfo);
|
||||
if (layout == null) {
|
||||
return null;
|
||||
}
|
||||
return displayInfos;
|
||||
// Retrieve the details of the given display within this layout.
|
||||
Layout.Display display = layout.getById(displayId);
|
||||
if (display == null) {
|
||||
return null;
|
||||
}
|
||||
// Retrieve the display info for the display that matches the display id.
|
||||
final DisplayDevice device = mDisplayDeviceRepo.getByAddressLocked(display.getAddress());
|
||||
if (device == null) {
|
||||
Slog.w(TAG, "The display device (" + display.getAddress() + "), is not available"
|
||||
+ " for the display state " + mDeviceState);
|
||||
return null;
|
||||
}
|
||||
LogicalDisplay logicalDisplay = getDisplayLocked(device, /* includeDisabled= */ true);
|
||||
if (logicalDisplay == null) {
|
||||
Slog.w(TAG, "The logical display associated with address (" + display.getAddress()
|
||||
+ "), is not available for the display state " + mDeviceState);
|
||||
return null;
|
||||
}
|
||||
DisplayInfo displayInfo = new DisplayInfo(logicalDisplay.getDisplayInfoLocked());
|
||||
displayInfo.displayId = displayId;
|
||||
return displayInfo;
|
||||
}
|
||||
|
||||
public void dumpLocked(PrintWriter pw) {
|
||||
|
||||
@@ -18,10 +18,14 @@ package com.android.server.display;
|
||||
|
||||
import static android.view.Display.DEFAULT_DISPLAY;
|
||||
import static android.view.Display.DEFAULT_DISPLAY_GROUP;
|
||||
import static android.view.Display.TYPE_INTERNAL;
|
||||
import static android.view.Display.TYPE_VIRTUAL;
|
||||
|
||||
import static com.android.server.display.DeviceStateToLayoutMap.STATE_DEFAULT;
|
||||
import static com.android.server.display.DisplayAdapter.DISPLAY_DEVICE_EVENT_ADDED;
|
||||
import static com.android.server.display.DisplayAdapter.DISPLAY_DEVICE_EVENT_CHANGED;
|
||||
import static com.android.server.display.DisplayAdapter.DISPLAY_DEVICE_EVENT_REMOVED;
|
||||
import static com.android.server.display.DisplayDeviceInfo.FLAG_ALLOWED_TO_BE_DEFAULT_DISPLAY;
|
||||
import static com.android.server.display.LogicalDisplayMapper.LOGICAL_DISPLAY_EVENT_ADDED;
|
||||
import static com.android.server.display.LogicalDisplayMapper.LOGICAL_DISPLAY_EVENT_REMOVED;
|
||||
|
||||
@@ -69,7 +73,6 @@ import org.mockito.Spy;
|
||||
import java.io.InputStream;
|
||||
import java.io.OutputStream;
|
||||
import java.util.Arrays;
|
||||
import java.util.Set;
|
||||
|
||||
@SmallTest
|
||||
@Presubmit
|
||||
@@ -151,8 +154,8 @@ public class LogicalDisplayMapperTest {
|
||||
|
||||
@Test
|
||||
public void testDisplayDeviceAddAndRemove_Internal() {
|
||||
DisplayDevice device = createDisplayDevice(Display.TYPE_INTERNAL, 600, 800,
|
||||
DisplayDeviceInfo.FLAG_ALLOWED_TO_BE_DEFAULT_DISPLAY);
|
||||
DisplayDevice device = createDisplayDevice(TYPE_INTERNAL, 600, 800,
|
||||
FLAG_ALLOWED_TO_BE_DEFAULT_DISPLAY);
|
||||
|
||||
// add
|
||||
LogicalDisplay displayAdded = add(device);
|
||||
@@ -173,7 +176,7 @@ public class LogicalDisplayMapperTest {
|
||||
testDisplayDeviceAddAndRemove_NonInternal(Display.TYPE_EXTERNAL);
|
||||
testDisplayDeviceAddAndRemove_NonInternal(Display.TYPE_WIFI);
|
||||
testDisplayDeviceAddAndRemove_NonInternal(Display.TYPE_OVERLAY);
|
||||
testDisplayDeviceAddAndRemove_NonInternal(Display.TYPE_VIRTUAL);
|
||||
testDisplayDeviceAddAndRemove_NonInternal(TYPE_VIRTUAL);
|
||||
testDisplayDeviceAddAndRemove_NonInternal(Display.TYPE_UNKNOWN);
|
||||
|
||||
// Call the internal test again, just to verify that adding non-internal displays
|
||||
@@ -183,9 +186,9 @@ public class LogicalDisplayMapperTest {
|
||||
|
||||
@Test
|
||||
public void testDisplayDeviceAdd_TwoInternalOneDefault() {
|
||||
DisplayDevice device1 = createDisplayDevice(Display.TYPE_INTERNAL, 600, 800, 0);
|
||||
DisplayDevice device2 = createDisplayDevice(Display.TYPE_INTERNAL, 600, 800,
|
||||
DisplayDeviceInfo.FLAG_ALLOWED_TO_BE_DEFAULT_DISPLAY);
|
||||
DisplayDevice device1 = createDisplayDevice(TYPE_INTERNAL, 600, 800, 0);
|
||||
DisplayDevice device2 = createDisplayDevice(TYPE_INTERNAL, 600, 800,
|
||||
FLAG_ALLOWED_TO_BE_DEFAULT_DISPLAY);
|
||||
|
||||
LogicalDisplay display1 = add(device1);
|
||||
assertEquals(info(display1).address, info(device1).address);
|
||||
@@ -198,10 +201,10 @@ public class LogicalDisplayMapperTest {
|
||||
|
||||
@Test
|
||||
public void testDisplayDeviceAdd_TwoInternalBothDefault() {
|
||||
DisplayDevice device1 = createDisplayDevice(Display.TYPE_INTERNAL, 600, 800,
|
||||
DisplayDeviceInfo.FLAG_ALLOWED_TO_BE_DEFAULT_DISPLAY);
|
||||
DisplayDevice device2 = createDisplayDevice(Display.TYPE_INTERNAL, 600, 800,
|
||||
DisplayDeviceInfo.FLAG_ALLOWED_TO_BE_DEFAULT_DISPLAY);
|
||||
DisplayDevice device1 = createDisplayDevice(TYPE_INTERNAL, 600, 800,
|
||||
FLAG_ALLOWED_TO_BE_DEFAULT_DISPLAY);
|
||||
DisplayDevice device2 = createDisplayDevice(TYPE_INTERNAL, 600, 800,
|
||||
FLAG_ALLOWED_TO_BE_DEFAULT_DISPLAY);
|
||||
|
||||
LogicalDisplay display1 = add(device1);
|
||||
assertEquals(info(display1).address, info(device1).address);
|
||||
@@ -216,7 +219,7 @@ public class LogicalDisplayMapperTest {
|
||||
@Test
|
||||
public void testDisplayDeviceAddAndRemove_OneExternalDefault() {
|
||||
DisplayDevice device = createDisplayDevice(Display.TYPE_EXTERNAL, 600, 800,
|
||||
DisplayDeviceInfo.FLAG_ALLOWED_TO_BE_DEFAULT_DISPLAY);
|
||||
FLAG_ALLOWED_TO_BE_DEFAULT_DISPLAY);
|
||||
|
||||
// add
|
||||
LogicalDisplay displayAdded = add(device);
|
||||
@@ -234,10 +237,10 @@ public class LogicalDisplayMapperTest {
|
||||
|
||||
@Test
|
||||
public void testDisplayDeviceAddAndRemove_SwitchDefault() {
|
||||
DisplayDevice device1 = createDisplayDevice(Display.TYPE_INTERNAL, 600, 800,
|
||||
DisplayDeviceInfo.FLAG_ALLOWED_TO_BE_DEFAULT_DISPLAY);
|
||||
DisplayDevice device2 = createDisplayDevice(Display.TYPE_INTERNAL, 600, 800,
|
||||
DisplayDeviceInfo.FLAG_ALLOWED_TO_BE_DEFAULT_DISPLAY);
|
||||
DisplayDevice device1 = createDisplayDevice(TYPE_INTERNAL, 600, 800,
|
||||
FLAG_ALLOWED_TO_BE_DEFAULT_DISPLAY);
|
||||
DisplayDevice device2 = createDisplayDevice(TYPE_INTERNAL, 600, 800,
|
||||
FLAG_ALLOWED_TO_BE_DEFAULT_DISPLAY);
|
||||
|
||||
LogicalDisplay display1 = add(device1);
|
||||
assertEquals(info(display1).address, info(device1).address);
|
||||
@@ -263,10 +266,10 @@ public class LogicalDisplayMapperTest {
|
||||
|
||||
@Test
|
||||
public void testGetDisplayIdsLocked() {
|
||||
add(createDisplayDevice(Display.TYPE_INTERNAL, 600, 800,
|
||||
DisplayDeviceInfo.FLAG_ALLOWED_TO_BE_DEFAULT_DISPLAY));
|
||||
add(createDisplayDevice(TYPE_INTERNAL, 600, 800,
|
||||
FLAG_ALLOWED_TO_BE_DEFAULT_DISPLAY));
|
||||
add(createDisplayDevice(Display.TYPE_EXTERNAL, 600, 800, 0));
|
||||
add(createDisplayDevice(Display.TYPE_VIRTUAL, 600, 800, 0));
|
||||
add(createDisplayDevice(TYPE_VIRTUAL, 600, 800, 0));
|
||||
|
||||
int [] ids = mLogicalDisplayMapper.getDisplayIdsLocked(Process.SYSTEM_UID,
|
||||
/* includeDisabled= */ true);
|
||||
@@ -276,71 +279,98 @@ public class LogicalDisplayMapperTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetDisplayInfoForStateLocked_oneDisplayGroup_internalType() {
|
||||
add(createDisplayDevice(Display.TYPE_INTERNAL, 600, 800,
|
||||
DisplayDeviceInfo.FLAG_ALLOWED_TO_BE_DEFAULT_DISPLAY));
|
||||
add(createDisplayDevice(Display.TYPE_INTERNAL, 200, 800,
|
||||
DisplayDeviceInfo.FLAG_ALLOWED_TO_BE_DEFAULT_DISPLAY));
|
||||
add(createDisplayDevice(Display.TYPE_INTERNAL, 700, 800,
|
||||
DisplayDeviceInfo.FLAG_ALLOWED_TO_BE_DEFAULT_DISPLAY));
|
||||
public void testGetDisplayInfoForStateLocked_defaultLayout() {
|
||||
final DisplayDevice device1 = createDisplayDevice(TYPE_INTERNAL, 600, 800,
|
||||
FLAG_ALLOWED_TO_BE_DEFAULT_DISPLAY);
|
||||
final DisplayDevice device2 = createDisplayDevice(TYPE_INTERNAL, 200, 800,
|
||||
FLAG_ALLOWED_TO_BE_DEFAULT_DISPLAY);
|
||||
|
||||
Set<DisplayInfo> displayInfos = mLogicalDisplayMapper.getDisplayInfoForStateLocked(
|
||||
DeviceStateToLayoutMap.STATE_DEFAULT, DEFAULT_DISPLAY, DEFAULT_DISPLAY_GROUP);
|
||||
assertThat(displayInfos.size()).isEqualTo(1);
|
||||
for (DisplayInfo displayInfo : displayInfos) {
|
||||
assertThat(displayInfo.displayId).isEqualTo(DEFAULT_DISPLAY);
|
||||
assertThat(displayInfo.displayGroupId).isEqualTo(DEFAULT_DISPLAY_GROUP);
|
||||
assertThat(displayInfo.logicalWidth).isEqualTo(600);
|
||||
assertThat(displayInfo.logicalHeight).isEqualTo(800);
|
||||
}
|
||||
add(device1);
|
||||
add(device2);
|
||||
|
||||
Layout layout1 = new Layout();
|
||||
layout1.createDisplayLocked(info(device1).address, /* isDefault= */ true,
|
||||
/* isEnabled= */ true);
|
||||
layout1.createDisplayLocked(info(device2).address, /* isDefault= */ false,
|
||||
/* isEnabled= */ true);
|
||||
when(mDeviceStateToLayoutMapSpy.get(STATE_DEFAULT)).thenReturn(layout1);
|
||||
assertThat(layout1.size()).isEqualTo(2);
|
||||
final int logicalId2 = layout1.getByAddress(info(device2).address).getLogicalDisplayId();
|
||||
|
||||
final DisplayInfo displayInfoDefault = mLogicalDisplayMapper.getDisplayInfoForStateLocked(
|
||||
STATE_DEFAULT, DEFAULT_DISPLAY);
|
||||
assertThat(displayInfoDefault.displayId).isEqualTo(DEFAULT_DISPLAY);
|
||||
assertThat(displayInfoDefault.logicalWidth).isEqualTo(width(device1));
|
||||
assertThat(displayInfoDefault.logicalHeight).isEqualTo(height(device1));
|
||||
|
||||
final DisplayInfo displayInfoOther = mLogicalDisplayMapper.getDisplayInfoForStateLocked(
|
||||
STATE_DEFAULT, logicalId2);
|
||||
assertThat(displayInfoOther).isNotNull();
|
||||
assertThat(displayInfoOther.displayId).isEqualTo(logicalId2);
|
||||
assertThat(displayInfoOther.logicalWidth).isEqualTo(width(device2));
|
||||
assertThat(displayInfoOther.logicalHeight).isEqualTo(height(device2));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetDisplayInfoForStateLocked_oneDisplayGroup_differentTypes() {
|
||||
add(createDisplayDevice(Display.TYPE_INTERNAL, 600, 800,
|
||||
DisplayDeviceInfo.FLAG_ALLOWED_TO_BE_DEFAULT_DISPLAY));
|
||||
add(createDisplayDevice(Display.TYPE_INTERNAL, 200, 800,
|
||||
DisplayDeviceInfo.FLAG_ALLOWED_TO_BE_DEFAULT_DISPLAY));
|
||||
add(createDisplayDevice(Display.TYPE_EXTERNAL, 700, 800,
|
||||
DisplayDeviceInfo.FLAG_ALLOWED_TO_BE_DEFAULT_DISPLAY));
|
||||
public void testGetDisplayInfoForStateLocked_multipleLayouts() {
|
||||
final DisplayDevice device1 = createDisplayDevice(TYPE_INTERNAL, 600, 800,
|
||||
FLAG_ALLOWED_TO_BE_DEFAULT_DISPLAY);
|
||||
final DisplayDevice device2 = createDisplayDevice(TYPE_INTERNAL, 200, 800,
|
||||
FLAG_ALLOWED_TO_BE_DEFAULT_DISPLAY);
|
||||
final DisplayDevice device3 = createDisplayDevice(TYPE_VIRTUAL, 700, 800,
|
||||
DisplayDeviceInfo.FLAG_OWN_DISPLAY_GROUP);
|
||||
|
||||
Set<DisplayInfo> displayInfos = mLogicalDisplayMapper.getDisplayInfoForStateLocked(
|
||||
DeviceStateToLayoutMap.STATE_DEFAULT, DEFAULT_DISPLAY, DEFAULT_DISPLAY_GROUP);
|
||||
assertThat(displayInfos.size()).isEqualTo(1);
|
||||
for (DisplayInfo displayInfo : displayInfos) {
|
||||
assertThat(displayInfo.displayId).isEqualTo(DEFAULT_DISPLAY);
|
||||
assertThat(displayInfo.displayGroupId).isEqualTo(DEFAULT_DISPLAY_GROUP);
|
||||
assertThat(displayInfo.logicalWidth).isEqualTo(600);
|
||||
assertThat(displayInfo.logicalHeight).isEqualTo(800);
|
||||
}
|
||||
}
|
||||
add(device1);
|
||||
add(device2);
|
||||
add(device3);
|
||||
|
||||
@Test
|
||||
public void testGetDisplayInfoForStateLocked_multipleDisplayGroups_defaultGroup() {
|
||||
add(createDisplayDevice(Display.TYPE_INTERNAL, 600, 800,
|
||||
DisplayDeviceInfo.FLAG_ALLOWED_TO_BE_DEFAULT_DISPLAY));
|
||||
add(createDisplayDevice(Display.TYPE_INTERNAL, 200, 800,
|
||||
DisplayDeviceInfo.FLAG_ALLOWED_TO_BE_DEFAULT_DISPLAY));
|
||||
add(createDisplayDevice(Display.TYPE_VIRTUAL, 700, 800,
|
||||
DisplayDeviceInfo.FLAG_OWN_DISPLAY_GROUP));
|
||||
Layout layout1 = new Layout();
|
||||
layout1.createDisplayLocked(info(device1).address,
|
||||
/* isDefault= */ true, /* isEnabled= */ true);
|
||||
when(mDeviceStateToLayoutMapSpy.get(STATE_DEFAULT)).thenReturn(layout1);
|
||||
|
||||
Set<DisplayInfo> displayInfos = mLogicalDisplayMapper.getDisplayInfoForStateLocked(
|
||||
DeviceStateToLayoutMap.STATE_DEFAULT, DEFAULT_DISPLAY, DEFAULT_DISPLAY_GROUP);
|
||||
assertThat(displayInfos.size()).isEqualTo(1);
|
||||
for (DisplayInfo displayInfo : displayInfos) {
|
||||
assertThat(displayInfo.displayId).isEqualTo(DEFAULT_DISPLAY);
|
||||
assertThat(displayInfo.displayGroupId).isEqualTo(DEFAULT_DISPLAY_GROUP);
|
||||
assertThat(displayInfo.logicalWidth).isEqualTo(600);
|
||||
assertThat(displayInfo.logicalHeight).isEqualTo(800);
|
||||
}
|
||||
final int layoutState2 = 2;
|
||||
Layout layout2 = new Layout();
|
||||
layout2.createDisplayLocked(info(device2).address,
|
||||
/* isDefault= */ false, /* isEnabled= */ true);
|
||||
// Device3 is the default display.
|
||||
layout2.createDisplayLocked(info(device3).address,
|
||||
/* isDefault= */ true, /* isEnabled= */ true);
|
||||
when(mDeviceStateToLayoutMapSpy.get(layoutState2)).thenReturn(layout2);
|
||||
assertThat(layout2.size()).isEqualTo(2);
|
||||
final int logicalId2 = layout2.getByAddress(info(device2).address).getLogicalDisplayId();
|
||||
|
||||
// Default layout.
|
||||
final DisplayInfo displayInfoLayout1Default =
|
||||
mLogicalDisplayMapper.getDisplayInfoForStateLocked(
|
||||
STATE_DEFAULT, DEFAULT_DISPLAY);
|
||||
assertThat(displayInfoLayout1Default.displayId).isEqualTo(DEFAULT_DISPLAY);
|
||||
assertThat(displayInfoLayout1Default.logicalWidth).isEqualTo(width(device1));
|
||||
assertThat(displayInfoLayout1Default.logicalHeight).isEqualTo(height(device1));
|
||||
|
||||
// Second layout, where device3 is the default display.
|
||||
final DisplayInfo displayInfoLayout2Default =
|
||||
mLogicalDisplayMapper.getDisplayInfoForStateLocked(
|
||||
layoutState2, DEFAULT_DISPLAY);
|
||||
assertThat(displayInfoLayout2Default.displayId).isEqualTo(DEFAULT_DISPLAY);
|
||||
assertThat(displayInfoLayout2Default.logicalWidth).isEqualTo(width(device3));
|
||||
assertThat(displayInfoLayout2Default.logicalHeight).isEqualTo(height(device3));
|
||||
|
||||
final DisplayInfo displayInfoLayout2Other =
|
||||
mLogicalDisplayMapper.getDisplayInfoForStateLocked(
|
||||
layoutState2, logicalId2);
|
||||
assertThat(displayInfoLayout2Other).isNotNull();
|
||||
assertThat(displayInfoLayout2Other.displayId).isEqualTo(logicalId2);
|
||||
assertThat(displayInfoLayout2Other.logicalWidth).isEqualTo(width(device2));
|
||||
assertThat(displayInfoLayout2Other.logicalHeight).isEqualTo(height(device2));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testSingleDisplayGroup() {
|
||||
LogicalDisplay display1 = add(createDisplayDevice(Display.TYPE_INTERNAL, 600, 800,
|
||||
DisplayDeviceInfo.FLAG_ALLOWED_TO_BE_DEFAULT_DISPLAY));
|
||||
LogicalDisplay display2 = add(createDisplayDevice(Display.TYPE_INTERNAL, 600, 800, 0));
|
||||
LogicalDisplay display3 = add(createDisplayDevice(Display.TYPE_VIRTUAL, 600, 800, 0));
|
||||
LogicalDisplay display1 = add(createDisplayDevice(TYPE_INTERNAL, 600, 800,
|
||||
FLAG_ALLOWED_TO_BE_DEFAULT_DISPLAY));
|
||||
LogicalDisplay display2 = add(createDisplayDevice(TYPE_INTERNAL, 600, 800, 0));
|
||||
LogicalDisplay display3 = add(createDisplayDevice(TYPE_VIRTUAL, 600, 800, 0));
|
||||
|
||||
assertEquals(DEFAULT_DISPLAY_GROUP,
|
||||
mLogicalDisplayMapper.getDisplayGroupIdFromDisplayIdLocked(id(display1)));
|
||||
@@ -352,12 +382,12 @@ public class LogicalDisplayMapperTest {
|
||||
|
||||
@Test
|
||||
public void testMultipleDisplayGroups() {
|
||||
LogicalDisplay display1 = add(createDisplayDevice(Display.TYPE_INTERNAL, 600, 800,
|
||||
DisplayDeviceInfo.FLAG_ALLOWED_TO_BE_DEFAULT_DISPLAY));
|
||||
LogicalDisplay display2 = add(createDisplayDevice(Display.TYPE_INTERNAL, 600, 800, 0));
|
||||
LogicalDisplay display1 = add(createDisplayDevice(TYPE_INTERNAL, 600, 800,
|
||||
FLAG_ALLOWED_TO_BE_DEFAULT_DISPLAY));
|
||||
LogicalDisplay display2 = add(createDisplayDevice(TYPE_INTERNAL, 600, 800, 0));
|
||||
|
||||
|
||||
TestDisplayDevice device3 = createDisplayDevice(Display.TYPE_VIRTUAL, 600, 800,
|
||||
TestDisplayDevice device3 = createDisplayDevice(TYPE_VIRTUAL, 600, 800,
|
||||
DisplayDeviceInfo.FLAG_OWN_DISPLAY_GROUP);
|
||||
LogicalDisplay display3 = add(device3);
|
||||
|
||||
@@ -423,10 +453,10 @@ public class LogicalDisplayMapperTest {
|
||||
|
||||
@Test
|
||||
public void testDeviceStateLocked() {
|
||||
DisplayDevice device1 = createDisplayDevice(Display.TYPE_INTERNAL, 600, 800,
|
||||
DisplayDeviceInfo.FLAG_ALLOWED_TO_BE_DEFAULT_DISPLAY);
|
||||
DisplayDevice device2 = createDisplayDevice(Display.TYPE_INTERNAL, 600, 800,
|
||||
DisplayDeviceInfo.FLAG_ALLOWED_TO_BE_DEFAULT_DISPLAY);
|
||||
DisplayDevice device1 = createDisplayDevice(TYPE_INTERNAL, 600, 800,
|
||||
FLAG_ALLOWED_TO_BE_DEFAULT_DISPLAY);
|
||||
DisplayDevice device2 = createDisplayDevice(TYPE_INTERNAL, 600, 800,
|
||||
FLAG_ALLOWED_TO_BE_DEFAULT_DISPLAY);
|
||||
|
||||
Layout layout = new Layout();
|
||||
layout.createDisplayLocked(device1.getDisplayDeviceInfoLocked().address, true, true);
|
||||
@@ -479,13 +509,13 @@ public class LogicalDisplayMapperTest {
|
||||
DisplayAddress displayAddressTwo = new TestUtils.TestDisplayAddress();
|
||||
DisplayAddress displayAddressThree = new TestUtils.TestDisplayAddress();
|
||||
|
||||
TestDisplayDevice device1 = createDisplayDevice(displayAddressOne, Display.TYPE_INTERNAL,
|
||||
TestDisplayDevice device1 = createDisplayDevice(displayAddressOne, TYPE_INTERNAL,
|
||||
600, 800,
|
||||
DisplayDeviceInfo.FLAG_ALLOWED_TO_BE_DEFAULT_DISPLAY);
|
||||
TestDisplayDevice device2 = createDisplayDevice(displayAddressTwo, Display.TYPE_INTERNAL,
|
||||
FLAG_ALLOWED_TO_BE_DEFAULT_DISPLAY);
|
||||
TestDisplayDevice device2 = createDisplayDevice(displayAddressTwo, TYPE_INTERNAL,
|
||||
200, 800,
|
||||
DisplayDeviceInfo.FLAG_OWN_DISPLAY_GROUP);
|
||||
TestDisplayDevice device3 = createDisplayDevice(displayAddressThree, Display.TYPE_INTERNAL,
|
||||
TestDisplayDevice device3 = createDisplayDevice(displayAddressThree, TYPE_INTERNAL,
|
||||
600, 900, DisplayDeviceInfo.FLAG_OWN_DISPLAY_GROUP);
|
||||
|
||||
Layout threeDevicesEnabledLayout = new Layout();
|
||||
@@ -502,7 +532,7 @@ public class LogicalDisplayMapperTest {
|
||||
/* isDefault= */ false,
|
||||
/* isEnabled= */ true);
|
||||
|
||||
when(mDeviceStateToLayoutMapSpy.get(DeviceStateToLayoutMap.STATE_DEFAULT))
|
||||
when(mDeviceStateToLayoutMapSpy.get(STATE_DEFAULT))
|
||||
.thenReturn(threeDevicesEnabledLayout);
|
||||
|
||||
LogicalDisplay display1 = add(device1);
|
||||
@@ -620,6 +650,14 @@ public class LogicalDisplayMapperTest {
|
||||
return device.getDisplayDeviceInfoLocked();
|
||||
}
|
||||
|
||||
private int width(DisplayDevice device) {
|
||||
return info(device).width;
|
||||
}
|
||||
|
||||
private int height(DisplayDevice device) {
|
||||
return info(device).height;
|
||||
}
|
||||
|
||||
private DisplayInfo info(LogicalDisplay display) {
|
||||
return display.getDisplayInfoLocked();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user