hal: add check for BT SCO status when start voice call

Before starting the voice call over BT SCO, BT SCO status
is checked, and if BT SCO status is true, APM set output
to BT SCO, but bt-sco disconnect then. Voice usecase would
start without enabling BT SCO back end, and failure happens
with setting in_call to true. Finally no sound issue happens
during bt-sco call, and voice call usecase also cannot start
even if APM set output to handset due to in_call is true already.

Fix by adding check for BT SCO status when staring voice
usecase to avoid voice call still route BT SCO even if BT
SCO has been disconnected, and reseting in_call flag when
voice start failure happens.

CRs-Fixed: 2107853
Change-Id: I7d9f05447e8c29d038a2ed49e9f3ed2a7994eb6c
diff --git a/hal/voice.c b/hal/voice.c
index 5a3ff33..b3645be 100644
--- a/hal/voice.c
+++ b/hal/voice.c
@@ -221,6 +221,13 @@
     uc_info->in_snd_device = SND_DEVICE_NONE;
     uc_info->out_snd_device = SND_DEVICE_NONE;
 
+    if (audio_is_bluetooth_sco_device(uc_info->devices) && !adev->bt_sco_on) {
+        ALOGE("start_call: couldn't find BT SCO, SCO is not ready");
+        adev->voice.in_call = false;
+        ret = -EIO;
+        goto error_start_voice;
+    }
+
     list_add_tail(&adev->usecase_list, &uc_info->list);
 
     select_devices(adev, usecase_id);