Chromium Code Reviews| 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 d3f91bd5e1e654d25c9ad0441df62098acc3c5fa..22145a3058c1e2e5b613a6ed9f793d26693dc4db 100644 |
| --- a/components/arc/bluetooth/arc_bluetooth_bridge.cc |
| +++ b/components/arc/bluetooth/arc_bluetooth_bridge.cc |
| @@ -173,6 +173,11 @@ bool IsGattOffsetValid(int offset) { |
| return 0 <= offset && offset < kMaxGattAttributeLength; |
| } |
| +uint16_t GetUUID16(const BluetoothUUID& uuid) { |
|
rickyz (no longer on Chrome)
2016/08/17 00:35:59
Let's add a comment explaining why we send a uuid1
puthik_chromium
2016/08/17 00:45:50
Comment added.
|
| + // Convert xxxxyyyy-xxxx-xxxx-xxxx-xxxxxxxxxxxx to int16 yyyy |
| + return std::stoi(uuid.canonical_value().substr(4, 4), nullptr, 16); |
| +} |
| + |
| } // namespace |
| namespace arc { |
| @@ -1544,11 +1549,14 @@ ArcBluetoothBridge::GetAdvertisingData(BluetoothDevice* device) const { |
| // ServiceUuid |
| BluetoothDevice::UUIDList uuid_list = device->GetUUIDs(); |
| if (uuid_list.size() > 0) { |
| - mojom::BluetoothAdvertisingDataPtr service_uuids = |
| + mojom::BluetoothAdvertisingDataPtr service_uuids_16 = |
| mojom::BluetoothAdvertisingData::New(); |
| - service_uuids->set_service_uuids( |
| - mojo::Array<mojom::BluetoothUUIDPtr>::From(uuid_list)); |
| - advertising_data.push_back(std::move(service_uuids)); |
| + mojo::Array<uint16_t> uuid16s; |
| + for (auto& uuid : uuid_list) { |
| + uuid16s.push_back(GetUUID16(uuid)); |
| + } |
| + service_uuids_16->set_service_uuids_16(std::move(uuid16s)); |
| + advertising_data.push_back(std::move(service_uuids_16)); |
| } |
| // Service data |
| @@ -1565,9 +1573,7 @@ ArcBluetoothBridge::GetAdvertisingData(BluetoothDevice* device) const { |
| mojom::BluetoothServiceDataPtr service_data = |
| mojom::BluetoothServiceData::New(); |
| - std::string uuid_str = uuid.canonical_value(); |
| - // Convert xxxxyyyy-xxxx-xxxx-xxxx-xxxxxxxxxxxx to int16 yyyy |
| - service_data->uuid_16bit = std::stoi(uuid_str.substr(4, 4), nullptr, 16); |
| + service_data->uuid_16bit = GetUUID16(uuid); |
| for (auto& c : data_str) { |
| service_data->data.push_back(c); |
| } |