From a4b9e3a77674c54546fe9eee7b477712686ebfc0 Mon Sep 17 00:00:00 2001 From: Chris Manton Date: Tue, 22 Sep 2020 10:18:01 -0700 Subject: [PATCH] Add common API to set hci handle Towards readable code Bug: 163134718 Tag: #refactor Test: compile & verify basic functions working Change-Id: I77837cc51daaca9f89c8b5d83aa84996b2d9e38f --- stack/l2cap/l2c_int.h | 1 + stack/l2cap/l2c_utils.cc | 9 +++++++++ 2 files changed, 10 insertions(+) diff --git a/stack/l2cap/l2c_int.h b/stack/l2cap/l2c_int.h index a36dcd364..80f3a8a4a 100644 --- a/stack/l2cap/l2c_int.h +++ b/stack/l2cap/l2c_int.h @@ -342,6 +342,7 @@ typedef struct t_l2c_linkcb { uint16_t conn_timeout); friend void l2c_link_hci_conn_comp(uint8_t status, uint16_t handle, const RawAddress& p_bda); + friend void l2cu_set_lcb_handle(struct t_l2c_linkcb& p_lcb, uint16_t handle); void SetHandle(uint16_t handle) { handle_ = handle; } public: diff --git a/stack/l2cap/l2c_utils.cc b/stack/l2cap/l2c_utils.cc index ead38c1f2..c39d13c2e 100644 --- a/stack/l2cap/l2c_utils.cc +++ b/stack/l2cap/l2c_utils.cc @@ -34,6 +34,7 @@ #include "l2c_int.h" #include "l2cdefs.h" #include "osi/include/allocator.h" +#include "osi/include/log.h" #include "stack/btm/btm_sec.h" #include "stack/include/acl_api.h" @@ -94,6 +95,14 @@ tL2C_LCB* l2cu_allocate_lcb(const RawAddress& p_bd_addr, bool is_bonding, return (NULL); } +void l2cu_set_lcb_handle(struct t_l2c_linkcb& p_lcb, uint16_t handle) { + if (p_lcb.Handle() != HCI_INVALID_HANDLE) { + LOG_WARN("Should not replace active handle:%hu with new handle:%hu", + p_lcb.Handle(), handle); + } + p_lcb.SetHandle(handle); +} + /******************************************************************************* * * Function l2cu_update_lcb_4_bonding -- 2.11.0