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

Commit 12aa0c41 authored by Myles Watson's avatar Myles Watson Committed by Automerger Merge Worker
Browse files

Merge changes I600c39dd,Ib9f8ace3,Ib9c717b5 am: cef1a943 am: f390b873 am: bfa8d950

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

MUST ONLY BE SUBMITTED BY AUTOMERGER

Change-Id: I234ee40be03840c567010dec5455dda3a22dd24d
parents c2d3508d bfa8d950
Loading
Loading
Loading
Loading
+1 −1
Original line number Original line Diff line number Diff line
@@ -196,7 +196,6 @@ struct LeAdvertisingManager::impl : public bluetooth::hci::LeAddressManagerCallb
    if (advertising_sets_.count(advertiser_id) == 0) {
    if (advertising_sets_.count(advertiser_id) == 0) {
      return;
      return;
    }
    }
    advertising_sets_.erase(advertiser_id);
    if (advertising_sets_.empty() && address_manager_registered) {
    if (advertising_sets_.empty() && address_manager_registered) {
      le_address_manager_->Unregister(this);
      le_address_manager_->Unregister(this);
      address_manager_registered = false;
      address_manager_registered = false;
@@ -212,6 +211,7 @@ struct LeAdvertisingManager::impl : public bluetooth::hci::LeAddressManagerCallb
        advertising_sets_[advertiser_id].address_rotation_alarm.reset();
        advertising_sets_[advertiser_id].address_rotation_alarm.reset();
      }
      }
    }
    }
    advertising_sets_.erase(advertiser_id);
  }
  }


  void create_advertiser(
  void create_advertiser(
+14 −0
Original line number Original line Diff line number Diff line
@@ -29,6 +29,14 @@
#include "gd/hci/le_scanning_manager.h"
#include "gd/hci/le_scanning_manager.h"
#include "main/shim/entry.h"
#include "main/shim/entry.h"


#include "stack/btm/btm_int_types.h"

extern void btm_ble_process_adv_pkt_cont_for_inquiry(
    uint16_t event_type, uint8_t address_type, const RawAddress& raw_address,
    uint8_t primary_phy, uint8_t secondary_phy, uint8_t advertising_sid,
    int8_t tx_power, int8_t rssi, uint16_t periodic_adv_int,
    std::vector<uint8_t> advertising_data);

class BleScannerInterfaceImpl : public BleScannerInterface,
class BleScannerInterfaceImpl : public BleScannerInterface,
                                public bluetooth::hci::ScanningCallback {
                                public bluetooth::hci::ScanningCallback {
 public:
 public:
@@ -209,6 +217,12 @@ class BleScannerInterfaceImpl : public BleScannerInterface,
                       address_type, raw_address, primary_phy, secondary_phy,
                       address_type, raw_address, primary_phy, secondary_phy,
                       advertising_sid, tx_power, rssi,
                       advertising_sid, tx_power, rssi,
                       periodic_advertising_interval, advertising_data));
                       periodic_advertising_interval, advertising_data));

    // TODO: Remove when StartInquiry in GD part implemented
    btm_ble_process_adv_pkt_cont_for_inquiry(
        event_type, address_type, raw_address, primary_phy, secondary_phy,
        advertising_sid, tx_power, rssi, periodic_advertising_interval,
        advertising_data);
  }
  }


  void OnTrackAdvFoundLost() {}
  void OnTrackAdvFoundLost() {}
+9 −0
Original line number Original line Diff line number Diff line
@@ -32,6 +32,7 @@
#include "hcimsgs.h"
#include "hcimsgs.h"


