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

Commit 47670c9e authored by Eric Laurent's avatar Eric Laurent
Browse files

audiopolicy: fix accessibility service capture

Commit 589171c8 introduced a regression when an accessibility service
is capturing with UI on top and using an audio source different from
VOICE_RECOGNITION or HOTWORD.

Bug: 140072679
Test: repro steps in bug
Change-Id: Ia322f801066b9ec0cc4afa8d6c5e8296e9ecb1cc
parent 33d7ab05
Loading
Loading
Loading
Loading
+9 −12
Original line number Diff line number Diff line
@@ -552,21 +552,19 @@ void AudioPolicyService::updateUidStates_l()
            }
        } else if (mUidPolicy->isA11yUid(current->uid)) {
            // For accessibility service allow capture if:
            //     Is on TOP
            //          AND the source is VOICE_RECOGNITION or HOTWORD
            //     Or
            //     The assistant is not on TOP
            //         AND there is no active privacy sensitive capture or call
            //             OR client has CAPTURE_AUDIO_OUTPUT privileged permission
            if (isA11yOnTop) {
                if (source == AUDIO_SOURCE_VOICE_RECOGNITION || source == AUDIO_SOURCE_HOTWORD) {
                    allowCapture = true;
                }
            } else {
            //     OR
            //         Is on TOP AND the source is VOICE_RECOGNITION or HOTWORD
            if (!isAssistantOnTop
                    && (!(isSensitiveActive || isInCall) || current->canCaptureOutput)) {
                allowCapture = true;
            }
            if (isA11yOnTop) {
                if (source == AUDIO_SOURCE_VOICE_RECOGNITION || source == AUDIO_SOURCE_HOTWORD) {
                    allowCapture = true;
                }
            }
        }
        setAppState_l(current->uid,
@@ -993,8 +991,7 @@ void AudioPolicyService::UidPolicy::updateUidLocked(std::unordered_map<uid_t,

bool AudioPolicyService::UidPolicy::isA11yOnTop() {
    for (const auto &uid : mCachedUids) {
        std::vector<uid_t>::iterator it = find(mA11yUids.begin(), mA11yUids.end(), uid.first);
        if (it == mA11yUids.end()) {
        if (!isA11yUid(uid.first)) {
            continue;
        }
        if (uid.second.second >= ActivityManager::PROCESS_STATE_TOP