HAL interface for IGraphicBufferProducer V2

Test: Builds

Bug: 112508112

Change-Id: Ic3afaa1e27116d4ff9e5035dfce5c20de3d876e5
diff --git a/graphics/common/1.2/Android.bp b/graphics/common/1.2/Android.bp
index a86f3b5..a3ebdbf 100644
--- a/graphics/common/1.2/Android.bp
+++ b/graphics/common/1.2/Android.bp
@@ -15,7 +15,9 @@
         "android.hardware.graphics.common@1.1",
     ],
     types: [
+        "ColorMode",
         "Dataspace",
+        "HardwareBuffer",
     ],
     gen_java: true,
     gen_java_constants: true,
diff --git a/graphics/common/1.2/types.hal b/graphics/common/1.2/types.hal
index cf4e34a..15f2c14 100644
--- a/graphics/common/1.2/types.hal
+++ b/graphics/common/1.2/types.hal
@@ -51,3 +51,39 @@
      */
     DISPLAY_BT2020 = 13,
 };
+
+/**
+ * HIDL counterpart of `AHardwareBuffer_Desc`.
+ *
+ * An `AHardwareBuffer_Desc` object can be converted to and from a
+ * `HardwareBufferDescription` object by `memcpy()`.
+ *
+ * @sa +ndk libnativewindow#AHardwareBuffer_Desc.
+ */
+typedef uint32_t[10] HardwareBufferDescription;
+
+/**
+ * HIDL counterpart of `AHardwareBuffer`.
+ *
+ * AHardwareBuffer_createFromHandle() can be used to convert a `HardwareBuffer`
+ * object to an `AHardwareBuffer` object.
+ *
+ * Conversely, AHardwareBuffer_getNativeHandle() can be used to extract a native
+ * handle from an `AHardwareBuffer` object. Paired with `AHardwareBuffer_Desc`,
+ * AHardwareBuffer_getNativeHandle() can be used to convert between
+ * `HardwareBuffer` and `AHardwareBuffer`.
+ *
+ * @sa +ndk libnativewindow#AHardwareBuffer".
+ */
+struct HardwareBuffer {
+    HardwareBufferDescription description;
+    handle nativeHandle;
+};
+
+/**
+ * HIDL counterpart of `ARect`.
+ *
+ * @sa +ndk libarect_headers#ARect.
+ */
+typedef int32_t[4] Rect;
+