Loading services/core/java/com/android/server/display/LocalDisplayAdapter.java +3 −4 Original line number Diff line number Diff line Loading @@ -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. Loading @@ -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; Loading @@ -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. Loading services/tests/mockingservicestests/src/com/android/server/display/LocalDisplayAdapterTest.java +45 −7 Original line number Diff line number Diff line Loading @@ -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); } /** Loading @@ -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); Loading @@ -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(); Loading Loading
services/core/java/com/android/server/display/LocalDisplayAdapter.java +3 −4 Original line number Diff line number Diff line Loading @@ -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. Loading @@ -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; Loading @@ -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. Loading
services/tests/mockingservicestests/src/com/android/server/display/LocalDisplayAdapterTest.java +45 −7 Original line number Diff line number Diff line Loading @@ -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); } /** Loading @@ -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); Loading @@ -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(); Loading