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

Commit 2065ec8c authored by Eric Laurent's avatar Eric Laurent Committed by Android (Google) Code Review
Browse files

Merge "audio policy: check volume device before setVoiceVolume" into main

parents 794a9bd7 c2575c62
Loading
Loading
Loading
Loading
+15 −13
Original line number Diff line number Diff line
@@ -3804,21 +3804,23 @@ status_t AudioPolicyManager::setVolumeIndexForAttributes(const audio_attributes_
        }
    }

    // update voice volume if the an active call route exists
    if (mCallRxSourceClient != nullptr && mCallRxSourceClient->isConnected()
            && (curSrcDevices.find(
                Volume::getDeviceForVolume({mCallRxSourceClient->sinkDevice()->type()}))
                != curSrcDevices.end())) {
    // update voice volume if the an active call route exists and target device is same as current
    if (mCallRxSourceClient != nullptr && mCallRxSourceClient->isConnected()) {
        audio_devices_t rxSinkDevice = mCallRxSourceClient->sinkDevice()->type();
        audio_devices_t curVoiceDevice = Volume::getDeviceForVolume({rxSinkDevice});
        if (curVoiceDevice == device
                && curSrcDevices.find(curVoiceDevice) != curSrcDevices.end()) {
            bool isVoiceVolSrc;
            bool isBtScoVolSrc;
        if (isVolumeConsistentForCalls(vs, {mCallRxSourceClient->sinkDevice()->type()},
            if (isVolumeConsistentForCalls(vs, {rxSinkDevice},
                    isVoiceVolSrc, isBtScoVolSrc, __func__)
                    && (isVoiceVolSrc || isBtScoVolSrc)) {
                bool voiceVolumeManagedByHost = !isBtScoVolSrc &&
                    !audio_is_ble_out_device(mCallRxSourceClient->sinkDevice()->type());
                        !audio_is_ble_out_device(rxSinkDevice);
                setVoiceVolume(index, curves, voiceVolumeManagedByHost, 0);
            }
        }
    }

    mpClientInterface->onAudioVolumeGroupChanged(group, 0 /*flags*/);
    return status;