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

Commit b94558ae authored by Martin Brabham's avatar Martin Brabham
Browse files

BLE Scanning: Pass original address back to GattService#onScanResult

Bug: 202162086
Test: Manual
Tag: #feature
Change-Id: Icc94ac06edbe7e55f77c35ef74ea06eeb95b70ea
parent 6bf2e507
Loading
Loading
Loading
Loading
+5 −0
Original line number Diff line number Diff line
@@ -1809,6 +1809,10 @@ static void bta_dm_inq_results_cb(tBTM_INQ_RESULTS* p_inq, const uint8_t* p_eir,
  uint16_t service_class;

  result.inq_res.bd_addr = p_inq->remote_bd_addr;

  // Pass the original address to GattService#onScanResult
  result.inq_res.original_bda = p_inq->original_bda;

  memcpy(result.inq_res.dev_class, p_inq->dev_class, DEV_CLASS_LEN);
  BTM_COD_SERVICE_CLASS(service_class, p_inq->dev_class);
  result.inq_res.is_limited =
@@ -3312,6 +3316,7 @@ static void bta_dm_observe_results_cb(tBTM_INQ_RESULTS* p_inq,
  APPL_TRACE_DEBUG("bta_dm_observe_results_cb");

  result.inq_res.bd_addr = p_inq->remote_bd_addr;
  result.inq_res.original_bda = p_inq->original_bda;
  result.inq_res.rssi = p_inq->rssi;
  result.inq_res.ble_addr_type = p_inq->ble_addr_type;
  result.inq_res.inq_result_type = p_inq->inq_result_type;
+2 −0
Original line number Diff line number Diff line
@@ -434,6 +434,8 @@ typedef struct {
  tBT_DEVICE_TYPE device_type;
  uint8_t flag;
  bool include_rsi; /* true, if ADV contains RSI data */
  RawAddress original_bda; /* original address to pass up to
                              GattService#onScanResult */
} tBTA_DM_INQ_RES;

/* Structure associated with BTA_DM_INQ_CMPL_EVT */
+8 −7
Original line number Diff line number Diff line
@@ -110,7 +110,7 @@ void bta_scan_results_cb_impl(RawAddress bd_addr, tBT_DEVICE_TYPE device_type,
                              uint8_t ble_secondary_phy,
                              uint8_t ble_advertising_sid, int8_t ble_tx_power,
                              uint16_t ble_periodic_adv_int,
                              vector<uint8_t> value) {
                              vector<uint8_t> value, RawAddress original_bda) {
  uint8_t remote_name_len;
  bt_device_type_t dev_type;
  bt_property_t properties;
@@ -156,7 +156,8 @@ void bta_scan_results_cb_impl(RawAddress bd_addr, tBT_DEVICE_TYPE device_type,
  btif_storage_set_remote_addr_type(&bd_addr, addr_type);
  HAL_CBACK(bt_gatt_callbacks, scanner->scan_result_cb, ble_evt_type, addr_type,
            &bd_addr, ble_primary_phy, ble_secondary_phy, ble_advertising_sid,
            ble_tx_power, rssi, ble_periodic_adv_int, std::move(value));
            ble_tx_power, rssi, ble_periodic_adv_int, std::move(value),
            &original_bda);
}

void bta_scan_results_cb(tBTA_DM_SEARCH_EVT event, tBTA_DM_SEARCH* p_data) {
@@ -185,11 +186,11 @@ void bta_scan_results_cb(tBTA_DM_SEARCH_EVT event, tBTA_DM_SEARCH* p_data) {
  }

  tBTA_DM_INQ_RES* r = &p_data->inq_res;
  do_in_jni_thread(Bind(bta_scan_results_cb_impl, r->bd_addr, r->device_type,
                        r->rssi, r->ble_addr_type, r->ble_evt_type,
                        r->ble_primary_phy, r->ble_secondary_phy,
                        r->ble_advertising_sid, r->ble_tx_power,
                        r->ble_periodic_adv_int, std::move(value)));
  do_in_jni_thread(
      Bind(bta_scan_results_cb_impl, r->bd_addr, r->device_type, r->rssi,
           r->ble_addr_type, r->ble_evt_type, r->ble_primary_phy,
           r->ble_secondary_phy, r->ble_advertising_sid, r->ble_tx_power,
           r->ble_periodic_adv_int, std::move(value), r->original_bda));
}

void bta_track_adv_event_cb(tBTM_BLE_TRACK_ADV_DATA* p_track_adv_data) {
+2 −1
Original line number Diff line number Diff line
@@ -46,7 +46,8 @@ typedef void (*scan_result_callback)(uint16_t event_type, uint8_t addr_type,
                                     uint8_t secondary_phy,
                                     uint8_t advertising_sid, int8_t tx_power,
                                     int8_t rssi, uint16_t periodic_adv_int,
                                     std::vector<uint8_t> adv_data);
                                     std::vector<uint8_t> adv_data,
                                     RawAddress* original_bda);

typedef struct {
  scan_result_callback scan_result_cb;
+8 −6
Original line number Diff line number Diff line
@@ -63,7 +63,7 @@ extern void btm_ble_process_adv_pkt_cont(
    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, uint8_t data_len,
    const uint8_t* data);
    const uint8_t* data, const RawAddress& original_bda);

extern void btm_api_process_inquiry_result(const RawAddress& raw_address,
                                           uint8_t page_scan_rep_mode,
@@ -128,12 +128,14 @@ void Btm::ScanningCallbacks::OnScanResult(
    btm_ble_process_adv_addr(raw_address, &ble_address_type);
  }

  // Pass up to GattService#onScanResult
  RawAddress original_bda = raw_address;
  btm_ble_process_adv_addr(raw_address, &ble_address_type);
  btm_ble_process_adv_pkt_cont(extended_event_type, ble_address_type,
                               raw_address, primary_phy, secondary_phy,
                               advertising_sid, tx_power, rssi,
                               periodic_advertising_interval,
                               advertising_data.size(), &advertising_data[0]);
  btm_ble_process_adv_pkt_cont(
      extended_event_type, ble_address_type, raw_address, primary_phy,
      secondary_phy, advertising_sid, tx_power, rssi,
      periodic_advertising_interval, advertising_data.size(),
      &advertising_data[0], original_bda);
}

void Btm::ScanningCallbacks::OnTrackAdvFoundLost(
Loading