Loading core/java/android/view/Display.java +1 −2 Original line number Diff line number Diff line Loading @@ -1339,7 +1339,7 @@ public final class Display { public HdrCapabilities getHdrCapabilities() { synchronized (mLock) { updateDisplayInfoLocked(); if (mDisplayInfo.hdrCapabilities == null || mDisplayInfo.isForceSdr) { if (mDisplayInfo.hdrCapabilities == null) { return null; } int[] supportedHdrTypes; Loading @@ -1361,7 +1361,6 @@ public final class Display { supportedHdrTypes[index++] = enabledType; } } return new HdrCapabilities(supportedHdrTypes, mDisplayInfo.hdrCapabilities.mMaxLuminance, mDisplayInfo.hdrCapabilities.mMaxAverageLuminance, Loading core/java/android/view/DisplayInfo.java +0 −9 Original line number Diff line number Diff line Loading @@ -230,9 +230,6 @@ public final class DisplayInfo implements Parcelable { /** The formats disabled by user **/ public int[] userDisabledHdrTypes = {}; /** When true, all HDR capabilities are disabled **/ public boolean isForceSdr; /** * Indicates whether the display can be switched into a mode with minimal post * processing. Loading Loading @@ -443,7 +440,6 @@ public final class DisplayInfo implements Parcelable { && colorMode == other.colorMode && Arrays.equals(supportedColorModes, other.supportedColorModes) && Objects.equals(hdrCapabilities, other.hdrCapabilities) && isForceSdr == other.isForceSdr && Arrays.equals(userDisabledHdrTypes, other.userDisabledHdrTypes) && minimalPostProcessingSupported == other.minimalPostProcessingSupported && logicalDensityDpi == other.logicalDensityDpi Loading Loading @@ -506,7 +502,6 @@ public final class DisplayInfo implements Parcelable { supportedColorModes = Arrays.copyOf( other.supportedColorModes, other.supportedColorModes.length); hdrCapabilities = other.hdrCapabilities; isForceSdr = other.isForceSdr; userDisabledHdrTypes = other.userDisabledHdrTypes; minimalPostProcessingSupported = other.minimalPostProcessingSupported; logicalDensityDpi = other.logicalDensityDpi; Loading Loading @@ -572,7 +567,6 @@ public final class DisplayInfo implements Parcelable { supportedColorModes[i] = source.readInt(); } hdrCapabilities = source.readParcelable(null, android.view.Display.HdrCapabilities.class); isForceSdr = source.readBoolean(); minimalPostProcessingSupported = source.readBoolean(); logicalDensityDpi = source.readInt(); physicalXDpi = source.readFloat(); Loading Loading @@ -642,7 +636,6 @@ public final class DisplayInfo implements Parcelable { dest.writeInt(supportedColorModes[i]); } dest.writeParcelable(hdrCapabilities, flags); dest.writeBoolean(isForceSdr); dest.writeBoolean(minimalPostProcessingSupported); dest.writeInt(logicalDensityDpi); dest.writeFloat(physicalXDpi); Loading Loading @@ -881,8 +874,6 @@ public final class DisplayInfo implements Parcelable { sb.append(Arrays.toString(appsSupportedModes)); sb.append(", hdrCapabilities "); sb.append(hdrCapabilities); sb.append(", isForceSdr "); sb.append(isForceSdr); sb.append(", userDisabledHdrTypes "); sb.append(Arrays.toString(userDisabledHdrTypes)); sb.append(", minimalPostProcessingSupported "); Loading services/core/java/com/android/server/display/DisplayControl.java +1 −1 Original line number Diff line number Diff line Loading @@ -109,7 +109,7 @@ public class DisplayControl { /** * Sets the HDR conversion mode for the device. * * Returns the system preferred HDR output type in case when HDR conversion mode is * Returns the system preferred Hdr output type nn case when HDR conversion mode is * {@link android.hardware.display.HdrConversionMode#HDR_CONVERSION_SYSTEM}. * Returns Hdr::INVALID in other cases. * @hide Loading services/core/java/com/android/server/display/DisplayDeviceInfo.java +1 −7 Original line number Diff line number Diff line Loading @@ -318,16 +318,13 @@ final class DisplayDeviceInfo { */ public Display.HdrCapabilities hdrCapabilities; /** When true, all HDR capabilities are hidden from public APIs */ public boolean isForceSdr; /** * Indicates whether this display supports Auto Low Latency Mode. */ public boolean allmSupported; /** * Indicates whether this display supports Game content type. * Indicates whether this display suppors Game content type. */ public boolean gameContentTypeSupported; Loading Loading @@ -519,7 +516,6 @@ final class DisplayDeviceInfo { || !Arrays.equals(supportedModes, other.supportedModes) || !Arrays.equals(supportedColorModes, other.supportedColorModes) || !Objects.equals(hdrCapabilities, other.hdrCapabilities) || isForceSdr != other.isForceSdr || allmSupported != other.allmSupported || gameContentTypeSupported != other.gameContentTypeSupported || densityDpi != other.densityDpi Loading Loading @@ -564,7 +560,6 @@ final class DisplayDeviceInfo { colorMode = other.colorMode; supportedColorModes = other.supportedColorModes; hdrCapabilities = other.hdrCapabilities; isForceSdr = other.isForceSdr; allmSupported = other.allmSupported; gameContentTypeSupported = other.gameContentTypeSupported; densityDpi = other.densityDpi; Loading Loading @@ -608,7 +603,6 @@ final class DisplayDeviceInfo { sb.append(", colorMode ").append(colorMode); sb.append(", supportedColorModes ").append(Arrays.toString(supportedColorModes)); sb.append(", hdrCapabilities ").append(hdrCapabilities); sb.append(", isForceSdr ").append(isForceSdr); sb.append(", allmSupported ").append(allmSupported); sb.append(", gameContentTypeSupported ").append(gameContentTypeSupported); sb.append(", density ").append(densityDpi); Loading services/core/java/com/android/server/display/DisplayManagerService.java +50 −95 Original line number Diff line number Diff line Loading @@ -48,7 +48,6 @@ import static android.os.Process.ROOT_UID; import static android.provider.Settings.Secure.RESOLUTION_MODE_FULL; import static android.provider.Settings.Secure.RESOLUTION_MODE_HIGH; import static android.provider.Settings.Secure.RESOLUTION_MODE_UNKNOWN; import static android.view.Display.HdrCapabilities.HDR_TYPE_INVALID; import static com.android.server.display.layout.Layout.Display.POSITION_REAR; Loading Loading @@ -283,7 +282,7 @@ public final class DisplayManagerService extends SystemService { @GuardedBy("mSyncRoot") private int[] mUserDisabledHdrTypes = {}; @Display.HdrCapabilities.HdrType private int[] mSupportedHdrOutputTypes; private int[] mSupportedHdrOutputType; @GuardedBy("mSyncRoot") private boolean mAreUserDisabledHdrTypesAllowed = true; Loading @@ -298,10 +297,10 @@ public final class DisplayManagerService extends SystemService { // HDR conversion mode chosen by user @GuardedBy("mSyncRoot") private HdrConversionMode mHdrConversionMode = null; // Whether app has disabled HDR conversion private boolean mShouldDisableHdrConversion = false; // Actual HDR conversion mode, which takes app overrides into account. private HdrConversionMode mOverrideHdrConversionMode = null; @GuardedBy("mSyncRoot") private int mSystemPreferredHdrOutputType = HDR_TYPE_INVALID; private int mSystemPreferredHdrOutputType = Display.HdrCapabilities.HDR_TYPE_INVALID; // The synchronization root for the display manager. Loading Loading @@ -1408,8 +1407,7 @@ public final class DisplayManagerService extends SystemService { } } @VisibleForTesting void setUserDisabledHdrTypesInternal(int[] userDisabledHdrTypes) { private void setUserDisabledHdrTypesInternal(int[] userDisabledHdrTypes) { synchronized (mSyncRoot) { if (userDisabledHdrTypes == null) { Slog.e(TAG, "Null is not an expected argument to " Loading @@ -1427,7 +1425,6 @@ public final class DisplayManagerService extends SystemService { if (Arrays.equals(mUserDisabledHdrTypes, userDisabledHdrTypes)) { return; } String userDisabledFormatsString = ""; if (userDisabledHdrTypes.length != 0) { userDisabledFormatsString = TextUtils.join(",", Loading @@ -1443,15 +1440,6 @@ public final class DisplayManagerService extends SystemService { handleLogicalDisplayChangedLocked(display); }); } /** Note: it may be expected to reset the Conversion Mode when an HDR type is enabled and the Conversion Mode is set to System Preferred. This is handled in the Settings code because in the special case where HDR is indirectly disabled by Force SDR Conversion, manually enabling HDR is not recognized as an action that reduces the disabled HDR count. Thus, this case needs to be checked in the Settings code when we know we're enabling an HDR mode. If we split checking for SystemConversion and isForceSdr in two places, we may have duplicate calls to resetting to System Conversion and get two black screens. */ } } Loading @@ -1464,20 +1452,19 @@ public final class DisplayManagerService extends SystemService { return true; } @VisibleForTesting void setAreUserDisabledHdrTypesAllowedInternal( private void setAreUserDisabledHdrTypesAllowedInternal( boolean areUserDisabledHdrTypesAllowed) { synchronized (mSyncRoot) { if (mAreUserDisabledHdrTypesAllowed == areUserDisabledHdrTypesAllowed) { return; } mAreUserDisabledHdrTypesAllowed = areUserDisabledHdrTypesAllowed; Settings.Global.putInt(mContext.getContentResolver(), Settings.Global.ARE_USER_DISABLED_HDR_FORMATS_ALLOWED, areUserDisabledHdrTypesAllowed ? 1 : 0); if (mUserDisabledHdrTypes.length == 0) { return; } Settings.Global.putInt(mContext.getContentResolver(), Settings.Global.ARE_USER_DISABLED_HDR_FORMATS_ALLOWED, areUserDisabledHdrTypesAllowed ? 1 : 0); int userDisabledHdrTypes[] = {}; if (!mAreUserDisabledHdrTypesAllowed) { userDisabledHdrTypes = mUserDisabledHdrTypes; Loading @@ -1488,14 +1475,6 @@ public final class DisplayManagerService extends SystemService { display.setUserDisabledHdrTypes(finalUserDisabledHdrTypes); handleLogicalDisplayChangedLocked(display); }); // When HDR conversion mode is set to SYSTEM, modification to // areUserDisabledHdrTypesAllowed requires refreshing the HDR conversion mode to tell // the system which HDR types it is not allowed to use. if (getHdrConversionModeInternal().getConversionMode() == HdrConversionMode.HDR_CONVERSION_SYSTEM) { setHdrConversionModeInternal( new HdrConversionMode(HdrConversionMode.HDR_CONVERSION_SYSTEM)); } } } Loading Loading @@ -2369,7 +2348,7 @@ public final class DisplayManagerService extends SystemService { final int preferredHdrOutputType = hdrConversionMode.getConversionMode() == HdrConversionMode.HDR_CONVERSION_FORCE ? hdrConversionMode.getPreferredHdrOutputType() : HDR_TYPE_INVALID; : Display.HdrCapabilities.HDR_TYPE_INVALID; Settings.Global.putInt(mContext.getContentResolver(), Settings.Global.HDR_FORCE_CONVERSION_TYPE, preferredHdrOutputType); } Loading @@ -2382,7 +2361,7 @@ public final class DisplayManagerService extends SystemService { ? Settings.Global.getInt(mContext.getContentResolver(), Settings.Global.HDR_FORCE_CONVERSION_TYPE, Display.HdrCapabilities.HDR_TYPE_DOLBY_VISION) : HDR_TYPE_INVALID; : Display.HdrCapabilities.HDR_TYPE_INVALID; mHdrConversionMode = new HdrConversionMode(conversionMode, preferredHdrOutputType); setHdrConversionModeInternal(mHdrConversionMode); } Loading Loading @@ -2519,38 +2498,22 @@ public final class DisplayManagerService extends SystemService { }); } /** * Returns the HDR output types that are supported by the device's HDR conversion capabilities, * stripping out any user-disabled HDR types if mAreUserDisabledHdrTypesAllowed is false. */ @GuardedBy("mSyncRoot") @VisibleForTesting int[] getEnabledHdrOutputTypesLocked() { if (mAreUserDisabledHdrTypesAllowed) { return getSupportedHdrOutputTypesInternal(); } // Strip out all HDR formats that are currently user-disabled IntArray enabledHdrOutputTypesArray = new IntArray(); private int[] getEnabledAutoHdrTypesLocked() { IntArray autoHdrOutputTypesArray = new IntArray(); for (int type : getSupportedHdrOutputTypesInternal()) { boolean isEnabled = true; boolean isDisabled = false; for (int disabledType : mUserDisabledHdrTypes) { if (type == disabledType) { isEnabled = false; isDisabled = true; break; } } if (isEnabled) { enabledHdrOutputTypesArray.add(type); if (!isDisabled) { autoHdrOutputTypesArray.add(type); } } return enabledHdrOutputTypesArray.toArray(); } @VisibleForTesting int[] getEnabledHdrOutputTypes() { synchronized (mSyncRoot) { return getEnabledHdrOutputTypesLocked(); } return autoHdrOutputTypesArray.toArray(); } @GuardedBy("mSyncRoot") Loading @@ -2559,7 +2522,7 @@ public final class DisplayManagerService extends SystemService { final int preferredHdrOutputType = mode.getConversionMode() == HdrConversionMode.HDR_CONVERSION_SYSTEM ? mSystemPreferredHdrOutputType : mode.getPreferredHdrOutputType(); if (preferredHdrOutputType != HDR_TYPE_INVALID) { if (preferredHdrOutputType != Display.HdrCapabilities.HDR_TYPE_INVALID) { int[] hdrTypesWithLatency = mInjector.getHdrOutputTypesWithLatency(); return ArrayUtils.contains(hdrTypesWithLatency, preferredHdrOutputType); } Loading Loading @@ -2593,57 +2556,41 @@ public final class DisplayManagerService extends SystemService { if (!mInjector.getHdrOutputConversionSupport()) { return; } int[] autoHdrOutputTypes = null; synchronized (mSyncRoot) { if (hdrConversionMode.getConversionMode() == HdrConversionMode.HDR_CONVERSION_SYSTEM && hdrConversionMode.getPreferredHdrOutputType() != HDR_TYPE_INVALID) { != Display.HdrCapabilities.HDR_TYPE_INVALID) { throw new IllegalArgumentException("preferredHdrOutputType must not be set if" + " the conversion mode is HDR_CONVERSION_SYSTEM"); } mHdrConversionMode = hdrConversionMode; storeHdrConversionModeLocked(mHdrConversionMode); // If the HDR conversion is HDR_CONVERSION_SYSTEM, all supported HDR types are allowed // except the ones specifically disabled by the user. int[] enabledHdrOutputTypes = null; // For auto mode, all supported HDR types are allowed except the ones specifically // disabled by the user. if (hdrConversionMode.getConversionMode() == HdrConversionMode.HDR_CONVERSION_SYSTEM) { enabledHdrOutputTypes = getEnabledHdrOutputTypesLocked(); autoHdrOutputTypes = getEnabledAutoHdrTypesLocked(); } int conversionMode = hdrConversionMode.getConversionMode(); int preferredHdrType = hdrConversionMode.getPreferredHdrOutputType(); // If the HDR conversion is disabled by an app through WindowManager.LayoutParams, then // set HDR conversion mode to HDR_CONVERSION_PASSTHROUGH. if (mShouldDisableHdrConversion) { conversionMode = HdrConversionMode.HDR_CONVERSION_PASSTHROUGH; preferredHdrType = -1; enabledHdrOutputTypes = null; } else { if (mOverrideHdrConversionMode == null) { // HDR_CONVERSION_FORCE with HDR_TYPE_INVALID is used to represent forcing SDR type. // But, internally SDR is forced by using passthrough mode and not reporting any // HDR capabilities to apps. // But, internally SDR is selected by using passthrough mode. if (conversionMode == HdrConversionMode.HDR_CONVERSION_FORCE && preferredHdrType == HDR_TYPE_INVALID) { && preferredHdrType == Display.HdrCapabilities.HDR_TYPE_INVALID) { conversionMode = HdrConversionMode.HDR_CONVERSION_PASSTHROUGH; mLogicalDisplayMapper.forEachLocked( logicalDisplay -> { if (logicalDisplay.setIsForceSdr(true)) { handleLogicalDisplayChangedLocked(logicalDisplay); } }); } else { mLogicalDisplayMapper.forEachLocked( logicalDisplay -> { if (logicalDisplay.setIsForceSdr(false)) { handleLogicalDisplayChangedLocked(logicalDisplay); } }); } conversionMode = mOverrideHdrConversionMode.getConversionMode(); preferredHdrType = mOverrideHdrConversionMode.getPreferredHdrOutputType(); autoHdrOutputTypes = null; } mSystemPreferredHdrOutputType = mInjector.setHdrConversionMode( conversionMode, preferredHdrType, enabledHdrOutputTypes); conversionMode, preferredHdrType, autoHdrOutputTypes); } } Loading @@ -2665,8 +2612,8 @@ public final class DisplayManagerService extends SystemService { } HdrConversionMode mode; synchronized (mSyncRoot) { mode = mShouldDisableHdrConversion ? new HdrConversionMode(HdrConversionMode.HDR_CONVERSION_PASSTHROUGH) mode = mOverrideHdrConversionMode != null ? mOverrideHdrConversionMode : mHdrConversionMode; // Handle default: PASSTHROUGH. Don't include the system-preferred type. if (mode == null Loading @@ -2674,6 +2621,8 @@ public final class DisplayManagerService extends SystemService { return new HdrConversionMode(HdrConversionMode.HDR_CONVERSION_PASSTHROUGH); } // Handle default or current mode: SYSTEM. Include the system preferred type. // mOverrideHdrConversionMode and mHdrConversionMode do not include the system // preferred type, it is kept separately in mSystemPreferredHdrOutputType. if (mode == null || mode.getConversionMode() == HdrConversionMode.HDR_CONVERSION_SYSTEM) { return new HdrConversionMode( Loading @@ -2684,10 +2633,10 @@ public final class DisplayManagerService extends SystemService { } private @Display.HdrCapabilities.HdrType int[] getSupportedHdrOutputTypesInternal() { if (mSupportedHdrOutputTypes == null) { mSupportedHdrOutputTypes = mInjector.getSupportedHdrOutputTypes(); if (mSupportedHdrOutputType == null) { mSupportedHdrOutputType = mInjector.getSupportedHdrOutputTypes(); } return mSupportedHdrOutputTypes; return mSupportedHdrOutputType; } void setShouldAlwaysRespectAppRequestedModeInternal(boolean enabled) { Loading Loading @@ -2873,9 +2822,15 @@ public final class DisplayManagerService extends SystemService { // HDR conversion is disabled in two cases: // - HDR conversion introduces latency and minimal post-processing is requested // - app requests to disable HDR conversion boolean previousShouldDisableHdrConversion = mShouldDisableHdrConversion; mShouldDisableHdrConversion = disableHdrConversion || disableHdrConversionForLatency; if (previousShouldDisableHdrConversion != mShouldDisableHdrConversion) { if (mOverrideHdrConversionMode == null && (disableHdrConversion || disableHdrConversionForLatency)) { mOverrideHdrConversionMode = new HdrConversionMode(HdrConversionMode.HDR_CONVERSION_PASSTHROUGH); setHdrConversionModeInternal(mHdrConversionMode); handleLogicalDisplayChangedLocked(display); } else if (mOverrideHdrConversionMode != null && !disableHdrConversion && !disableHdrConversionForLatency) { mOverrideHdrConversionMode = null; setHdrConversionModeInternal(mHdrConversionMode); handleLogicalDisplayChangedLocked(display); } Loading Loading @@ -3554,9 +3509,9 @@ public final class DisplayManagerService extends SystemService { } int setHdrConversionMode(int conversionMode, int preferredHdrOutputType, int[] allowedHdrOutputTypes) { int[] autoHdrTypes) { return DisplayControl.setHdrConversionMode(conversionMode, preferredHdrOutputType, allowedHdrOutputTypes); autoHdrTypes); } @Display.HdrCapabilities.HdrType Loading Loading
core/java/android/view/Display.java +1 −2 Original line number Diff line number Diff line Loading @@ -1339,7 +1339,7 @@ public final class Display { public HdrCapabilities getHdrCapabilities() { synchronized (mLock) { updateDisplayInfoLocked(); if (mDisplayInfo.hdrCapabilities == null || mDisplayInfo.isForceSdr) { if (mDisplayInfo.hdrCapabilities == null) { return null; } int[] supportedHdrTypes; Loading @@ -1361,7 +1361,6 @@ public final class Display { supportedHdrTypes[index++] = enabledType; } } return new HdrCapabilities(supportedHdrTypes, mDisplayInfo.hdrCapabilities.mMaxLuminance, mDisplayInfo.hdrCapabilities.mMaxAverageLuminance, Loading
core/java/android/view/DisplayInfo.java +0 −9 Original line number Diff line number Diff line Loading @@ -230,9 +230,6 @@ public final class DisplayInfo implements Parcelable { /** The formats disabled by user **/ public int[] userDisabledHdrTypes = {}; /** When true, all HDR capabilities are disabled **/ public boolean isForceSdr; /** * Indicates whether the display can be switched into a mode with minimal post * processing. Loading Loading @@ -443,7 +440,6 @@ public final class DisplayInfo implements Parcelable { && colorMode == other.colorMode && Arrays.equals(supportedColorModes, other.supportedColorModes) && Objects.equals(hdrCapabilities, other.hdrCapabilities) && isForceSdr == other.isForceSdr && Arrays.equals(userDisabledHdrTypes, other.userDisabledHdrTypes) && minimalPostProcessingSupported == other.minimalPostProcessingSupported && logicalDensityDpi == other.logicalDensityDpi Loading Loading @@ -506,7 +502,6 @@ public final class DisplayInfo implements Parcelable { supportedColorModes = Arrays.copyOf( other.supportedColorModes, other.supportedColorModes.length); hdrCapabilities = other.hdrCapabilities; isForceSdr = other.isForceSdr; userDisabledHdrTypes = other.userDisabledHdrTypes; minimalPostProcessingSupported = other.minimalPostProcessingSupported; logicalDensityDpi = other.logicalDensityDpi; Loading Loading @@ -572,7 +567,6 @@ public final class DisplayInfo implements Parcelable { supportedColorModes[i] = source.readInt(); } hdrCapabilities = source.readParcelable(null, android.view.Display.HdrCapabilities.class); isForceSdr = source.readBoolean(); minimalPostProcessingSupported = source.readBoolean(); logicalDensityDpi = source.readInt(); physicalXDpi = source.readFloat(); Loading Loading @@ -642,7 +636,6 @@ public final class DisplayInfo implements Parcelable { dest.writeInt(supportedColorModes[i]); } dest.writeParcelable(hdrCapabilities, flags); dest.writeBoolean(isForceSdr); dest.writeBoolean(minimalPostProcessingSupported); dest.writeInt(logicalDensityDpi); dest.writeFloat(physicalXDpi); Loading Loading @@ -881,8 +874,6 @@ public final class DisplayInfo implements Parcelable { sb.append(Arrays.toString(appsSupportedModes)); sb.append(", hdrCapabilities "); sb.append(hdrCapabilities); sb.append(", isForceSdr "); sb.append(isForceSdr); sb.append(", userDisabledHdrTypes "); sb.append(Arrays.toString(userDisabledHdrTypes)); sb.append(", minimalPostProcessingSupported "); Loading
services/core/java/com/android/server/display/DisplayControl.java +1 −1 Original line number Diff line number Diff line Loading @@ -109,7 +109,7 @@ public class DisplayControl { /** * Sets the HDR conversion mode for the device. * * Returns the system preferred HDR output type in case when HDR conversion mode is * Returns the system preferred Hdr output type nn case when HDR conversion mode is * {@link android.hardware.display.HdrConversionMode#HDR_CONVERSION_SYSTEM}. * Returns Hdr::INVALID in other cases. * @hide Loading
services/core/java/com/android/server/display/DisplayDeviceInfo.java +1 −7 Original line number Diff line number Diff line Loading @@ -318,16 +318,13 @@ final class DisplayDeviceInfo { */ public Display.HdrCapabilities hdrCapabilities; /** When true, all HDR capabilities are hidden from public APIs */ public boolean isForceSdr; /** * Indicates whether this display supports Auto Low Latency Mode. */ public boolean allmSupported; /** * Indicates whether this display supports Game content type. * Indicates whether this display suppors Game content type. */ public boolean gameContentTypeSupported; Loading Loading @@ -519,7 +516,6 @@ final class DisplayDeviceInfo { || !Arrays.equals(supportedModes, other.supportedModes) || !Arrays.equals(supportedColorModes, other.supportedColorModes) || !Objects.equals(hdrCapabilities, other.hdrCapabilities) || isForceSdr != other.isForceSdr || allmSupported != other.allmSupported || gameContentTypeSupported != other.gameContentTypeSupported || densityDpi != other.densityDpi Loading Loading @@ -564,7 +560,6 @@ final class DisplayDeviceInfo { colorMode = other.colorMode; supportedColorModes = other.supportedColorModes; hdrCapabilities = other.hdrCapabilities; isForceSdr = other.isForceSdr; allmSupported = other.allmSupported; gameContentTypeSupported = other.gameContentTypeSupported; densityDpi = other.densityDpi; Loading Loading @@ -608,7 +603,6 @@ final class DisplayDeviceInfo { sb.append(", colorMode ").append(colorMode); sb.append(", supportedColorModes ").append(Arrays.toString(supportedColorModes)); sb.append(", hdrCapabilities ").append(hdrCapabilities); sb.append(", isForceSdr ").append(isForceSdr); sb.append(", allmSupported ").append(allmSupported); sb.append(", gameContentTypeSupported ").append(gameContentTypeSupported); sb.append(", density ").append(densityDpi); Loading
services/core/java/com/android/server/display/DisplayManagerService.java +50 −95 Original line number Diff line number Diff line Loading @@ -48,7 +48,6 @@ import static android.os.Process.ROOT_UID; import static android.provider.Settings.Secure.RESOLUTION_MODE_FULL; import static android.provider.Settings.Secure.RESOLUTION_MODE_HIGH; import static android.provider.Settings.Secure.RESOLUTION_MODE_UNKNOWN; import static android.view.Display.HdrCapabilities.HDR_TYPE_INVALID; import static com.android.server.display.layout.Layout.Display.POSITION_REAR; Loading Loading @@ -283,7 +282,7 @@ public final class DisplayManagerService extends SystemService { @GuardedBy("mSyncRoot") private int[] mUserDisabledHdrTypes = {}; @Display.HdrCapabilities.HdrType private int[] mSupportedHdrOutputTypes; private int[] mSupportedHdrOutputType; @GuardedBy("mSyncRoot") private boolean mAreUserDisabledHdrTypesAllowed = true; Loading @@ -298,10 +297,10 @@ public final class DisplayManagerService extends SystemService { // HDR conversion mode chosen by user @GuardedBy("mSyncRoot") private HdrConversionMode mHdrConversionMode = null; // Whether app has disabled HDR conversion private boolean mShouldDisableHdrConversion = false; // Actual HDR conversion mode, which takes app overrides into account. private HdrConversionMode mOverrideHdrConversionMode = null; @GuardedBy("mSyncRoot") private int mSystemPreferredHdrOutputType = HDR_TYPE_INVALID; private int mSystemPreferredHdrOutputType = Display.HdrCapabilities.HDR_TYPE_INVALID; // The synchronization root for the display manager. Loading Loading @@ -1408,8 +1407,7 @@ public final class DisplayManagerService extends SystemService { } } @VisibleForTesting void setUserDisabledHdrTypesInternal(int[] userDisabledHdrTypes) { private void setUserDisabledHdrTypesInternal(int[] userDisabledHdrTypes) { synchronized (mSyncRoot) { if (userDisabledHdrTypes == null) { Slog.e(TAG, "Null is not an expected argument to " Loading @@ -1427,7 +1425,6 @@ public final class DisplayManagerService extends SystemService { if (Arrays.equals(mUserDisabledHdrTypes, userDisabledHdrTypes)) { return; } String userDisabledFormatsString = ""; if (userDisabledHdrTypes.length != 0) { userDisabledFormatsString = TextUtils.join(",", Loading @@ -1443,15 +1440,6 @@ public final class DisplayManagerService extends SystemService { handleLogicalDisplayChangedLocked(display); }); } /** Note: it may be expected to reset the Conversion Mode when an HDR type is enabled and the Conversion Mode is set to System Preferred. This is handled in the Settings code because in the special case where HDR is indirectly disabled by Force SDR Conversion, manually enabling HDR is not recognized as an action that reduces the disabled HDR count. Thus, this case needs to be checked in the Settings code when we know we're enabling an HDR mode. If we split checking for SystemConversion and isForceSdr in two places, we may have duplicate calls to resetting to System Conversion and get two black screens. */ } } Loading @@ -1464,20 +1452,19 @@ public final class DisplayManagerService extends SystemService { return true; } @VisibleForTesting void setAreUserDisabledHdrTypesAllowedInternal( private void setAreUserDisabledHdrTypesAllowedInternal( boolean areUserDisabledHdrTypesAllowed) { synchronized (mSyncRoot) { if (mAreUserDisabledHdrTypesAllowed == areUserDisabledHdrTypesAllowed) { return; } mAreUserDisabledHdrTypesAllowed = areUserDisabledHdrTypesAllowed; Settings.Global.putInt(mContext.getContentResolver(), Settings.Global.ARE_USER_DISABLED_HDR_FORMATS_ALLOWED, areUserDisabledHdrTypesAllowed ? 1 : 0); if (mUserDisabledHdrTypes.length == 0) { return; } Settings.Global.putInt(mContext.getContentResolver(), Settings.Global.ARE_USER_DISABLED_HDR_FORMATS_ALLOWED, areUserDisabledHdrTypesAllowed ? 1 : 0); int userDisabledHdrTypes[] = {}; if (!mAreUserDisabledHdrTypesAllowed) { userDisabledHdrTypes = mUserDisabledHdrTypes; Loading @@ -1488,14 +1475,6 @@ public final class DisplayManagerService extends SystemService { display.setUserDisabledHdrTypes(finalUserDisabledHdrTypes); handleLogicalDisplayChangedLocked(display); }); // When HDR conversion mode is set to SYSTEM, modification to // areUserDisabledHdrTypesAllowed requires refreshing the HDR conversion mode to tell // the system which HDR types it is not allowed to use. if (getHdrConversionModeInternal().getConversionMode() == HdrConversionMode.HDR_CONVERSION_SYSTEM) { setHdrConversionModeInternal( new HdrConversionMode(HdrConversionMode.HDR_CONVERSION_SYSTEM)); } } } Loading Loading @@ -2369,7 +2348,7 @@ public final class DisplayManagerService extends SystemService { final int preferredHdrOutputType = hdrConversionMode.getConversionMode() == HdrConversionMode.HDR_CONVERSION_FORCE ? hdrConversionMode.getPreferredHdrOutputType() : HDR_TYPE_INVALID; : Display.HdrCapabilities.HDR_TYPE_INVALID; Settings.Global.putInt(mContext.getContentResolver(), Settings.Global.HDR_FORCE_CONVERSION_TYPE, preferredHdrOutputType); } Loading @@ -2382,7 +2361,7 @@ public final class DisplayManagerService extends SystemService { ? Settings.Global.getInt(mContext.getContentResolver(), Settings.Global.HDR_FORCE_CONVERSION_TYPE, Display.HdrCapabilities.HDR_TYPE_DOLBY_VISION) : HDR_TYPE_INVALID; : Display.HdrCapabilities.HDR_TYPE_INVALID; mHdrConversionMode = new HdrConversionMode(conversionMode, preferredHdrOutputType); setHdrConversionModeInternal(mHdrConversionMode); } Loading Loading @@ -2519,38 +2498,22 @@ public final class DisplayManagerService extends SystemService { }); } /** * Returns the HDR output types that are supported by the device's HDR conversion capabilities, * stripping out any user-disabled HDR types if mAreUserDisabledHdrTypesAllowed is false. */ @GuardedBy("mSyncRoot") @VisibleForTesting int[] getEnabledHdrOutputTypesLocked() { if (mAreUserDisabledHdrTypesAllowed) { return getSupportedHdrOutputTypesInternal(); } // Strip out all HDR formats that are currently user-disabled IntArray enabledHdrOutputTypesArray = new IntArray(); private int[] getEnabledAutoHdrTypesLocked() { IntArray autoHdrOutputTypesArray = new IntArray(); for (int type : getSupportedHdrOutputTypesInternal()) { boolean isEnabled = true; boolean isDisabled = false; for (int disabledType : mUserDisabledHdrTypes) { if (type == disabledType) { isEnabled = false; isDisabled = true; break; } } if (isEnabled) { enabledHdrOutputTypesArray.add(type); if (!isDisabled) { autoHdrOutputTypesArray.add(type); } } return enabledHdrOutputTypesArray.toArray(); } @VisibleForTesting int[] getEnabledHdrOutputTypes() { synchronized (mSyncRoot) { return getEnabledHdrOutputTypesLocked(); } return autoHdrOutputTypesArray.toArray(); } @GuardedBy("mSyncRoot") Loading @@ -2559,7 +2522,7 @@ public final class DisplayManagerService extends SystemService { final int preferredHdrOutputType = mode.getConversionMode() == HdrConversionMode.HDR_CONVERSION_SYSTEM ? mSystemPreferredHdrOutputType : mode.getPreferredHdrOutputType(); if (preferredHdrOutputType != HDR_TYPE_INVALID) { if (preferredHdrOutputType != Display.HdrCapabilities.HDR_TYPE_INVALID) { int[] hdrTypesWithLatency = mInjector.getHdrOutputTypesWithLatency(); return ArrayUtils.contains(hdrTypesWithLatency, preferredHdrOutputType); } Loading Loading @@ -2593,57 +2556,41 @@ public final class DisplayManagerService extends SystemService { if (!mInjector.getHdrOutputConversionSupport()) { return; } int[] autoHdrOutputTypes = null; synchronized (mSyncRoot) { if (hdrConversionMode.getConversionMode() == HdrConversionMode.HDR_CONVERSION_SYSTEM && hdrConversionMode.getPreferredHdrOutputType() != HDR_TYPE_INVALID) { != Display.HdrCapabilities.HDR_TYPE_INVALID) { throw new IllegalArgumentException("preferredHdrOutputType must not be set if" + " the conversion mode is HDR_CONVERSION_SYSTEM"); } mHdrConversionMode = hdrConversionMode; storeHdrConversionModeLocked(mHdrConversionMode); // If the HDR conversion is HDR_CONVERSION_SYSTEM, all supported HDR types are allowed // except the ones specifically disabled by the user. int[] enabledHdrOutputTypes = null; // For auto mode, all supported HDR types are allowed except the ones specifically // disabled by the user. if (hdrConversionMode.getConversionMode() == HdrConversionMode.HDR_CONVERSION_SYSTEM) { enabledHdrOutputTypes = getEnabledHdrOutputTypesLocked(); autoHdrOutputTypes = getEnabledAutoHdrTypesLocked(); } int conversionMode = hdrConversionMode.getConversionMode(); int preferredHdrType = hdrConversionMode.getPreferredHdrOutputType(); // If the HDR conversion is disabled by an app through WindowManager.LayoutParams, then // set HDR conversion mode to HDR_CONVERSION_PASSTHROUGH. if (mShouldDisableHdrConversion) { conversionMode = HdrConversionMode.HDR_CONVERSION_PASSTHROUGH; preferredHdrType = -1; enabledHdrOutputTypes = null; } else { if (mOverrideHdrConversionMode == null) { // HDR_CONVERSION_FORCE with HDR_TYPE_INVALID is used to represent forcing SDR type. // But, internally SDR is forced by using passthrough mode and not reporting any // HDR capabilities to apps. // But, internally SDR is selected by using passthrough mode. if (conversionMode == HdrConversionMode.HDR_CONVERSION_FORCE && preferredHdrType == HDR_TYPE_INVALID) { && preferredHdrType == Display.HdrCapabilities.HDR_TYPE_INVALID) { conversionMode = HdrConversionMode.HDR_CONVERSION_PASSTHROUGH; mLogicalDisplayMapper.forEachLocked( logicalDisplay -> { if (logicalDisplay.setIsForceSdr(true)) { handleLogicalDisplayChangedLocked(logicalDisplay); } }); } else { mLogicalDisplayMapper.forEachLocked( logicalDisplay -> { if (logicalDisplay.setIsForceSdr(false)) { handleLogicalDisplayChangedLocked(logicalDisplay); } }); } conversionMode = mOverrideHdrConversionMode.getConversionMode(); preferredHdrType = mOverrideHdrConversionMode.getPreferredHdrOutputType(); autoHdrOutputTypes = null; } mSystemPreferredHdrOutputType = mInjector.setHdrConversionMode( conversionMode, preferredHdrType, enabledHdrOutputTypes); conversionMode, preferredHdrType, autoHdrOutputTypes); } } Loading @@ -2665,8 +2612,8 @@ public final class DisplayManagerService extends SystemService { } HdrConversionMode mode; synchronized (mSyncRoot) { mode = mShouldDisableHdrConversion ? new HdrConversionMode(HdrConversionMode.HDR_CONVERSION_PASSTHROUGH) mode = mOverrideHdrConversionMode != null ? mOverrideHdrConversionMode : mHdrConversionMode; // Handle default: PASSTHROUGH. Don't include the system-preferred type. if (mode == null Loading @@ -2674,6 +2621,8 @@ public final class DisplayManagerService extends SystemService { return new HdrConversionMode(HdrConversionMode.HDR_CONVERSION_PASSTHROUGH); } // Handle default or current mode: SYSTEM. Include the system preferred type. // mOverrideHdrConversionMode and mHdrConversionMode do not include the system // preferred type, it is kept separately in mSystemPreferredHdrOutputType. if (mode == null || mode.getConversionMode() == HdrConversionMode.HDR_CONVERSION_SYSTEM) { return new HdrConversionMode( Loading @@ -2684,10 +2633,10 @@ public final class DisplayManagerService extends SystemService { } private @Display.HdrCapabilities.HdrType int[] getSupportedHdrOutputTypesInternal() { if (mSupportedHdrOutputTypes == null) { mSupportedHdrOutputTypes = mInjector.getSupportedHdrOutputTypes(); if (mSupportedHdrOutputType == null) { mSupportedHdrOutputType = mInjector.getSupportedHdrOutputTypes(); } return mSupportedHdrOutputTypes; return mSupportedHdrOutputType; } void setShouldAlwaysRespectAppRequestedModeInternal(boolean enabled) { Loading Loading @@ -2873,9 +2822,15 @@ public final class DisplayManagerService extends SystemService { // HDR conversion is disabled in two cases: // - HDR conversion introduces latency and minimal post-processing is requested // - app requests to disable HDR conversion boolean previousShouldDisableHdrConversion = mShouldDisableHdrConversion; mShouldDisableHdrConversion = disableHdrConversion || disableHdrConversionForLatency; if (previousShouldDisableHdrConversion != mShouldDisableHdrConversion) { if (mOverrideHdrConversionMode == null && (disableHdrConversion || disableHdrConversionForLatency)) { mOverrideHdrConversionMode = new HdrConversionMode(HdrConversionMode.HDR_CONVERSION_PASSTHROUGH); setHdrConversionModeInternal(mHdrConversionMode); handleLogicalDisplayChangedLocked(display); } else if (mOverrideHdrConversionMode != null && !disableHdrConversion && !disableHdrConversionForLatency) { mOverrideHdrConversionMode = null; setHdrConversionModeInternal(mHdrConversionMode); handleLogicalDisplayChangedLocked(display); } Loading Loading @@ -3554,9 +3509,9 @@ public final class DisplayManagerService extends SystemService { } int setHdrConversionMode(int conversionMode, int preferredHdrOutputType, int[] allowedHdrOutputTypes) { int[] autoHdrTypes) { return DisplayControl.setHdrConversionMode(conversionMode, preferredHdrOutputType, allowedHdrOutputTypes); autoHdrTypes); } @Display.HdrCapabilities.HdrType Loading