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

Commit 499faed9 authored by Bhalchandra Gajare's avatar Bhalchandra Gajare
Browse files

audio policy: check permissions for AUDIO_INPUT_FLAG_HW_HOTWORD

Allow audio capture with AUDIO_INPUT_FLAG_HW_HOTWORD only if the
caller has CAPTURE_AUDIO_HOTWORD permission granted. While at it,
update the return code to PERMISSION_DENIED for other permission
checks as well.

Bug: 178654411
Test: tested by setting hotword mode from AGSA application that has the
required permission. Able to see hal opened with correct flag.
Test: Forced to always return error if flag was set and verified
AudioRecord starting in application fails.

Change-Id: I827ab5933621bff71a96164e40026ecccf1ba44f
parent 4e74cdb3
Loading
Loading
Loading
Loading
+8 −1
Original line number Diff line number Diff line
@@ -590,7 +590,14 @@ Status AudioPolicyService::getInputForAttr(const media::AudioAttributesInternal&

    bool canCaptureHotword = captureHotwordAllowed(opPackageName, pid, uid);
    if ((inputSource == AUDIO_SOURCE_HOTWORD) && !canCaptureHotword) {
        return binderStatusFromStatusT(BAD_VALUE);
        return binderStatusFromStatusT(PERMISSION_DENIED);
    }

    if (((flags & AUDIO_INPUT_FLAG_HW_HOTWORD) != 0)
            && !canCaptureHotword) {
        ALOGE("%s: permission denied: hotword mode not allowed"
              " for uid %d pid %d", __func__, uid, pid);
        return binderStatusFromStatusT(PERMISSION_DENIED);
    }

    sp<AudioPolicyEffects>audioPolicyEffects;