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

Commit ef24fda0 authored by Evan Severson's avatar Evan Severson Committed by Android (Google) Code Review
Browse files

Merge "AudioService Remove direct check to sensor privacy service" into sc-dev

parents b5c421e3 1f700cd0
Loading
Loading
Loading
Loading
+26 −41
Original line number Diff line number Diff line
@@ -537,9 +537,7 @@ void AudioPolicyService::updateUidStates_l()
{
//    Go over all active clients and allow capture (does not force silence) in the
//    following cases:
//    The client source is virtual (remote submix, call audio TX or RX...)
//    OR The user the client is running in has microphone sensor privacy disabled
//        AND 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
@@ -554,6 +552,7 @@ void AudioPolicyService::updateUidStates_l()
//                    OR client has CAPTURE_AUDIO_OUTPUT privileged permission
//        AND is on TOP
//        AND the source is VOICE_RECOGNITION or HOTWORD
//    OR the client source is virtual (remote submix, call audio TX or RX...)
//    OR the client source is HOTWORD
//        AND is on TOP
//            OR all active clients are using HOTWORD source
@@ -596,8 +595,7 @@ void AudioPolicyService::updateUidStates_l()
    for (size_t i =0; i < mAudioRecordClients.size(); i++) {
        sp<AudioRecordClient> current = mAudioRecordClients[i];
        uid_t currentUid = VALUE_OR_FATAL(aidl2legacy_int32_t_uid_t(current->identity.uid));
        if (!current->active || (!isVirtualSource(current->attributes.source)
                && isUserSensorPrivacyEnabledForUid(currentUid))) {
        if (!current->active) {
            continue;
        }

@@ -734,9 +732,6 @@ void AudioPolicyService::updateUidStates_l()
        if (isVirtualSource(source)) {
            // Allow capture for virtual (remote submix, call audio TX or RX...) sources
            allowCapture = true;
        } else if (isUserSensorPrivacyEnabledForUid(currentUid)) {
            // If sensor privacy is enabled, don't allow capture
            allowCapture = false;
        } else if (mUidPolicy->isAssistantUid(currentUid)) {
            // For assistant allow capture if:
            //     An accessibility service is on TOP or a RTT call is active
@@ -1145,16 +1140,6 @@ status_t AudioPolicyService::handleGetUidState(Vector<String16>& args, int out,
    return NO_INIT;
}

bool AudioPolicyService::isUserSensorPrivacyEnabledForUid(uid_t uid) {
    userid_t userId = multiuser_get_user_id(uid);
    if (mMicrophoneSensorPrivacyPolicies.find(userId) == mMicrophoneSensorPrivacyPolicies.end()) {
        sp<SensorPrivacyPolicy> userPolicy = new SensorPrivacyPolicy(this);
        userPolicy->registerSelfForMicrophoneOnly(userId);
        mMicrophoneSensorPrivacyPolicies[userId] = userPolicy;
    }
    return mMicrophoneSensorPrivacyPolicies[userId]->isSensorPrivacyEnabled();
}

status_t AudioPolicyService::printHelp(int out) {
    return dprintf(out, "Audio policy service commands:\n"
        "  get-uid-state <PACKAGE> [--user USER_ID] gets the uid state\n"
+0 −4
Original line number Diff line number Diff line
@@ -346,8 +346,6 @@ private:
    status_t validateUsage(audio_usage_t usage);
    status_t validateUsage(audio_usage_t usage, const media::permission::Identity& identity);

    bool isUserSensorPrivacyEnabledForUid(uid_t uid);

    void updateUidStates();
    void updateUidStates_l() REQUIRES(mLock);

@@ -908,8 +906,6 @@ private:
    void *mLibraryHandle = nullptr;
    CreateAudioPolicyManagerInstance mCreateAudioPolicyManager;
    DestroyAudioPolicyManagerInstance mDestroyAudioPolicyManager;

    std::map<userid_t, sp<SensorPrivacyPolicy>> mMicrophoneSensorPrivacyPolicies;
};

} // namespace android