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

Unified Diff: components/arc/bluetooth/arc_bluetooth_bridge.cc

Issue 2376873002: arc: bluetooth: Use uuid 128 bit for service uuid (Closed)
Patch Set: fix comment Created 4 years, 2 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | components/arc/bluetooth/arc_bluetooth_bridge_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: components/arc/bluetooth/arc_bluetooth_bridge.cc
diff --git a/components/arc/bluetooth/arc_bluetooth_bridge.cc b/components/arc/bluetooth/arc_bluetooth_bridge.cc
index 3b8cf87ba4cd2e19c14df0cc88ef04ff501e8bc6..79f375d7e19eee765b9887638a04f75fb81827ba 100644
--- a/components/arc/bluetooth/arc_bluetooth_bridge.cc
+++ b/components/arc/bluetooth/arc_bluetooth_bridge.cc
@@ -194,7 +194,8 @@ bool IsGattOffsetValid(int offset) {
return 0 <= offset && offset < kMaxGattAttributeLength;
}
-// This is needed because Android only support UUID 16 bits in advertising data.
+// This is needed because Android only support UUID 16 bits in service data
+// section in advertising data
uint16_t GetUUID16(const BluetoothUUID& uuid) {
// Convert xxxxyyyy-xxxx-xxxx-xxxx-xxxxxxxxxxxx to int16 yyyy
return std::stoi(uuid.canonical_value().substr(4, 4), nullptr, 16);
@@ -1864,8 +1865,8 @@ ArcBluetoothBridge::GetAdapterProperties(
// Android support 5 types of Advertising Data.
// However Chrome didn't expose AdvertiseFlag and ManufacturerData.
// So we will only expose local_name, service_uuids and service_data.
-// Note that we need to use UUID 16 bits because Android does not support
-// UUID 128 bits.
+// Note that we need to use UUID 16 bits in service_data section
+// because Android does not support UUID 128 bits there.
// TODO(crbug.com/618442) Make Chrome expose missing data.
mojo::Array<mojom::BluetoothAdvertisingDataPtr>
ArcBluetoothBridge::GetAdvertisingData(BluetoothDevice* device) const {
@@ -1879,18 +1880,13 @@ ArcBluetoothBridge::GetAdvertisingData(BluetoothDevice* device) const {
advertising_data.push_back(std::move(local_name));
// ServiceUuid
- BluetoothDevice::UUIDSet uuid_set = device->GetUUIDs();
+ const BluetoothDevice::UUIDSet& uuid_set = device->GetUUIDs();
if (uuid_set.size() > 0) {
- mojom::BluetoothAdvertisingDataPtr service_uuids_16 =
+ mojom::BluetoothAdvertisingDataPtr service_uuids =
mojom::BluetoothAdvertisingData::New();
- mojo::Array<uint16_t> uuid16s(uuid_set.size());
- size_t i = 0;
- for (const auto& uuid : uuid_set) {
- uuid16s[i] = GetUUID16(uuid);
- i++;
- }
- service_uuids_16->set_service_uuids_16(std::move(uuid16s));
- advertising_data.push_back(std::move(service_uuids_16));
+ service_uuids->set_service_uuids(mojo::Array<BluetoothUUID>::From(
+ std::vector<BluetoothUUID>(uuid_set.begin(), uuid_set.end())));
+ advertising_data.push_back(std::move(service_uuids));
}
// Service data
@@ -1900,6 +1896,7 @@ ArcBluetoothBridge::GetAdvertisingData(BluetoothDevice* device) const {
mojom::BluetoothServiceDataPtr service_data =
mojom::BluetoothServiceData::New();
+ // Android only supports UUID 16 bit here.
service_data->uuid_16bit = GetUUID16(uuid);
const std::vector<uint8_t>* data = device->GetServiceDataForUUID(uuid);
« 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