diff --git a/core/java/android/view/Display.java b/core/java/android/view/Display.java index fb6a9d552c544..22d5ed862690b 100644 --- a/core/java/android/view/Display.java +++ b/core/java/android/view/Display.java @@ -16,6 +16,7 @@ package android.view; +import android.annotation.IntDef; import android.annotation.RequiresPermission; import android.content.Context; import android.content.res.CompatibilityInfo; @@ -31,6 +32,8 @@ import android.os.SystemClock; import android.util.DisplayMetrics; import android.util.Log; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; import java.util.Arrays; import static android.Manifest.permission.CONFIGURE_DISPLAY_COLOR_TRANSFORM; @@ -714,6 +717,14 @@ public final class Display { } } + /** + * Returns the display's HDR capabilities. + * @hide + */ + public HdrCapabilities getHdrCapabilities() { + return new HdrCapabilities(); + } + /** * Gets the supported color transforms of this device. * @hide @@ -1111,6 +1122,117 @@ public final class Display { }; } + /** + * Encapsulates the HDR capabilities of a given display. + * For example, what HDR types it supports and details about the desired luminance data. + *
You can get an instance for a given {@link Display} object with
+ * {@link Display#getHdrCapabilities getHdrCapabilities()}.
+ * @hide
+ */
+ public static final class HdrCapabilities implements Parcelable {
+ /**
+ * Invalid luminance value.
+ */
+ public static final float INVALID_LUMINANCE = -1;
+ /**
+ * Dolby Vision high dynamic range (HDR) display.
+ */
+ public static final int HDR_TYPE_DOLBY_VISION = 1;
+ /**
+ * HDR10 display.
+ */
+ public static final int HDR_TYPE_HDR10 = 2;
+ /**
+ * Hybrid Log-Gamma HDR display.
+ */
+ public static final int HDR_TYPE_HLG = 3;
+
+ @IntDef({
+ HDR_TYPE_DOLBY_VISION,
+ HDR_TYPE_HDR10,
+ HDR_TYPE_HLG,
+ })
+ @Retention(RetentionPolicy.SOURCE)
+ public @interface HdrType {}
+
+ private @HdrType int[] mSupportedHdrTypes = new int[0];
+ private float mMaxLuminance = INVALID_LUMINANCE;
+ private float mMaxAverageLuminance = INVALID_LUMINANCE;
+ private float mMinLuminance = INVALID_LUMINANCE;
+
+ public HdrCapabilities() {
+ }
+
+ /**
+ * Gets the supported HDR types of this display.
+ * Returns empty array if HDR is not supported by the display.
+ */
+ public @HdrType int[] getSupportedHdrTypes() {
+ return mSupportedHdrTypes;
+ }
+ /**
+ * Returns the desired content max luminance data in cd/m2 for this display.
+ */
+ public float getDesiredMaxLuminance() {
+ return mMaxLuminance;
+ }
+ /**
+ * Returns the desired content max frame-average luminance data in cd/m2 for this display.
+ */
+ public float getDesiredMaxAverageLuminance() {
+ return mMaxAverageLuminance;
+ }
+ /**
+ * Returns the desired content min luminance data in cd/m2 for this display.
+ */
+ public float getDesiredMinLuminance() {
+ return mMinLuminance;
+ }
+
+ public static final Creator