OSDN Git Service

Add common API to set hci handle
authorChris Manton <cmanton@google.com>
Tue, 22 Sep 2020 17:18:01 +0000 (10:18 -0700)
committerChris Manton <cmanton@google.com>
Thu, 8 Oct 2020 06:07:58 +0000 (06:07 +0000)
Towards readable code

Bug: 163134718
Tag: #refactor
Test: compile & verify basic functions working
Change-Id: I77837cc51daaca9f89c8b5d83aa84996b2d9e38f

stack/l2cap/l2c_int.h
stack/l2cap/l2c_utils.cc

index a36dcd3..80f3a8a 100644 (file)
@@ -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:
index ead38c1..c39d13c 100644 (file)
@@ -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