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

Commit 67f5099c authored by Eric Laurent's avatar Eric Laurent Committed by Android (Google) Code Review
Browse files

Merge "audio policy: update permission check for REMOTE_SUBMIX audio source."

parents d1599505 637bd201
Loading
Loading
Loading
Loading
+6 −1
Original line number Diff line number Diff line
@@ -128,6 +128,11 @@ status_t MediaRecorderClient::setAudioSource(int as)
    if ((as == AUDIO_SOURCE_FM_TUNER
                && !(captureAudioOutputAllowed(mAttributionSource)
                    || captureTunerAudioInputAllowed(mAttributionSource)))
            || (as == AUDIO_SOURCE_REMOTE_SUBMIX
                && !(captureAudioOutputAllowed(mAttributionSource)
                    || modifyAudioRoutingAllowed(mAttributionSource)))
            || (as == AUDIO_SOURCE_ECHO_REFERENCE
                && !captureAudioOutputAllowed(mAttributionSource))
            || !recordingAllowed(mAttributionSource, (audio_source_t)as)) {
        return PERMISSION_DENIED;
    }
+23 −14
Original line number Diff line number Diff line
@@ -609,28 +609,35 @@ Status AudioPolicyService::getInputForAttr(const media::AudioAttributesInternal&
            adjAttributionSource)));

    // check calling permissions.
    // Capturing from FM_TUNER source is controlled by captureTunerAudioInputAllowed() and
    // captureAudioOutputAllowed() (deprecated) as this does not affect users privacy
    // as does capturing from an actual microphone.
    if (!(recordingAllowed(adjAttributionSource, attr.source)
            || attr.source == AUDIO_SOURCE_FM_TUNER)) {
    // Capturing from the following sources does not require permission RECORD_AUDIO
    // as the captured audio does not come from a microphone:
    // - FM_TUNER source is controlled by captureTunerAudioInputAllowed() or
    // captureAudioOutputAllowed() (deprecated).
    // - REMOTE_SUBMIX source is controlled by captureAudioOutputAllowed() if the input
    // type is API_INPUT_MIX_EXT_POLICY_REROUTE and by AudioService if a media projection
    // is used and input type is API_INPUT_MIX_PUBLIC_CAPTURE_PLAYBACK
    // - ECHO_REFERENCE source is controlled by captureAudioOutputAllowed()
    if (!(recordingAllowed(adjAttributionSource, inputSource)
            || inputSource == AUDIO_SOURCE_FM_TUNER
            || inputSource == AUDIO_SOURCE_REMOTE_SUBMIX
            || inputSource == AUDIO_SOURCE_ECHO_REFERENCE)) {
        ALOGE("%s permission denied: recording not allowed for %s",
                __func__, adjAttributionSource.toString().c_str());
        return binderStatusFromStatusT(PERMISSION_DENIED);
    }

    bool canCaptureOutput = captureAudioOutputAllowed(adjAttributionSource);
    if ((inputSource == AUDIO_SOURCE_VOICE_UPLINK ||
        inputSource == AUDIO_SOURCE_VOICE_DOWNLINK ||
        inputSource == AUDIO_SOURCE_VOICE_CALL ||
        inputSource == AUDIO_SOURCE_ECHO_REFERENCE)
    if ((inputSource == AUDIO_SOURCE_VOICE_UPLINK
            || inputSource == AUDIO_SOURCE_VOICE_DOWNLINK
            || inputSource == AUDIO_SOURCE_VOICE_CALL
            || inputSource == AUDIO_SOURCE_ECHO_REFERENCE)
            && !canCaptureOutput) {
        return binderStatusFromStatusT(PERMISSION_DENIED);
    }

    if (inputSource == AUDIO_SOURCE_FM_TUNER
        && !captureTunerAudioInputAllowed(adjAttributionSource)
        && !canCaptureOutput) {
        && !canCaptureOutput
        && !captureTunerAudioInputAllowed(adjAttributionSource)) {
        return binderStatusFromStatusT(PERMISSION_DENIED);
    }

@@ -759,7 +766,9 @@ Status AudioPolicyService::startInput(int32_t portIdAidl)
    // check calling permissions
    if (!(startRecording(client->attributionSource, String16(msg.str().c_str()),
                         client->attributes.source)
            || client->attributes.source == AUDIO_SOURCE_FM_TUNER)) {
            || client->attributes.source == AUDIO_SOURCE_FM_TUNER
            || client->attributes.source == AUDIO_SOURCE_REMOTE_SUBMIX
            || client->attributes.source == AUDIO_SOURCE_ECHO_REFERENCE)) {
        ALOGE("%s permission denied: recording not allowed for attribution source %s",
                __func__, client->attributionSource.toString().c_str());
        return binderStatusFromStatusT(PERMISSION_DENIED);
+1 −0
Original line number Diff line number Diff line
@@ -908,6 +908,7 @@ bool AudioPolicyService::isAppOpSource(audio_source_t source)
    switch (source) {
        case AUDIO_SOURCE_FM_TUNER:
        case AUDIO_SOURCE_ECHO_REFERENCE:
        case AUDIO_SOURCE_REMOTE_SUBMIX:
            return false;
        default:
            break;