[BLE Refactor] Removes fast advertisement uuid in StartAdvertising and StartScanning.

PiperOrigin-RevId: 448426759
This commit is contained in:
edwinwu
2022-05-13 00:19:16 -07:00
committed by Copybara-Service
parent 080e964a4c
commit eddf53ec29
14 changed files with 68 additions and 180 deletions
+1 -1
View File
@@ -319,7 +319,7 @@ class BleMedium {
// HIGH:
// - Scan window = ~4096ms
// - Scan interval = ~4096ms
virtual bool StartScanning(const std::vector<std::string>& service_uuids,
virtual bool StartScanning(const std::string& service_uuid,
PowerMode power_mode, ScanCallback callback) = 0;
// https://developer.android.com/reference/android/bluetooth/le/BluetoothLeScanner.html#stopScan(android.bluetooth.le.ScanCallback)
@@ -103,13 +103,13 @@ bool BleV2Medium::StopAdvertising() {
return true;
}
bool BleV2Medium::StartScanning(const std::vector<std::string>& service_uuids,
bool BleV2Medium::StartScanning(const std::string& service_uuid,
PowerMode power_mode, ScanCallback callback) {
NEARBY_LOGS(INFO) << "G3 Ble StartScanning";
absl::MutexLock lock(&mutex_);
MediumEnvironment::Instance().UpdateBleV2MediumForScanning(
/*enabled=*/true, service_uuids.front(), std::move(callback), *this);
/*enabled=*/true, service_uuid, std::move(callback), *this);
return true;
}
+1 -1
View File
@@ -42,7 +42,7 @@ class BleV2Medium : public api::ble_v2::BleMedium {
api::ble_v2::PowerMode power_mode) override ABSL_LOCKS_EXCLUDED(mutex_);
bool StopAdvertising() override ABSL_LOCKS_EXCLUDED(mutex_);
bool StartScanning(const std::vector<std::string>& service_uuids,
bool StartScanning(const std::string& service_uuid,
api::ble_v2::PowerMode power_mode,
ScanCallback callback) override
ABSL_LOCKS_EXCLUDED(mutex_);
@@ -216,7 +216,7 @@ bool BleV2Medium::StopAdvertising() {
return true;
}
bool BleV2Medium::StartScanning(const std::vector<std::string>& service_uuids,
bool BleV2Medium::StartScanning(const std::string& service_uuid,
PowerMode power_mode, ScanCallback callback) {
NEARBY_LOGS(INFO) << "Windows Ble StartScanning";
absl::MutexLock lock(&mutex_);
@@ -53,7 +53,7 @@ class BleV2Medium : public api::ble_v2::BleMedium {
api::ble_v2::PowerMode power_mode) override ABSL_LOCKS_EXCLUDED(mutex_);
bool StopAdvertising() override ABSL_LOCKS_EXCLUDED(mutex_);
bool StartScanning(const std::vector<std::string>& service_uuids,
bool StartScanning(const std::string& service_uuid,
api::ble_v2::PowerMode power_mode,
ScanCallback callback) override
ABSL_LOCKS_EXCLUDED(mutex_);
@@ -14,6 +14,8 @@
#include "internal/platform/implementation/windows/ble_v2.h"
#include <string>
#include "gtest/gtest.h"
#include "absl/synchronization/notification.h"
#include "internal/platform/implementation/ble_v2.h"
@@ -53,7 +55,7 @@ TEST(BleV2Medium, DISABLED_StartScanning) {
BluetoothAdapter bluetoothAdapter;
BleV2Medium blev2_medium(bluetoothAdapter);
std::vector<std::string> service_uuids;
std::string service_uuid;
api::ble_v2::BleMedium::ScanCallback callback;
callback.advertisement_found_cb =
@@ -65,7 +67,7 @@ TEST(BleV2Medium, DISABLED_StartScanning) {
};
EXPECT_TRUE(blev2_medium.StartScanning(
service_uuids, api::ble_v2::PowerMode::kHigh, callback));
service_uuid, api::ble_v2::PowerMode::kHigh, callback));
EXPECT_TRUE(scan_response_notification.WaitForNotificationWithTimeout(
absl::Seconds(5)));
@@ -75,7 +77,7 @@ TEST(BleV2Medium, DISABLED_StartScanning) {
TEST(BleV2Medium, DISABLED_StopScanning) {
BluetoothAdapter bluetoothAdapter;
BleV2Medium blev2_medium(bluetoothAdapter);
std::vector<std::string> service_uuids;
std::string service_uuid;
api::ble_v2::BleMedium::ScanCallback callback;
callback.advertisement_found_cb =
@@ -83,7 +85,7 @@ TEST(BleV2Medium, DISABLED_StopScanning) {
const api::ble_v2::BleAdvertisementData& advertisement_data) {};
EXPECT_TRUE(blev2_medium.StartScanning(
service_uuids, api::ble_v2::PowerMode::kHigh, callback));
service_uuid, api::ble_v2::PowerMode::kHigh, callback));
EXPECT_TRUE(blev2_medium.StopScanning());
}