Chromium Code Reviews| Index: device/bluetooth/bluez/bluetooth_device_bluez.cc |
| diff --git a/device/bluetooth/bluez/bluetooth_device_bluez.cc b/device/bluetooth/bluez/bluetooth_device_bluez.cc |
| index 417ed161d40b86266ffbb43cea208a835ae1a5ec..82e586e9a6fd082e6602b38dee3e47c3b61a0acd 100644 |
| --- a/device/bluetooth/bluez/bluetooth_device_bluez.cc |
| +++ b/device/bluetooth/bluez/bluetooth_device_bluez.cc |
| @@ -375,6 +375,50 @@ BluetoothDevice::UUIDSet BluetoothDeviceBlueZ::GetUUIDs() const { |
| return uuids; |
| } |
| +BluetoothDevice::UUIDSet BluetoothDeviceBlueZ::GetServiceDataUUIDs() const { |
| + bluez::BluetoothDeviceClient::Properties* properties = |
| + bluez::BluezDBusManager::Get()->GetBluetoothDeviceClient()->GetProperties( |
| + object_path_); |
| + DCHECK(properties); |
| + |
| + UUIDSet uuids; |
| + |
| + if (!properties->service_data.is_valid()) |
| + return uuids; |
| + |
| + for (const auto& pair : properties->service_data.value()) { |
| + device::BluetoothUUID uuid(pair.first); |
| + DCHECK(uuid.IsValid()); |
| + uuids.insert(std::move(uuid)); |
| + } |
| + |
| + return uuids; |
| +} |
| + |
| +const std::vector<uint8_t>* BluetoothDeviceBlueZ::GetServiceDataForUUID( |
| + const BluetoothUUID& uuid) const { |
| + bluez::BluetoothDeviceClient::Properties* properties = |
| + bluez::BluezDBusManager::Get()->GetBluetoothDeviceClient()->GetProperties( |
| + object_path_); |
| + DCHECK(properties); |
| + |
| + if (!properties->service_data.is_valid()) |
| + return nullptr; |
| + |
| + const auto& dbus_service_data = properties->service_data.value(); |
| + auto it = std::find_if( |
| + dbus_service_data.begin(), dbus_service_data.end(), |
| + [&uuid](const std::pair<std::string, std::vector<uint8_t>>& entry) { |
| + return uuid.canonical_value() == |
| + device::BluetoothUUID(entry.first).canonical_value(); |
| + }); |
| + |
| + if (it == dbus_service_data.end()) |
| + return nullptr; |
| + |
| + return &it->second; |
| +} |
| + |
| base::Optional<int8_t> BluetoothDeviceBlueZ::GetInquiryRSSI() const { |
| bluez::BluetoothDeviceClient::Properties* properties = |
| bluez::BluezDBusManager::Get()->GetBluetoothDeviceClient()->GetProperties( |
| @@ -755,7 +799,7 @@ void BluetoothDeviceBlueZ::OnConnect(bool after_pairing, |
| if (--num_connecting_calls_ == 0) |
| adapter()->NotifyDeviceChanged(this); |
| - DCHECK(num_connecting_calls_ >= 0); |
| + DCHECK_GE(num_connecting_calls_, 0); |
|
Rahul Chaturvedi
2016/09/27 20:52:59
Cleanup should be in its own CL. Usually conflatin
puthik_chromium
2016/09/27 21:04:07
Acknowledged.
Will fix this once I got your full c
puthik_chromium
2016/10/06 01:49:56
Done.
|
| VLOG(1) << object_path_.value() << ": Connected, " << num_connecting_calls_ |
| << " still in progress"; |
| @@ -784,7 +828,7 @@ void BluetoothDeviceBlueZ::OnConnectError( |
| if (--num_connecting_calls_ == 0) |
| adapter()->NotifyDeviceChanged(this); |
| - DCHECK(num_connecting_calls_ >= 0); |
| + DCHECK_GE(num_connecting_calls_, 0); |
| LOG(WARNING) << object_path_.value() |
| << ": Failed to connect device: " << error_name << ": " |
| << error_message; |
| @@ -823,7 +867,7 @@ void BluetoothDeviceBlueZ::OnPairDuringConnectError( |
| if (--num_connecting_calls_ == 0) |
| adapter()->NotifyDeviceChanged(this); |
| - DCHECK(num_connecting_calls_ >= 0); |
| + DCHECK_GE(num_connecting_calls_, 0); |
| LOG(WARNING) << object_path_.value() |
| << ": Failed to pair device: " << error_name << ": " |
| << error_message; |