diff --git a/fastpair/internal/mediums/ble_v2.cc b/fastpair/internal/mediums/ble_v2.cc index 9d156596..813f83ee 100644 --- a/fastpair/internal/mediums/ble_v2.cc +++ b/fastpair/internal/mediums/ble_v2.cc @@ -48,7 +48,8 @@ std::unique_ptr BleV2::ConnectToGattServer( return nullptr; } - BleV2Peripheral v2_peripheral = medium_.GetRemotePeripheral(ble_address); + BleV2Peripheral v2_peripheral = + medium_.GetRemotePeripheral(std::string(ble_address)); return medium_.ConnectToGattServer(v2_peripheral, api::ble_v2::TxPowerLevel::kUnknown, {}); } diff --git a/internal/platform/ble_v2.cc b/internal/platform/ble_v2.cc index fd34813b..1348159f 100644 --- a/internal/platform/ble_v2.cc +++ b/internal/platform/ble_v2.cc @@ -289,7 +289,7 @@ bool BleV2Medium::IsExtendedAdvertisementsAvailable() { } BleV2Peripheral BleV2Medium::GetRemotePeripheral( - absl::string_view mac_address) { + const std::string& mac_address) { BleV2Peripheral peripheral; impl_->GetRemotePeripheral(mac_address, [&](api::ble_v2::BlePeripheral& device) { diff --git a/internal/platform/ble_v2.h b/internal/platform/ble_v2.h index ba8fedcc..197be021 100644 --- a/internal/platform/ble_v2.h +++ b/internal/platform/ble_v2.h @@ -444,7 +444,7 @@ class BleV2Medium final { // Returns a `BleV2Peripheral` with given mac address. `mac_address` is in // canonical format. - BleV2Peripheral GetRemotePeripheral(absl::string_view mac_address); + BleV2Peripheral GetRemotePeripheral(const std::string& mac_address); api::ble_v2::BleMedium* GetImpl() const { return impl_.get(); } BluetoothAdapter& GetAdapter() { return adapter_; } diff --git a/internal/platform/implementation/apple/ble.h b/internal/platform/implementation/apple/ble.h index 1f4965ba..6d41a16d 100644 --- a/internal/platform/implementation/apple/ble.h +++ b/internal/platform/implementation/apple/ble.h @@ -145,7 +145,7 @@ class BleMedium : public api::ble_v2::BleMedium { CancellationFlag *cancellation_flag) override; bool IsExtendedAdvertisementsAvailable() override; - bool GetRemotePeripheral(absl::string_view mac_address, + bool GetRemotePeripheral(const std::string& mac_address, GetRemotePeripheralCallback callback) override { return false; } diff --git a/internal/platform/implementation/ble_v2.h b/internal/platform/implementation/ble_v2.h index 04709eb0..3c1bca53 100644 --- a/internal/platform/implementation/ble_v2.h +++ b/internal/platform/implementation/ble_v2.h @@ -510,7 +510,7 @@ class BleMedium { // Calls `callback` and returns true if `mac_address` is a valid BLE address. // Otherwise, does not call the callback and returns false. - virtual bool GetRemotePeripheral(absl::string_view mac_address, + virtual bool GetRemotePeripheral(const std::string& mac_address, GetRemotePeripheralCallback callback) = 0; // Calls `callback` and returns true if `id` refers to a known BLE peripheral. diff --git a/internal/platform/implementation/g3/ble_v2.cc b/internal/platform/implementation/g3/ble_v2.cc index 2e334605..050c7eff 100644 --- a/internal/platform/implementation/g3/ble_v2.cc +++ b/internal/platform/implementation/g3/ble_v2.cc @@ -378,7 +378,7 @@ bool BleV2Medium::IsExtendedAdvertisementsAvailable() { return is_support_extended_advertisement_; } -bool BleV2Medium::GetRemotePeripheral(absl::string_view mac_address, +bool BleV2Medium::GetRemotePeripheral(const std::string& mac_address, GetRemotePeripheralCallback callback) { NEARBY_LOGS(INFO) << "GetRemotePeripheral, address= " << mac_address; absl::MutexLock lock(&mutex_); diff --git a/internal/platform/implementation/g3/ble_v2.h b/internal/platform/implementation/g3/ble_v2.h index ed467555..a3a9b2f3 100644 --- a/internal/platform/implementation/g3/ble_v2.h +++ b/internal/platform/implementation/g3/ble_v2.h @@ -221,7 +221,7 @@ class BleV2Medium : public api::ble_v2::BleMedium { BleV2Peripheral& GetPeripheral() { return peripheral_; } - bool GetRemotePeripheral(absl::string_view mac_address, + bool GetRemotePeripheral(const std::string& mac_address, GetRemotePeripheralCallback callback) override; bool GetRemotePeripheral(api::ble_v2::BlePeripheral::UniqueId id, diff --git a/internal/platform/implementation/windows/ble_v2.cc b/internal/platform/implementation/windows/ble_v2.cc index e979614a..7349d70c 100644 --- a/internal/platform/implementation/windows/ble_v2.cc +++ b/internal/platform/implementation/windows/ble_v2.cc @@ -843,7 +843,7 @@ void BleV2Medium::AdvertisementReceivedHandler( } } -bool BleV2Medium::GetRemotePeripheral(absl::string_view mac_address, +bool BleV2Medium::GetRemotePeripheral(const std::string& mac_address, GetRemotePeripheralCallback callback) { for (auto& item : peripherals_) { if (item.second->GetAddress() == mac_address) { diff --git a/internal/platform/implementation/windows/ble_v2.h b/internal/platform/implementation/windows/ble_v2.h index ec0b15ae..5dc8d745 100644 --- a/internal/platform/implementation/windows/ble_v2.h +++ b/internal/platform/implementation/windows/ble_v2.h @@ -71,7 +71,7 @@ class BleV2Medium : public api::ble_v2::BleMedium { CancellationFlag* cancellation_flag) override; bool IsExtendedAdvertisementsAvailable() override; - bool GetRemotePeripheral(absl::string_view mac_address, + bool GetRemotePeripheral(const std::string& mac_address, GetRemotePeripheralCallback callback) override; bool GetRemotePeripheral(api::ble_v2::BlePeripheral::UniqueId id,