OSDN Git Service

Add new APIS stack/acl/btm_acl
authorChris Manton <cmanton@google.com>
Tue, 22 Sep 2020 23:01:31 +0000 (16:01 -0700)
committerChris Manton <cmanton@google.com>
Wed, 23 Sep 2020 20:54:10 +0000 (13:54 -0700)
Towards readable code

internal_.acl_allocate_connection
acl_initialize_power_mode

Bug: 163134718
Tag: #refactor
Test: acts -tc BleCocTest
Test: ble paired 2 phones
Change-Id: Ib76feefe0e95557b324dd837c294050da73c8106

stack/acl/acl.h
stack/acl/btm_acl.cc

index 6e0aff5..b5cf1b4 100644 (file)
@@ -192,6 +192,7 @@ typedef struct {
   friend void BTM_acl_after_controller_started();
   friend void BTM_default_block_role_switch();
   friend void BTM_default_unblock_role_switch();
+  friend void acl_initialize_power_mode(const tACL_CONN& p_acl);
   friend void acl_set_disconnect_reason(uint8_t acl_disc_reason);
   friend void btm_acl_created(const RawAddress& bda, uint16_t hci_handle,
                               uint8_t link_role, tBT_TRANSPORT transport);
index 5fd19d2..79133ee 100644 (file)
@@ -60,6 +60,7 @@
 #include "types/raw_address.h"
 
 struct StackAclBtmAcl {
+  tACL_CONN* acl_allocate_connection();
   tACL_CONN* acl_get_connection_from_handle(uint16_t handle);
   tACL_CONN* btm_bda_to_acl(const RawAddress& bda, tBT_TRANSPORT transport);
   tBTM_STATUS btm_set_packet_types(tACL_CONN* p, uint16_t pkt_types);
@@ -331,6 +332,23 @@ void btm_acl_process_sca_cmpl_pkt(uint8_t len, uint8_t* data) {
  * Returns          void
  *
  ******************************************************************************/
+void acl_initialize_power_mode(const tACL_CONN& p_acl) {
+  tBTM_PM_MCB* p_db =
+      &btm_cb.acl_cb_.pm_mode_db[btm_handle_to_acl_index(p_acl.hci_handle)];
+  memset(p_db, 0, sizeof(tBTM_PM_MCB));
+  p_db->state = BTM_PM_ST_ACTIVE;
+}
+
+tACL_CONN* StackAclBtmAcl::acl_allocate_connection() {
+  tACL_CONN* p_acl = &btm_cb.acl_cb_.acl_db[0];
+  for (uint8_t xx = 0; xx < MAX_L2CAP_LINKS; xx++, p_acl++) {
+    if (!p_acl->in_use) {
+      return p_acl;
+    }
+  }
+  return nullptr;
+}
+
 void btm_acl_created(const RawAddress& bda, uint16_t hci_handle,
                      uint8_t link_role, tBT_TRANSPORT transport) {
   tBTM_SEC_DEV_REC* p_dev_rec = NULL;