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

Commit c2575c62 authored by Ping Tsai's avatar Ping Tsai Committed by Eric Laurent
Browse files

audio policy: check volume device before setVoiceVolume

If the volume device setting is different from the current rx device, there is no need to call setVoiceVolume to change the call volume.

Bug: 376772314
Test: Manual
Switch to speaker mode quickly after initiating a call
(cherry picked from https://partner-android-review.googlesource.com/q/commit:ebcece6a374834a9dd0581bace727a4ba081b9c8)
Flag: EXEMPT bug fix
Merged-In: I60b360d0adcc940706405e6e9618bc40e0717436
Change-Id: I60b360d0adcc940706405e6e9618bc40e0717436
parent 98b7adc7
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;