BufferQueueProducer: use the correct IPCThreadState.

The system variant of libgui maybe be double loaded. Also
IGraphicBufferProducer functions may be called from hwbinder threads due
to the presence of TWGraphicBufferProducer wrappers (hybrid interfaces).
Therefore, we should use the correct IPCThreadState/ hardware::IPCThreadState to query
callingPids. This also avoids access to /dev/binder in vendor processes,
in case the system variant of the library is loaded, for eg: in
libmediandk.

Bug: 124128212

Test: Selinux denials realted to/dev/binder acccess are not present when AImageReader from
      libmediandk is used in a vendor process.

Test: Play Youtube movies on Chrome, use camera to take pictures/ record
      videos (sanity).

Change-Id: I27d78e30e16b7df5e3dfbb130121f3d7078671a3
Signed-off-by: Jayant Chowdhary <jchowdhary@google.com>
diff --git a/libs/gui/Android.bp b/libs/gui/Android.bp
index 0510492..8b663bc 100644
--- a/libs/gui/Android.bp
+++ b/libs/gui/Android.bp
@@ -91,6 +91,7 @@
         "BufferQueueConsumer.cpp",
         "BufferQueueCore.cpp",
         "BufferQueueProducer.cpp",
+        "BufferQueueThreadState.cpp",
         "BufferSlot.cpp",
         "ConsumerBase.cpp",
         "CpuConsumer.cpp",
@@ -128,6 +129,7 @@
         "libbase",
         "libsync",
         "libbinder",
+        "libhwbinder",
         "libbufferhub",
         "libbufferhubqueue", // TODO(b/70046255): Remove this once BufferHub is integrated into libgui.
         "libpdx_default_transport",
@@ -143,12 +145,16 @@
         "libhidltransport",
         "android.hidl.token@1.0-utils",
         "android.hardware.graphics.bufferqueue@1.0",
+        "libvndksupport",
     ],
 
     // bufferhub is not used when building libgui for vendors
     target: {
         vendor: {
-            cflags: ["-DNO_BUFFERHUB", "-DNO_INPUT"],
+            cflags: [
+                "-DNO_BUFFERHUB",
+                "-DNO_INPUT",
+            ],
             exclude_srcs: [
                 "BufferHubConsumer.cpp",
                 "BufferHubProducer.cpp",
@@ -158,7 +164,7 @@
                 "libbufferhub",
                 "libbufferhubqueue",
                 "libpdx_default_transport",
-                "libinput"
+                "libinput",
             ],
         },
     },