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

Commit b79899b6 authored by Ahaan Ugale's avatar Ahaan Ugale Committed by Automerger Merge Worker
Browse files

Merge "Switch media fw hotword permission check to PermissionChecker (av)"...

Merge "Switch media fw hotword permission check to PermissionChecker (av)" into sc-dev am: 61967de3

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

Change-Id: Ia99ffad98cfffb38fdb3eaa1f5b2b8e31072320b
parents 25817399 61967de3
Loading
Loading
Loading
Loading
+6 −3
Original line number Diff line number Diff line
@@ -215,14 +215,17 @@ bool captureVoiceCommunicationOutputAllowed(const AttributionSourceState& attrib
}

bool captureHotwordAllowed(const AttributionSourceState& attributionSource) {
    uid_t uid = VALUE_OR_FATAL(aidl2legacy_int32_t_uid_t(attributionSource.uid));
    uid_t pid = VALUE_OR_FATAL(aidl2legacy_int32_t_pid_t(attributionSource.pid));
    // CAPTURE_AUDIO_HOTWORD permission implies RECORD_AUDIO permission
    bool ok = recordingAllowed(attributionSource);

    if (ok) {
        static const String16 sCaptureHotwordAllowed("android.permission.CAPTURE_AUDIO_HOTWORD");
        ok = PermissionCache::checkPermission(sCaptureHotwordAllowed, pid, uid);
        // Use PermissionChecker, which includes some logic for allowing the isolated
        // HotwordDetectionService to hold certain permissions.
        permission::PermissionChecker permissionChecker;
        ok = (permissionChecker.checkPermissionForPreflight(
                sCaptureHotwordAllowed, attributionSource, String16(),
                AppOpsManager::OP_NONE) != permission::PermissionChecker::PERMISSION_HARD_DENIED);
    }
    if (!ok) ALOGV("android.permission.CAPTURE_AUDIO_HOTWORD");
    return ok;