Refactor LE scanning HAL (2/3)
This patch converts btgatt_scanner_interface_t struct into
BleScannerInterface class. It also refactors three most important
methods from this interface: RegisterAdvertiser, Scan, and Unregister.
Rest of this interface will be updated in following patches.
Bug: 30622771
Test: sl4a BleScanApiTest
Change-Id: Ie35356f6c3c4f5488514ef55a48a32c93fb21b83
diff --git a/btif/include/btif_gatt.h b/btif/include/btif_gatt.h
index c5d56b0..e84811e 100644
--- a/btif/include/btif_gatt.h
+++ b/btif/include/btif_gatt.h
@@ -29,7 +29,7 @@
extern const btgatt_client_interface_t btgattClientInterface;
extern const btgatt_server_interface_t btgattServerInterface;
-extern const btgatt_scanner_interface_t btgattScannerInterface;
BleAdvertiserInterface* get_ble_advertiser_instance();
+BleScannerInterface* get_ble_scanner_instance();
#endif
diff --git a/btif/src/btif_ble_scanner.cc b/btif/src/btif_ble_scanner.cc
index 492f159..c5b73e8 100644
--- a/btif/src/btif_ble_scanner.cc
+++ b/btif/src/btif_ble_scanner.cc
@@ -35,6 +35,7 @@
#include <hardware/bt_gatt.h>
#include "bta_api.h"
+#include "bta_closure_api.h"
#include "bta_gatt_api.h"
#include "btif_config.h"
#include "btif_dm.h"
@@ -47,8 +48,7 @@
using base::Bind;
using base::Owned;
using std::vector;
-using RegisterCallback =
- base::Callback<void(uint8_t /* scanner_id */, uint8_t /* status */)>;
+using RegisterCallback = BleScannerInterface::RegisterCallback;
extern bt_status_t do_in_jni_thread(const base::Closure& task);
extern const btgatt_callbacks_t* bt_gatt_callbacks;
@@ -363,55 +363,6 @@
SCAN_CBACK_IN_JNI(track_adv_event_cb, Owned(btif_scan_track_cb));
}
-bt_status_t btif_gattc_register_scanner(bt_uuid_t* uuid) {
- CHECK_BTGATT_INIT();
-
- tBT_UUID bt_uuid;
- btif_to_bta_uuid(&bt_uuid, uuid);
-
- return do_in_jni_thread(Bind(
- [](tBT_UUID bt_uuid) {
- BTA_GATTC_AppRegister(
- bta_gatts_cback,
- base::Bind(
- [](tBT_UUID bt_uuid, uint8_t client_id, uint8_t status) {
- do_in_jni_thread(Bind(
- [](tBT_UUID bt_uuid, uint8_t client_id, uint8_t status) {
- bt_uuid_t app_uuid;
- bta_to_btif_uuid(&app_uuid, &bt_uuid);
-
- HAL_CBACK(bt_gatt_callbacks,
- scanner->register_scanner_cb, status,
- client_id, &app_uuid);
- },
- bt_uuid, client_id, status));
- },
- bt_uuid));
- },
- bt_uuid));
-}
-
-void btif_gattc_unregister_scanner_impl(int client_if) {
- BTA_GATTC_AppDeregister(client_if);
-}
-
-bt_status_t btif_gattc_unregister_scanner(int scanner_id) {
- CHECK_BTGATT_INIT();
- return do_in_jni_thread(
- Bind(&btif_gattc_unregister_scanner_impl, scanner_id));
-}
-
-bt_status_t btif_gattc_scan(bool start) {
- CHECK_BTGATT_INIT();
- if (start) {
- btif_gattc_init_dev_cb();
- return do_in_jni_thread(Bind(&BTA_DmBleObserve, true, 0,
- (tBTA_DM_SEARCH_CBACK*)bta_scan_results_cb));
- }
-
- return do_in_jni_thread(Bind(&BTA_DmBleObserve, false, 0, nullptr));
-}
-
void btif_gattc_scan_filter_param_setup_impl(
int client_if, uint8_t action, int filt_index,
tBTA_DM_BLE_PF_FILT_PARAMS* adv_filt_param) {
@@ -423,29 +374,6 @@
bta_scan_filt_param_setup_cb, client_if);
}
-bt_status_t btif_gattc_scan_filter_param_setup(
- btgatt_filt_param_setup_t filt_param) {
- CHECK_BTGATT_INIT();
- BTIF_TRACE_DEBUG("%s", __func__);
-
- tBTA_DM_BLE_PF_FILT_PARAMS* adv_filt_param = new tBTA_DM_BLE_PF_FILT_PARAMS;
- adv_filt_param->feat_seln = filt_param.feat_seln;
- adv_filt_param->list_logic_type = filt_param.list_logic_type;
- adv_filt_param->filt_logic_type = filt_param.filt_logic_type;
- adv_filt_param->rssi_high_thres = filt_param.rssi_high_thres;
- adv_filt_param->rssi_low_thres = filt_param.rssi_low_thres;
- adv_filt_param->dely_mode = filt_param.dely_mode;
- adv_filt_param->found_timeout = filt_param.found_timeout;
- adv_filt_param->lost_timeout = filt_param.lost_timeout;
- adv_filt_param->found_timeout_cnt = filt_param.found_timeout_cnt;
- adv_filt_param->num_of_tracking_entries = filt_param.num_of_tracking_entries;
-
- return do_in_jni_thread(
- Bind(base::IgnoreResult(&btif_gattc_scan_filter_param_setup_impl),
- filt_param.client_if, filt_param.action, filt_param.filt_index,
- base::Owned(adv_filt_param)));
-}
-
void btif_gattc_scan_filter_add_srvc_uuid(tBT_UUID uuid,
tBTA_DM_BLE_PF_COND_MASK* p_uuid_mask,
int action, int filt_type,
@@ -505,164 +433,220 @@
&bta_scan_filt_cfg_cb, client_if);
}
-bt_status_t btif_gattc_scan_filter_add_remove(
- int client_if, int action, int filt_type, int filt_index, int company_id,
- int company_id_mask, const bt_uuid_t* p_uuid, const bt_uuid_t* p_uuid_mask,
- const bt_bdaddr_t* bd_addr, char addr_type, vector<uint8_t> data,
- vector<uint8_t> mask) {
- CHECK_BTGATT_INIT();
- BTIF_TRACE_DEBUG("%s, %d, %d", __func__, action, filt_type);
+class BleScannerInterfaceImpl : public BleScannerInterface {
+ ~BleScannerInterfaceImpl(){};
- /* If data is passed, both mask and data have to be the same length */
- if (data.size() != mask.size() && data.size() != 0 && mask.size() != 0)
- return BT_STATUS_PARM_INVALID;
+ void RegisterScanner(RegisterCallback cb) override {
+ do_in_bta_thread(
+ FROM_HERE,
+ Bind(
+ [](RegisterCallback cb) {
+ BTA_GATTC_AppRegister(
+ bta_gatts_cback,
+ base::Bind(
+ [](RegisterCallback cb, uint8_t client_id,
+ uint8_t status) {
+ do_in_jni_thread(base::Bind(cb, client_id, status));
+ },
+ std::move(cb)));
+ },
+ std::move(cb)));
+ }
- switch (filt_type) {
- case BTA_DM_BLE_PF_ADDR_FILTER: {
- tBTA_DM_BLE_PF_COND_PARAM* cond = new tBTA_DM_BLE_PF_COND_PARAM;
- memset(cond, 0, sizeof(tBTA_DM_BLE_PF_COND_PARAM));
+ void Unregister(int scanner_id) override {
+ do_in_bta_thread(FROM_HERE, Bind(&BTA_GATTC_AppDeregister, scanner_id));
+ }
- bdcpy(cond->target_addr.bda, bd_addr->address);
- cond->target_addr.type = addr_type;
- return do_in_jni_thread(Bind(&BTA_DmBleCfgFilterCondition, action,
- filt_type, filt_index, base::Owned(cond),
- &bta_scan_filt_cfg_cb, client_if));
+ void Scan(bool start) override {
+ if (!start) {
+ do_in_bta_thread(FROM_HERE, Bind(&BTA_DmBleObserve, false, 0, nullptr));
+ return;
}
- case BTA_DM_BLE_PF_SRVC_DATA:
- return do_in_jni_thread(Bind(&BTA_DmBleCfgFilterCondition, action,
- filt_type, filt_index, nullptr,
- &bta_scan_filt_cfg_cb, client_if));
+ btif_gattc_init_dev_cb();
+ do_in_bta_thread(FROM_HERE,
+ Bind(&BTA_DmBleObserve, true, 0,
+ (tBTA_DM_SEARCH_CBACK*)bta_scan_results_cb));
+ }
- case BTA_DM_BLE_PF_SRVC_UUID: {
- tBT_UUID bt_uuid;
- btif_to_bta_uuid(&bt_uuid, p_uuid);
+ bt_status_t scan_filter_param_setup(
+ btgatt_filt_param_setup_t filt_param) override {
+ BTIF_TRACE_DEBUG("%s", __func__);
- if (p_uuid_mask != NULL) {
- tBTA_DM_BLE_PF_COND_MASK* uuid_mask = new tBTA_DM_BLE_PF_COND_MASK;
- btif_to_bta_uuid_mask(uuid_mask, p_uuid_mask, p_uuid);
+ tBTA_DM_BLE_PF_FILT_PARAMS* adv_filt_param = new tBTA_DM_BLE_PF_FILT_PARAMS;
+ adv_filt_param->feat_seln = filt_param.feat_seln;
+ adv_filt_param->list_logic_type = filt_param.list_logic_type;
+ adv_filt_param->filt_logic_type = filt_param.filt_logic_type;
+ adv_filt_param->rssi_high_thres = filt_param.rssi_high_thres;
+ adv_filt_param->rssi_low_thres = filt_param.rssi_low_thres;
+ adv_filt_param->dely_mode = filt_param.dely_mode;
+ adv_filt_param->found_timeout = filt_param.found_timeout;
+ adv_filt_param->lost_timeout = filt_param.lost_timeout;
+ adv_filt_param->found_timeout_cnt = filt_param.found_timeout_cnt;
+ adv_filt_param->num_of_tracking_entries =
+ filt_param.num_of_tracking_entries;
+
+ return do_in_jni_thread(
+ Bind(base::IgnoreResult(&btif_gattc_scan_filter_param_setup_impl),
+ filt_param.client_if, filt_param.action, filt_param.filt_index,
+ base::Owned(adv_filt_param)));
+ }
+
+ bt_status_t scan_filter_add_remove(
+ int client_if, int action, int filt_type, int filt_index, int company_id,
+ int company_id_mask, const bt_uuid_t* p_uuid,
+ const bt_uuid_t* p_uuid_mask, const bt_bdaddr_t* bd_addr, char addr_type,
+ vector<uint8_t> data, vector<uint8_t> mask) override {
+ CHECK_BTGATT_INIT();
+ BTIF_TRACE_DEBUG("%s, %d, %d", __func__, action, filt_type);
+
+ /* If data is passed, both mask and data have to be the same length */
+ if (data.size() != mask.size() && data.size() != 0 && mask.size() != 0)
+ return BT_STATUS_PARM_INVALID;
+
+ switch (filt_type) {
+ case BTA_DM_BLE_PF_ADDR_FILTER: {
+ tBTA_DM_BLE_PF_COND_PARAM* cond = new tBTA_DM_BLE_PF_COND_PARAM;
+ memset(cond, 0, sizeof(tBTA_DM_BLE_PF_COND_PARAM));
+
+ bdcpy(cond->target_addr.bda, bd_addr->address);
+ cond->target_addr.type = addr_type;
+ return do_in_jni_thread(Bind(&BTA_DmBleCfgFilterCondition, action,
+ filt_type, filt_index, base::Owned(cond),
+ &bta_scan_filt_cfg_cb, client_if));
+ }
+
+ case BTA_DM_BLE_PF_SRVC_DATA:
+ return do_in_jni_thread(Bind(&BTA_DmBleCfgFilterCondition, action,
+ filt_type, filt_index, nullptr,
+ &bta_scan_filt_cfg_cb, client_if));
+
+ case BTA_DM_BLE_PF_SRVC_UUID: {
+ tBT_UUID bt_uuid;
+ btif_to_bta_uuid(&bt_uuid, p_uuid);
+
+ if (p_uuid_mask != NULL) {
+ tBTA_DM_BLE_PF_COND_MASK* uuid_mask = new tBTA_DM_BLE_PF_COND_MASK;
+ btif_to_bta_uuid_mask(uuid_mask, p_uuid_mask, p_uuid);
+ return do_in_jni_thread(Bind(&btif_gattc_scan_filter_add_srvc_uuid,
+ bt_uuid, base::Owned(uuid_mask), action,
+ filt_type, filt_index, client_if));
+ }
+
return do_in_jni_thread(Bind(&btif_gattc_scan_filter_add_srvc_uuid,
- bt_uuid, base::Owned(uuid_mask), action,
+ bt_uuid, nullptr, action, filt_type,
+ filt_index, client_if));
+ }
+
+ case BTA_DM_BLE_PF_SRVC_SOL_UUID: {
+ tBTA_DM_BLE_PF_COND_PARAM* cond = new tBTA_DM_BLE_PF_COND_PARAM;
+ memset(cond, 0, sizeof(tBTA_DM_BLE_PF_COND_PARAM));
+
+ cond->solicitate_uuid.p_target_addr = NULL;
+ cond->solicitate_uuid.cond_logic = BTA_DM_BLE_PF_LOGIC_AND;
+ btif_to_bta_uuid(&cond->solicitate_uuid.uuid, p_uuid);
+
+ return do_in_jni_thread(Bind(&BTA_DmBleCfgFilterCondition, action,
+ filt_type, filt_index, base::Owned(cond),
+ &bta_scan_filt_cfg_cb, client_if));
+ }
+
+ case BTA_DM_BLE_PF_LOCAL_NAME: {
+ return do_in_jni_thread(Bind(&btif_gattc_scan_filter_add_local_name,
+ std::move(data), action, filt_type,
+ filt_index, client_if));
+ }
+
+ case BTA_DM_BLE_PF_MANU_DATA: {
+ return do_in_jni_thread(Bind(&btif_gattc_scan_filter_add_manu_data,
+ company_id, company_id_mask,
+ std::move(data), std::move(mask), action,
filt_type, filt_index, client_if));
}
- return do_in_jni_thread(Bind(&btif_gattc_scan_filter_add_srvc_uuid,
- bt_uuid, nullptr, action, filt_type,
- filt_index, client_if));
+ case BTA_DM_BLE_PF_SRVC_DATA_PATTERN: {
+ return do_in_jni_thread(Bind(&btif_gattc_scan_filter_add_data_pattern,
+ std::move(data), std::move(mask), action,
+ filt_type, filt_index, client_if));
+ }
+
+ default:
+ LOG_ERROR(LOG_TAG, "%s: Unknown filter type (%d)!", __func__, action);
+ return (bt_status_t)BTA_GATT_OK;
}
-
- case BTA_DM_BLE_PF_SRVC_SOL_UUID: {
- tBTA_DM_BLE_PF_COND_PARAM* cond = new tBTA_DM_BLE_PF_COND_PARAM;
- memset(cond, 0, sizeof(tBTA_DM_BLE_PF_COND_PARAM));
-
- cond->solicitate_uuid.p_target_addr = NULL;
- cond->solicitate_uuid.cond_logic = BTA_DM_BLE_PF_LOGIC_AND;
- btif_to_bta_uuid(&cond->solicitate_uuid.uuid, p_uuid);
-
- return do_in_jni_thread(Bind(&BTA_DmBleCfgFilterCondition, action,
- filt_type, filt_index, base::Owned(cond),
- &bta_scan_filt_cfg_cb, client_if));
- }
-
- case BTA_DM_BLE_PF_LOCAL_NAME: {
- return do_in_jni_thread(Bind(&btif_gattc_scan_filter_add_local_name,
- std::move(data), action, filt_type,
- filt_index, client_if));
- }
-
- case BTA_DM_BLE_PF_MANU_DATA: {
- return do_in_jni_thread(Bind(&btif_gattc_scan_filter_add_manu_data,
- company_id, company_id_mask, std::move(data),
- std::move(mask), action, filt_type,
- filt_index, client_if));
- }
-
- case BTA_DM_BLE_PF_SRVC_DATA_PATTERN: {
- return do_in_jni_thread(Bind(&btif_gattc_scan_filter_add_data_pattern,
- std::move(data), std::move(mask), action,
- filt_type, filt_index, client_if));
- }
-
- default:
- LOG_ERROR(LOG_TAG, "%s: Unknown filter type (%d)!", __func__, action);
- return (bt_status_t)BTA_GATT_OK;
}
-}
-bt_status_t btif_gattc_scan_filter_clear(int client_if, int filter_index) {
- CHECK_BTGATT_INIT();
- BTIF_TRACE_DEBUG("%s: filter_index: %d", __func__, filter_index);
+ bt_status_t scan_filter_clear(int client_if, int filter_index) override {
+ CHECK_BTGATT_INIT();
+ BTIF_TRACE_DEBUG("%s: filter_index: %d", __func__, filter_index);
- return do_in_jni_thread(Bind(&BTA_DmBleCfgFilterCondition,
- BTA_DM_BLE_SCAN_COND_CLEAR,
- BTA_DM_BLE_PF_TYPE_ALL, filter_index, nullptr,
- &bta_scan_filt_cfg_cb, client_if));
-}
+ return do_in_jni_thread(Bind(&BTA_DmBleCfgFilterCondition,
+ BTA_DM_BLE_SCAN_COND_CLEAR,
+ BTA_DM_BLE_PF_TYPE_ALL, filter_index, nullptr,
+ &bta_scan_filt_cfg_cb, client_if));
+ }
-bt_status_t btif_gattc_scan_filter_enable(int client_if, bool enable) {
- CHECK_BTGATT_INIT();
- BTIF_TRACE_DEBUG("%s: enable: %d", __func__, enable);
+ bt_status_t scan_filter_enable(int client_if, bool enable) override {
+ CHECK_BTGATT_INIT();
+ BTIF_TRACE_DEBUG("%s: enable: %d", __func__, enable);
- uint8_t action = enable ? 1 : 0;
+ uint8_t action = enable ? 1 : 0;
- return do_in_jni_thread(Bind(&BTA_DmEnableScanFilter, action,
- &bta_scan_filt_status_cb, client_if));
-}
+ return do_in_jni_thread(Bind(&BTA_DmEnableScanFilter, action,
+ &bta_scan_filt_status_cb, client_if));
+ }
-bt_status_t btif_gattc_set_scan_parameters(int client_if, int scan_interval,
- int scan_window) {
- CHECK_BTGATT_INIT();
- return do_in_jni_thread(
- Bind(BTA_DmSetBleScanParams, client_if, scan_interval, scan_window,
- BTM_BLE_SCAN_MODE_ACTI,
- (tBLE_SCAN_PARAM_SETUP_CBACK)bta_scan_param_setup_cb));
-}
+ bt_status_t set_scan_parameters(int client_if, int scan_interval,
+ int scan_window) override {
+ CHECK_BTGATT_INIT();
+ return do_in_jni_thread(
+ Bind(BTA_DmSetBleScanParams, client_if, scan_interval, scan_window,
+ BTM_BLE_SCAN_MODE_ACTI,
+ (tBLE_SCAN_PARAM_SETUP_CBACK)bta_scan_param_setup_cb));
+ }
-bt_status_t btif_gattc_cfg_storage(int client_if, int batch_scan_full_max,
- int batch_scan_trunc_max,
- int batch_scan_notify_threshold) {
- CHECK_BTGATT_INIT();
- return do_in_jni_thread(
- Bind(BTA_DmBleSetStorageParams, batch_scan_full_max, batch_scan_trunc_max,
- batch_scan_notify_threshold,
- (tBTA_BLE_SCAN_SETUP_CBACK*)bta_batch_scan_setup_cb,
- (tBTA_BLE_SCAN_THRESHOLD_CBACK*)bta_batch_scan_threshold_cb,
- (tBTA_BLE_SCAN_REP_CBACK*)bta_batch_scan_reports_cb,
- (tBTA_DM_BLE_REF_VALUE)client_if));
-}
+ bt_status_t batchscan_cfg_storage(int client_if, int batch_scan_full_max,
+ int batch_scan_trunc_max,
+ int batch_scan_notify_threshold) override {
+ CHECK_BTGATT_INIT();
+ return do_in_jni_thread(
+ Bind(BTA_DmBleSetStorageParams, batch_scan_full_max,
+ batch_scan_trunc_max, batch_scan_notify_threshold,
+ (tBTA_BLE_SCAN_SETUP_CBACK*)bta_batch_scan_setup_cb,
+ (tBTA_BLE_SCAN_THRESHOLD_CBACK*)bta_batch_scan_threshold_cb,
+ (tBTA_BLE_SCAN_REP_CBACK*)bta_batch_scan_reports_cb,
+ (tBTA_DM_BLE_REF_VALUE)client_if));
+ }
-bt_status_t btif_gattc_enb_batch_scan(int client_if, int scan_mode,
- int scan_interval, int scan_window,
- int addr_type, int discard_rule) {
- CHECK_BTGATT_INIT();
- return do_in_jni_thread(Bind(BTA_DmBleEnableBatchScan, scan_mode,
- scan_interval, scan_window, discard_rule,
- addr_type, client_if));
-}
+ bt_status_t batchscan_enb_batch_scan(int client_if, int scan_mode,
+ int scan_interval, int scan_window,
+ int addr_type,
+ int discard_rule) override {
+ CHECK_BTGATT_INIT();
+ return do_in_jni_thread(Bind(BTA_DmBleEnableBatchScan, scan_mode,
+ scan_interval, scan_window, discard_rule,
+ addr_type, client_if));
+ }
-bt_status_t btif_gattc_dis_batch_scan(int client_if) {
- CHECK_BTGATT_INIT();
- return do_in_jni_thread(Bind(BTA_DmBleDisableBatchScan, client_if));
-}
+ bt_status_t batchscan_dis_batch_scan(int client_if) override {
+ CHECK_BTGATT_INIT();
+ return do_in_jni_thread(Bind(BTA_DmBleDisableBatchScan, client_if));
+ }
-bt_status_t btif_gattc_read_batch_scan_reports(int client_if, int scan_mode) {
- CHECK_BTGATT_INIT();
- return do_in_jni_thread(Bind(BTA_DmBleReadScanReports, scan_mode, client_if));
-}
+ bt_status_t batchscan_read_reports(int client_if, int scan_mode) override {
+ CHECK_BTGATT_INIT();
+ return do_in_jni_thread(
+ Bind(BTA_DmBleReadScanReports, scan_mode, client_if));
+ }
+};
+
+BleScannerInterface* btLeScannerInstance = nullptr;
} // namespace
-const btgatt_scanner_interface_t btgattScannerInterface = {
- btif_gattc_register_scanner,
- btif_gattc_unregister_scanner,
- btif_gattc_scan,
- btif_gattc_scan_filter_param_setup,
- btif_gattc_scan_filter_add_remove,
- btif_gattc_scan_filter_clear,
- btif_gattc_scan_filter_enable,
- btif_gattc_set_scan_parameters,
- btif_gattc_cfg_storage,
- btif_gattc_enb_batch_scan,
- btif_gattc_dis_batch_scan,
- btif_gattc_read_batch_scan_reports,
-};
+BleScannerInterface* get_ble_scanner_instance() {
+ if (btLeScannerInstance == nullptr)
+ btLeScannerInstance = new BleScannerInterfaceImpl();
+
+ return btLeScannerInstance;
+}
diff --git a/btif/src/btif_gatt.cc b/btif/src/btif_gatt.cc
index 1e05aa2..67296f9 100644
--- a/btif/src/btif_gatt.cc
+++ b/btif/src/btif_gatt.cc
@@ -82,8 +82,8 @@
&btgattClientInterface,
&btgattServerInterface,
- &btgattScannerInterface,
- nullptr // filled in btif_gatt_get_interface
+ nullptr, // filled in btif_gatt_get_interface
+ nullptr // filled in btif_gatt_get_interface
};
/*******************************************************************************
@@ -99,6 +99,7 @@
// TODO(jpawlowski) right now initializing advertiser field in static
// structure cause explosion of dependencies. It must be initialized here
// until those dependencies are properly abstracted for tests.
+ btgattInterface.scanner = get_ble_scanner_instance();
btgattInterface.advertiser = get_ble_advertiser_instance();
return &btgattInterface;
}
diff --git a/service/gatt_server_old.cc b/service/gatt_server_old.cc
index c71ceda..17eaa8c 100644
--- a/service/gatt_server_old.cc
+++ b/service/gatt_server_old.cc
@@ -360,11 +360,6 @@
0 /* no timeout */, base::Bind(&DoNothing));
}
-void RegisterScannerCallback(int status, int scanner_id, bt_uuid_t* app_uuid) {
- LOG_INFO(LOG_TAG, "%s: status:%d scanner_id:%d uuid[0]:%u", __func__, status,
- scanner_id, app_uuid->uu[0]);
-}
-
void ServiceStoppedCallback(int status, int server_if, int srvc_handle) {
LOG_INFO(LOG_TAG, "%s: status:%d server_if:%d srvc_handle:%d", __func__,
status, server_if, srvc_handle);
@@ -445,7 +440,6 @@
};
const btgatt_scanner_callbacks_t gatt_scanner_callbacks = {
- RegisterScannerCallback,
ScanResultCallback,
nullptr, /* batchscan_cfg_storage_cb; */
nullptr, /* batchscan_enb_disable_cb; */
@@ -691,20 +685,12 @@
}
bool Server::ScanEnable() {
- bt_status_t btstat = internal_->gatt->scanner->scan(true);
- if (btstat) {
- LOG_ERROR(LOG_TAG, "Enable scan failed: %d", btstat);
- return false;
- }
+ internal_->gatt->scanner->Scan(true);
return true;
}
bool Server::ScanDisable() {
- bt_status_t btstat = internal_->gatt->scanner->scan(false);
- if (btstat) {
- LOG_ERROR(LOG_TAG, "Disable scan failed: %d", btstat);
- return false;
- }
+ internal_->gatt->scanner->Scan(false);
return true;
}
diff --git a/service/hal/bluetooth_gatt_interface.cc b/service/hal/bluetooth_gatt_interface.cc
index ff54b63..f672b3b 100644
--- a/service/hal/bluetooth_gatt_interface.cc
+++ b/service/hal/bluetooth_gatt_interface.cc
@@ -88,17 +88,6 @@
RegisterClientCallback(g_interface, status, client_if, *app_uuid));
}
-void RegisterScannerCallback(int status, int scanner_id, bt_uuid_t* app_uuid) {
- shared_lock<shared_mutex_impl> lock(g_instance_lock);
- VLOG(2) << __func__ << " - status: " << status
- << " scanner_id: " << scanner_id;
- VERIFY_INTERFACE_OR_RETURN();
- CHECK(app_uuid);
-
- FOR_EACH_SCANNER_OBSERVER(
- RegisterScannerCallback(g_interface, status, scanner_id, *app_uuid));
-}
-
void ScanResultCallback(
bt_bdaddr_t* bda, int rssi,
std::vector<uint8_t> adv_data) { // NOLINT(pass-by-value)
@@ -387,7 +376,6 @@
// GATT client-role and GAP events.
const btgatt_scanner_callbacks_t gatt_scanner_callbacks = {
- RegisterScannerCallback,
ScanResultCallback,
nullptr, // batchscan_cfg_storage_cb
nullptr, // batchscan_enb_disable_cb
@@ -481,7 +469,7 @@
return hal_iface_->advertiser;
}
- const btgatt_scanner_interface_t* GetScannerHALInterface() const override {
+ BleScannerInterface* GetScannerHALInterface() const override {
return hal_iface_->scanner;
}
@@ -574,12 +562,6 @@
// Default observer implementations. These are provided so that the methods
// themselves are optional.
-void BluetoothGattInterface::ScannerObserver::RegisterScannerCallback(
- BluetoothGattInterface* /* gatt_iface */, int /* status */,
- int /* scanner_id */, const bt_uuid_t& /* app_uuid */) {
- // Do nothing.
-}
-
void BluetoothGattInterface::ScannerObserver::ScanResultCallback(
BluetoothGattInterface* /* gatt_iface */, const bt_bdaddr_t& /* bda */,
int /* rssi */,
@@ -807,11 +789,7 @@
// If this is the first scan client, then make a call into the stack. We
// only do this when the reference count changes to or from 0.
if (scan_client_set_.empty()) {
- bt_status_t status = GetScannerHALInterface()->scan(true);
- if (status != BT_STATUS_SUCCESS) {
- LOG(ERROR) << "HAL call to scan failed";
- return status;
- }
+ GetScannerHALInterface()->Scan(true);
}
scan_client_set_.insert(client_id);
@@ -831,11 +809,7 @@
}
if (scan_client_set_.size() == 1) {
- bt_status_t status = GetScannerHALInterface()->scan(false);
- if (status != BT_STATUS_SUCCESS) {
- LOG(ERROR) << "HAL call to stop scan failed";
- return status;
- }
+ GetScannerHALInterface()->Scan(false);
}
scan_client_set_.erase(iter);
diff --git a/service/hal/bluetooth_gatt_interface.h b/service/hal/bluetooth_gatt_interface.h
index 72ac823..9627dc1 100644
--- a/service/hal/bluetooth_gatt_interface.h
+++ b/service/hal/bluetooth_gatt_interface.h
@@ -52,10 +52,6 @@
// All of the events below correspond to callbacks defined in
// "btgatt_scanner_callbacks_t" in the HAL API definitions.
- virtual void RegisterScannerCallback(BluetoothGattInterface* gatt_iface,
- int status, int scanner_id,
- const bt_uuid_t& app_uuid);
-
virtual void ScanResultCallback(
BluetoothGattInterface* gatt_iface, const bt_bdaddr_t& bda, int rssi,
std::vector<uint8_t> adv_data); // NOLINT(pass-by-value)
@@ -226,7 +222,7 @@
//
// Upper layers can make ble_scanner_interface_t API calls through this
// structure.
- virtual const btgatt_scanner_interface_t* GetScannerHALInterface() const = 0;
+ virtual BleScannerInterface* GetScannerHALInterface() const = 0;
// The HAL module pointer that represents the standard BT-GATT client
// interface. This is implemented in and provided by the shared Bluetooth
diff --git a/service/hal/fake_bluetooth_gatt_interface.cc b/service/hal/fake_bluetooth_gatt_interface.cc
index d7d84d7..66b8bac 100644
--- a/service/hal/fake_bluetooth_gatt_interface.cc
+++ b/service/hal/fake_bluetooth_gatt_interface.cc
@@ -24,8 +24,7 @@
// interface methods all have to be global and their signatures don't allow us
// to pass in user_data.
std::shared_ptr<BleAdvertiserInterface> g_advertiser_handler;
-std::shared_ptr<FakeBluetoothGattInterface::TestScannerHandler>
- g_scanner_handler;
+std::shared_ptr<BleScannerInterface> g_scanner_handler;
std::shared_ptr<FakeBluetoothGattInterface::TestClientHandler> g_client_handler;
std::shared_ptr<FakeBluetoothGattInterface::TestServerHandler> g_server_handler;
@@ -41,24 +40,6 @@
return BT_STATUS_FAIL;
}
-bt_status_t FakeRegisterScanner(bt_uuid_t* app_uuid) {
- if (g_scanner_handler) return g_scanner_handler->RegisterScanner(app_uuid);
-
- return BT_STATUS_FAIL;
-}
-
-bt_status_t FakeUnregisterScanner(int client_if) {
- if (g_scanner_handler) return g_scanner_handler->UnregisterScanner(client_if);
-
- return BT_STATUS_FAIL;
-}
-
-bt_status_t FakeScan(bool start) {
- if (g_scanner_handler) return g_scanner_handler->Scan(start);
-
- return BT_STATUS_FAIL;
-}
-
bt_status_t FakeConnect(int client_if, const bt_bdaddr_t* bd_addr,
bool is_direct, int transport) {
if (g_client_handler)
@@ -119,21 +100,6 @@
return BT_STATUS_FAIL;
}
-btgatt_scanner_interface_t fake_scanner_iface = {
- FakeRegisterScanner,
- FakeUnregisterScanner,
- FakeScan,
- nullptr, // scan_filter_param_setup
- nullptr, // scan_filter_add_remove
- nullptr, // scan_filter_clear
- nullptr, // scan_filter_enable
- nullptr, // set_scan_parameters
- nullptr, // batchscan_cfg_storate
- nullptr, // batchscan_enb_batch_scan
- nullptr, // batchscan_dis_batch_scan
- nullptr, // batchscan_read_reports
-};
-
btgatt_client_interface_t fake_btgattc_iface = {
FakeRegisterClient,
FakeUnregisterClient,
@@ -172,7 +138,7 @@
FakeBluetoothGattInterface::FakeBluetoothGattInterface(
std::shared_ptr<BleAdvertiserInterface> advertiser_handler,
- std::shared_ptr<TestScannerHandler> scanner_handler,
+ std::shared_ptr<BleScannerInterface> scanner_handler,
std::shared_ptr<TestClientHandler> client_handler,
std::shared_ptr<TestServerHandler> server_handler)
: client_handler_(client_handler) {
@@ -203,12 +169,6 @@
// The methods below can be used to notify observers with certain events and
// given parameters.
-void FakeBluetoothGattInterface::NotifyRegisterScannerCallback(
- int status, int client_if, const bt_uuid_t& app_uuid) {
- FOR_EACH_OBSERVER(ScannerObserver, scanner_observers_,
- RegisterScannerCallback(this, status, client_if, app_uuid));
-}
-
void FakeBluetoothGattInterface::NotifyScanResultCallback(
const bt_bdaddr_t& bda, int rssi, std::vector<uint8_t> adv_data) {
FOR_EACH_OBSERVER(ScannerObserver, scanner_observers_,
@@ -340,9 +300,9 @@
return g_advertiser_handler.get();
}
-const btgatt_scanner_interface_t*
-FakeBluetoothGattInterface::GetScannerHALInterface() const {
- return &fake_scanner_iface;
+BleScannerInterface* FakeBluetoothGattInterface::GetScannerHALInterface()
+ const {
+ return g_scanner_handler.get();
}
const btgatt_client_interface_t*
diff --git a/service/hal/fake_bluetooth_gatt_interface.h b/service/hal/fake_bluetooth_gatt_interface.h
index 3e79f52..c96f7f0 100644
--- a/service/hal/fake_bluetooth_gatt_interface.h
+++ b/service/hal/fake_bluetooth_gatt_interface.h
@@ -26,19 +26,6 @@
class FakeBluetoothGattInterface : public BluetoothGattInterface {
public:
- // Handles HAL LE scanner API calls for testing. Test code can
- // provide a fake or mock implementation of this and all calls will be routed
- // to it.
- class TestScannerHandler {
- public:
- virtual ~TestScannerHandler() = default;
-
- virtual bt_status_t RegisterScanner(bt_uuid_t* app_uuid) = 0;
- virtual bt_status_t UnregisterScanner(int client_if) = 0;
-
- virtual bt_status_t Scan(bool start) = 0;
- };
-
// Handles HAL Bluetooth GATT client API calls for testing. Test code can
// provide a fake or mock implementation of this and all calls will be routed
// to it.
@@ -79,7 +66,7 @@
// behavior in which BT_STATUS_FAIL will be returned from all calls.
FakeBluetoothGattInterface(
std::shared_ptr<BleAdvertiserInterface> advertiser_handler,
- std::shared_ptr<TestScannerHandler> scanner_handler,
+ std::shared_ptr<BleScannerInterface> scanner_handler,
std::shared_ptr<TestClientHandler> client_handler,
std::shared_ptr<TestServerHandler> server_handler);
~FakeBluetoothGattInterface();
@@ -144,7 +131,7 @@
void AddServerObserver(ServerObserver* observer) override;
void RemoveServerObserver(ServerObserver* observer) override;
BleAdvertiserInterface* GetAdvertiserHALInterface() const override;
- const btgatt_scanner_interface_t* GetScannerHALInterface() const override;
+ BleScannerInterface* GetScannerHALInterface() const override;
const btgatt_client_interface_t* GetClientHALInterface() const override;
const btgatt_server_interface_t* GetServerHALInterface() const override;
@@ -152,7 +139,7 @@
base::ObserverList<ScannerObserver> scanner_observers_;
base::ObserverList<ClientObserver> client_observers_;
base::ObserverList<ServerObserver> server_observers_;
- std::shared_ptr<TestScannerHandler> scanner_handler_;
+ std::shared_ptr<BleScannerInterface> scanner_handler_;
std::shared_ptr<TestClientHandler> client_handler_;
std::shared_ptr<TestServerHandler> server_handler_;
diff --git a/service/low_energy_scanner.cc b/service/low_energy_scanner.cc
index c51ef3d..5220414 100644
--- a/service/low_energy_scanner.cc
+++ b/service/low_energy_scanner.cc
@@ -81,9 +81,8 @@
// Unregister as observer so we no longer receive any callbacks.
hal::BluetoothGattInterface::Get()->RemoveScannerObserver(this);
- hal::BluetoothGattInterface::Get()
- ->GetScannerHALInterface()
- ->unregister_scanner(scanner_id_);
+ hal::BluetoothGattInterface::Get()->GetScannerHALInterface()->Unregister(
+ scanner_id_);
// Stop any scans started by this client.
if (scan_started_.load()) StopScan();
@@ -182,20 +181,21 @@
return false;
}
- const btgatt_scanner_interface_t* hal_iface =
+ BleScannerInterface* hal_iface =
hal::BluetoothGattInterface::Get()->GetScannerHALInterface();
- bt_uuid_t app_uuid = uuid.GetBlueDroid();
- if (hal_iface->register_scanner(&app_uuid) != BT_STATUS_SUCCESS) return false;
+ hal_iface->RegisterScanner(
+ base::Bind(&LowEnergyScannerFactory::RegisterScannerCallback,
+ base::Unretained(this), callback, uuid));
- pending_calls_[uuid] = callback;
+ pending_calls_.insert(uuid);
return true;
}
void LowEnergyScannerFactory::RegisterScannerCallback(
- hal::BluetoothGattInterface* gatt_iface, int status, int scanner_id,
- const bt_uuid_t& app_uuid) {
+ const RegisterCallback& callback, const UUID& app_uuid, uint8_t scanner_id,
+ uint8_t status) {
UUID uuid(app_uuid);
VLOG(1) << __func__ << " - UUID: " << uuid.ToString();
@@ -213,13 +213,13 @@
if (status == BT_STATUS_SUCCESS) {
scanner.reset(new LowEnergyScanner(adapter_, uuid, scanner_id));
- gatt_iface->AddScannerObserver(scanner.get());
+ hal::BluetoothGattInterface::Get()->AddScannerObserver(scanner.get());
result = BLE_STATUS_SUCCESS;
}
// Notify the result via the result callback.
- iter->second(result, uuid, std::move(scanner));
+ callback(result, app_uuid, std::move(scanner));
pending_calls_.erase(iter);
}
diff --git a/service/low_energy_scanner.h b/service/low_energy_scanner.h
index f80e484..e7f6584 100644
--- a/service/low_energy_scanner.h
+++ b/service/low_energy_scanner.h
@@ -144,13 +144,13 @@
friend class LowEnergyScanner;
// BluetoothGattInterface::ScannerObserver overrides:
- void RegisterScannerCallback(hal::BluetoothGattInterface* gatt_iface,
- int status, int scanner_id,
- const bt_uuid_t& app_uuid);
+ void RegisterScannerCallback(const RegisterCallback& callback,
+ const UUID& app_uuid, uint8_t scanner_id,
+ uint8_t status);
// Map of pending calls to register.
std::mutex pending_calls_lock_;
- std::map<UUID, RegisterCallback> pending_calls_;
+ std::unordered_set<UUID> pending_calls_;
// Raw pointer to the Adapter that owns this factory.
Adapter& adapter_;
diff --git a/service/test/low_energy_scanner_unittest.cc b/service/test/low_energy_scanner_unittest.cc
index 9f592c2..de34dab 100644
--- a/service/test/low_energy_scanner_unittest.cc
+++ b/service/test/low_energy_scanner_unittest.cc
@@ -30,24 +30,49 @@
using ::testing::Pointee;
using ::testing::DoAll;
using ::testing::Invoke;
+using ::testing::SaveArg;
namespace bluetooth {
namespace {
-class MockGattHandler
- : public hal::FakeBluetoothGattInterface::TestScannerHandler {
+class MockScannerHandler : public BleScannerInterface {
public:
- MockGattHandler() {
- ON_CALL(*this, Scan(false)).WillByDefault(Return(BT_STATUS_SUCCESS));
- }
- ~MockGattHandler() override = default;
+ MockScannerHandler() {}
+ ~MockScannerHandler() override = default;
- MOCK_METHOD1(RegisterScanner, bt_status_t(bt_uuid_t*));
- MOCK_METHOD1(UnregisterScanner, bt_status_t(int));
- MOCK_METHOD1(Scan, bt_status_t(bool));
+ MOCK_METHOD1(RegisterScanner, void(BleScannerInterface::RegisterCallback));
+ MOCK_METHOD1(Unregister, void(int));
+ MOCK_METHOD1(Scan, void(bool));
- private:
- DISALLOW_COPY_AND_ASSIGN(MockGattHandler);
+ MOCK_METHOD1(scan_filter_param_setup,
+ bt_status_t(btgatt_filt_param_setup_t filt_param));
+ MOCK_METHOD2(scan_filter_clear, bt_status_t(int client_if, int filt_index));
+ MOCK_METHOD2(scan_filter_enable, bt_status_t(int client_if, bool enable));
+
+ MOCK_METHOD3(set_scan_parameters,
+ bt_status_t(int client_if, int scan_interval, int scan_window));
+
+ MOCK_METHOD4(batchscan_cfg_storage,
+ bt_status_t(int client_if, int batch_scan_full_max,
+ int batch_scan_trunc_max,
+ int batch_scan_notify_threshold));
+
+ MOCK_METHOD6(batchscan_enb_batch_scan,
+ bt_status_t(int client_if, int scan_mode, int scan_interval,
+ int scan_window, int addr_type, int discard_rule));
+
+ MOCK_METHOD1(batchscan_dis_batch_scan, bt_status_t(int client_if));
+
+ MOCK_METHOD2(batchscan_read_reports,
+ bt_status_t(int client_if, int scan_mode));
+
+ bt_status_t scan_filter_add_remove(
+ int client_if, int action, int filt_type, int filt_index, int company_id,
+ int company_id_mask, const bt_uuid_t* p_uuid,
+ const bt_uuid_t* p_uuid_mask, const bt_bdaddr_t* bd_addr, char addr_type,
+ std::vector<uint8_t> data, std::vector<uint8_t> p_mask) {
+ return BT_STATUS_SUCCESS;
+ };
};
class TestDelegate : public LowEnergyScanner::Delegate {
@@ -79,11 +104,9 @@
void SetUp() override {
// Only set |mock_handler_| if a test hasn't set it.
- if (!mock_handler_) mock_handler_.reset(new MockGattHandler());
+ if (!mock_handler_) mock_handler_.reset(new MockScannerHandler());
fake_hal_gatt_iface_ = new hal::FakeBluetoothGattInterface(
- nullptr,
- std::static_pointer_cast<
- hal::FakeBluetoothGattInterface::TestScannerHandler>(mock_handler_),
+ nullptr, std::static_pointer_cast<BleScannerInterface>(mock_handler_),
nullptr, nullptr);
hal::BluetoothGattInterface::InitializeForTesting(fake_hal_gatt_iface_);
ble_factory_.reset(new LowEnergyScannerFactory(mock_adapter_));
@@ -97,7 +120,7 @@
protected:
hal::FakeBluetoothGattInterface* fake_hal_gatt_iface_;
testing::MockAdapter mock_adapter_;
- std::shared_ptr<MockGattHandler> mock_handler_;
+ std::shared_ptr<MockScannerHandler> mock_handler_;
std::unique_ptr<LowEnergyScannerFactory> ble_factory_;
private:
@@ -119,9 +142,7 @@
}
void TearDown() override {
- EXPECT_CALL(*mock_handler_, UnregisterScanner(_))
- .Times(1)
- .WillOnce(Return(BT_STATUS_SUCCESS));
+ EXPECT_CALL(*mock_handler_, Unregister(_)).Times(1).WillOnce(Return());
le_scanner_.reset();
LowEnergyScannerTest::TearDown();
}
@@ -140,15 +161,14 @@
static_cast<LowEnergyScanner*>(in_scanner.release())));
};
+ BleScannerInterface::RegisterCallback reg_scanner_cb;
EXPECT_CALL(*mock_handler_, RegisterScanner(_))
.Times(1)
- .WillOnce(Return(BT_STATUS_SUCCESS));
+ .WillOnce(SaveArg<0>(®_scanner_cb));
ble_factory_->RegisterInstance(uuid, api_callback);
- bt_uuid_t hal_uuid = uuid.GetBlueDroid();
- fake_hal_gatt_iface_->NotifyRegisterScannerCallback(0, next_scanner_id_++,
- hal_uuid);
+ reg_scanner_cb.Run(next_scanner_id_++, BT_STATUS_SUCCESS);
::testing::Mock::VerifyAndClearExpectations(mock_handler_.get());
}
@@ -162,10 +182,10 @@
};
TEST_F(LowEnergyScannerTest, RegisterInstance) {
+ BleScannerInterface::RegisterCallback reg_scanner_cb1;
EXPECT_CALL(*mock_handler_, RegisterScanner(_))
- .Times(2)
- .WillOnce(Return(BT_STATUS_FAIL))
- .WillOnce(Return(BT_STATUS_SUCCESS));
+ .Times(1)
+ .WillOnce(SaveArg<0>(®_scanner_cb1));
// These will be asynchronously populated with a result when the callback
// executes.
@@ -185,10 +205,6 @@
UUID uuid0 = UUID::GetRandom();
- // HAL returns failure.
- EXPECT_FALSE(ble_factory_->RegisterInstance(uuid0, callback));
- EXPECT_EQ(0, callback_count);
-
// HAL returns success.
EXPECT_TRUE(ble_factory_->RegisterInstance(uuid0, callback));
EXPECT_EQ(0, callback_count);
@@ -201,22 +217,15 @@
// Call with a different UUID while one is pending.
UUID uuid1 = UUID::GetRandom();
+ BleScannerInterface::RegisterCallback reg_scanner_cb2;
EXPECT_CALL(*mock_handler_, RegisterScanner(_))
.Times(1)
- .WillOnce(Return(BT_STATUS_SUCCESS));
+ .WillOnce(SaveArg<0>(®_scanner_cb2));
EXPECT_TRUE(ble_factory_->RegisterInstance(uuid1, callback));
- // Trigger callback with an unknown UUID. This should get ignored.
- UUID uuid2 = UUID::GetRandom();
- bt_uuid_t hal_uuid = uuid2.GetBlueDroid();
- fake_hal_gatt_iface_->NotifyRegisterScannerCallback(0, 0, hal_uuid);
- EXPECT_EQ(0, callback_count);
-
// |uuid0| succeeds.
int scanner_if0 = 2; // Pick something that's not 0.
- hal_uuid = uuid0.GetBlueDroid();
- fake_hal_gatt_iface_->NotifyRegisterScannerCallback(BT_STATUS_SUCCESS,
- scanner_if0, hal_uuid);
+ reg_scanner_cb1.Run(scanner_if0, BT_STATUS_SUCCESS);
EXPECT_EQ(1, callback_count);
ASSERT_TRUE(scanner.get() !=
@@ -227,17 +236,15 @@
EXPECT_EQ(uuid0, cb_uuid);
// The scanner should unregister itself when deleted.
- EXPECT_CALL(*mock_handler_, UnregisterScanner(scanner_if0))
+ EXPECT_CALL(*mock_handler_, Unregister(scanner_if0))
.Times(1)
- .WillOnce(Return(BT_STATUS_SUCCESS));
+ .WillOnce(Return());
scanner.reset();
::testing::Mock::VerifyAndClearExpectations(mock_handler_.get());
// |uuid1| fails.
int scanner_if1 = 3;
- hal_uuid = uuid1.GetBlueDroid();
- fake_hal_gatt_iface_->NotifyRegisterScannerCallback(BT_STATUS_FAIL,
- scanner_if1, hal_uuid);
+ reg_scanner_cb2.Run(scanner_if1, BT_STATUS_FAIL);
EXPECT_EQ(2, callback_count);
ASSERT_TRUE(scanner.get() ==
@@ -261,15 +268,11 @@
// implemented
// These should succeed and result in a HAL call
- EXPECT_CALL(*mock_handler_, Scan(true))
- .Times(1)
- .WillOnce(Return(BT_STATUS_SUCCESS));
+ EXPECT_CALL(*mock_handler_, Scan(true)).Times(1).WillOnce(Return());
EXPECT_TRUE(le_scanner_->StartScan(settings, filters));
// These should succeed and result in a HAL call
- EXPECT_CALL(*mock_handler_, Scan(false))
- .Times(1)
- .WillOnce(Return(BT_STATUS_SUCCESS));
+ EXPECT_CALL(*mock_handler_, Scan(false)).Times(1).WillOnce(Return());
EXPECT_TRUE(le_scanner_->StopScan());
::testing::Mock::VerifyAndClearExpectations(mock_handler_.get());
@@ -303,8 +306,8 @@
EXPECT_CALL(mock_adapter_, IsEnabled()).Times(1).WillOnce(Return(true));
EXPECT_CALL(*mock_handler_, Scan(_))
.Times(2)
- .WillOnce(Return(BT_STATUS_SUCCESS))
- .WillOnce(Return(BT_STATUS_SUCCESS));
+ .WillOnce(Return())
+ .WillOnce(Return());
ScanSettings settings;
std::vector<ScanFilter> filters;
ASSERT_TRUE(le_scanner_->StartScan(settings, filters));
diff --git a/test/suite/gatt/gatt_test.cc b/test/suite/gatt/gatt_test.cc
index 7700cd9..2ea43cf 100644
--- a/test/suite/gatt/gatt_test.cc
+++ b/test/suite/gatt/gatt_test.cc
@@ -78,7 +78,7 @@
BluetoothTest::TearDown();
}
-const btgatt_scanner_interface_t* GattTest::gatt_scanner_interface() {
+const BleScannerInterface* GattTest::gatt_scanner_interface() {
return gatt_scanner_interface_;
}
diff --git a/test/suite/gatt/gatt_test.h b/test/suite/gatt/gatt_test.h
index 038ca2b..cdf532c 100644
--- a/test/suite/gatt/gatt_test.h
+++ b/test/suite/gatt/gatt_test.h
@@ -32,7 +32,7 @@
virtual ~GattTest() = default;
// Gets the gatt_scanner_interface
- const btgatt_scanner_interface_t* gatt_scanner_interface();
+ const BleScannerInterface* gatt_scanner_interface();
// Gets the gatt_client_interface
const btgatt_client_interface_t* gatt_client_interface();
@@ -95,7 +95,7 @@
private:
// The btgatt_scanner_interface_t that all the tests use to interact with the
// HAL
- const btgatt_scanner_interface_t* gatt_scanner_interface_;
+ const BleScannerInterface* gatt_scanner_interface_;
// The gatt_client_interface that all the tests use to interact with the HAL
const btgatt_client_interface_t* gatt_client_interface_;