* When trying to connect SCO to non-active and active device back to
back, the first connection to non-active device must fail gracefully
* Otherwise, BTA SCO state machine may stuck in a irrecoverable state
* Schedule to send AUDIO_CONNECTING state before starting SCO connection
to avoid race condition between connecting state and connection
failure
Bug:
111101075
Test: Manual test, make a call and switch path A->speaker->B on phone UI
Change-Id: I9bfa389e04863944d88f2bca49d27f1247fa072b
(cherry picked from commit
5360d6ac01702aa0657a10e561fae760fd6a151d)
if (!bta_ag_sco_is_active_device(p_scb->peer_addr)) {
LOG(WARNING) << __func__ << ": device " << p_scb->peer_addr
<< " is not active, active_device=" << active_device_addr;
+ if (bta_ag_cb.sco.p_curr_scb != nullptr &&
+ bta_ag_cb.sco.p_curr_scb->in_use && p_scb == bta_ag_cb.sco.p_curr_scb) {
+ do_in_bta_thread(
+ FROM_HERE, base::Bind(&bta_ag_sm_execute, p_scb, BTA_AG_SCO_CLOSE_EVT,
+ tBTA_AG_DATA::kEmpty));
+ }
return;
}
/* Make sure this SCO handle is not already in use */
LOG(ERROR) << ": SLC not connected for " << *bd_addr;
return BT_STATUS_NOT_READY;
}
- BTA_AgAudioOpen(btif_hf_cb[idx].handle);
- // Inform the application that the audio connection has been initiated
- // successfully
do_in_jni_thread(base::Bind(&Callbacks::AudioStateCallback,
// Manual pointer management for now
base::Unretained(bt_hf_callbacks),
BTHF_AUDIO_STATE_CONNECTING,
&btif_hf_cb[idx].connected_bda));
+ BTA_AgAudioOpen(btif_hf_cb[idx].handle);
return BT_STATUS_SUCCESS;
}