HFP: move sco sm to OPENNING only if initiate SCO connection to peer (2/2)
If peer device is not active device, bta_ag_create_sco will not initate
sco connection to peer, but return directly. As a result, bta ag sco or
bta twsp sco SM will block in OPENNING state. To avoid this issue, move
sco sm to OPENNING only if initate SCO connection to peer.
Change-Id: Ifb9564fe67585f5a400b2551a2c92be4220280be
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 849aa1c..4a22347 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
@@ -264,8 +264,13 @@
twsp_select_microphone(get_other_twsp_scb(p_scb->peer_addr), p_scb);
}
/* create sco connection to peer */
- bta_ag_create_sco(p_scb, true);
- p_sco->state = BTA_AG_SCO_OPENING_ST;
+ if (bta_ag_create_sco(p_scb, true)) {
+ p_sco->state = BTA_AG_SCO_OPENING_ST;
+ } else {
+ APPL_TRACE_WARNING("%s: create sco connection failed", __func__);
+ p_sco->state = BTA_AG_SCO_LISTEN_ST;
+ bta_ag_cback_sco(p_scb, BTA_AG_AUDIO_CLOSE_EVT);
+ }
break;
case BTA_AG_SCO_CONN_CLOSE_E:
//SCO failed back to LISTEN