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 <bluetooth/bluetooth.h> | 7 #include <bluetooth/bluetooth.h> |
8 #include <fcntl.h> | 8 #include <fcntl.h> |
9 #include <stddef.h> | 9 #include <stddef.h> |
10 #include <sys/socket.h> | 10 #include <sys/socket.h> |
(...skipping 1354 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1365 | 1365 |
1366 mojo::Array<mojom::BluetoothPropertyPtr> | 1366 mojo::Array<mojom::BluetoothPropertyPtr> |
1367 ArcBluetoothBridge::GetDeviceProperties(mojom::BluetoothPropertyType type, | 1367 ArcBluetoothBridge::GetDeviceProperties(mojom::BluetoothPropertyType type, |
1368 BluetoothDevice* device) const { | 1368 BluetoothDevice* device) const { |
1369 mojo::Array<mojom::BluetoothPropertyPtr> properties; | 1369 mojo::Array<mojom::BluetoothPropertyPtr> properties; |
1370 | 1370 |
1371 if (!device) { | 1371 if (!device) { |
1372 return properties; | 1372 return properties; |
1373 } | 1373 } |
1374 | 1374 |
1375 if (type == mojom::BluetoothPropertyType::ALL || | 1375 if ((type == mojom::BluetoothPropertyType::ALL || |
1376 type == mojom::BluetoothPropertyType::BDNAME) { | 1376 type == mojom::BluetoothPropertyType::BDNAME) && |
1377 device->GetName()) { | |
1377 mojom::BluetoothPropertyPtr btp = mojom::BluetoothProperty::New(); | 1378 mojom::BluetoothPropertyPtr btp = mojom::BluetoothProperty::New(); |
1378 // TODO(615720): Use the upcoming GetName (was GetDeviceName). | 1379 btp->set_bdname(mojo::String::From(device->GetName().value())); |
1379 btp->set_bdname( | |
1380 mojo::String::From(base::UTF16ToUTF8(device->GetNameForDisplay()))); | |
1381 properties.push_back(std::move(btp)); | 1380 properties.push_back(std::move(btp)); |
1382 } | 1381 } |
1383 if (type == mojom::BluetoothPropertyType::ALL || | 1382 if (type == mojom::BluetoothPropertyType::ALL || |
1384 type == mojom::BluetoothPropertyType::BDADDR) { | 1383 type == mojom::BluetoothPropertyType::BDADDR) { |
1385 mojom::BluetoothPropertyPtr btp = mojom::BluetoothProperty::New(); | 1384 mojom::BluetoothPropertyPtr btp = mojom::BluetoothProperty::New(); |
1386 btp->set_bdaddr(mojom::BluetoothAddress::From(device->GetAddress())); | 1385 btp->set_bdaddr(mojom::BluetoothAddress::From(device->GetAddress())); |
1387 properties.push_back(std::move(btp)); | 1386 properties.push_back(std::move(btp)); |
1388 } | 1387 } |
1389 if (type == mojom::BluetoothPropertyType::ALL || | 1388 if (type == mojom::BluetoothPropertyType::ALL || |
1390 type == mojom::BluetoothPropertyType::UUIDS) { | 1389 type == mojom::BluetoothPropertyType::UUIDS) { |
(...skipping 17 matching lines...) Expand all Loading... | |
1408 } | 1407 } |
1409 if (type == mojom::BluetoothPropertyType::ALL || | 1408 if (type == mojom::BluetoothPropertyType::ALL || |
1410 type == mojom::BluetoothPropertyType::TYPE_OF_DEVICE) { | 1409 type == mojom::BluetoothPropertyType::TYPE_OF_DEVICE) { |
1411 mojom::BluetoothPropertyPtr btp = mojom::BluetoothProperty::New(); | 1410 mojom::BluetoothPropertyPtr btp = mojom::BluetoothProperty::New(); |
1412 btp->set_device_type(device->GetType()); | 1411 btp->set_device_type(device->GetType()); |
1413 properties.push_back(std::move(btp)); | 1412 properties.push_back(std::move(btp)); |
1414 } | 1413 } |
1415 if (type == mojom::BluetoothPropertyType::ALL || | 1414 if (type == mojom::BluetoothPropertyType::ALL || |
1416 type == mojom::BluetoothPropertyType::REMOTE_FRIENDLY_NAME) { | 1415 type == mojom::BluetoothPropertyType::REMOTE_FRIENDLY_NAME) { |
1417 mojom::BluetoothPropertyPtr btp = mojom::BluetoothProperty::New(); | 1416 mojom::BluetoothPropertyPtr btp = mojom::BluetoothProperty::New(); |
1418 // TODO(615720): Use the upcoming GetName (was GetDeviceName). | |
1419 btp->set_remote_friendly_name( | 1417 btp->set_remote_friendly_name( |
1420 mojo::String::From(base::UTF16ToUTF8(device->GetNameForDisplay()))); | 1418 mojo::String::From(base::UTF16ToUTF8(device->GetNameForDisplay()))); |
1421 properties.push_back(std::move(btp)); | 1419 properties.push_back(std::move(btp)); |
1422 } | 1420 } |
1423 if (type == mojom::BluetoothPropertyType::ALL || | 1421 if (type == mojom::BluetoothPropertyType::ALL || |
1424 type == mojom::BluetoothPropertyType::REMOTE_RSSI) { | 1422 type == mojom::BluetoothPropertyType::REMOTE_RSSI) { |
1425 mojom::BluetoothPropertyPtr btp = mojom::BluetoothProperty::New(); | 1423 mojom::BluetoothPropertyPtr btp = mojom::BluetoothProperty::New(); |
1426 btp->set_remote_rssi(device->GetInquiryRSSI()); | 1424 btp->set_remote_rssi(device->GetInquiryRSSI()); |
1427 properties.push_back(std::move(btp)); | 1425 properties.push_back(std::move(btp)); |
1428 } | 1426 } |
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1513 // However Chrome didn't expose AdvertiseFlag and ManufacturerData. | 1511 // However Chrome didn't expose AdvertiseFlag and ManufacturerData. |
1514 // So we will only expose local_name, service_uuids and service_data. | 1512 // So we will only expose local_name, service_uuids and service_data. |
1515 // TODO(crbug.com/618442) Make Chrome expose missing data. | 1513 // TODO(crbug.com/618442) Make Chrome expose missing data. |
1516 mojo::Array<mojom::BluetoothAdvertisingDataPtr> | 1514 mojo::Array<mojom::BluetoothAdvertisingDataPtr> |
1517 ArcBluetoothBridge::GetAdvertisingData(BluetoothDevice* device) const { | 1515 ArcBluetoothBridge::GetAdvertisingData(BluetoothDevice* device) const { |
1518 mojo::Array<mojom::BluetoothAdvertisingDataPtr> advertising_data; | 1516 mojo::Array<mojom::BluetoothAdvertisingDataPtr> advertising_data; |
1519 | 1517 |
1520 // LocalName | 1518 // LocalName |
1521 mojom::BluetoothAdvertisingDataPtr local_name = | 1519 mojom::BluetoothAdvertisingDataPtr local_name = |
1522 mojom::BluetoothAdvertisingData::New(); | 1520 mojom::BluetoothAdvertisingData::New(); |
1523 local_name->set_local_name(base::UTF16ToUTF8(device->GetNameForDisplay())); | 1521 local_name->set_local_name(base::UTF16ToUTF8(device->GetNameForDisplay())); |
puthik_chromium
2016/08/02 20:12:55
We need to change here too if we want to use GetNa
| |
1524 advertising_data.push_back(std::move(local_name)); | 1522 advertising_data.push_back(std::move(local_name)); |
1525 | 1523 |
1526 // ServiceUuid | 1524 // ServiceUuid |
1527 BluetoothDevice::UUIDList uuid_list = device->GetServiceDataUUIDs(); | 1525 BluetoothDevice::UUIDList uuid_list = device->GetServiceDataUUIDs(); |
1528 if (uuid_list.size() > 0) { | 1526 if (uuid_list.size() > 0) { |
1529 mojom::BluetoothAdvertisingDataPtr service_uuids = | 1527 mojom::BluetoothAdvertisingDataPtr service_uuids = |
1530 mojom::BluetoothAdvertisingData::New(); | 1528 mojom::BluetoothAdvertisingData::New(); |
1531 service_uuids->set_service_uuids( | 1529 service_uuids->set_service_uuids( |
1532 mojo::Array<mojom::BluetoothUUIDPtr>::From(uuid_list)); | 1530 mojo::Array<mojom::BluetoothUUIDPtr>::From(uuid_list)); |
1533 advertising_data.push_back(std::move(service_uuids)); | 1531 advertising_data.push_back(std::move(service_uuids)); |
(...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1642 LOG(WARNING) << "Bluetooth instance is too old (version " << version | 1640 LOG(WARNING) << "Bluetooth instance is too old (version " << version |
1643 << ") need version " << version_need; | 1641 << ") need version " << version_need; |
1644 return false; | 1642 return false; |
1645 } | 1643 } |
1646 | 1644 |
1647 bool ArcBluetoothBridge::CalledOnValidThread() { | 1645 bool ArcBluetoothBridge::CalledOnValidThread() { |
1648 return thread_checker_.CalledOnValidThread(); | 1646 return thread_checker_.CalledOnValidThread(); |
1649 } | 1647 } |
1650 | 1648 |
1651 } // namespace arc | 1649 } // namespace arc |
OLD | NEW |