Loading core/java/android/view/Display.java +3 −6 Original line number Diff line number Diff line Loading @@ -1261,20 +1261,17 @@ public final class Display { /** * @hide * Returns the display's HDR supported types. * Returns the current mode's supported HDR types. * * @see #isHdr() * @see HdrCapabilities#getSupportedHdrTypes() * @see Mode#getSupportedHdrTypes() */ @TestApi @NonNull public int[] getReportedHdrTypes() { synchronized (mLock) { updateDisplayInfoLocked(); if (mDisplayInfo.hdrCapabilities == null) { return new int[0]; } return mDisplayInfo.hdrCapabilities.getSupportedHdrTypes(); return mDisplayInfo.getMode().getSupportedHdrTypes(); } } Loading core/tests/mockingcoretests/src/android/view/DisplayTest.java +25 −0 Original line number Diff line number Diff line Loading @@ -116,6 +116,31 @@ public class DisplayTest { Mockito.framework().clearInlineMocks(); } @Test public void testGetReportedHdrTypes_returns_mode_specific_hdr_types() { setDisplayInfoPortrait(mDisplayInfo); float[] alternativeRefreshRates = new float[0]; int[] hdrTypesWithDv = new int[] {1, 2, 3, 4}; Display.Mode modeWithDv = new Display.Mode(/* modeId= */ 0, 0, 0, 0f, alternativeRefreshRates, hdrTypesWithDv); int[] hdrTypesWithoutDv = new int[]{2, 3, 4}; Display.Mode modeWithoutDv = new Display.Mode(/* modeId= */ 1, 0, 0, 0f, alternativeRefreshRates, hdrTypesWithoutDv); mDisplayInfo.supportedModes = new Display.Mode[] {modeWithoutDv, modeWithDv}; mDisplayInfo.hdrCapabilities = new Display.HdrCapabilities(hdrTypesWithDv, 0, 0, 0); final Display display = new Display(mDisplayManagerGlobal, DEFAULT_DISPLAY, mDisplayInfo, DisplayAdjustments.DEFAULT_DISPLAY_ADJUSTMENTS); mDisplayInfo.modeId = 0; assertArrayEquals(hdrTypesWithDv, display.getReportedHdrTypes()); mDisplayInfo.modeId = 1; assertArrayEquals(hdrTypesWithoutDv, display.getReportedHdrTypes()); } @Test public void testConstructor_defaultDisplayAdjustments_matchesDisplayInfo() { setDisplayInfoPortrait(mDisplayInfo); Loading Loading
core/java/android/view/Display.java +3 −6 Original line number Diff line number Diff line Loading @@ -1261,20 +1261,17 @@ public final class Display { /** * @hide * Returns the display's HDR supported types. * Returns the current mode's supported HDR types. * * @see #isHdr() * @see HdrCapabilities#getSupportedHdrTypes() * @see Mode#getSupportedHdrTypes() */ @TestApi @NonNull public int[] getReportedHdrTypes() { synchronized (mLock) { updateDisplayInfoLocked(); if (mDisplayInfo.hdrCapabilities == null) { return new int[0]; } return mDisplayInfo.hdrCapabilities.getSupportedHdrTypes(); return mDisplayInfo.getMode().getSupportedHdrTypes(); } } Loading
core/tests/mockingcoretests/src/android/view/DisplayTest.java +25 −0 Original line number Diff line number Diff line Loading @@ -116,6 +116,31 @@ public class DisplayTest { Mockito.framework().clearInlineMocks(); } @Test public void testGetReportedHdrTypes_returns_mode_specific_hdr_types() { setDisplayInfoPortrait(mDisplayInfo); float[] alternativeRefreshRates = new float[0]; int[] hdrTypesWithDv = new int[] {1, 2, 3, 4}; Display.Mode modeWithDv = new Display.Mode(/* modeId= */ 0, 0, 0, 0f, alternativeRefreshRates, hdrTypesWithDv); int[] hdrTypesWithoutDv = new int[]{2, 3, 4}; Display.Mode modeWithoutDv = new Display.Mode(/* modeId= */ 1, 0, 0, 0f, alternativeRefreshRates, hdrTypesWithoutDv); mDisplayInfo.supportedModes = new Display.Mode[] {modeWithoutDv, modeWithDv}; mDisplayInfo.hdrCapabilities = new Display.HdrCapabilities(hdrTypesWithDv, 0, 0, 0); final Display display = new Display(mDisplayManagerGlobal, DEFAULT_DISPLAY, mDisplayInfo, DisplayAdjustments.DEFAULT_DISPLAY_ADJUSTMENTS); mDisplayInfo.modeId = 0; assertArrayEquals(hdrTypesWithDv, display.getReportedHdrTypes()); mDisplayInfo.modeId = 1; assertArrayEquals(hdrTypesWithoutDv, display.getReportedHdrTypes()); } @Test public void testConstructor_defaultDisplayAdjustments_matchesDisplayInfo() { setDisplayInfoPortrait(mDisplayInfo); Loading