Encapsulate tL2C_CB::tL2C_LCB::disc_reason
Towards proper interfaces
Bug: 163134718
Tag: #refactor
Test: compile & verify basic functions working
Change-Id: I475eb9127e50dc58b7a0bc8f6f269db9ab63a94a
diff --git a/system/stack/l2cap/l2c_api.cc b/system/stack/l2cap/l2c_api.cc
index 456cd94..f1e91b9 100644
--- a/system/stack/l2cap/l2c_api.cc
+++ b/system/stack/l2cap/l2c_api.cc
@@ -1446,7 +1446,7 @@
// Get a CCB and link the lcb to it
if (!l2cu_initialize_fixed_ccb(p_lcb, fixed_cid)) {
- p_lcb->disc_reason = L2CAP_CONN_NO_RESOURCES;
+ p_lcb->SetDisconnectReason(L2CAP_CONN_NO_RESOURCES);
L2CAP_TRACE_WARNING("%s(0x%04x) - no CCB", __func__, fixed_cid);
l2cu_release_lcb(p_lcb);
return false;
@@ -1633,7 +1633,7 @@
p_ccb = p_lcb->p_fixed_ccbs[fixed_cid - L2CAP_FIRST_FIXED_CHNL];
p_lcb->p_fixed_ccbs[fixed_cid - L2CAP_FIRST_FIXED_CHNL] = NULL;
- p_lcb->disc_reason = HCI_ERR_CONN_CAUSE_LOCAL_HOST;
+ p_lcb->SetDisconnectReason(HCI_ERR_CONN_CAUSE_LOCAL_HOST);
// Retain the link for a few more seconds after SMP pairing is done, since
// the Android platform always does service discovery after pairing is
diff --git a/system/stack/l2cap/l2c_ble.cc b/system/stack/l2cap/l2c_ble.cc
index 3eaa706..a920048 100644
--- a/system/stack/l2cap/l2c_ble.cc
+++ b/system/stack/l2cap/l2c_ble.cc
@@ -71,7 +71,7 @@
/* Do not remove lcb if an LE link is already up as a peripheral */
if (p_lcb != NULL && !(p_lcb->IsLinkRoleSlave() &&
BTM_IsAclConnectionUp(rem_bda, BT_TRANSPORT_LE))) {
- p_lcb->disc_reason = L2CAP_CONN_CANCEL;
+ p_lcb->SetDisconnectReason(L2CAP_CONN_CANCEL);
l2cu_release_lcb(p_lcb);
}
return (true);
@@ -216,7 +216,7 @@
uint16_t reason = 0;
p_lcb = l2cu_find_lcb_by_bd_addr(remote_bda, transport);
- if (p_lcb != NULL) reason = p_lcb->disc_reason;
+ if (p_lcb != NULL) reason = p_lcb->DisconnectReason();
L2CAP_TRACE_DEBUG("L2CA_GetDisconnectReason=%d ", reason);
diff --git a/system/stack/l2cap/l2c_int.h b/system/stack/l2cap/l2c_int.h
index 5266741..507cc81 100644
--- a/system/stack/l2cap/l2c_int.h
+++ b/system/stack/l2cap/l2c_int.h
@@ -381,7 +381,13 @@
tL2CA_NOCP_CB* p_nocp_cb; /* Num Cmpl pkts callback */
tL2C_CCB* p_fixed_ccbs[L2CAP_NUM_FIXED_CHNLS];
- uint16_t disc_reason;
+
+ private:
+ uint16_t disc_reason_;
+
+ public:
+ uint16_t DisconnectReason() const { return disc_reason_; }
+ void SetDisconnectReason(uint16_t disc_reason) { disc_reason_ = disc_reason; }
tBT_TRANSPORT transport;
uint8_t initiating_phys; // LE PHY used for connection initiation
diff --git a/system/stack/l2cap/l2c_link.cc b/system/stack/l2cap/l2c_link.cc
index 3dec7a8..babfd7c 100644
--- a/system/stack/l2cap/l2c_link.cc
+++ b/system/stack/l2cap/l2c_link.cc
@@ -219,7 +219,7 @@
p_ccb = pn;
}
- p_lcb->disc_reason = status;
+ p_lcb->SetDisconnectReason(status);
/* Release the LCB */
if (p_lcb->ccb_queue.p_first_ccb == NULL)
l2cu_release_lcb(p_lcb);
@@ -336,7 +336,7 @@
acl_set_disconnect_reason(reason);
}
- p_lcb->disc_reason = acl_get_disconnect_reason();
+ p_lcb->SetDisconnectReason(acl_get_disconnect_reason());
/* Just in case app decides to try again in the callback context */
p_lcb->link_state = LST_DISCONNECTING;
@@ -395,7 +395,7 @@
p_lcb->p_fixed_ccbs[xx] != p_lcb->p_pending_ccb) {
(*l2cb.fixed_reg[xx].pL2CA_FixedConn_Cb)(
xx + L2CAP_FIRST_FIXED_CHNL, p_lcb->remote_bd_addr, false,
- p_lcb->disc_reason, p_lcb->transport);
+ p_lcb->DisconnectReason(), p_lcb->transport);
if (p_lcb->p_fixed_ccbs[xx] == NULL) {
L2CAP_TRACE_ERROR(
"%s: unexpected p_fixed_ccbs[%d] is NULL remote_bd_addr = %s "
@@ -404,8 +404,8 @@
"%d",
__func__, xx, p_lcb->remote_bd_addr.ToString().c_str(), p_lcb,
p_lcb->in_use, p_lcb->link_state, p_lcb->handle,
- p_lcb->LinkRole(), p_lcb->IsBonding(), p_lcb->disc_reason,
- p_lcb->transport);
+ p_lcb->LinkRole(), p_lcb->IsBonding(),
+ p_lcb->DisconnectReason(), p_lcb->transport);
}
CHECK(p_lcb->p_fixed_ccbs[xx] != NULL);
l2cu_release_ccb(p_lcb->p_fixed_ccbs[xx]);
diff --git a/system/stack/l2cap/l2c_utils.cc b/system/stack/l2cap/l2c_utils.cc
index b3d27ca..f18375a 100644
--- a/system/stack/l2cap/l2c_utils.cc
+++ b/system/stack/l2cap/l2c_utils.cc
@@ -2539,7 +2539,7 @@
channel_id, p_lcb->remote_bd_addr, true, 0, p_lcb->transport);
} else {
(*l2cb.fixed_reg[xx].pL2CA_FixedConn_Cb)(
- channel_id, p_lcb->remote_bd_addr, false, p_lcb->disc_reason,
+ channel_id, p_lcb->remote_bd_addr, false, p_lcb->DisconnectReason(),
p_lcb->transport);
if (p_lcb->p_fixed_ccbs[xx]) {
@@ -2577,13 +2577,13 @@
l2cu_release_ccb(p_l2c_chnl_ctrl_block);
(*l2cb.fixed_reg[xx].pL2CA_FixedConn_Cb)(
xx + L2CAP_FIRST_FIXED_CHNL, p_lcb->remote_bd_addr, false,
- p_lcb->disc_reason, p_lcb->transport);
+ p_lcb->DisconnectReason(), p_lcb->transport);
}
} else if ((peer_channel_mask & (1 << (xx + L2CAP_FIRST_FIXED_CHNL))) &&
(l2cb.fixed_reg[xx].pL2CA_FixedConn_Cb != NULL))
(*l2cb.fixed_reg[xx].pL2CA_FixedConn_Cb)(
xx + L2CAP_FIRST_FIXED_CHNL, p_lcb->remote_bd_addr, false,
- p_lcb->disc_reason, p_lcb->transport);
+ p_lcb->DisconnectReason(), p_lcb->transport);
}
}