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

Commit 1eb39b6b authored by Treehugger Robot's avatar Treehugger Robot Committed by Automerger Merge Worker
Browse files

Merge changes Ib1f71d7e,I917ba220,Ic58e879c,If152037d,I063d0092 am: efe95cca...

Merge changes Ib1f71d7e,I917ba220,Ic58e879c,If152037d,I063d0092 am: efe95cca am: 0068a6d3 am: 2cd05930 am: 0777d310

Original change: https://android-review.googlesource.com/c/platform/system/bt/+/1443581

Change-Id: I3df16624bc34baff60de7f02e555551482519385
parents d17ab6dc 0777d310
Loading
Loading
Loading
Loading
+12 −11
Original line number Diff line number Diff line
@@ -95,7 +95,7 @@ void btm_ble_create_ll_conn_complete(uint8_t status) {
}

static bool maybe_resolve_address(RawAddress* bda, tBLE_ADDR_TYPE* bda_type) {
  bool match = false;
  bool is_in_security_db = false;
  tBLE_ADDR_TYPE peer_addr_type = *bda_type;
  bool addr_is_rpa =
      (peer_addr_type == BLE_ADDR_RANDOM && BTM_BLE_IS_RESOLVE_BDA(*bda));
@@ -106,16 +106,16 @@ static bool maybe_resolve_address(RawAddress* bda, tBLE_ADDR_TYPE* bda_type) {
   * address, or Random Static Address, we convert it into the "pseudo"
   * address here. */
  if (!addr_is_rpa || peer_addr_type & BLE_ADDR_TYPE_ID_BIT) {
    match = btm_identity_addr_to_random_pseudo(bda, bda_type, true);
    is_in_security_db = btm_identity_addr_to_random_pseudo(bda, bda_type, true);
  }

  /* possiblly receive connection complete with resolvable random while
     the device has been paired */
  if (!match && addr_is_rpa) {
  if (!is_in_security_db && addr_is_rpa) {
    tBTM_SEC_DEV_REC* match_rec = btm_ble_resolve_random_addr(*bda);
    if (match_rec) {
      LOG(INFO) << __func__ << ": matched and resolved random address";
      match = true;
      is_in_security_db = true;
      match_rec->ble.active_addr_type = tBTM_SEC_BLE::BTM_BLE_ADDR_RRA;
      match_rec->ble.cur_rand_addr = *bda;
      if (!btm_ble_init_pseudo_addr(match_rec, *bda)) {
@@ -129,7 +129,7 @@ static bool maybe_resolve_address(RawAddress* bda, tBLE_ADDR_TYPE* bda_type) {
      LOG(INFO) << __func__ << ": unable to match and resolve random address";
    }
  }
  return match;
  return is_in_security_db;
}

/** LE connection complete. */
@@ -162,7 +162,7 @@ void btm_ble_conn_complete(uint8_t* p, UNUSED_ATTR uint16_t evt_len,

  if (status == HCI_SUCCESS) {
    tBLE_ADDR_TYPE peer_addr_type = bda_type;
    bool match = maybe_resolve_address(&bda, &bda_type);
    bool is_in_security_db = maybe_resolve_address(&bda, &bda_type);

    // Log for the HCI success case after maybe resolving Bluetooth address
    bluetooth::common::LogLinkLayerConnectionEvent(
@@ -178,7 +178,7 @@ void btm_ble_conn_complete(uint8_t* p, UNUSED_ATTR uint16_t evt_len,

    connection_manager::on_connection_complete(bda);
    btm_ble_connected(bda, handle, HCI_ENCRYPT_MODE_DISABLED, role, bda_type,
                      match);
                      is_in_security_db);

    l2cble_conn_comp(handle, role, bda, bda_type, conn_interval, conn_latency,
                     conn_timeout);
@@ -186,12 +186,13 @@ void btm_ble_conn_complete(uint8_t* p, UNUSED_ATTR uint16_t evt_len,
    tBLE_BD_ADDR address_with_type{.bda = bda, .type = bda_type};
    if (enhanced) {
      acl_ble_enhanced_connection_complete(
          address_with_type, handle, role, match, conn_interval, conn_latency,
          conn_timeout, local_rpa, peer_rpa, peer_addr_type);
          address_with_type, handle, role, is_in_security_db, conn_interval,
          conn_latency, conn_timeout, local_rpa, peer_rpa, peer_addr_type);

    } else {
      acl_ble_connection_complete(address_with_type, handle, role, match,
                                  conn_interval, conn_latency, conn_timeout);
      acl_ble_connection_complete(address_with_type, handle, role,
                                  is_in_security_db, conn_interval,
                                  conn_latency, conn_timeout);
    }
  } else {
    bluetooth::common::LogLinkLayerConnectionEvent(
+58 −64
Original line number Diff line number Diff line
@@ -23,80 +23,74 @@
#include "types/raw_address.h"

/* Discoverable modes */
#define BTM_NON_DISCOVERABLE 0
#define BTM_LIMITED_DISCOVERABLE 1
#define BTM_GENERAL_DISCOVERABLE 2
#define BTM_DISCOVERABLE_MASK \
  (BTM_LIMITED_DISCOVERABLE | BTM_GENERAL_DISCOVERABLE)
#define BTM_MAX_DISCOVERABLE BTM_GENERAL_DISCOVERABLE
enum : uint16_t {
  BTM_NON_DISCOVERABLE = 0,
  BTM_LIMITED_DISCOVERABLE = (1 << 0),
  BTM_GENERAL_DISCOVERABLE = (1 << 1),
  BTM_MAX_DISCOVERABLE = BTM_GENERAL_DISCOVERABLE,
  BTM_DISCOVERABLE_MASK = (BTM_LIMITED_DISCOVERABLE | BTM_GENERAL_DISCOVERABLE),
  /* high byte for BLE Discoverable modes */
#define BTM_BLE_NON_DISCOVERABLE 0x0000
#define BTM_BLE_LIMITED_DISCOVERABLE 0x0100
#define BTM_BLE_GENERAL_DISCOVERABLE 0x0200
#define BTM_BLE_MAX_DISCOVERABLE BTM_BLE_GENERAL_DISCOVERABLE
#define BTM_BLE_DISCOVERABLE_MASK                            \
  (BTM_BLE_NON_DISCOVERABLE | BTM_BLE_LIMITED_DISCOVERABLE | \
   BTM_BLE_GENERAL_DISCOVERABLE)
  BTM_BLE_NON_DISCOVERABLE = 0x0000,
  BTM_BLE_LIMITED_DISCOVERABLE = 0x0100,
  BTM_BLE_GENERAL_DISCOVERABLE = 0x0200,
  BTM_BLE_MAX_DISCOVERABLE = BTM_BLE_GENERAL_DISCOVERABLE,
  BTM_BLE_DISCOVERABLE_MASK =
      (BTM_BLE_LIMITED_DISCOVERABLE | BTM_BLE_GENERAL_DISCOVERABLE),
};

/* Connectable modes */
#define BTM_NON_CONNECTABLE 0
#define BTM_CONNECTABLE 1
#define BTM_CONNECTABLE_MASK (BTM_NON_CONNECTABLE | BTM_CONNECTABLE)
enum : uint16_t {
  BTM_NON_CONNECTABLE = 0,
  BTM_CONNECTABLE = (1 << 0),
  BTM_CONNECTABLE_MASK = (BTM_NON_CONNECTABLE | BTM_CONNECTABLE),
  /* high byte for BLE Connectable modes */
#define BTM_BLE_NON_CONNECTABLE 0x0000
#define BTM_BLE_CONNECTABLE 0x0100
#define BTM_BLE_MAX_CONNECTABLE BTM_BLE_CONNECTABLE
#define BTM_BLE_CONNECTABLE_MASK (BTM_BLE_NON_CONNECTABLE | BTM_BLE_CONNECTABLE)
  BTM_BLE_NON_CONNECTABLE = BTM_NON_CONNECTABLE,
  BTM_BLE_CONNECTABLE = 0x0100,
  BTM_BLE_MAX_CONNECTABLE = BTM_BLE_CONNECTABLE,
  BTM_BLE_CONNECTABLE_MASK = (BTM_BLE_NON_CONNECTABLE | BTM_BLE_CONNECTABLE),
};

/* Inquiry modes
 * Note: These modes are associated with the inquiry active values (BTM_*ACTIVE)
 */
#define BTM_INQUIRY_NONE 0
#define BTM_GENERAL_INQUIRY 0x01
#define BTM_BR_INQUIRY_MASK (BTM_GENERAL_INQUIRY)

/* high byte of inquiry mode for BLE inquiry mode */
#define BTM_BLE_INQUIRY_NONE 0x00
#define BTM_BLE_GENERAL_INQUIRY 0x10
#define BTM_BLE_INQUIRY_MASK (BTM_BLE_GENERAL_INQUIRY)

/* BTM_IsInquiryActive return values (Bit Mask)
 * Note: These bit masks are associated with the inquiry modes (BTM_*_INQUIRY)
 */
/* no inquiry in progress */
#define BTM_INQUIRY_INACTIVE 0x0
/* a general inquiry is in progress */
#define BTM_GENERAL_INQUIRY_ACTIVE BTM_GENERAL_INQUIRY
enum : uint8_t {
  BTM_INQUIRY_NONE = 0,
  BTM_INQUIRY_INACTIVE = 0x0,
  BTM_GENERAL_INQUIRY = 0x01,
  /* SSP is active, so inquiry is disallowed (work around for FW bug) */
#define BTM_SSP_INQUIRY_ACTIVE 0x4
  BTM_SSP_INQUIRY_ACTIVE = 0x4,
  /* high nibble of inquiry mode for BLE inquiry mode */
  BTM_BLE_GENERAL_INQUIRY = 0x10,
  BTM_BR_INQUIRY_MASK = (BTM_GENERAL_INQUIRY),
  BTM_BLE_INQUIRY_MASK = (BTM_BLE_GENERAL_INQUIRY),
  BTM_BLE_INQUIRY_NONE = BTM_INQUIRY_NONE,
  BTM_GENERAL_INQUIRY_ACTIVE = BTM_GENERAL_INQUIRY,
  /* a general inquiry is in progress */
#define BTM_LE_GENERAL_INQUIRY_ACTIVE BTM_BLE_GENERAL_INQUIRY

/* inquiry activity mask */
  BTM_LE_GENERAL_INQUIRY_ACTIVE = BTM_BLE_GENERAL_INQUIRY,
  /* BR/EDR inquiry activity mask */
#define BTM_BR_INQ_ACTIVE_MASK (BTM_GENERAL_INQUIRY_ACTIVE)
  BTM_BR_INQ_ACTIVE_MASK = (BTM_GENERAL_INQUIRY_ACTIVE),
  /* LE scan activity mask */
#define BTM_BLE_SCAN_ACTIVE_MASK 0xF0
  BTM_BLE_SCAN_ACTIVE_MASK = 0xF0,
  /* LE inquiry activity mask*/
#define BTM_BLE_INQ_ACTIVE_MASK (BTM_LE_GENERAL_INQUIRY_ACTIVE)
  BTM_BLE_INQ_ACTIVE_MASK = (BTM_LE_GENERAL_INQUIRY_ACTIVE),
  /* inquiry activity mask */
#define BTM_INQUIRY_ACTIVE_MASK \
  (BTM_BR_INQ_ACTIVE_MASK | BTM_BLE_INQ_ACTIVE_MASK)
  BTM_INQUIRY_ACTIVE_MASK = (BTM_BR_INQ_ACTIVE_MASK | BTM_BLE_INQ_ACTIVE_MASK),
};

/* Define scan types */
#define BTM_SCAN_TYPE_STANDARD 0
#define BTM_SCAN_TYPE_INTERLACED 1 /* 1.2 devices only */
enum : uint16_t {
  BTM_SCAN_TYPE_STANDARD = 0,
  BTM_SCAN_TYPE_INTERLACED = 1, /* 1.2 devices only */
};

/* Define inquiry results mode */
#define BTM_INQ_RESULT_STANDARD 0
#define BTM_INQ_RESULT_WITH_RSSI 1
#define BTM_INQ_RESULT_EXTENDED 2
enum : uint8_t {
  BTM_INQ_RESULT_STANDARD = 0,
  BTM_INQ_RESULT_WITH_RSSI = 1,
  BTM_INQ_RESULT_EXTENDED = 2,
  /* RSSI value not supplied (ignore it) */
#define BTM_INQ_RES_IGNORE_RSSI 0x7f

/* Inquiry Filter Condition types (see tBTM_INQ_PARMS) */
/* Inquiry Filtering is turned off */
#define BTM_CLR_INQUIRY_FILTER 0
  BTM_INQ_RES_IGNORE_RSSI = 0x7f,
};

/* These are the fields returned in each device's response to the inquiry.  It
 * is returned in the results callback if registered.