| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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 "components/arc/bluetooth/arc_bluetooth_bridge.h" | 5 #include "components/arc/bluetooth/arc_bluetooth_bridge.h" |
| 6 | 6 |
| 7 #include <fcntl.h> | 7 #include <fcntl.h> |
| 8 #include <stddef.h> | 8 #include <stddef.h> |
| 9 | 9 |
| 10 #include <iomanip> | 10 #include <iomanip> |
| (...skipping 1542 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1553 ArcBluetoothBridge::GetAdvertisingData(BluetoothDevice* device) const { | 1553 ArcBluetoothBridge::GetAdvertisingData(BluetoothDevice* device) const { |
| 1554 mojo::Array<mojom::BluetoothAdvertisingDataPtr> advertising_data; | 1554 mojo::Array<mojom::BluetoothAdvertisingDataPtr> advertising_data; |
| 1555 | 1555 |
| 1556 // LocalName | 1556 // LocalName |
| 1557 mojom::BluetoothAdvertisingDataPtr local_name = | 1557 mojom::BluetoothAdvertisingDataPtr local_name = |
| 1558 mojom::BluetoothAdvertisingData::New(); | 1558 mojom::BluetoothAdvertisingData::New(); |
| 1559 local_name->set_local_name(base::UTF16ToUTF8(device->GetNameForDisplay())); | 1559 local_name->set_local_name(base::UTF16ToUTF8(device->GetNameForDisplay())); |
| 1560 advertising_data.push_back(std::move(local_name)); | 1560 advertising_data.push_back(std::move(local_name)); |
| 1561 | 1561 |
| 1562 // ServiceUuid | 1562 // ServiceUuid |
| 1563 BluetoothDevice::UUIDList uuid_list = device->GetServiceDataUUIDs(); | 1563 BluetoothDevice::UUIDList uuid_list = device->GetUUIDs(); |
| 1564 if (uuid_list.size() > 0) { | 1564 if (uuid_list.size() > 0) { |
| 1565 mojom::BluetoothAdvertisingDataPtr service_uuids_16 = | 1565 mojom::BluetoothAdvertisingDataPtr service_uuids_16 = |
| 1566 mojom::BluetoothAdvertisingData::New(); | 1566 mojom::BluetoothAdvertisingData::New(); |
| 1567 mojo::Array<uint16_t> uuid16s; | 1567 mojo::Array<uint16_t> uuid16s; |
| 1568 for (auto& uuid : uuid_list) { | 1568 for (auto& uuid : uuid_list) { |
| 1569 uuid16s.push_back(GetUUID16(uuid)); | 1569 uuid16s.push_back(GetUUID16(uuid)); |
| 1570 } | 1570 } |
| 1571 service_uuids_16->set_service_uuids_16(std::move(uuid16s)); | 1571 service_uuids_16->set_service_uuids_16(std::move(uuid16s)); |
| 1572 advertising_data.push_back(std::move(service_uuids_16)); | 1572 advertising_data.push_back(std::move(service_uuids_16)); |
| 1573 } | 1573 } |
| 1574 | 1574 |
| 1575 // Service data | 1575 // Service data |
| 1576 for (auto& uuid : uuid_list) { | 1576 for (auto& uuid : device->GetServiceDataUUIDs()) { |
| 1577 base::BinaryValue* data = device->GetServiceData(uuid); | 1577 base::BinaryValue* data = device->GetServiceData(uuid); |
| 1578 if (data->GetSize() == 0) | 1578 if (data->GetSize() == 0) |
| 1579 continue; | 1579 continue; |
| 1580 std::string data_str; | 1580 std::string data_str; |
| 1581 if (!data->GetAsString(&data_str)) | 1581 if (!data->GetAsString(&data_str)) |
| 1582 continue; | 1582 continue; |
| 1583 | 1583 |
| 1584 mojom::BluetoothAdvertisingDataPtr service_data_element = | 1584 mojom::BluetoothAdvertisingDataPtr service_data_element = |
| 1585 mojom::BluetoothAdvertisingData::New(); | 1585 mojom::BluetoothAdvertisingData::New(); |
| 1586 mojom::BluetoothServiceDataPtr service_data = | 1586 mojom::BluetoothServiceDataPtr service_data = |
| (...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1679 LOG(WARNING) << "Bluetooth instance is too old (version " << version | 1679 LOG(WARNING) << "Bluetooth instance is too old (version " << version |
| 1680 << ") need version " << version_need; | 1680 << ") need version " << version_need; |
| 1681 return false; | 1681 return false; |
| 1682 } | 1682 } |
| 1683 | 1683 |
| 1684 bool ArcBluetoothBridge::CalledOnValidThread() { | 1684 bool ArcBluetoothBridge::CalledOnValidThread() { |
| 1685 return thread_checker_.CalledOnValidThread(); | 1685 return thread_checker_.CalledOnValidThread(); |
| 1686 } | 1686 } |
| 1687 | 1687 |
| 1688 } // namespace arc | 1688 } // namespace arc |
| OLD | NEW |