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

Commit b18227c8 authored by Ahaan Ugale's avatar Ahaan Ugale
Browse files

Switch media fw hotword permission check to PermissionChecker (av)

PermissionChecker now includes some higher level logic for allowing the
HotwordDetectionService to access hotword audio.

Bug: 190011174
Test: manual - sample app can read audio (with a few other wip changes)
Change-Id: Id1b7755844c370c9465cd2180e5f03463186ef7b
parent 69124fa3
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;