Propagate BT5 specific scan result properties up the stack (2/3)
Bug: 30622771
Test: sl4a FilteringTest
Change-Id: Ib9d18ea3a1fc7d95300415a04b551d66767b04d2
diff --git a/bta/dm/bta_dm_act.cc b/bta/dm/bta_dm_act.cc
index 8972e0c..cf850cc 100644
--- a/bta/dm/bta_dm_act.cc
+++ b/bta/dm/bta_dm_act.cc
@@ -3942,6 +3942,12 @@
result.inq_res.inq_result_type = p_inq->inq_result_type;
result.inq_res.device_type = p_inq->device_type;
result.inq_res.flag = p_inq->flag;
+ result.inq_res.ble_evt_type = p_inq->ble_evt_type;
+ result.inq_res.ble_primary_phy = p_inq->ble_primary_phy;
+ result.inq_res.ble_secondary_phy = p_inq->ble_secondary_phy;
+ result.inq_res.ble_advertising_sid = p_inq->ble_advertising_sid;
+ result.inq_res.ble_tx_power = p_inq->ble_tx_power;
+ result.inq_res.ble_periodic_adv_int = p_inq->ble_periodic_adv_int;
/* application will parse EIR to find out remote device name */
result.inq_res.p_eir = p_eir;
diff --git a/bta/include/bta_api.h b/bta/include/bta_api.h
index da1d352..0a47898 100644
--- a/bta/include/bta_api.h
+++ b/bta/include/bta_api.h
@@ -731,6 +731,11 @@
uint8_t inq_result_type;
uint8_t ble_addr_type;
uint16_t ble_evt_type;
+ uint8_t ble_primary_phy;
+ uint8_t ble_secondary_phy;
+ uint8_t ble_advertising_sid;
+ int8_t ble_tx_power;
+ uint16_t ble_periodic_adv_int;
tBT_DEVICE_TYPE device_type;
uint8_t flag;
} tBTA_DM_INQ_RES;
diff --git a/btif/src/btif_ble_scanner.cc b/btif/src/btif_ble_scanner.cc
index 0dddfd7..2098476 100644
--- a/btif/src/btif_ble_scanner.cc
+++ b/btif/src/btif_ble_scanner.cc
@@ -217,6 +217,10 @@
void bta_scan_results_cb_impl(bt_bdaddr_t bd_addr, tBT_DEVICE_TYPE device_type,
int8_t rssi, uint8_t addr_type,
+ uint16_t ble_evt_type, uint8_t ble_primary_phy,
+ 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) {
uint8_t remote_name_len;
const uint8_t* p_eir_remote_name = NULL;
@@ -255,8 +259,9 @@
btif_storage_set_remote_addr_type(&bd_addr, addr_type);
- HAL_CBACK(bt_gatt_callbacks, scanner->scan_result_cb, &bd_addr, rssi,
- std::move(value));
+ 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));
}
void bta_scan_results_cb(tBTA_DM_SEARCH_EVT event, tBTA_DM_SEARCH* p_data) {
@@ -284,11 +289,14 @@
}
}
+ tBTA_DM_INQ_RES* r = &p_data->inq_res;
bt_bdaddr_t bdaddr;
- bdcpy(bdaddr.address, p_data->inq_res.bd_addr);
- do_in_jni_thread(Bind(bta_scan_results_cb_impl, bdaddr,
- p_data->inq_res.device_type, p_data->inq_res.rssi,
- p_data->inq_res.ble_addr_type, std::move(value)));
+ bdcpy(bdaddr.address, r->bd_addr);
+ do_in_jni_thread(Bind(bta_scan_results_cb_impl, bdaddr, 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)));
}
void bta_track_adv_event_cb(tBTM_BLE_TRACK_ADV_DATA* p_track_adv_data) {
diff --git a/service/gatt_server_old.cc b/service/gatt_server_old.cc
index 17eaa8c..7dfd2b1 100644
--- a/service/gatt_server_old.cc
+++ b/service/gatt_server_old.cc
@@ -369,10 +369,13 @@
g_internal->api_synchronize.notify_one();
}
-void ScanResultCallback(bt_bdaddr_t* bda, int rssi,
+void ScanResultCallback(uint16_t ble_evt_type, uint8_t addr_type,
+ bt_bdaddr_t* bda, uint8_t ble_primary_phy,
+ uint8_t ble_secondary_phy, uint8_t ble_advertising_sid,
+ int8_t ble_tx_power, int8_t rssi,
+ uint16_t ble_periodic_adv_int,
std::vector<uint8_t> adv_data) {
std::string addr(BtAddrString(bda));
- (void)adv_data;
std::lock_guard<std::mutex> lock(g_internal->lock);
g_internal->scan_results[addr] = rssi;
}
diff --git a/service/hal/bluetooth_gatt_interface.cc b/service/hal/bluetooth_gatt_interface.cc
index f672b3b..ea72e7b 100644
--- a/service/hal/bluetooth_gatt_interface.cc
+++ b/service/hal/bluetooth_gatt_interface.cc
@@ -89,7 +89,10 @@
}
void ScanResultCallback(
- bt_bdaddr_t* bda, int rssi,
+ uint16_t ble_evt_type, uint8_t addr_type, bt_bdaddr_t* bda,
+ uint8_t ble_primary_phy, uint8_t ble_secondary_phy,
+ uint8_t ble_advertising_sid, int8_t ble_tx_power, int8_t rssi,
+ uint16_t ble_periodic_adv_int,
std::vector<uint8_t> adv_data) { // NOLINT(pass-by-value)
shared_lock<shared_mutex_impl> lock(g_instance_lock);
VERIFY_INTERFACE_OR_RETURN();
diff --git a/stack/btm/btm_ble_gap.cc b/stack/btm/btm_ble_gap.cc
index 09d0cb9..e044e60 100644
--- a/stack/btm/btm_ble_gap.cc
+++ b/stack/btm/btm_ble_gap.cc
@@ -64,9 +64,10 @@
* Local functions
******************************************************************************/
static void btm_ble_update_adv_flag(uint8_t flag);
-static void btm_ble_process_adv_pkt_cont(BD_ADDR bda, uint8_t addr_type,
- uint16_t evt_type, uint8_t data_len,
- uint8_t* data, int8_t rssi);
+static void btm_ble_process_adv_pkt_cont(
+ uint16_t evt_type, uint8_t addr_type, BD_ADDR 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, uint8_t data_len, uint8_t* data);
static uint8_t btm_set_conn_mode_adv_init_addr(tBTM_BLE_INQ_CB* p_cb,
BD_ADDR_PTR p_peer_addr_ptr,
tBLE_ADDR_TYPE* p_peer_addr_type,
@@ -1859,8 +1860,11 @@
* Update adv packet information into inquiry result.
*/
bool btm_ble_update_inq_result(tINQ_DB_ENT* p_i, uint8_t addr_type,
- uint16_t evt_type, uint8_t data_len,
- uint8_t* data, int8_t rssi) {
+ uint16_t evt_type, 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,
+ uint8_t* data) {
bool to_report = true;
tBTM_INQ_RESULTS* p_cur = &p_i->inq_info.results;
uint8_t len;
@@ -1881,6 +1885,11 @@
p_cur->inq_result_type = BTM_INQ_RESULT_BLE;
p_cur->ble_addr_type = addr_type;
p_cur->rssi = rssi;
+ p_cur->ble_primary_phy = primary_phy;
+ p_cur->ble_secondary_phy = secondary_phy;
+ p_cur->ble_advertising_sid = advertising_sid;
+ p_cur->ble_tx_power = tx_power;
+ p_cur->ble_periodic_adv_int = periodic_adv_int;
/* active scan, always wait until get scan_rsp to report the result */
if (btm_cb.ble_ctr_cb.inq_var.scan_type == BTM_BLE_SCAN_MODE_ACTI &&
@@ -2061,8 +2070,9 @@
}
btm_ble_process_adv_addr(bda, addr_type);
- btm_ble_process_adv_pkt_cont(bda, addr_type, event_type, pkt_data_len,
- pkt_data, rssi);
+ btm_ble_process_adv_pkt_cont(event_type, addr_type, bda, primary_phy,
+ secondary_phy, advertising_sid, tx_power, rssi,
+ periodic_adv_int, pkt_data_len, pkt_data);
}
}
@@ -2129,8 +2139,10 @@
return;
}
- btm_ble_process_adv_pkt_cont(bda, addr_type, event_type, pkt_data_len,
- pkt_data, rssi);
+ btm_ble_process_adv_pkt_cont(
+ event_type, addr_type, bda, PHY_LE_1M, PHY_LE_NO_PACKET, NO_ADI_PRESENT,
+ TX_POWER_NOT_PRESENT, rssi, 0x00 /* no periodic adv */, pkt_data_len,
+ pkt_data);
}
}
@@ -2138,15 +2150,13 @@
* This function is called after random address resolution is done, and proceed
* to process adv packet.
*/
-static void btm_ble_process_adv_pkt_cont(BD_ADDR bda, uint8_t addr_type,
- uint16_t evt_type, uint8_t data_len,
- uint8_t* data, int8_t rssi) {
+static void btm_ble_process_adv_pkt_cont(
+ uint16_t evt_type, uint8_t addr_type, BD_ADDR 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, uint8_t data_len, uint8_t* data) {
tINQ_DB_ENT* p_i;
tBTM_INQUIRY_VAR_ST* p_inq = &btm_cb.btm_inq_vars;
- tBTM_INQ_RESULTS_CB* p_inq_results_cb = p_inq->p_inq_results_cb;
- tBTM_BLE_INQ_CB* p_le_inq_cb = &btm_cb.ble_ctr_cb.inq_var;
bool update = true;
- uint8_t result = 0;
p_i = btm_inq_db_find(bda);
@@ -2178,11 +2188,12 @@
p_inq->inq_cmpl_info.num_resp++;
}
/* update the LE device information in inquiry database */
- if (!btm_ble_update_inq_result(p_i, addr_type, evt_type, data_len, data,
- rssi))
+ if (!btm_ble_update_inq_result(p_i, addr_type, evt_type, primary_phy,
+ secondary_phy, advertising_sid, tx_power, rssi,
+ periodic_adv_int, data_len, data))
return;
- result = btm_ble_is_discoverable(bda);
+ uint8_t result = btm_ble_is_discoverable(bda);
if (result == 0) {
LOG_WARN(LOG_TAG,
"%s device no longer discoverable, discarding advertising packet",
@@ -2214,6 +2225,8 @@
}
}
+ tBTM_BLE_INQ_CB* p_le_inq_cb = &btm_cb.ble_ctr_cb.inq_var;
+ 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,
p_le_inq_cb->adv_data_cache);
diff --git a/stack/include/btm_api_types.h b/stack/include/btm_api_types.h
index a2f1a13..8abaa0c 100644
--- a/stack/include/btm_api_types.h
+++ b/stack/include/btm_api_types.h
@@ -621,6 +621,14 @@
constexpr uint8_t BLE_EVT_SCAN_RESPONSE_BIT = 3;
constexpr uint8_t BLE_EVT_LEGACY_BIT = 4;
+constexpr uint8_t PHY_LE_NO_PACKET = 0x00;
+constexpr uint8_t PHY_LE_1M = 0x01;
+constexpr uint8_t PHY_LE_2M = 0x02;
+constexpr uint8_t PHY_LE_CODED = 0x03;
+
+constexpr uint8_t NO_ADI_PRESENT = 0xFF;
+constexpr uint8_t TX_POWER_NOT_PRESENT = 0x7F;
+
/* These are the fields returned in each device's response to the inquiry. It
* is returned in the results callback if registered.
*/
@@ -638,6 +646,11 @@
uint8_t inq_result_type;
uint8_t ble_addr_type;
uint16_t ble_evt_type;
+ uint8_t ble_primary_phy;
+ uint8_t ble_secondary_phy;
+ uint8_t ble_advertising_sid;
+ int8_t ble_tx_power;
+ uint16_t ble_periodic_adv_int;
uint8_t flag;
} tBTM_INQ_RESULTS;