Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 08d726db authored by Chris Manton's avatar Chris Manton
Browse files

Add stack/gatt/gatt_main::gatt_find_in_device_record

Bug: 171568335
Tag: #refactor
Test: acts/bin/act.py -tp ~/Goog/tools/test/connectivity -tc BleCocTest
Test: atest --host bluetooth_test_gd

Change-Id: I5e1713f1a7cb00559448148d2275e8eeefb414dd
parent 1e3a86cf
Loading
Loading
Loading
Loading
+6 −0
Original line number Diff line number Diff line
@@ -62,6 +62,9 @@
#include "stack/include/sco_hci_link_interface.h"
#include "types/raw_address.h"

void gatt_find_in_device_record(const RawAddress& bd_addr,
                                tBLE_BD_ADDR* address_with_type);

struct StackAclBtmAcl {
  tACL_CONN* acl_allocate_connection();
  tACL_CONN* acl_get_connection_from_handle(uint16_t handle);
@@ -2883,6 +2886,9 @@ bool acl_create_le_connection_with_id(uint8_t id, const RawAddress& bd_addr) {
        .bda = bd_addr,
        .type = BLE_ADDR_RANDOM,
    };
    gatt_find_in_device_record(bd_addr, &address_with_type);
    LOG_DEBUG("Creating le connection to:%s",
              address_with_type.ToString().c_str());
    bluetooth::shim::ACL_CreateLeConnection(address_with_type);
    return true;
  }
+20 −0
Original line number Diff line number Diff line
@@ -175,6 +175,26 @@ void gatt_free(void) {
  EattExtension::GetInstance()->Stop();
}

void gatt_find_in_device_record(const RawAddress& bd_addr,
                                tBLE_BD_ADDR* address_with_type) {
  const tBTM_SEC_DEV_REC* p_dev_rec = btm_find_dev(bd_addr);
  if (p_dev_rec == nullptr) {
    return;
  }

  if (p_dev_rec->device_type & BT_DEVICE_TYPE_BLE) {
    if (p_dev_rec->ble.identity_address_with_type.bda.IsEmpty()) {
      *address_with_type = {.type = p_dev_rec->ble.ble_addr_type,
                            .bda = bd_addr};
      return;
    }
    *address_with_type = p_dev_rec->ble.identity_address_with_type;
    return;
  }
  *address_with_type = {.type = BLE_ADDR_PUBLIC, .bda = bd_addr};
  return;
}

/*******************************************************************************
 *
 * Function         gatt_connect