Add an llndk api to get a native handle corresponding to ANativeWindow in AImageReader.

Since vendor modules sometimes might need to transfer ANativeWindow(specific to
AImageReader) over hidl to system processes, here, we introduce an llndk
function to convert the ANativeWindow owned by AImageReader into a
native_handle_t which may be transported over hwbinder.

We also introduce a platform only api to retrieve an HIDL
IGraphicBufferProducer from the handle received.

Bug: 110364143

Test: mm -j64
Test: AImageReaderWindowHandleTest

Change-Id: I5f2aec41d9c67c619413c02e48cd97933e3b2986
Signed-off-by: Jayant Chowdhary <jchowdhary@google.com>
diff --git a/media/ndk/Android.bp b/media/ndk/Android.bp
index 05c8582..fc58583 100644
--- a/media/ndk/Android.bp
+++ b/media/ndk/Android.bp
@@ -57,7 +57,6 @@
     cflags: [
         "-fvisibility=hidden",
         "-DEXPORT=__attribute__((visibility(\"default\")))",
-
         "-Werror",
         "-Wall",
     ],
@@ -67,6 +66,8 @@
     ],
 
     shared_libs: [
+        "android.hardware.graphics.bufferqueue@1.0",
+        "android.hidl.token@1.0-utils",
         "libbinder",
         "libmedia",
         "libmedia_omx",
@@ -75,12 +76,15 @@
         "libmediaextractor",
         "libstagefright",
         "libstagefright_foundation",
+        "libstagefright_bufferqueue_helper",
         "liblog",
         "libutils",
         "libcutils",
         "libandroid",
         "libandroid_runtime",
         "libbinder",
+        "libhwbinder",
+        "libhidlbase",
         "libgui",
         "libui",
         "libmedia2_jni_core",
@@ -99,7 +103,9 @@
 llndk_library {
     name: "libmediandk",
     symbol_file: "libmediandk.map.txt",
-    export_include_dirs: ["include"],
+    export_include_dirs: [
+        "include",
+    ],
 }
 
 cc_library {
@@ -143,3 +149,24 @@
         },
     },
 }
+
+cc_test {
+    name: "AImageReaderWindowHandleTest",
+    srcs: ["tests/AImageReaderWindowHandleTest.cpp"],
+    shared_libs: [
+        "libbinder",
+        "libmediandk",
+        "libnativewindow",
+        "libgui",
+        "libutils",
+        "libui",
+        "libcutils",
+        "android.hardware.graphics.bufferqueue@1.0",
+    ],
+    cflags: [
+        "-D__ANDROID_VNDK__",
+    ],
+    include_dirs: [
+        "frameworks/av/media/ndk/",
+    ],
+}