TWSP-HFP: Setup SCO connection with earbud only if it is INEAR (2/2)
While earbud is not in ear state, SCO connection request will be rejected
by earbud. Then SCO audio disconnected event will cause VOIP call stop.
1) In BTA AG SM, SCO connection open event will trigger the secondary SCO
connection only if the earbud is INEAR state.
2) In BTIF HF, Move audio to connecting state and trigger BTA AG setup SCO
connection only if the earbud is INEAR state.
Change-Id: I55f25c84874132258c24d8b7eff2b355e51e0419
diff --git a/system_bt_ext/bta/tws_plus/ag/bta_ag_twsp_dev.cc b/system_bt_ext/bta/tws_plus/ag/bta_ag_twsp_dev.cc
index 7b3e8e2..8000abb 100644
--- a/system_bt_ext/bta/tws_plus/ag/bta_ag_twsp_dev.cc
+++ b/system_bt_ext/bta/tws_plus/ag/bta_ag_twsp_dev.cc
@@ -673,7 +673,10 @@
set_twsp_mic_quality(idx, int_arg);
} break;
case BTA_AG_TWSP_AT_QES_EVT: {
- set_twsp_state(idx, int_arg);
+ if (set_twsp_state(idx, int_arg)) {
+ APPL_TRACE_DEBUG("%s: Update twsp state to BTIF", __func__);
+ (*bta_ag_cb.p_cback)((tBTA_AG_EVT)BTA_AG_TWSP_STATE_UPDATE, (tBTA_AG *)val);
+ }
} break;
case BTA_AG_TWSP_AT_QER_EVT: {
set_twsp_role(idx, int_arg);
diff --git a/system_bt_ext/bta/tws_plus/ag/bta_ag_twsp_sco.cc b/system_bt_ext/bta/tws_plus/ag/bta_ag_twsp_sco.cc
index 2cfcdc2..5d579ed 100644
--- a/system_bt_ext/bta/tws_plus/ag/bta_ag_twsp_sco.cc
+++ b/system_bt_ext/bta/tws_plus/ag/bta_ag_twsp_sco.cc
@@ -307,7 +307,8 @@
/*SCO is up!*/
p_sco->state = BTA_AG_SCO_OPEN_ST;
other_scb = get_other_twsp_scb((p_scb->peer_addr));
- if (other_scb && twsp_sco_active(other_scb) == false) {
+ if (other_scb && twsp_sco_active(other_scb) == false &&
+ get_twsp_state(other_scb) == TWSPLUS_EB_STATE_INEAR) {
APPL_TRACE_WARNING("Calling SCO open");
dispatch_event_primary_peer_device(p_scb, BTA_AG_SCO_OPEN_E);
}
diff --git a/system_bt_ext/btif/include/btif_twsp_hf.h b/system_bt_ext/btif/include/btif_twsp_hf.h
index 2c9c7c4..cd7da30 100644
--- a/system_bt_ext/btif/include/btif_twsp_hf.h
+++ b/system_bt_ext/btif/include/btif_twsp_hf.h
@@ -32,9 +32,11 @@
* IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
+#define BTA_AG_TWSP_STATE_UPDATE 252
#define BTA_AG_TWSP_BATTERY_UPDATE 255
#include "bta_ag_api.h"
+#include "bta_ag_twsp_dev.h"
void btif_handle_vendor_hf_events(uint16_t event, tBTA_AG* data,
RawAddress *bd_addr);