@ -43,6 +43,7 @@
# include <binder/PermissionController.h>
# include <binder/ProcessInfoService.h>
# include <binder/IResultReceiver.h>
# include <binderthreadstate/CallerUtils.h>
# include <cutils/atomic.h>
# include <cutils/properties.h>
# include <cutils/misc.h>
@ -1179,7 +1180,7 @@ Status CameraService::validateClientPermissionsLocked(const String8& cameraId,
// Only allow clients who are being used by the current foreground device user, unless calling
// from our own process OR the caller is using the cameraserver's HIDL interface.
if ( ! hardware : : IPCThreadState : : self ( ) - > isServingCall ( ) & & callingPid ! = getpid ( ) & &
if ( getCurrentServingCall ( ) ! = BinderCallType : : HWBINDER & & callingPid ! = getpid ( ) & &
( mAllowedUsers . find ( clientUserId ) = = mAllowedUsers . end ( ) ) ) {
ALOGE ( " CameraService::connect X (PID %d) rejected (cannot connect from "
" device user %d, currently allowed device users: %s) " , callingPid , clientUserId ,
@ -1534,7 +1535,7 @@ bool CameraService::shouldRejectSystemCameraConnection(const String8& cameraId)
return false ;
}
// (2)
if ( ! hardware : : IPCThreadState : : self ( ) - > isServingCall ( ) & &
if ( getCurrentServingCall ( ) ! = BinderCallType : : HWBINDER & &
systemCameraKind = = SystemCameraKind : : HIDDEN_SECURE_CAMERA ) {
ALOGW ( " Rejecting access to secure hidden camera %s " , cameraId . c_str ( ) ) ;
return true ;
@ -1543,7 +1544,7 @@ bool CameraService::shouldRejectSystemCameraConnection(const String8& cameraId)
// getCameraCharacteristics() allows for calls to succeed (albeit after hiding some
// characteristics) even if clients don't have android.permission.CAMERA. We do not want the
// same behavior for system camera devices.
if ( ! hardware : : IPCThreadState : : self ( ) - > isServingCall ( ) & &
if ( getCurrentServingCall ( ) ! = BinderCallType : : HWBINDER & &
systemCameraKind = = SystemCameraKind : : SYSTEM_ONLY_CAMERA & &
! hasPermissionsForSystemCamera ( cPid , cUid ) ) {
ALOGW ( " Rejecting access to system only camera %s, inadequete permissions " ,
@ -1569,7 +1570,7 @@ Status CameraService::connectDevice(
sp < CameraDeviceClient > client = nullptr ;
String16 clientPackageNameAdj = clientPackageName ;
if ( hardware: : IPCThreadState : : self ( ) - > isServingCall ( ) ) {
if ( getCurrentServingCall( ) = = BinderCallType : : HWBINDER ) {
std : : string vendorClient =
StringPrintf ( " vendor.client.pid<%d> " , CameraThreadState : : getCallingPid ( ) ) ;
clientPackageNameAdj = String16 ( vendorClient . c_str ( ) ) ;
@ -2778,7 +2779,7 @@ CameraService::BasicClient::BasicClient(const sp<CameraService>& cameraService,
}
mClientPackageName = packages [ 0 ] ;
}
if ( ! hardware : : IPCThreadState : : self ( ) - > isServingCall ( ) ) {
if ( getCurrentServingCall ( ) ! = BinderCallType : : HWBINDER ) {
mAppOpsManager = std : : make_unique < AppOpsManager > ( ) ;
}
}
@ -3450,7 +3451,7 @@ CameraService::DescriptorPtr CameraService::CameraClientManager::makeClientDescr
const std : : set < String8 > & conflictingKeys , int32_t score , int32_t ownerId ,
int32_t state ) {
bool isVendorClient = hardware: : IPCThreadState : : self ( ) - > isServingCall ( ) ;
bool isVendorClient = getCurrentServingCall( ) = = BinderCallType : : HWBINDER ;
int32_t score_adj = isVendorClient ? kVendorClientScore : score ;
int32_t state_adj = isVendorClient ? kVendorClientState : state ;