Use physical density for external displays
The CL has LocalDisplayAdapter use physical density from surface flinger. Previously LocalDisplayAdapter always uses fake density for external displays. The fake density is no longer needed because surface flinger fills density always now. Bug: 144066777 Test: LocalDisplayAdapterTest Change-Id: I105de4f6ded17c6882d98e60e8c7d7c027299f56
This commit is contained in:
committed by
Garfield Tan
parent
654af7615b
commit
1eb2a91aa0
@@ -410,6 +410,9 @@ final class LocalDisplayAdapter extends DisplayAdapter {
|
||||
final DisplayAddress.Physical physicalAddress =
|
||||
DisplayAddress.fromPhysicalDisplayId(mPhysicalDisplayId);
|
||||
mInfo.address = physicalAddress;
|
||||
mInfo.densityDpi = (int) (phys.density * 160 + 0.5f);
|
||||
mInfo.xDpi = phys.xDpi;
|
||||
mInfo.yDpi = phys.yDpi;
|
||||
|
||||
// Assume that all built-in displays that have secure output (eg. HDCP) also
|
||||
// support compositing from gralloc protected buffers.
|
||||
@@ -436,9 +439,6 @@ final class LocalDisplayAdapter extends DisplayAdapter {
|
||||
mInfo.displayCutout = DisplayCutout.fromResourcesRectApproximation(res,
|
||||
mInfo.width, mInfo.height);
|
||||
mInfo.type = Display.TYPE_BUILT_IN;
|
||||
mInfo.densityDpi = (int)(phys.density * 160 + 0.5f);
|
||||
mInfo.xDpi = phys.xDpi;
|
||||
mInfo.yDpi = phys.yDpi;
|
||||
mInfo.touch = DisplayDeviceInfo.TOUCH_INTERNAL;
|
||||
} else {
|
||||
mInfo.displayCutout = null;
|
||||
@@ -447,7 +447,6 @@ final class LocalDisplayAdapter extends DisplayAdapter {
|
||||
mInfo.name = getContext().getResources().getString(
|
||||
com.android.internal.R.string.display_manager_hdmi_display_name);
|
||||
mInfo.touch = DisplayDeviceInfo.TOUCH_EXTERNAL;
|
||||
mInfo.setAssumedDensityForExternalDisplay(phys.width, phys.height);
|
||||
|
||||
// For demonstration purposes, allow rotation of the external display.
|
||||
// In the future we might allow the user to configure this directly.
|
||||
|
||||
@@ -120,11 +120,14 @@ public class LocalDisplayAdapterTest {
|
||||
waitForHandlerToComplete(mHandler, HANDLER_WAIT_MS);
|
||||
|
||||
// This should be public
|
||||
assertDisplay(mListener.addedDisplays.get(0).getDisplayDeviceInfoLocked(), PORT_A, false);
|
||||
// This should be private
|
||||
assertDisplay(mListener.addedDisplays.get(1).getDisplayDeviceInfoLocked(), PORT_B, true);
|
||||
assertDisplayPrivateFlag(mListener.addedDisplays.get(0).getDisplayDeviceInfoLocked(),
|
||||
PORT_A, false);
|
||||
// This should be public
|
||||
assertDisplay(mListener.addedDisplays.get(2).getDisplayDeviceInfoLocked(), PORT_C, false);
|
||||
assertDisplayPrivateFlag(mListener.addedDisplays.get(1).getDisplayDeviceInfoLocked(),
|
||||
PORT_B, true);
|
||||
// This should be public
|
||||
assertDisplayPrivateFlag(mListener.addedDisplays.get(2).getDisplayDeviceInfoLocked(),
|
||||
PORT_C, false);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -141,12 +144,14 @@ public class LocalDisplayAdapterTest {
|
||||
waitForHandlerToComplete(mHandler, HANDLER_WAIT_MS);
|
||||
|
||||
// This should be public
|
||||
assertDisplay(mListener.addedDisplays.get(0).getDisplayDeviceInfoLocked(), PORT_A, false);
|
||||
assertDisplayPrivateFlag(mListener.addedDisplays.get(0).getDisplayDeviceInfoLocked(),
|
||||
PORT_A, false);
|
||||
// This should be public
|
||||
assertDisplay(mListener.addedDisplays.get(1).getDisplayDeviceInfoLocked(), PORT_C, false);
|
||||
assertDisplayPrivateFlag(mListener.addedDisplays.get(1).getDisplayDeviceInfoLocked(),
|
||||
PORT_C, false);
|
||||
}
|
||||
|
||||
private static void assertDisplay(
|
||||
private static void assertDisplayPrivateFlag(
|
||||
DisplayDeviceInfo info, int expectedPort, boolean shouldBePrivate) {
|
||||
final DisplayAddress.Physical address = (DisplayAddress.Physical) info.address;
|
||||
assertNotNull(address);
|
||||
@@ -155,6 +160,39 @@ public class LocalDisplayAdapterTest {
|
||||
assertEquals(shouldBePrivate, (info.flags & DisplayDeviceInfo.FLAG_PRIVATE) != 0);
|
||||
}
|
||||
|
||||
/**
|
||||
* Confirm that external display uses physical density.
|
||||
*/
|
||||
@Test
|
||||
public void testDpiValues() throws Exception {
|
||||
// needs default one always
|
||||
setUpDisplay(new DisplayConfig(createDisplayAddress(PORT_A), createDummyDisplayInfo()));
|
||||
setUpDisplay(new DisplayConfig(createDisplayAddress(PORT_B), createDummyDisplayInfo()));
|
||||
updateAvailableDisplays();
|
||||
mAdapter.registerLocked();
|
||||
|
||||
waitForHandlerToComplete(mHandler, HANDLER_WAIT_MS);
|
||||
|
||||
assertDisplayDpi(
|
||||
mListener.addedDisplays.get(0).getDisplayDeviceInfoLocked(), PORT_A, 100, 100,
|
||||
16000);
|
||||
assertDisplayDpi(
|
||||
mListener.addedDisplays.get(1).getDisplayDeviceInfoLocked(), PORT_B, 100, 100,
|
||||
16000);
|
||||
}
|
||||
|
||||
private void assertDisplayDpi(DisplayDeviceInfo info, int expectedPort,
|
||||
float expectedXdpi,
|
||||
float expectedYDpi,
|
||||
int expectedDensityDpi) {
|
||||
final DisplayAddress.Physical physical = (DisplayAddress.Physical) info.address;
|
||||
assertNotNull(physical);
|
||||
assertEquals((byte) expectedPort, physical.getPort());
|
||||
assertEquals(expectedXdpi, info.xDpi, 0.01);
|
||||
assertEquals(expectedYDpi, info.yDpi, 0.01);
|
||||
assertEquals(expectedDensityDpi, info.densityDpi);
|
||||
}
|
||||
|
||||
private class DisplayConfig {
|
||||
public final DisplayAddress.Physical address;
|
||||
public final IBinder displayToken = new Binder();
|
||||
|
||||
Reference in New Issue
Block a user