cameraserver: Fix package name logged for system uid ndk clients
Bug: 376427318
Flag: EXEMPT bugfix
Test: Check system ndk client as well as 3P package name logged
Change-Id: I6e2efb61346cf1f8cbe3a8370d903f2f68fd7947
Signed-off-by: Jayant Chowdhary <jchowdhary@google.com>
diff --git a/services/camera/libcameraservice/CameraService.cpp b/services/camera/libcameraservice/CameraService.cpp
index 6da1606..f59ad18 100644
--- a/services/camera/libcameraservice/CameraService.cpp
+++ b/services/camera/libcameraservice/CameraService.cpp
@@ -2254,9 +2254,12 @@
int callingPid = getCallingPid();
int callingUid = getCallingUid();
bool systemNativeClient = false;
+ AttributionSourceState resolvedClientAttribution(clientAttribution);
if (callerHasSystemUid() && (clientPackageNameMaybe.size() == 0)) {
std::string systemClient = fmt::sprintf("client.pid<%d>", callingPid);
clientPackageNameMaybe = systemClient;
+ // Pass in packageName since AttributionAndPermissionUtils can't resolve vndk clients.
+ resolvedClientAttribution.packageName = clientPackageNameMaybe;
systemNativeClient = true;
}
@@ -2272,10 +2275,10 @@
bool isNonSystemNdk = clientPackageNameMaybe.size() == 0;
- AttributionSourceState resolvedClientAttribution(clientAttribution);
if (!flags::use_context_attribution_source()) {
resolvedClientAttribution.pid = USE_CALLING_PID;
}
+
ret = resolveAttributionSource(resolvedClientAttribution, __FUNCTION__, cameraId);
if (!ret.isOk()) {
logRejected(cameraId, getCallingPid(), clientAttribution.packageName.value_or(""),