3

I want to know the HDR capabilities on Android, so I write the following code to check this.

        Display display = getWindowManager().getDefaultDisplay();
        Display.HdrCapabilities hdrCapabilities = display.getHdrCapabilities();
        int[] types = hdrCapabilities.getSupportedHdrTypes();
        for (int i=0; i<types.length; i++) {
            Log.d(TAG, "Support HDR TYPE " + types[i]);
        }
        float maxAverage = hdrCapabilities.getDesiredMaxAverageLuminance();
        float maxLum = hdrCapabilities.getDesiredMaxLuminance();
        float minLum = hdrCapabilities.getDesiredMinLuminance();
        Log.d(TAG, "Max Average " + maxAverage + " maxLum " + maxLum + " minLum " + minLum);

        Configuration configuration = new Configuration();
        boolean isWideColor = configuration.isScreenWideColorGamut();
        boolean isHDR = configuration.isScreenHdr();
        Log.d(TAG,"Configuration wide color " + isWideColor + " hdr " + isHDR);

On my Pixel2 phone, the result is

Support HDR TYPE 2 //HDR_TYPE_HDR10
Support HDR TYPE 3 //HDR_TYPE_HLG
Max Average 500.0 maxLum 500.0 minLum 0.0
Configuration wide color false hdr false

I am confused by this, I know the Pixel2 can actually play HDR10 content, but why the configuration say it does not support HDR and wide color gamut.

reference: https://source.android.com/devices/tech/display/hdr

https://source.android.com/compatibility/android-cdd

wchen61
  • 93
  • 4

1 Answers1

0

You've constructed an invalid configuration: Configuration(); and passed it to the Configuration object. To solve it, Replace :

Configuration configuration = new Configuration();

with :

Configuration configuration = getResources().getConfiguration();

When checking for HDR and Wide Color Gamut Support you want the device's configuration not an empty constructor. So, it makes sense to use the latter code.
Reference: https://developer.android.com/reference/android/content/res/Configuration

This class describes all device configuration information that can impact the resources the application retrieves. This includes both user-specified configuration options (locale list and scaling) as well as device configurations (such as input modes, screen size and screen orientation).

You can acquire this object from Resources, using Resources#getConfiguration. Thus, from an activity, you can get it by chaining the request with ContextThemeWrapper.getResources():

Community
  • 1
  • 1
prof.Zoom
  • 31
  • 3
  • Thanks, you code is right. But I try with your code the result is the same. I get isScreenWideColorGamut and isScreenHdr both return false. – wchen61 Apr 14 '20 at 11:59
  • That is strange. Could you try on some other phone and report the result? – prof.Zoom Apr 14 '20 at 23:34