Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(450)

Unified Diff: device/bluetooth/bluetooth_adapter_mac.mm

Issue 2339253002: bluetooth: mac: add connected LE devices to chooser (Closed)
Patch Set: Created 4 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: device/bluetooth/bluetooth_adapter_mac.mm
diff --git a/device/bluetooth/bluetooth_adapter_mac.mm b/device/bluetooth/bluetooth_adapter_mac.mm
index 1690da6559fe9582cecaba733cc476a6c4d7d763..0049e2e179b1f75a459c8bbf7f0f98c01aa4a7d2 100644
--- a/device/bluetooth/bluetooth_adapter_mac.mm
+++ b/device/bluetooth/bluetooth_adapter_mac.mm
@@ -514,40 +514,42 @@ void BluetoothAdapterMac::LowEnergyDeviceUpdated(
DCHECK(device_mac);
- // Get Advertised UUIDs
- BluetoothDevice::UUIDList advertised_uuids;
- NSArray* service_uuids =
- [advertisement_data objectForKey:CBAdvertisementDataServiceUUIDsKey];
- for (CBUUID* uuid in service_uuids) {
- advertised_uuids.push_back(BluetoothUUID([[uuid UUIDString] UTF8String]));
- }
- NSArray* overflow_service_uuids = [advertisement_data
- objectForKey:CBAdvertisementDataOverflowServiceUUIDsKey];
- for (CBUUID* uuid in overflow_service_uuids) {
- advertised_uuids.push_back(BluetoothUUID([[uuid UUIDString] UTF8String]));
- }
+ if (advertisement_data) {
+ // Get Advertised UUIDs
+ BluetoothDevice::UUIDList advertised_uuids;
+ NSArray* service_uuids =
+ [advertisement_data objectForKey:CBAdvertisementDataServiceUUIDsKey];
+ for (CBUUID* uuid in service_uuids) {
+ advertised_uuids.push_back(BluetoothUUID([[uuid UUIDString] UTF8String]));
+ }
+ NSArray* overflow_service_uuids = [advertisement_data
+ objectForKey:CBAdvertisementDataOverflowServiceUUIDsKey];
+ for (CBUUID* uuid in overflow_service_uuids) {
+ advertised_uuids.push_back(BluetoothUUID([[uuid UUIDString] UTF8String]));
+ }
- // Get Service Data.
- BluetoothDevice::ServiceDataMap service_data_map;
- NSDictionary* service_data =
- [advertisement_data objectForKey:CBAdvertisementDataServiceDataKey];
- for (CBUUID* uuid in service_data) {
- NSData* data = [service_data objectForKey:uuid];
- const uint8_t* bytes = static_cast<const uint8_t*>([data bytes]);
- size_t length = [data length];
- service_data_map.emplace(BluetoothUUID([[uuid UUIDString] UTF8String]),
- std::vector<uint8_t>(bytes, bytes + length));
- }
+ // Get Service Data.
+ BluetoothDevice::ServiceDataMap service_data_map;
+ NSDictionary* service_data =
+ [advertisement_data objectForKey:CBAdvertisementDataServiceDataKey];
+ for (CBUUID* uuid in service_data) {
+ NSData* data = [service_data objectForKey:uuid];
+ const uint8_t* bytes = static_cast<const uint8_t*>([data bytes]);
+ size_t length = [data length];
+ service_data_map.emplace(BluetoothUUID([[uuid UUIDString] UTF8String]),
+ std::vector<uint8_t>(bytes, bytes + length));
+ }
- // Get Tx Power.
- NSNumber* tx_power =
- [advertisement_data objectForKey:CBAdvertisementDataTxPowerLevelKey];
- int8_t clamped_tx_power = BluetoothDevice::ClampPower([tx_power intValue]);
+ // Get Tx Power.
+ NSNumber* tx_power =
+ [advertisement_data objectForKey:CBAdvertisementDataTxPowerLevelKey];
+ int8_t clamped_tx_power = BluetoothDevice::ClampPower([tx_power intValue]);
- device_mac->UpdateAdvertisementData(
- BluetoothDevice::ClampPower(rssi), std::move(advertised_uuids),
- std::move(service_data_map),
- tx_power == nil ? nullptr : &clamped_tx_power);
+ device_mac->UpdateAdvertisementData(
+ BluetoothDevice::ClampPower(rssi), std::move(advertised_uuids),
+ std::move(service_data_map),
+ tx_power == nil ? nullptr : &clamped_tx_power);
+ }
if (is_new_device) {
std::string device_address =

Powered by Google App Engine
This is Rietveld 408576698