diff --git a/fastpair/scanning/fastpair/fast_pair_discoverable_scanner_impl.cc b/fastpair/scanning/fastpair/fast_pair_discoverable_scanner_impl.cc index f94b98b8..dbedf2e3 100644 --- a/fastpair/scanning/fastpair/fast_pair_discoverable_scanner_impl.cc +++ b/fastpair/scanning/fastpair/fast_pair_discoverable_scanner_impl.cc @@ -101,9 +101,9 @@ FastPairDiscoverableScannerImpl::FastPairDiscoverableScannerImpl( void FastPairDiscoverableScannerImpl::OnDeviceFound( const BlePeripheral& peripheral) { - ByteArray fast_pair_service_data = - peripheral.GetAdvertisementBytes(kServiceId); - if (fast_pair_service_data.Empty()) { + std::string fast_pair_service_data = + peripheral.GetAdvertisementBytes(kServiceId).string_data(); + if (fast_pair_service_data.empty()) { NEARBY_LOGS(WARNING) << __func__ << ": Device doesn't have any Fast Pair Service Data."; return; @@ -112,9 +112,8 @@ void FastPairDiscoverableScannerImpl::OnDeviceFound( model_id_parse_attempts_[peripheral.GetName()] = 1; NEARBY_LOGS(INFO) << __func__ << ": Attempting to get model ID"; std::vector service_data; - std::string model_id_bytes = fast_pair_service_data.data(); - std::move(std::begin(model_id_bytes), std::end(model_id_bytes), - std::back_inserter(service_data)); + std::move(std::begin(fast_pair_service_data), + std::end(fast_pair_service_data), std::back_inserter(service_data)); FastPairDataParser::GetHexModelIdFromServiceData( service_data, diff --git a/fastpair/scanning/fastpair/fast_pair_scanner_impl.cc b/fastpair/scanning/fastpair/fast_pair_scanner_impl.cc index de7c675e..02182fd7 100644 --- a/fastpair/scanning/fastpair/fast_pair_scanner_impl.cc +++ b/fastpair/scanning/fastpair/fast_pair_scanner_impl.cc @@ -115,14 +115,15 @@ void FastPairScannerImpl::StopScanning() { void FastPairScannerImpl::OnDeviceFound(const BlePeripheral& peripheral) { NEARBY_LOGS(INFO) << __func__ << "Found device with ble Address = " << peripheral.GetName(); - ByteArray service_data = peripheral.GetAdvertisementBytes(kServiceId); - if (service_data.Empty()) { + std::string service_data = + peripheral.GetAdvertisementBytes(kServiceId).string_data(); + if (service_data.empty()) { NEARBY_LOGS(WARNING) << "No Fast Pair service data found on device"; return; } device_address_advertisement_data_map_[peripheral.GetName()].insert( - peripheral.GetAdvertisementBytes(kServiceId)); + service_data); NotifyDeviceFound(peripheral); } diff --git a/fastpair/scanning/fastpair/fast_pair_scanner_impl.h b/fastpair/scanning/fastpair/fast_pair_scanner_impl.h index 0c8d0e17..7249fe90 100644 --- a/fastpair/scanning/fastpair/fast_pair_scanner_impl.h +++ b/fastpair/scanning/fastpair/fast_pair_scanner_impl.h @@ -21,6 +21,7 @@ #include #include +#include "absl/strings/string_view.h" #include "fastpair/internal/ble/ble.h" #include "fastpair/scanning/fastpair/fast_pair_scanner.h" #include "internal/base/observer_list.h" @@ -75,7 +76,7 @@ class FastPairScannerImpl : public FastPairScanner { // Map of a Bluetooth device address to a set of advertisement data we have // seen. - absl::flat_hash_map> + absl::flat_hash_map> device_address_advertisement_data_map_; BluetoothAdapter bluetooth_adapter_; diff --git a/internal/platform/implementation/ble_v2.h b/internal/platform/implementation/ble_v2.h index 31c47194..3c3ab19c 100644 --- a/internal/platform/implementation/ble_v2.h +++ b/internal/platform/implementation/ble_v2.h @@ -165,7 +165,6 @@ struct GattCharacteristic { // https://developer.android.com/reference/android/bluetooth/BluetoothGatt // // Representation of a client GATT connection to a remote GATT server. -// TODO(b/271625842) Convert ByteArray to std::string class GattClient { public: virtual ~GattClient() = default;