Use libbinderthreadstateutils.
Clients needing to differentiate between system/vendor used to be able
to use isServingCall. However, this was expensive to implement. This
alternative approach instead requires users of this API to use
libbinderthreadstateutils which does a slighty different operation.
Bug: 148692216
Test: atest VtsHalCameraServiceV2_0TargetTest
Test: running AImageReaderVendorTest
Test: try face unlock
Change-Id: I5615f4e8863487d0de8dad2d0529214750897036
diff --git a/services/camera/libcameraservice/utils/CameraThreadState.cpp b/services/camera/libcameraservice/utils/CameraThreadState.cpp
index b9e344b..2352b80 100644
--- a/services/camera/libcameraservice/utils/CameraThreadState.cpp
+++ b/services/camera/libcameraservice/utils/CameraThreadState.cpp
@@ -17,33 +17,34 @@
#include "CameraThreadState.h"
#include <binder/IPCThreadState.h>
#include <hwbinder/IPCThreadState.h>
+#include <binderthreadstate/CallerUtils.h>
#include <unistd.h>
namespace android {
int CameraThreadState::getCallingUid() {
- if (hardware::IPCThreadState::self()->isServingCall()) {
+ if (getCurrentServingCall() == BinderCallType::HWBINDER) {
return hardware::IPCThreadState::self()->getCallingUid();
}
return IPCThreadState::self()->getCallingUid();
}
int CameraThreadState::getCallingPid() {
- if (hardware::IPCThreadState::self()->isServingCall()) {
+ if (getCurrentServingCall() == BinderCallType::HWBINDER) {
return hardware::IPCThreadState::self()->getCallingPid();
}
return IPCThreadState::self()->getCallingPid();
}
int64_t CameraThreadState::clearCallingIdentity() {
- if (hardware::IPCThreadState::self()->isServingCall()) {
+ if (getCurrentServingCall() == BinderCallType::HWBINDER) {
return hardware::IPCThreadState::self()->clearCallingIdentity();
}
return IPCThreadState::self()->clearCallingIdentity();
}
void CameraThreadState::restoreCallingIdentity(int64_t token) {
- if (hardware::IPCThreadState::self()->isServingCall()) {
+ if (getCurrentServingCall() == BinderCallType::HWBINDER) {
hardware::IPCThreadState::self()->restoreCallingIdentity(token);
} else {
IPCThreadState::self()->restoreCallingIdentity(token);
diff --git a/services/camera/libcameraservice/utils/ClientManager.h b/services/camera/libcameraservice/utils/ClientManager.h
index ec6f01c..35d25bf 100644
--- a/services/camera/libcameraservice/utils/ClientManager.h
+++ b/services/camera/libcameraservice/utils/ClientManager.h
@@ -35,7 +35,7 @@
public:
/**
* Choosing to set mIsVendorClient through a parameter instead of calling
- * hardware::IPCThreadState::self()->isServingCall() to protect against the
+ * getCurrentServingCall() == BinderCallType::HWBINDER to protect against the
* case where the construction is offloaded to another thread which isn't a
* hwbinder thread.
*/
@@ -237,7 +237,7 @@
// We don't use the usual copy constructor here since we want to remember
// whether a client is a vendor client or not. This could have been wiped
// off in the incoming priority argument since an AIDL thread might have
- // called hardware::IPCThreadState::self()->isServingCall() after refreshing
+ // called getCurrentServingCall() == BinderCallType::HWBINDER after refreshing
// priorities for old clients through ProcessInfoService::getProcessStatesScoresFromPids().
mPriority.setScore(priority.getScore());
mPriority.setState(priority.getState());