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

Commit fe8aec3e authored by TreeHugger Robot's avatar TreeHugger Robot Committed by Automerger Merge Worker
Browse files

Merge "Use PermissionChecker (av) in captureAudioOutputAllowed method" into...

Merge "Use PermissionChecker (av) in captureAudioOutputAllowed method" into tm-dev am: 981bf0e8 am: 0490489b am: cd0fceb7 am: e1d03c63

Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/av/+/18672350



Change-Id: Ibcb8022a1ebd8b8eb086e483cc03ac6bacf0854c
Signed-off-by: default avatarAutomerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
parents 20b3953b e1d03c63
Loading
Loading
Loading
Loading
+6 −2
Original line number Diff line number Diff line
@@ -181,10 +181,14 @@ void finishRecording(const AttributionSourceState& attributionSource, audio_sour

bool captureAudioOutputAllowed(const AttributionSourceState& attributionSource) {
    uid_t uid = VALUE_OR_FATAL(aidl2legacy_int32_t_uid_t(attributionSource.uid));
    pid_t pid = VALUE_OR_FATAL(aidl2legacy_int32_t_pid_t(attributionSource.pid));
    if (isAudioServerOrRootUid(uid)) return true;
    static const String16 sCaptureAudioOutput("android.permission.CAPTURE_AUDIO_OUTPUT");
    bool ok = PermissionCache::checkPermission(sCaptureAudioOutput, pid, uid);
    // Use PermissionChecker, which includes some logic for allowing the isolated
    // HotwordDetectionService to hold certain permissions.
    permission::PermissionChecker permissionChecker;
    bool ok = (permissionChecker.checkPermissionForPreflight(
            sCaptureAudioOutput, attributionSource, String16(),
            AppOpsManager::OP_NONE) != permission::PermissionChecker::PERMISSION_HARD_DENIED);
    if (!ok) ALOGV("Request requires android.permission.CAPTURE_AUDIO_OUTPUT");
    return ok;
}