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

Commit 8ed73c1c authored by Eric Laurent's avatar Eric Laurent
Browse files

audio policy: improve capture policy for clients with same UID

Modify concurrent capture logic to allow different policies
applied to record clients sharing the same UID.
Previously, because the control granularity was the UID, we had to
enforce the same decision for all clients with the same UID.
Now that audio flinger and audio policy manager APIs to silence capture
are per port ID, we can apply a different policy for each record instance.

Bug: 139370731
Test: AudioRecordTest#testRecordNoDataForIdleUids

Change-Id: I533b74602fa465fd5df7f848eca48dfd49b424c8
parent 5ada82ee
Loading
Loading
Loading
Loading
+1 −14
Original line number Diff line number Diff line
@@ -406,8 +406,7 @@ void AudioPolicyService::updateUidStates_l()
{
//    Go over all active clients and allow capture (does not force silence) in the
//    following cases:
//    Another client in the same UID has already been allowed to capture
//    OR The client is the assistant
//    The client is the assistant
//        AND an accessibility service is on TOP or a RTT call is active
//                AND the source is VOICE_RECOGNITION or HOTWORD
//            OR uses VOICE_RECOGNITION AND is on TOP
@@ -498,21 +497,12 @@ void AudioPolicyService::updateUidStates_l()
        topActive = latestActive;
    }

    std::vector<uid_t> enabledUids;

    for (size_t i =0; i < mAudioRecordClients.size(); i++) {
        sp<AudioRecordClient> current = mAudioRecordClients[i];
        if (!current->active) {
            continue;
        }

        // keep capture allowed if another client with the same UID has already
        // been allowed to capture
        if (std::find(enabledUids.begin(), enabledUids.end(), current->uid)
                != enabledUids.end()) {
            continue;
        }

        audio_source_t source = current->attributes.source;
        bool isTopOrLatestActive = topActive == nullptr ? false : current->uid == topActive->uid;
        bool isLatestSensitive = latestSensitiveActive == nullptr ?
@@ -572,9 +562,6 @@ void AudioPolicyService::updateUidStates_l()
        setAppState_l(current->portId,
                      allowCapture ? apmStatFromAmState(mUidPolicy->getUidState(current->uid)) :
                                APP_STATE_IDLE);
        if (allowCapture) {
            enabledUids.push_back(current->uid);
        }
    }
}