#include "btm_ble_int.h"
#include "btm_ble_int.h"
#include "main/shim/shim.h"
#include "stack/btm/btm_dev.h"
#include "stack/btm/btm_dev.h"
#include "stack/crypto_toolbox/crypto_toolbox.h"
#include "stack/crypto_toolbox/crypto_toolbox.h"
#include "stack/include/acl_api.h"
#include "stack/include/acl_api.h"
@@ -72,6 +73,14 @@ static void btm_ble_refresh_raddr_timer_timeout(UNUSED_ATTR void* data) {
/** This function is called when random address for local controller was
/** This function is called when random address for local controller was
 * generated */
 * generated */
void btm_gen_resolve_paddr_low(const RawAddress& address) {
void btm_gen_resolve_paddr_low(const RawAddress& address) {
  /* when GD advertising and scanning modules are enabled, set random address
   * via address manager in GD */
  if (bluetooth::shim::is_gd_advertising_enabled() &&
      bluetooth::shim::is_gd_scanning_enabled()) {
    LOG_INFO("GD advertising and scanning modules are enabled, skip");
    return;
  }

  tBTM_LE_RANDOM_CB* p_cb = &btm_cb.ble_ctr_cb.addr_mgnt_cb;
  tBTM_LE_RANDOM_CB* p_cb = &btm_cb.ble_ctr_cb.addr_mgnt_cb;
  p_cb->private_addr = address;
  p_cb->private_addr = address;


+66 −1
Original line number Original line Diff line number Diff line
@@ -1930,7 +1930,7 @@ void btm_ble_process_adv_pkt_cont(uint16_t evt_type, uint8_t addr_type,
  if (btm_inq_find_bdaddr(bda)) {
  if (btm_inq_find_bdaddr(bda)) {
    /* never been report as an LE device */
    /* never been report as an LE device */
    if (p_i && (!(p_i->inq_info.results.device_type & BT_DEVICE_TYPE_BLE) ||
    if (p_i && (!(p_i->inq_info.results.device_type & BT_DEVICE_TYPE_BLE) ||
                /* scan repsonse to be updated */
                /* scan response to be updated */
                (!p_i->scan_rsp))) {
                (!p_i->scan_rsp))) {
      update = true;
      update = true;
    } else if (btm_cb.ble_ctr_cb.is_ble_observe_active()) {
    } else if (btm_cb.ble_ctr_cb.is_ble_observe_active()) {
@@ -1986,6 +1986,71 @@ void btm_ble_process_adv_pkt_cont(uint16_t evt_type, uint8_t addr_type,
  cache.Clear(addr_type, bda);
  cache.Clear(addr_type, bda);
}
}


/**
 * This function copy from btm_ble_process_adv_pkt_cont to process adv packet
 * from gd scanning module to handle inquiry result callback.
 */
void btm_ble_process_adv_pkt_cont_for_inquiry(
    uint16_t evt_type, uint8_t addr_type, const RawAddress& bda,
    uint8_t primary_phy, uint8_t secondary_phy, uint8_t advertising_sid,
    int8_t tx_power, int8_t rssi, uint16_t periodic_adv_int,
    std::vector<uint8_t> advertising_data) {
  tBTM_INQUIRY_VAR_ST* p_inq = &btm_cb.btm_inq_vars;
  bool update = true;

  tINQ_DB_ENT* p_i = btm_inq_db_find(bda);

  /* Check if this address has already been processed for this inquiry */
  if (btm_inq_find_bdaddr(bda)) {
    /* never been report as an LE device */
    if (p_i && (!(p_i->inq_info.results.device_type & BT_DEVICE_TYPE_BLE) ||
                /* scan response to be updated */
                (!p_i->scan_rsp))) {
      update = true;
    } else if (btm_cb.ble_ctr_cb.is_ble_observe_active()) {
      update = false;
    } else {
      /* if yes, skip it */
      return; /* assumption: one result per event */
    }
  }

  /* If existing entry, use that, else get  a new one (possibly reusing the
   * oldest) */
  if (p_i == NULL) {
    p_i = btm_inq_db_new(bda);
    if (p_i != NULL) {
      p_inq->inq_cmpl_info.num_resp++;
      p_i->time_of_resp = bluetooth::common::time_get_os_boottime_ms();
    } else
      return;
  } else if (p_i->inq_count !=
             p_inq->inq_counter) /* first time seen in this inquiry */
  {
    p_i->time_of_resp = bluetooth::common::time_get_os_boottime_ms();
    p_inq->inq_cmpl_info.num_resp++;
  }

  /* update the LE device information in inquiry database */
  btm_ble_update_inq_result(p_i, addr_type, bda, evt_type, primary_phy,
                            secondary_phy, advertising_sid, tx_power, rssi,
                            periodic_adv_int, advertising_data);

  uint8_t result = btm_ble_is_discoverable(bda, advertising_data);
  if (result == 0) {
    return;
  }

  if (!update) result &= ~BTM_BLE_INQ_RESULT;

  tBTM_INQ_RESULTS_CB* p_inq_results_cb = p_inq->p_inq_results_cb;
  if (p_inq_results_cb && (result & BTM_BLE_INQ_RESULT)) {
    (p_inq_results_cb)((tBTM_INQ_RESULTS*)&p_i->inq_info.results,
                       const_cast<uint8_t*>(advertising_data.data()),
                       advertising_data.size());
  }
}

void btm_ble_process_phy_update_pkt(uint8_t len, uint8_t* data) {
void btm_ble_process_phy_update_pkt(uint8_t len, uint8_t* data) {
  uint8_t status, tx_phy, rx_phy;
  uint8_t status, tx_phy, rx_phy;
  uint16_t handle;
  uint16_t handle;