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

Commit 2dab0303 authored by Eric Laurent's avatar Eric Laurent
Browse files

audioflinger: honor flag AUDIO_FLAG_BYPASS_INTERRUPTION_POLICY

commit 74e01fa7 did not bypass app ops policy when flag
AUDIO_FLAG_BYPASS_INTERRUPTION_POLICY is set.

Bug: 131873101
Test: repro steps in bug
Change-Id: Idbce26cfdcddbb7a2ae8702ce3d135ef5a69f047
parent af0b1c1b
Loading
Loading
Loading
Loading
+1 −1
Original line number Original line Diff line number Diff line
@@ -26,7 +26,7 @@ public:
    bool hasOpPlayAudio() const;
    bool hasOpPlayAudio() const;


    static sp<OpPlayAudioMonitor> createIfNeeded(
    static sp<OpPlayAudioMonitor> createIfNeeded(
            uid_t uid, audio_usage_t usage, int id, audio_stream_type_t streamType);
            uid_t uid, const audio_attributes_t& attr, int id, audio_stream_type_t streamType);


private:
private:
    OpPlayAudioMonitor(uid_t uid, audio_usage_t usage, int id);
    OpPlayAudioMonitor(uid_t uid, audio_usage_t usage, int id);
+11 −5
Original line number Original line Diff line number Diff line
@@ -387,18 +387,24 @@ status_t AudioFlinger::TrackHandle::onTransact(
// static
// static
sp<AudioFlinger::PlaybackThread::OpPlayAudioMonitor>
sp<AudioFlinger::PlaybackThread::OpPlayAudioMonitor>
AudioFlinger::PlaybackThread::OpPlayAudioMonitor::createIfNeeded(
AudioFlinger::PlaybackThread::OpPlayAudioMonitor::createIfNeeded(
            uid_t uid, audio_usage_t usage, int id, audio_stream_type_t streamType)
            uid_t uid, const audio_attributes_t& attr, int id, audio_stream_type_t streamType)
{
{
    if (isAudioServerOrRootUid(uid)) {
    if (isAudioServerOrRootUid(uid)) {
        ALOGD("OpPlayAudio: not muting track:%d usage:%d root or audioserver", id, usage);
        ALOGD("OpPlayAudio: not muting track:%d usage:%d root or audioserver", id, attr.usage);
        return nullptr;
        return nullptr;
    }
    }
    // stream type has been filtered by audio policy to indicate whether it can be muted
    // stream type has been filtered by audio policy to indicate whether it can be muted
    if (streamType == AUDIO_STREAM_ENFORCED_AUDIBLE) {
    if (streamType == AUDIO_STREAM_ENFORCED_AUDIBLE) {
        ALOGD("OpPlayAudio: not muting track:%d usage:%d ENFORCED_AUDIBLE", id, usage);
        ALOGD("OpPlayAudio: not muting track:%d usage:%d ENFORCED_AUDIBLE", id, attr.usage);
        return nullptr;
        return nullptr;
    }
    }
    return new OpPlayAudioMonitor(uid, usage, id);
    if ((attr.flags & AUDIO_FLAG_BYPASS_INTERRUPTION_POLICY)
            == AUDIO_FLAG_BYPASS_INTERRUPTION_POLICY) {
        ALOGD("OpPlayAudio: not muting track:%d flags %#x have FLAG_BYPASS_INTERRUPTION_POLICY",
            id, attr.flags);
        return nullptr;
    }
    return new OpPlayAudioMonitor(uid, attr.usage, id);
}
}


AudioFlinger::PlaybackThread::OpPlayAudioMonitor::OpPlayAudioMonitor(
AudioFlinger::PlaybackThread::OpPlayAudioMonitor::OpPlayAudioMonitor(
@@ -508,7 +514,7 @@ AudioFlinger::PlaybackThread::Track::Track(
    mPresentationCompleteFrames(0),
    mPresentationCompleteFrames(0),
    mFrameMap(16 /* sink-frame-to-track-frame map memory */),
    mFrameMap(16 /* sink-frame-to-track-frame map memory */),
    mVolumeHandler(new media::VolumeHandler(sampleRate)),
    mVolumeHandler(new media::VolumeHandler(sampleRate)),
    mOpPlayAudioMonitor(OpPlayAudioMonitor::createIfNeeded(uid, attr.usage, id(), streamType)),
    mOpPlayAudioMonitor(OpPlayAudioMonitor::createIfNeeded(uid, attr, id(), streamType)),
    // mSinkTimestamp
    // mSinkTimestamp
    mFastIndex(-1),
    mFastIndex(-1),
    mCachedVolume(1.0),
    mCachedVolume(1.0),