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

Commit c8b226f4 authored by Jeff Brown's avatar Jeff Brown Committed by Android (Google) Code Review
Browse files

Merge "Enforce permission for recording from remote submix." into klp-dev

parents cf2a123e 893a5642
Loading
Loading
Loading
Loading
+10 −0
Original line number Diff line number Diff line
@@ -1206,6 +1206,10 @@ void AudioFlinger::NotificationClient::binderDied(const wp<IBinder>& who)

// ----------------------------------------------------------------------------

static bool deviceRequiresCaptureAudioOutputPermission(audio_devices_t inDevice) {
    return audio_is_remote_submix_device(inDevice);
}

sp<IAudioRecord> AudioFlinger::openRecord(
        audio_io_handle_t input,
        uint32_t sampleRate,
@@ -1246,6 +1250,12 @@ sp<IAudioRecord> AudioFlinger::openRecord(
            goto Exit;
        }

        if (deviceRequiresCaptureAudioOutputPermission(thread->inDevice())
                && !captureAudioOutputAllowed()) {
            lStatus = PERMISSION_DENIED;
            goto Exit;
        }

        pid_t pid = IPCThreadState::self()->getCallingPid();
        client = registerPid_l(pid);

+9 −0
Original line number Diff line number Diff line
@@ -34,6 +34,15 @@ bool recordingAllowed() {
    return ok;
}

bool captureAudioOutputAllowed() {
    if (getpid_cached == IPCThreadState::self()->getCallingPid()) return true;
    static const String16 sCaptureAudioOutput("android.permission.CAPTURE_AUDIO_OUTPUT");
    // don't use PermissionCache; this is not a system permission
    bool ok = checkCallingPermission(sCaptureAudioOutput);
    if (!ok) ALOGE("Request requires android.permission.CAPTURE_AUDIO_OUTPUT");
    return ok;
}

bool settingsAllowed() {
    if (getpid_cached == IPCThreadState::self()->getCallingPid()) return true;
    static const String16 sAudioSettings("android.permission.MODIFY_AUDIO_SETTINGS");
+1 −0
Original line number Diff line number Diff line
@@ -21,6 +21,7 @@ namespace android {
extern pid_t getpid_cached;

bool recordingAllowed();
bool captureAudioOutputAllowed();
bool settingsAllowed();
bool dumpAllowed();