hal: fix voice call device routing issue
voice_device_set flag is to indicate voice call device routing
update from policymanager to HAL. It is set to true in voice_extn_start_call
and reset in update_calls() which causes mismatch in flag update during back
to back voice calls scenario. Update adev->voice_device_set flag in
voice_extn_stop_call instead of update_calls().
Bug: 17149385
Cherry-pick of CAF commit: e0085d06416a8fb6d0b4503900508c16fbc98c58
Change-Id: Ie07105671f254899890bdb4c0635c7dc1f55dbff
diff --git a/hal/voice.c b/hal/voice.c
index 278f0fb..2d3ec7c 100644
--- a/hal/voice.c
+++ b/hal/voice.c
@@ -163,26 +163,32 @@
}
session->state.current = CALL_ACTIVE;
- return 0;
+ goto done;
error_start_voice:
stop_call(adev, usecase_id);
+done:
ALOGD("%s: exit: status(%d)", __func__, ret);
return ret;
}
-bool voice_is_in_call(struct audio_device *adev)
+bool voice_is_call_state_active(struct audio_device *adev)
{
- bool in_call = false;
+ bool call_state = false;
int ret = 0;
- ret = voice_extn_is_in_call(adev, &in_call);
+ ret = voice_extn_is_call_state_active(adev, &call_state);
if (ret == -ENOSYS) {
- in_call = (adev->voice.session[VOICE_SESS_IDX].state.current == CALL_ACTIVE) ? true : false;
+ call_state = (adev->voice.session[VOICE_SESS_IDX].state.current == CALL_ACTIVE) ? true : false;
}
- return in_call;
+ return call_state;
+}
+
+bool voice_is_in_call(struct audio_device *adev)
+{
+ return adev->voice.in_call;
}
bool voice_is_in_call_rec_stream(struct stream_in *in)
@@ -218,7 +224,7 @@
int usecase_id;
int rec_mode = INCALL_REC_NONE;
- if (voice_is_in_call(adev)) {
+ if (voice_is_call_state_active(adev)) {
switch (in->source) {
case AUDIO_SOURCE_VOICE_UPLINK:
in->usecase = USECASE_INCALL_REC_UPLINK;
@@ -327,6 +333,7 @@
if (ret == -ENOSYS) {
ret = start_call(adev, USECASE_VOICE_CALL);
}
+ adev->voice.in_call = true;
return ret;
}
@@ -335,6 +342,7 @@
{
int ret = 0;
+ adev->voice.in_call = false;
ret = voice_extn_stop_call(adev);
if (ret == -ENOSYS) {
ret = stop_call(adev, USECASE_VOICE_CALL);
@@ -389,7 +397,7 @@
if (tty_mode != adev->voice.tty_mode) {
adev->voice.tty_mode = tty_mode;
adev->acdb_settings = (adev->acdb_settings & TTY_MODE_CLEAR) | tty_mode;
- if (voice_is_in_call(adev))
+ if (voice_is_call_state_active(adev))
voice_update_devices_for_all_voice_usecases(adev);
}
}
@@ -434,7 +442,7 @@
adev->voice.hac = false;
adev->voice.volume = 1.0f;
adev->voice.mic_mute = false;
- adev->voice.voice_device_set = false;
+ adev->voice.in_call = false;
for (i = 0; i < MAX_VOICE_SESSIONS; i++) {
adev->voice.session[i].pcm_rx = NULL;
adev->voice.session[i].pcm_tx = NULL;