When we initiate a disconnection, the reason should always be terminated
by local host. We only need to check the reason when there is a
disconnection complete HCI event. Therefore, we can get rid of
L2CA_GetDisconnectReason().
The only GATT app using disconnect reason is HOGP, and the only
interesting state is connection timeout. Send this event from shim.
Test: cert/run
Tag: #gd-refactor
Bug:
141555841
Change-Id: I89973ece3ab5f24f3d1bc015daaf758d0600d002
******************************************************************************/
static void bta_gatts_conn_cback(tGATT_IF gatt_if, const RawAddress& bdaddr,
uint16_t conn_id, bool connected,
- tGATT_DISCONN_REASON reason,
+ tGATT_DISCONN_REASON,
tBT_TRANSPORT transport) {
tBTA_GATTS cb_data;
uint8_t evt = connected ? BTA_GATTS_CONNECT_EVT : BTA_GATTS_DISCONNECT_EVT;
conn_dat.bda = p_cb->addr;
conn_dat.le_hid = true;
conn_dat.scps_supported = p_cb->scps_supported;
-
- if (p_cb->status == BTA_HH_OK)
- conn_dat.status = (p_data->le_close.reason == GATT_CONN_UNKNOWN)
- ? p_cb->status
- : BTA_HH_ERR;
- else
- conn_dat.status = p_cb->status;
+ conn_dat.status = p_cb->status;
+ if (p_data->le_close.reason != GATT_CONN_OK) {
+ conn_dat.status = BTA_HH_ERR;
+ }
/* Report OPEN fail event */
(*bta_hh_cb.p_cback)(BTA_HH_OPEN_EVT, (tBTA_HH*)&conn_dat);
bta_hh_disc_cmpl();
} else {
#if (BTA_HH_LE_RECONN == TRUE)
- if (p_data->le_close.reason == GATT_CONN_TIMEOUT) {
+ if (p_data->le_close.reason == HCI_ERR_CONNECTION_TOUT) {
bta_hh_le_add_dev_bg_conn(p_cb, false);
}
#endif
channel_enqueue_buffer_[device] = nullptr;
channels_[device]->GetQueueUpEnd()->UnregisterDequeue();
channels_[device] = nullptr;
- (freg_.pL2CA_FixedConn_Cb)(cid_, address, false, 0, BT_TRANSPORT_LE);
+ uint8_t error = static_cast<uint8_t>(error_code);
+ (freg_.pL2CA_FixedConn_Cb)(cid_, address, false, error, BT_TRANSPORT_LE);
}
void on_channel_open(std::unique_ptr<le::FixedChannel> channel) {
tGATT_TCB* p_tcb = gatt_find_tcb_by_cid(lcid);
if (p_tcb == nullptr) return;
if (gatt_get_ch_state(p_tcb) == GATT_CH_CONN) {
- gatt_cleanup_upon_disc(p_tcb->peer_bda,
- static_cast<tGATT_DISCONN_REASON>(result),
+ gatt_cleanup_upon_disc(p_tcb->peer_bda, GATT_CONN_L2C_FAILURE,
BT_TRANSPORT_BR_EDR);
} else {
gatt_l2cif_disconnect(lcid);
if (btm_sec_is_a_bonded_dev(p_tcb->peer_bda))
gatt_add_a_bonded_dev_for_srv_chg(p_tcb->peer_bda);
}
- /* if ACL link is still up, no reason is logged, l2cap is disconnect from
- * peer */
- tGATT_DISCONN_REASON reason = static_cast<tGATT_DISCONN_REASON>(
- L2CA_GetDisconnectReason(p_tcb->peer_bda, p_tcb->transport));
- if (reason == GATT_CONN_OK) reason = GATT_CONN_TERMINATE_PEER_USER;
-
/* send disconnect callback */
- gatt_cleanup_upon_disc(p_tcb->peer_bda, reason, BT_TRANSPORT_BR_EDR);
+ gatt_cleanup_upon_disc(p_tcb->peer_bda, GATT_CONN_TERMINATE_PEER_USER,
+ BT_TRANSPORT_BR_EDR);
}
static void gatt_l2cif_disconnect(uint16_t lcid) {
gatt_add_a_bonded_dev_for_srv_chg(p_tcb->peer_bda);
}
- /* send disconnect callback */
- /* if ACL link is still up, no reason is logged, l2cap is disconnect from
- * peer */
- tGATT_DISCONN_REASON reason = static_cast<tGATT_DISCONN_REASON>(
- L2CA_GetDisconnectReason(p_tcb->peer_bda, p_tcb->transport));
- if (reason == GATT_CONN_OK) reason = GATT_CONN_TERMINATE_LOCAL_HOST;
-
- gatt_cleanup_upon_disc(p_tcb->peer_bda, reason, BT_TRANSPORT_BR_EDR);
+ gatt_cleanup_upon_disc(p_tcb->peer_bda, GATT_CONN_TERMINATE_LOCAL_HOST,
+ BT_TRANSPORT_BR_EDR);
}
/** This is the L2CAP data indication callback function */
******************************************************************************/
extern uint8_t L2CA_GetBleConnRole(const RawAddress& bd_addr);
-/*******************************************************************************
- *
- * Function L2CA_GetDisconnectReason
- *
- * Description This function returns the disconnect reason code.
- *
- * Parameters: BD Address of remote
- * Physical transport for the L2CAP connection (BR/EDR or LE)
- *
- * Returns disconnect reason
- *
- ******************************************************************************/
-extern uint16_t L2CA_GetDisconnectReason(const RawAddress& remote_bda,
- tBT_TRANSPORT transport);
-
extern void L2CA_AdjustConnectionIntervals(uint16_t* min_interval,
uint16_t* max_interval,
uint16_t floor_interval);
/*******************************************************************************
*
- * Function L2CA_GetDisconnectReason
- *
- * Description This function returns the disconnect reason code.
- *
- * Returns disconnect reason
- *
- ******************************************************************************/
-uint16_t L2CA_GetDisconnectReason(const RawAddress& remote_bda,
- tBT_TRANSPORT transport) {
- tL2C_LCB* p_lcb;
- uint16_t reason = 0;
-
- p_lcb = l2cu_find_lcb_by_bd_addr(remote_bda, transport);
- if (p_lcb != NULL) reason = p_lcb->DisconnectReason();
-
- L2CAP_TRACE_DEBUG("L2CA_GetDisconnectReason=%d ", reason);
-
- return reason;
-}
-
-/*******************************************************************************
- *
* Function l2cble_notify_le_connection
*
* Description This function notifiy the l2cap connection to the app layer