Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit c6451f27 authored by Marin Shalamanov's avatar Marin Shalamanov
Browse files

Fix NPEs for virtual displays

Fix for NPEs in Display.getHdrCapabilities(), isHdr() and
getReportedHdrTypes() for virtual displays.

Bug: 184722440
Test: atest VirtualDisplayTest
Change-Id: Iad5706fd66c01e0e58e43c63d617557e1532ae05
parent eb709a0c
Loading
Loading
Loading
Loading
+14 −1
Original line number Diff line number Diff line
@@ -1070,6 +1070,11 @@ public final class Display {
            if (mDisplayInfo.userDisabledHdrTypes.length == 0) {
                return mDisplayInfo.hdrCapabilities;
            }

            if (mDisplayInfo.hdrCapabilities == null) {
                return null;
            }

            ArraySet<Integer> enabledTypesSet = new ArraySet<>();
            for (int supportedType : mDisplayInfo.hdrCapabilities.getSupportedHdrTypes()) {
                boolean typeDisabled = false;
@@ -1083,6 +1088,7 @@ public final class Display {
                    enabledTypesSet.add(supportedType);
                }
            }

            int[] enabledTypes = new int[enabledTypesSet.size()];
            int index = 0;
            for (int enabledType : enabledTypesSet) {
@@ -1107,6 +1113,9 @@ public final class Display {
    public int[] getReportedHdrTypes() {
        synchronized (mLock) {
            updateDisplayInfoLocked();
            if (mDisplayInfo.hdrCapabilities == null) {
                return new int[0];
            }
            return mDisplayInfo.hdrCapabilities.getSupportedHdrTypes();
        }
    }
@@ -1120,7 +1129,11 @@ public final class Display {
    public boolean isHdr() {
        synchronized (mLock) {
            updateDisplayInfoLocked();
            return !(getHdrCapabilities().getSupportedHdrTypes().length == 0);
            HdrCapabilities hdrCapabilities = getHdrCapabilities();
            if (hdrCapabilities == null) {
                return false;
            }
            return !(hdrCapabilities.getSupportedHdrTypes().length == 0);
        }
    }