Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 0267d472 authored by Jayant Chowdhary's avatar Jayant Chowdhary
Browse files

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: default avatarJayant Chowdhary <jchowdhary@google.com>
parent 9f3eff9a
Loading
Loading
Loading
Loading
+4 −1
Original line number Diff line number Diff line
@@ -2254,9 +2254,12 @@ Status CameraService::connectDevice(
    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 @@ Status CameraService::connectDevice(

    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(""),
+14 −2
Original line number Diff line number Diff line
@@ -263,8 +263,20 @@ class AttributionAndPermissionUtilsEncapsulator {
    binder::Status resolveAttributionSource(AttributionSourceState& resolvedAttributionSource,
                                            const std::string& methodName,
                                            const std::optional<std::string>& cameraIdMaybe) {
        return mAttributionAndPermissionUtils->resolveAttributionSource(resolvedAttributionSource,
                                                                        methodName, cameraIdMaybe);
        std::string passedPackageName;
        if (resolvedAttributionSource.packageName.has_value()) {
            passedPackageName = resolvedAttributionSource.packageName.value();
        }
        auto ret = mAttributionAndPermissionUtils->resolveAttributionSource(
                resolvedAttributionSource, methodName, cameraIdMaybe);
        if (!ret.isOk()) {
            return ret;
        }
        // Fix up package name
        if (passedPackageName.size() != 0) {
            resolvedAttributionSource.packageName = std::move(passedPackageName);
        }
        return ret;
    }

    // The word 'System' here does not refer to callers only on the system