cameraserver: Wrap calls to IPCThreadState functions to factor in different transports.
Add a wrapper around calls to IPCThreadState to
account for the fact that remote HIDL calls may use binder function
implementations internally.Therefore, we need to know whether we are on
a binder / hwbinder thread and call the appropriate IPCThreadState /
hardware::IPCThreadState function internally.
Bug: 110364143
Test: GCA
Test: Third party app
Test: camera CTS (no new failures).
Change-Id: Ibad03fafd2ccc53a5352a6df45cf8f641bc7a3bf
Signed-off-by: Jayant Chowdhary <jchowdhary@google.com>
diff --git a/services/camera/libcameraservice/api2/CameraDeviceClient.cpp b/services/camera/libcameraservice/api2/CameraDeviceClient.cpp
index 84428c2..dd2ef99 100644
--- a/services/camera/libcameraservice/api2/CameraDeviceClient.cpp
+++ b/services/camera/libcameraservice/api2/CameraDeviceClient.cpp
@@ -19,6 +19,7 @@
//#define LOG_NDEBUG 0
#include <cutils/properties.h>
+#include <utils/CameraThreadState.h>
#include <utils/Log.h>
#include <utils/Trace.h>
#include <gui/Surface.h>
@@ -1724,7 +1725,7 @@
// TODO: move to Camera2ClientBase
bool CameraDeviceClient::enforceRequestPermissions(CameraMetadata& metadata) {
- const int pid = IPCThreadState::self()->getCallingPid();
+ const int pid = CameraThreadState::getCallingPid();
const int selfPid = getpid();
camera_metadata_entry_t entry;
@@ -1763,7 +1764,7 @@
String16 permissionString =
String16("android.permission.CAMERA_DISABLE_TRANSMIT_LED");
if (!checkCallingPermission(permissionString)) {
- const int uid = IPCThreadState::self()->getCallingUid();
+ const int uid = CameraThreadState::getCallingUid();
ALOGE("Permission Denial: "
"can't disable transmit LED pid=%d, uid=%d", pid, uid);
return false;