From: Hansong Zhang Date: Fri, 2 Oct 2020 00:47:03 +0000 (-0700) Subject: SMP: Assume L2cap tx completes immediately X-Git-Url: http://git.osdn.net/view?a=commitdiff_plain;h=8326b49c4cf83b747dcaf4b69f8040db1db5d09e;p=android-x86%2Fsystem-bt.git SMP: Assume L2cap tx completes immediately Bug: 159815595 Tag: #refactor Test: compile & verify basic functions working Change-Id: I5bf5c5067f3ad3d48716fdc65f73920107d034cf --- diff --git a/stack/smp/smp_l2c.cc b/stack/smp/smp_l2c.cc index 2e0025c49..f652c295b 100644 --- a/stack/smp/smp_l2c.cc +++ b/stack/smp/smp_l2c.cc @@ -208,24 +208,7 @@ static void smp_data_received(uint16_t channel, const RawAddress& bd_addr, * Description SMP channel tx complete callback * ******************************************************************************/ -static void smp_tx_complete_callback(uint16_t cid, uint16_t num_pkt) { - tSMP_CB* p_cb = &smp_cb; - - if (p_cb->total_tx_unacked >= num_pkt) - p_cb->total_tx_unacked -= num_pkt; - else - SMP_TRACE_ERROR("Unexpected %s: num_pkt = %d", __func__, num_pkt); - - if (p_cb->total_tx_unacked == 0 && p_cb->wait_for_authorization_complete) { - tSMP_INT_DATA smp_int_data; - smp_int_data.status = SMP_SUCCESS; - if (cid == L2CAP_SMP_CID) { - smp_sm_event(p_cb, SMP_AUTH_CMPL_EVT, &smp_int_data); - } else { - smp_br_state_machine_event(p_cb, SMP_BR_AUTH_CMPL_EVT, &smp_int_data); - } - } -} +static void smp_tx_complete_callback(uint16_t cid, uint16_t num_pkt) {} /******************************************************************************* * diff --git a/stack/smp/smp_utils.cc b/stack/smp/smp_utils.cc index 9716468da..43ae4ea73 100644 --- a/stack/smp/smp_utils.cc +++ b/stack/smp/smp_utils.cc @@ -340,18 +340,28 @@ bool smp_send_msg_to_L2CAP(const RawAddress& rem_bda, BT_HDR* p_toL2CAP) { } SMP_TRACE_EVENT("%s", __func__); - smp_cb.total_tx_unacked += 1; smp_log_metrics(rem_bda, true /* outgoing */, p_toL2CAP->data + p_toL2CAP->offset, p_toL2CAP->len); l2cap_ret = L2CA_SendFixedChnlData(fixed_cid, rem_bda, p_toL2CAP); if (l2cap_ret == L2CAP_DW_FAILED) { - smp_cb.total_tx_unacked -= 1; SMP_TRACE_ERROR("SMP failed to pass msg to L2CAP"); return false; - } else + } else { + tSMP_CB* p_cb = &smp_cb; + + if (p_cb->wait_for_authorization_complete) { + tSMP_INT_DATA smp_int_data; + smp_int_data.status = SMP_SUCCESS; + if (fixed_cid == L2CAP_SMP_CID) { + smp_sm_event(p_cb, SMP_AUTH_CMPL_EVT, &smp_int_data); + } else { + smp_br_state_machine_event(p_cb, SMP_BR_AUTH_CMPL_EVT, &smp_int_data); + } + } return true; + } } /*******************************************************************************