OLD | NEW |
---|---|
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "device/bluetooth/bluez/bluetooth_device_bluez.h" | 5 #include "device/bluetooth/bluez/bluetooth_device_bluez.h" |
6 | 6 |
7 #include <stdio.h> | 7 #include <stdio.h> |
8 | 8 |
9 #include <algorithm> | 9 #include <algorithm> |
10 #include <memory> | 10 #include <memory> |
(...skipping 357 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
368 UUIDSet uuids; | 368 UUIDSet uuids; |
369 const std::vector<std::string>& dbus_uuids = properties->uuids.value(); | 369 const std::vector<std::string>& dbus_uuids = properties->uuids.value(); |
370 for (const std::string& dbus_uuid : dbus_uuids) { | 370 for (const std::string& dbus_uuid : dbus_uuids) { |
371 device::BluetoothUUID uuid(dbus_uuid); | 371 device::BluetoothUUID uuid(dbus_uuid); |
372 DCHECK(uuid.IsValid()); | 372 DCHECK(uuid.IsValid()); |
373 uuids.insert(std::move(uuid)); | 373 uuids.insert(std::move(uuid)); |
374 } | 374 } |
375 return uuids; | 375 return uuids; |
376 } | 376 } |
377 | 377 |
378 std::unordered_map<uint16_t, std::vector<uint8_t>> | |
379 BluetoothDeviceBlueZ::GetManufacturerData() const { | |
380 bluez::BluetoothDeviceClient::Properties* properties = | |
381 bluez::BluezDBusManager::Get()->GetBluetoothDeviceClient()->GetProperties( | |
382 object_path_); | |
383 DCHECK(properties); | |
384 | |
385 if (!properties->manufacturer_data.is_valid()) | |
386 return std::unordered_map<uint16_t, std::vector<uint8_t>>(); | |
387 | |
388 return properties->manufacturer_data.value(); | |
389 } | |
390 | |
391 base::Optional<uint8_t> BluetoothDeviceBlueZ::GetFlags() const { | |
392 bluez::BluetoothDeviceClient::Properties* properties = | |
393 bluez::BluezDBusManager::Get()->GetBluetoothDeviceClient()->GetProperties( | |
394 object_path_); | |
395 DCHECK(properties); | |
396 | |
397 // BlueZ always have flags available. | |
ortuno
2016/10/14 00:15:10
Can you DCHECK this? Also I don't think this is tr
Rahul Chaturvedi
2016/10/17 20:41:21
This is not true. Depending on the version of Blue
puthik_chromium
2016/10/17 23:30:32
I added the check if it is valid or not.
| |
398 return properties->flags.value(); | |
399 } | |
400 | |
378 base::Optional<int8_t> BluetoothDeviceBlueZ::GetInquiryRSSI() const { | 401 base::Optional<int8_t> BluetoothDeviceBlueZ::GetInquiryRSSI() const { |
379 bluez::BluetoothDeviceClient::Properties* properties = | 402 bluez::BluetoothDeviceClient::Properties* properties = |
380 bluez::BluezDBusManager::Get()->GetBluetoothDeviceClient()->GetProperties( | 403 bluez::BluezDBusManager::Get()->GetBluetoothDeviceClient()->GetProperties( |
381 object_path_); | 404 object_path_); |
382 DCHECK(properties); | 405 DCHECK(properties); |
383 | 406 |
384 if (!properties->rssi.is_valid()) | 407 if (!properties->rssi.is_valid()) |
385 return base::nullopt; | 408 return base::nullopt; |
386 | 409 |
387 // BlueZ uses int16_t because there is no int8_t for DBus, so we should never | 410 // BlueZ uses int16_t because there is no int8_t for DBus, so we should never |
(...skipping 525 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
913 void BluetoothDeviceBlueZ::OnForgetError(const ErrorCallback& error_callback, | 936 void BluetoothDeviceBlueZ::OnForgetError(const ErrorCallback& error_callback, |
914 const std::string& error_name, | 937 const std::string& error_name, |
915 const std::string& error_message) { | 938 const std::string& error_message) { |
916 LOG(WARNING) << object_path_.value() | 939 LOG(WARNING) << object_path_.value() |
917 << ": Failed to remove device: " << error_name << ": " | 940 << ": Failed to remove device: " << error_name << ": " |
918 << error_message; | 941 << error_message; |
919 error_callback.Run(); | 942 error_callback.Run(); |
920 } | 943 } |
921 | 944 |
922 } // namespace bluez | 945 } // namespace bluez |
OLD | NEW |