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

Side by Side Diff: components/arc/bluetooth/arc_bluetooth_bridge.cc

Issue 2244703005: arc: bluetooth: Fix advertised uuid (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix service dat, fix test, add test Created 4 years, 4 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 unified diff | Download patch
« no previous file with comments | « no previous file | components/arc/bluetooth/arc_bluetooth_bridge_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 1524 matching lines...) Expand 10 before | Expand all | Expand 10 after
1535 mojo::Array<mojom::BluetoothAdvertisingDataPtr> advertising_data; 1535 mojo::Array<mojom::BluetoothAdvertisingDataPtr> advertising_data;
1536 1536
1537 // LocalName 1537 // LocalName
1538 mojom::BluetoothAdvertisingDataPtr local_name = 1538 mojom::BluetoothAdvertisingDataPtr local_name =
1539 mojom::BluetoothAdvertisingData::New(); 1539 mojom::BluetoothAdvertisingData::New();
1540 local_name->set_local_name(device->GetName() ? device->GetName().value() 1540 local_name->set_local_name(device->GetName() ? device->GetName().value()
1541 : nullptr); 1541 : nullptr);
1542 advertising_data.push_back(std::move(local_name)); 1542 advertising_data.push_back(std::move(local_name));
1543 1543
1544 // ServiceUuid 1544 // ServiceUuid
1545 BluetoothDevice::UUIDList uuid_list = device->GetServiceDataUUIDs(); 1545 BluetoothDevice::UUIDList uuid_list = device->GetUUIDs();
Luis Héctor Chávez 2016/08/15 21:23:12 nit: const BluetoothDevice::UUIDList&
Luis Héctor Chávez 2016/08/15 21:25:43 ignore this, I double checked and the code is corr
1546 if (uuid_list.size() > 0) { 1546 if (uuid_list.size() > 0) {
1547 mojom::BluetoothAdvertisingDataPtr service_uuids = 1547 mojom::BluetoothAdvertisingDataPtr service_uuids =
1548 mojom::BluetoothAdvertisingData::New(); 1548 mojom::BluetoothAdvertisingData::New();
1549 service_uuids->set_service_uuids( 1549 service_uuids->set_service_uuids(
1550 mojo::Array<mojom::BluetoothUUIDPtr>::From(uuid_list)); 1550 mojo::Array<mojom::BluetoothUUIDPtr>::From(uuid_list));
1551 advertising_data.push_back(std::move(service_uuids)); 1551 advertising_data.push_back(std::move(service_uuids));
1552 } 1552 }
1553 1553
1554 // Service data 1554 // Service data
1555 for (auto& uuid : uuid_list) { 1555 for (auto& uuid : device->GetServiceDataUUIDs()) {
1556 base::BinaryValue* data = device->GetServiceData(uuid); 1556 base::BinaryValue* data = device->GetServiceData(uuid);
1557 if (data->GetSize() == 0) 1557 if (data->GetSize() == 0)
1558 continue; 1558 continue;
1559 std::string data_str; 1559 std::string data_str;
1560 if (!data->GetAsString(&data_str)) 1560 if (!data->GetAsString(&data_str))
1561 continue; 1561 continue;
1562 1562
1563 mojom::BluetoothAdvertisingDataPtr service_data_element = 1563 mojom::BluetoothAdvertisingDataPtr service_data_element =
1564 mojom::BluetoothAdvertisingData::New(); 1564 mojom::BluetoothAdvertisingData::New();
1565 mojom::BluetoothServiceDataPtr service_data = 1565 mojom::BluetoothServiceDataPtr service_data =
1566 mojom::BluetoothServiceData::New(); 1566 mojom::BluetoothServiceData::New();
1567 1567
1568 std::string uuid_str = uuid.canonical_value(); 1568 std::string uuid_str = uuid.canonical_value();
1569 // Convert xxxxyyyy-xxxx-xxxx-xxxx-xxxxxxxxxxxx to int16 yyyy 1569 // Convert xxxxyyyy-xxxx-xxxx-xxxx-xxxxxxxxxxxx to int16 yyyy
ortuno 2016/08/15 21:27:09 Out of curiosity: Does android really expect only
puthik_chromium 2016/08/15 21:32:15 Unfortunately yes[1]. The advertised service uuid
ortuno 2016/08/15 21:37:33 *sigh* ok
1570 service_data->uuid_16bit = std::stoi(uuid_str.substr(4, 4), nullptr, 16); 1570 service_data->uuid_16bit = std::stoi(uuid_str.substr(4, 4), nullptr, 16);
1571 for (auto& c : data_str) { 1571 for (auto& c : data_str) {
1572 service_data->data.push_back(c); 1572 service_data->data.push_back(c);
1573 } 1573 }
1574 service_data_element->set_service_data(std::move(service_data)); 1574 service_data_element->set_service_data(std::move(service_data));
1575 advertising_data.push_back(std::move(service_data_element)); 1575 advertising_data.push_back(std::move(service_data_element));
1576 } 1576 }
1577 1577
1578 return advertising_data; 1578 return advertising_data;
1579 } 1579 }
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after
1662 LOG(WARNING) << "Bluetooth instance is too old (version " << version 1662 LOG(WARNING) << "Bluetooth instance is too old (version " << version
1663 << ") need version " << version_need; 1663 << ") need version " << version_need;
1664 return false; 1664 return false;
1665 } 1665 }
1666 1666
1667 bool ArcBluetoothBridge::CalledOnValidThread() { 1667 bool ArcBluetoothBridge::CalledOnValidThread() {
1668 return thread_checker_.CalledOnValidThread(); 1668 return thread_checker_.CalledOnValidThread();
1669 } 1669 }
1670 1670
1671 } // namespace arc 1671 } // namespace arc
OLDNEW
« no previous file with comments | « no previous file | components/arc/bluetooth/arc_bluetooth_bridge_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698