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

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

Issue 2511253002: arc: bluetooth: enable use_new_wrapper_types for bluetooth.mojom (Closed)
Patch Set: Rebase again Created 4 years, 1 month 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
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 134 matching lines...) Expand 10 before | Expand all | Expand 10 after
145 BluetoothGattService::GattErrorCode error_code) { 145 BluetoothGattService::GattErrorCode error_code) {
146 callback.Run(mojo::ConvertTo<arc::mojom::BluetoothGattStatus>(error_code)); 146 callback.Run(mojo::ConvertTo<arc::mojom::BluetoothGattStatus>(error_code));
147 } 147 }
148 148
149 // Common success callback for ReadGattCharacteristic and ReadGattDescriptor 149 // Common success callback for ReadGattCharacteristic and ReadGattDescriptor
150 void OnGattReadDone(const GattReadCallback& callback, 150 void OnGattReadDone(const GattReadCallback& callback,
151 const std::vector<uint8_t>& result) { 151 const std::vector<uint8_t>& result) {
152 arc::mojom::BluetoothGattValuePtr gattValue = 152 arc::mojom::BluetoothGattValuePtr gattValue =
153 arc::mojom::BluetoothGattValue::New(); 153 arc::mojom::BluetoothGattValue::New();
154 gattValue->status = arc::mojom::BluetoothGattStatus::GATT_SUCCESS; 154 gattValue->status = arc::mojom::BluetoothGattStatus::GATT_SUCCESS;
155 gattValue->value = mojo::Array<uint8_t>::From(result); 155 gattValue->value = result;
156 callback.Run(std::move(gattValue)); 156 callback.Run(std::move(gattValue));
157 } 157 }
158 158
159 // Common error callback for ReadGattCharacteristic and ReadGattDescriptor 159 // Common error callback for ReadGattCharacteristic and ReadGattDescriptor
160 void OnGattReadError(const GattReadCallback& callback, 160 void OnGattReadError(const GattReadCallback& callback,
161 BluetoothGattService::GattErrorCode error_code) { 161 BluetoothGattService::GattErrorCode error_code) {
162 arc::mojom::BluetoothGattValuePtr gattValue = 162 arc::mojom::BluetoothGattValuePtr gattValue =
163 arc::mojom::BluetoothGattValue::New(); 163 arc::mojom::BluetoothGattValue::New();
164 gattValue->status = 164 gattValue->status =
165 mojo::ConvertTo<arc::mojom::BluetoothGattStatus>(error_code); 165 mojo::ConvertTo<arc::mojom::BluetoothGattStatus>(error_code);
166 gattValue->value = nullptr;
167 callback.Run(std::move(gattValue)); 166 callback.Run(std::move(gattValue));
168 } 167 }
169 168
170 // Callback function for mojom::BluetoothInstance::RequestGattRead 169 // Callback function for mojom::BluetoothInstance::RequestGattRead
171 void OnGattServerRead( 170 void OnGattServerRead(
172 const BluetoothLocalGattService::Delegate::ValueCallback& success_callback, 171 const BluetoothLocalGattService::Delegate::ValueCallback& success_callback,
173 const BluetoothLocalGattService::Delegate::ErrorCallback& error_callback, 172 const BluetoothLocalGattService::Delegate::ErrorCallback& error_callback,
174 arc::mojom::BluetoothGattStatus status, 173 arc::mojom::BluetoothGattStatus status,
175 mojo::Array<uint8_t> value) { 174 const std::vector<uint8_t>& value) {
176 if (status == arc::mojom::BluetoothGattStatus::GATT_SUCCESS) 175 if (status == arc::mojom::BluetoothGattStatus::GATT_SUCCESS)
177 success_callback.Run(value.To<std::vector<uint8_t>>()); 176 success_callback.Run(value);
178 else 177 else
179 error_callback.Run(); 178 error_callback.Run();
180 } 179 }
181 180
182 // Callback function for mojom::BluetoothInstance::RequestGattWrite 181 // Callback function for mojom::BluetoothInstance::RequestGattWrite
183 void OnGattServerWrite( 182 void OnGattServerWrite(
184 const base::Closure& success_callback, 183 const base::Closure& success_callback,
185 const BluetoothLocalGattService::Delegate::ErrorCallback& error_callback, 184 const BluetoothLocalGattService::Delegate::ErrorCallback& error_callback,
186 arc::mojom::BluetoothGattStatus status) { 185 arc::mojom::BluetoothGattStatus status) {
187 if (status == arc::mojom::BluetoothGattStatus::GATT_SUCCESS) 186 if (status == arc::mojom::BluetoothGattStatus::GATT_SUCCESS)
(...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after
311 if (bluetooth_adapter_) 310 if (bluetooth_adapter_)
312 bluetooth_adapter_->RemoveObserver(this); 311 bluetooth_adapter_->RemoveObserver(this);
313 } 312 }
314 313
315 void ArcBluetoothBridge::SendDevice(const BluetoothDevice* device) const { 314 void ArcBluetoothBridge::SendDevice(const BluetoothDevice* device) const {
316 auto* bluetooth_instance = 315 auto* bluetooth_instance =
317 arc_bridge_service()->bluetooth()->GetInstanceForMethod("OnDeviceFound"); 316 arc_bridge_service()->bluetooth()->GetInstanceForMethod("OnDeviceFound");
318 if (!bluetooth_instance) 317 if (!bluetooth_instance)
319 return; 318 return;
320 319
321 mojo::Array<mojom::BluetoothPropertyPtr> properties = 320 std::vector<mojom::BluetoothPropertyPtr> properties =
322 GetDeviceProperties(mojom::BluetoothPropertyType::ALL, device); 321 GetDeviceProperties(mojom::BluetoothPropertyType::ALL, device);
323 322
324 bluetooth_instance->OnDeviceFound(std::move(properties)); 323 bluetooth_instance->OnDeviceFound(std::move(properties));
325 324
326 325
327 if (!(device->GetType() & device::BLUETOOTH_TRANSPORT_LE)) 326 if (!(device->GetType() & device::BLUETOOTH_TRANSPORT_LE))
328 return; 327 return;
329 328
330 base::Optional<int8_t> rssi = device->GetInquiryRSSI(); 329 base::Optional<int8_t> rssi = device->GetInquiryRSSI();
331 mojom::BluetoothAddressPtr addr; 330 mojom::BluetoothAddressPtr addr;
332 331
333 // We only want to send updated advertise data to Android only when we are 332 // We only want to send updated advertise data to Android only when we are
334 // scanning which is checked by the validity of rssi. Here are the 2 cases 333 // scanning which is checked by the validity of rssi. Here are the 2 cases
335 // that we don't want to send updated advertise data to Android. 334 // that we don't want to send updated advertise data to Android.
336 // 1) Cached found device and 2) rssi became invalid when we stop scanning. 335 // 1) Cached found device and 2) rssi became invalid when we stop scanning.
337 if (rssi.has_value()) { 336 if (rssi.has_value()) {
338 auto* btle_instance = 337 auto* btle_instance =
339 arc_bridge_service()->bluetooth()->GetInstanceForMethod( 338 arc_bridge_service()->bluetooth()->GetInstanceForMethod(
340 "OnLEDeviceFound", kMinBtleVersion); 339 "OnLEDeviceFound", kMinBtleVersion);
341 if (!btle_instance) 340 if (!btle_instance)
342 return; 341 return;
343 mojo::Array<mojom::BluetoothAdvertisingDataPtr> adv_data = 342 std::vector<mojom::BluetoothAdvertisingDataPtr> adv_data =
344 GetAdvertisingData(device); 343 GetAdvertisingData(device);
345 addr = mojom::BluetoothAddress::From(device->GetAddress()); 344 addr = mojom::BluetoothAddress::From(device->GetAddress());
346 btle_instance->OnLEDeviceFound(std::move(addr), rssi.value(), 345 btle_instance->OnLEDeviceFound(std::move(addr), rssi.value(),
347 std::move(adv_data)); 346 std::move(adv_data));
348 } 347 }
349 348
350 if (!device->IsConnected()) 349 if (!device->IsConnected())
351 return; 350 return;
352 351
353 addr = mojom::BluetoothAddress::From(device->GetAddress()); 352 addr = mojom::BluetoothAddress::From(device->GetAddress());
(...skipping 178 matching lines...) Expand 10 before | Expand all | Expand 10 after
532 service_id->is_primary = service->IsPrimary(); 531 service_id->is_primary = service->IsPrimary();
533 service_id->id = mojom::BluetoothGattID::New(); 532 service_id->id = mojom::BluetoothGattID::New();
534 service_id->id->inst_id = ConvertGattIdentifierToId(service->GetIdentifier()); 533 service_id->id->inst_id = ConvertGattIdentifierToId(service->GetIdentifier());
535 service_id->id->uuid = service->GetUUID(); 534 service_id->id->uuid = service->GetUUID();
536 535
537 mojom::BluetoothGattIDPtr char_id = mojom::BluetoothGattID::New(); 536 mojom::BluetoothGattIDPtr char_id = mojom::BluetoothGattID::New();
538 char_id->inst_id = ConvertGattIdentifierToId(characteristic->GetIdentifier()); 537 char_id->inst_id = ConvertGattIdentifierToId(characteristic->GetIdentifier());
539 char_id->uuid = characteristic->GetUUID(); 538 char_id->uuid = characteristic->GetUUID();
540 539
541 btle_instance->OnGattNotify(std::move(address), std::move(service_id), 540 btle_instance->OnGattNotify(std::move(address), std::move(service_id),
542 std::move(char_id), true /* is_notify */, 541 std::move(char_id), true /* is_notify */, value);
543 mojo::Array<uint8_t>::From(value));
544 } 542 }
545 543
546 void ArcBluetoothBridge::GattDescriptorValueChanged( 544 void ArcBluetoothBridge::GattDescriptorValueChanged(
547 BluetoothAdapter* adapter, 545 BluetoothAdapter* adapter,
548 BluetoothRemoteGattDescriptor* descriptor, 546 BluetoothRemoteGattDescriptor* descriptor,
549 const std::vector<uint8_t>& value) { 547 const std::vector<uint8_t>& value) {
550 // Placeholder for GATT client functionality 548 // Placeholder for GATT client functionality
551 } 549 }
552 550
553 template <class LocalGattAttribute> 551 template <class LocalGattAttribute>
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
588 "RequestGattWrite", kMinGattServerVersion); 586 "RequestGattWrite", kMinGattServerVersion);
589 if (!bluetooth_instance || !IsGattOffsetValid(offset)) { 587 if (!bluetooth_instance || !IsGattOffsetValid(offset)) {
590 error_callback.Run(); 588 error_callback.Run();
591 return; 589 return;
592 } 590 }
593 591
594 DCHECK(gatt_handle_.find(attribute->GetIdentifier()) != gatt_handle_.end()); 592 DCHECK(gatt_handle_.find(attribute->GetIdentifier()) != gatt_handle_.end());
595 593
596 bluetooth_instance->RequestGattWrite( 594 bluetooth_instance->RequestGattWrite(
597 mojom::BluetoothAddress::From(device->GetAddress()), 595 mojom::BluetoothAddress::From(device->GetAddress()),
598 gatt_handle_[attribute->GetIdentifier()], offset, 596 gatt_handle_[attribute->GetIdentifier()], offset, value,
599 mojo::Array<uint8_t>::From(value),
600 base::Bind(&OnGattServerWrite, success_callback, error_callback)); 597 base::Bind(&OnGattServerWrite, success_callback, error_callback));
601 } 598 }
602 599
603 void ArcBluetoothBridge::OnCharacteristicReadRequest( 600 void ArcBluetoothBridge::OnCharacteristicReadRequest(
604 const BluetoothDevice* device, 601 const BluetoothDevice* device,
605 const BluetoothLocalGattCharacteristic* characteristic, 602 const BluetoothLocalGattCharacteristic* characteristic,
606 int offset, 603 int offset,
607 const ValueCallback& callback, 604 const ValueCallback& callback,
608 const ErrorCallback& error_callback) { 605 const ErrorCallback& error_callback) {
609 OnGattAttributeReadRequest(device, characteristic, offset, callback, 606 OnGattAttributeReadRequest(device, characteristic, offset, callback,
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after
675 } 672 }
676 673
677 void ArcBluetoothBridge::GetAdapterProperty(mojom::BluetoothPropertyType type) { 674 void ArcBluetoothBridge::GetAdapterProperty(mojom::BluetoothPropertyType type) {
678 DCHECK(bluetooth_adapter_); 675 DCHECK(bluetooth_adapter_);
679 auto* bluetooth_instance = 676 auto* bluetooth_instance =
680 arc_bridge_service()->bluetooth()->GetInstanceForMethod( 677 arc_bridge_service()->bluetooth()->GetInstanceForMethod(
681 "OnAdapterProperties"); 678 "OnAdapterProperties");
682 if (!bluetooth_instance) 679 if (!bluetooth_instance)
683 return; 680 return;
684 681
685 mojo::Array<mojom::BluetoothPropertyPtr> properties = 682 std::vector<mojom::BluetoothPropertyPtr> properties =
686 GetAdapterProperties(type); 683 GetAdapterProperties(type);
687 684
688 bluetooth_instance->OnAdapterProperties(mojom::BluetoothStatus::SUCCESS, 685 bluetooth_instance->OnAdapterProperties(mojom::BluetoothStatus::SUCCESS,
689 std::move(properties)); 686 std::move(properties));
690 } 687 }
691 688
692 void ArcBluetoothBridge::OnSetDiscoverable(bool discoverable, 689 void ArcBluetoothBridge::OnSetDiscoverable(bool discoverable,
693 bool success, 690 bool success,
694 uint32_t timeout) { 691 uint32_t timeout) {
695 DCHECK(CalledOnValidThread()); 692 DCHECK(CalledOnValidThread());
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
740 } 737 }
741 738
742 void ArcBluetoothBridge::OnSetAdapterProperty( 739 void ArcBluetoothBridge::OnSetAdapterProperty(
743 mojom::BluetoothStatus status, 740 mojom::BluetoothStatus status,
744 mojom::BluetoothPropertyPtr property) { 741 mojom::BluetoothPropertyPtr property) {
745 auto* bluetooth_instance = 742 auto* bluetooth_instance =
746 arc_bridge_service()->bluetooth()->GetInstanceForMethod( 743 arc_bridge_service()->bluetooth()->GetInstanceForMethod(
747 "OnAdapterProperties"); 744 "OnAdapterProperties");
748 DCHECK(bluetooth_instance); 745 DCHECK(bluetooth_instance);
749 746
750 auto properties = mojo::Array<arc::mojom::BluetoothPropertyPtr>::New(0); 747 std::vector<arc::mojom::BluetoothPropertyPtr> properties;
751 properties.push_back(std::move(property)); 748 properties.push_back(std::move(property));
752 749
753 bluetooth_instance->OnAdapterProperties(status, std::move(properties)); 750 bluetooth_instance->OnAdapterProperties(status, std::move(properties));
754 } 751 }
755 752
756 void ArcBluetoothBridge::SetAdapterProperty( 753 void ArcBluetoothBridge::SetAdapterProperty(
757 mojom::BluetoothPropertyPtr property) { 754 mojom::BluetoothPropertyPtr property) {
758 DCHECK(bluetooth_adapter_); 755 DCHECK(bluetooth_adapter_);
759 756
760 if (property->is_discovery_timeout()) { 757 if (property->is_discovery_timeout()) {
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
798 DCHECK(bluetooth_adapter_); 795 DCHECK(bluetooth_adapter_);
799 auto* bluetooth_instance = 796 auto* bluetooth_instance =
800 arc_bridge_service()->bluetooth()->GetInstanceForMethod( 797 arc_bridge_service()->bluetooth()->GetInstanceForMethod(
801 "OnRemoteDeviceProperties"); 798 "OnRemoteDeviceProperties");
802 if (!bluetooth_instance) 799 if (!bluetooth_instance)
803 return; 800 return;
804 801
805 std::string addr_str = remote_addr->To<std::string>(); 802 std::string addr_str = remote_addr->To<std::string>();
806 BluetoothDevice* device = bluetooth_adapter_->GetDevice(addr_str); 803 BluetoothDevice* device = bluetooth_adapter_->GetDevice(addr_str);
807 804
808 mojo::Array<mojom::BluetoothPropertyPtr> properties = 805 std::vector<mojom::BluetoothPropertyPtr> properties =
809 GetDeviceProperties(type, device); 806 GetDeviceProperties(type, device);
810 mojom::BluetoothStatus status = mojom::BluetoothStatus::SUCCESS; 807 mojom::BluetoothStatus status = mojom::BluetoothStatus::SUCCESS;
811 808
812 if (!device) { 809 if (!device) {
813 VLOG(1) << __func__ << ": device " << addr_str << " not available"; 810 VLOG(1) << __func__ << ": device " << addr_str << " not available";
814 status = mojom::BluetoothStatus::FAIL; 811 status = mojom::BluetoothStatus::FAIL;
815 } 812 }
816 813
817 bluetooth_instance->OnRemoteDeviceProperties(status, std::move(remote_addr), 814 bluetooth_instance->OnRemoteDeviceProperties(status, std::move(remote_addr),
818 std::move(properties)); 815 std::move(properties));
819 } 816 }
820 817
821 void ArcBluetoothBridge::SetRemoteDeviceProperty( 818 void ArcBluetoothBridge::SetRemoteDeviceProperty(
822 mojom::BluetoothAddressPtr remote_addr, 819 mojom::BluetoothAddressPtr remote_addr,
823 mojom::BluetoothPropertyPtr property) { 820 mojom::BluetoothPropertyPtr property) {
824 DCHECK(bluetooth_adapter_); 821 DCHECK(bluetooth_adapter_);
825 auto* bluetooth_instance = 822 auto* bluetooth_instance =
826 arc_bridge_service()->bluetooth()->GetInstanceForMethod( 823 arc_bridge_service()->bluetooth()->GetInstanceForMethod(
827 "OnRemoteDeviceProperties"); 824 "OnRemoteDeviceProperties");
828 if (!bluetooth_instance) 825 if (!bluetooth_instance)
829 return; 826 return;
830 827
831 // Unsupported. Only used by Android hidden API, BluetoothDevice.SetAlias(). 828 // Unsupported. Only used by Android hidden API, BluetoothDevice.SetAlias().
832 // And only Android Settings App / Android TV / NFC used that. 829 // And only Android Settings App / Android TV / NFC used that.
833 bluetooth_instance->OnRemoteDeviceProperties( 830 bluetooth_instance->OnRemoteDeviceProperties(
834 mojom::BluetoothStatus::UNSUPPORTED, std::move(remote_addr), 831 mojom::BluetoothStatus::UNSUPPORTED, std::move(remote_addr),
835 mojo::Array<mojom::BluetoothPropertyPtr>::New(0)); 832 std::vector<mojom::BluetoothPropertyPtr>());
836 } 833 }
837 834
838 void ArcBluetoothBridge::GetRemoteServiceRecord( 835 void ArcBluetoothBridge::GetRemoteServiceRecord(
839 mojom::BluetoothAddressPtr remote_addr, 836 mojom::BluetoothAddressPtr remote_addr,
840 const BluetoothUUID& uuid) { 837 const BluetoothUUID& uuid) {
841 // TODO(smbarber): Implement GetRemoteServiceRecord 838 // TODO(smbarber): Implement GetRemoteServiceRecord
842 } 839 }
843 840
844 void ArcBluetoothBridge::GetRemoteServices( 841 void ArcBluetoothBridge::GetRemoteServices(
845 mojom::BluetoothAddressPtr remote_addr) { 842 mojom::BluetoothAddressPtr remote_addr) {
(...skipping 363 matching lines...) Expand 10 before | Expand all | Expand 10 after
1209 1206
1210 void ArcBluetoothBridge::GetGattDB(mojom::BluetoothAddressPtr remote_addr) { 1207 void ArcBluetoothBridge::GetGattDB(mojom::BluetoothAddressPtr remote_addr) {
1211 auto* bluetooth_instance = 1208 auto* bluetooth_instance =
1212 arc_bridge_service()->bluetooth()->GetInstanceForMethod("OnGetGattDB", 1209 arc_bridge_service()->bluetooth()->GetInstanceForMethod("OnGetGattDB",
1213 kMinBtleVersion); 1210 kMinBtleVersion);
1214 if (!bluetooth_instance) 1211 if (!bluetooth_instance)
1215 return; 1212 return;
1216 1213
1217 BluetoothDevice* device = 1214 BluetoothDevice* device =
1218 bluetooth_adapter_->GetDevice(remote_addr->To<std::string>()); 1215 bluetooth_adapter_->GetDevice(remote_addr->To<std::string>());
1219 mojo::Array<mojom::BluetoothGattDBElementPtr> db; 1216 std::vector<mojom::BluetoothGattDBElementPtr> db;
1220 for (auto* service : device->GetGattServices()) { 1217 for (auto* service : device->GetGattServices()) {
1221 mojom::BluetoothGattDBElementPtr service_element = CreateGattDBElement( 1218 mojom::BluetoothGattDBElementPtr service_element = CreateGattDBElement(
1222 service->IsPrimary() 1219 service->IsPrimary()
1223 ? mojom::BluetoothGattDBAttributeType::BTGATT_DB_PRIMARY_SERVICE 1220 ? mojom::BluetoothGattDBAttributeType::BTGATT_DB_PRIMARY_SERVICE
1224 : mojom::BluetoothGattDBAttributeType::BTGATT_DB_SECONDARY_SERVICE, 1221 : mojom::BluetoothGattDBAttributeType::BTGATT_DB_SECONDARY_SERVICE,
1225 service); 1222 service);
1226 1223
1227 const auto& characteristics = service->GetCharacteristics(); 1224 const auto& characteristics = service->GetCharacteristics();
1228 if (characteristics.size() > 0) { 1225 if (characteristics.size() > 0) {
1229 const auto& descriptors = characteristics.back()->GetDescriptors(); 1226 const auto& descriptors = characteristics.back()->GetDescriptors();
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after
1309 mojom::BluetoothGattServiceIDPtr service_id, 1306 mojom::BluetoothGattServiceIDPtr service_id,
1310 mojom::BluetoothGattIDPtr char_id, 1307 mojom::BluetoothGattIDPtr char_id,
1311 mojom::BluetoothGattValuePtr value, 1308 mojom::BluetoothGattValuePtr value,
1312 const WriteGattCharacteristicCallback& callback) { 1309 const WriteGattCharacteristicCallback& callback) {
1313 BluetoothRemoteGattCharacteristic* characteristic = FindGattCharacteristic( 1310 BluetoothRemoteGattCharacteristic* characteristic = FindGattCharacteristic(
1314 std::move(remote_addr), std::move(service_id), std::move(char_id)); 1311 std::move(remote_addr), std::move(service_id), std::move(char_id));
1315 DCHECK(characteristic); 1312 DCHECK(characteristic);
1316 DCHECK(characteristic->GetPermissions() & kGattWritePermission); 1313 DCHECK(characteristic->GetPermissions() & kGattWritePermission);
1317 1314
1318 characteristic->WriteRemoteCharacteristic( 1315 characteristic->WriteRemoteCharacteristic(
1319 value->value.To<std::vector<uint8_t>>(), 1316 value->value, base::Bind(&OnGattOperationDone, callback),
1320 base::Bind(&OnGattOperationDone, callback),
1321 base::Bind(&OnGattOperationError, callback)); 1317 base::Bind(&OnGattOperationError, callback));
1322 } 1318 }
1323 1319
1324 void ArcBluetoothBridge::ReadGattDescriptor( 1320 void ArcBluetoothBridge::ReadGattDescriptor(
1325 mojom::BluetoothAddressPtr remote_addr, 1321 mojom::BluetoothAddressPtr remote_addr,
1326 mojom::BluetoothGattServiceIDPtr service_id, 1322 mojom::BluetoothGattServiceIDPtr service_id,
1327 mojom::BluetoothGattIDPtr char_id, 1323 mojom::BluetoothGattIDPtr char_id,
1328 mojom::BluetoothGattIDPtr desc_id, 1324 mojom::BluetoothGattIDPtr desc_id,
1329 const ReadGattDescriptorCallback& callback) { 1325 const ReadGattDescriptorCallback& callback) {
1330 BluetoothRemoteGattDescriptor* descriptor = 1326 BluetoothRemoteGattDescriptor* descriptor =
(...skipping 26 matching lines...) Expand all
1357 // directly to the CCC Descriptor. Therefore, until we fix 1353 // directly to the CCC Descriptor. Therefore, until we fix
1358 // https://crbug.com/622832, we return successfully when we encounter this. 1354 // https://crbug.com/622832, we return successfully when we encounter this.
1359 // TODO(http://crbug.com/622832) 1355 // TODO(http://crbug.com/622832)
1360 if (descriptor->GetUUID() == 1356 if (descriptor->GetUUID() ==
1361 BluetoothGattDescriptor::ClientCharacteristicConfigurationUuid()) { 1357 BluetoothGattDescriptor::ClientCharacteristicConfigurationUuid()) {
1362 OnGattOperationDone(callback); 1358 OnGattOperationDone(callback);
1363 return; 1359 return;
1364 } 1360 }
1365 1361
1366 descriptor->WriteRemoteDescriptor( 1362 descriptor->WriteRemoteDescriptor(
1367 value->value.To<std::vector<uint8_t>>(), 1363 value->value, base::Bind(&OnGattOperationDone, callback),
1368 base::Bind(&OnGattOperationDone, callback),
1369 base::Bind(&OnGattOperationError, callback)); 1364 base::Bind(&OnGattOperationError, callback));
1370 } 1365 }
1371 1366
1372 void ArcBluetoothBridge::OnGattNotifyStartDone( 1367 void ArcBluetoothBridge::OnGattNotifyStartDone(
1373 const RegisterForGattNotificationCallback& callback, 1368 const RegisterForGattNotificationCallback& callback,
1374 const std::string char_string_id, 1369 const std::string char_string_id,
1375 std::unique_ptr<BluetoothGattNotifySession> notify_session) { 1370 std::unique_ptr<BluetoothGattNotifySession> notify_session) {
1376 DCHECK(CalledOnValidThread()); 1371 DCHECK(CalledOnValidThread());
1377 notification_session_[char_string_id] = std::move(notify_session); 1372 notification_session_[char_string_id] = std::move(notify_session);
1378 callback.Run(mojom::BluetoothGattStatus::GATT_SUCCESS); 1373 callback.Run(mojom::BluetoothGattStatus::GATT_SUCCESS);
(...skipping 209 matching lines...) Expand 10 before | Expand all | Expand 10 after
1588 gatt_identifier_.erase(service_handle); 1583 gatt_identifier_.erase(service_handle);
1589 gatt_handle_.erase(service->GetIdentifier()); 1584 gatt_handle_.erase(service->GetIdentifier());
1590 service->Delete(); 1585 service->Delete();
1591 OnGattOperationDone(callback); 1586 OnGattOperationDone(callback);
1592 } 1587 }
1593 1588
1594 void ArcBluetoothBridge::SendIndication( 1589 void ArcBluetoothBridge::SendIndication(
1595 int32_t attribute_handle, 1590 int32_t attribute_handle,
1596 mojom::BluetoothAddressPtr address, 1591 mojom::BluetoothAddressPtr address,
1597 bool confirm, 1592 bool confirm,
1598 mojo::Array<uint8_t> value, 1593 const std::vector<uint8_t>& value,
1599 const SendIndicationCallback& callback) {} 1594 const SendIndicationCallback& callback) {}
1600 1595
1601 void ArcBluetoothBridge::GetSdpRecords(mojom::BluetoothAddressPtr remote_addr, 1596 void ArcBluetoothBridge::GetSdpRecords(mojom::BluetoothAddressPtr remote_addr,
1602 const BluetoothUUID& target_uuid) { 1597 const BluetoothUUID& target_uuid) {
1603 BluetoothDevice* device = 1598 BluetoothDevice* device =
1604 bluetooth_adapter_->GetDevice(remote_addr->To<std::string>()); 1599 bluetooth_adapter_->GetDevice(remote_addr->To<std::string>());
1605 1600
1606 bluez::BluetoothDeviceBlueZ* device_bluez = 1601 bluez::BluetoothDeviceBlueZ* device_bluez =
1607 static_cast<bluez::BluetoothDeviceBlueZ*>(device); 1602 static_cast<bluez::BluetoothDeviceBlueZ*>(device);
1608 1603
(...skipping 228 matching lines...) Expand 10 before | Expand all | Expand 10 after
1837 BluetoothDevice* device = 1832 BluetoothDevice* device =
1838 bluetooth_adapter_->GetDevice(addr->To<std::string>()); 1833 bluetooth_adapter_->GetDevice(addr->To<std::string>());
1839 mojom::BluetoothBondState bond_state = mojom::BluetoothBondState::NONE; 1834 mojom::BluetoothBondState bond_state = mojom::BluetoothBondState::NONE;
1840 if (device && device->IsPaired()) { 1835 if (device && device->IsPaired()) {
1841 bond_state = mojom::BluetoothBondState::BONDED; 1836 bond_state = mojom::BluetoothBondState::BONDED;
1842 } 1837 }
1843 bluetooth_instance->OnBondStateChanged(mojom::BluetoothStatus::FAIL, 1838 bluetooth_instance->OnBondStateChanged(mojom::BluetoothStatus::FAIL,
1844 std::move(addr), bond_state); 1839 std::move(addr), bond_state);
1845 } 1840 }
1846 1841
1847 mojo::Array<mojom::BluetoothPropertyPtr> 1842 std::vector<mojom::BluetoothPropertyPtr>
1848 ArcBluetoothBridge::GetDeviceProperties(mojom::BluetoothPropertyType type, 1843 ArcBluetoothBridge::GetDeviceProperties(mojom::BluetoothPropertyType type,
1849 const BluetoothDevice* device) const { 1844 const BluetoothDevice* device) const {
1850 mojo::Array<mojom::BluetoothPropertyPtr> properties; 1845 std::vector<mojom::BluetoothPropertyPtr> properties;
1851 1846
1852 if (!device) { 1847 if (!device) {
1853 return properties; 1848 return properties;
1854 } 1849 }
1855 1850
1856 if (type == mojom::BluetoothPropertyType::ALL || 1851 if (type == mojom::BluetoothPropertyType::ALL ||
1857 type == mojom::BluetoothPropertyType::BDNAME) { 1852 type == mojom::BluetoothPropertyType::BDNAME) {
1858 mojom::BluetoothPropertyPtr btp = mojom::BluetoothProperty::New(); 1853 mojom::BluetoothPropertyPtr btp = mojom::BluetoothProperty::New();
1859 btp->set_bdname(device->GetName() ? device->GetName().value() : ""); 1854 btp->set_bdname(device->GetName() ? device->GetName().value() : "");
1860 properties.push_back(std::move(btp)); 1855 properties.push_back(std::move(btp));
(...skipping 22 matching lines...) Expand all
1883 if (type == mojom::BluetoothPropertyType::ALL || 1878 if (type == mojom::BluetoothPropertyType::ALL ||
1884 type == mojom::BluetoothPropertyType::TYPE_OF_DEVICE) { 1879 type == mojom::BluetoothPropertyType::TYPE_OF_DEVICE) {
1885 mojom::BluetoothPropertyPtr btp = mojom::BluetoothProperty::New(); 1880 mojom::BluetoothPropertyPtr btp = mojom::BluetoothProperty::New();
1886 btp->set_device_type(device->GetType()); 1881 btp->set_device_type(device->GetType());
1887 properties.push_back(std::move(btp)); 1882 properties.push_back(std::move(btp));
1888 } 1883 }
1889 if (type == mojom::BluetoothPropertyType::ALL || 1884 if (type == mojom::BluetoothPropertyType::ALL ||
1890 type == mojom::BluetoothPropertyType::REMOTE_FRIENDLY_NAME) { 1885 type == mojom::BluetoothPropertyType::REMOTE_FRIENDLY_NAME) {
1891 mojom::BluetoothPropertyPtr btp = mojom::BluetoothProperty::New(); 1886 mojom::BluetoothPropertyPtr btp = mojom::BluetoothProperty::New();
1892 btp->set_remote_friendly_name( 1887 btp->set_remote_friendly_name(
1893 mojo::String::From(base::UTF16ToUTF8(device->GetNameForDisplay()))); 1888 base::UTF16ToUTF8(device->GetNameForDisplay()));
1894 properties.push_back(std::move(btp)); 1889 properties.push_back(std::move(btp));
1895 } 1890 }
1896 if (type == mojom::BluetoothPropertyType::ALL || 1891 if (type == mojom::BluetoothPropertyType::ALL ||
1897 type == mojom::BluetoothPropertyType::REMOTE_RSSI) { 1892 type == mojom::BluetoothPropertyType::REMOTE_RSSI) {
1898 base::Optional<int8_t> rssi = device->GetInquiryRSSI(); 1893 base::Optional<int8_t> rssi = device->GetInquiryRSSI();
1899 if (rssi.has_value()) { 1894 if (rssi.has_value()) {
1900 mojom::BluetoothPropertyPtr btp = mojom::BluetoothProperty::New(); 1895 mojom::BluetoothPropertyPtr btp = mojom::BluetoothProperty::New();
1901 btp->set_remote_rssi(rssi.value()); 1896 btp->set_remote_rssi(rssi.value());
1902 properties.push_back(std::move(btp)); 1897 properties.push_back(std::move(btp));
1903 } 1898 }
1904 } 1899 }
1905 // TODO(smbarber): Add remote version info 1900 // TODO(smbarber): Add remote version info
1906 1901
1907 return properties; 1902 return properties;
1908 } 1903 }
1909 1904
1910 mojo::Array<mojom::BluetoothPropertyPtr> 1905 std::vector<mojom::BluetoothPropertyPtr>
1911 ArcBluetoothBridge::GetAdapterProperties( 1906 ArcBluetoothBridge::GetAdapterProperties(
1912 mojom::BluetoothPropertyType type) const { 1907 mojom::BluetoothPropertyType type) const {
1913 mojo::Array<mojom::BluetoothPropertyPtr> properties; 1908 std::vector<mojom::BluetoothPropertyPtr> properties;
1914 1909
1915 if (type == mojom::BluetoothPropertyType::ALL || 1910 if (type == mojom::BluetoothPropertyType::ALL ||
1916 type == mojom::BluetoothPropertyType::BDNAME) { 1911 type == mojom::BluetoothPropertyType::BDNAME) {
1917 mojom::BluetoothPropertyPtr btp = mojom::BluetoothProperty::New(); 1912 mojom::BluetoothPropertyPtr btp = mojom::BluetoothProperty::New();
1918 std::string name = bluetooth_adapter_->GetName(); 1913 std::string name = bluetooth_adapter_->GetName();
1919 btp->set_bdname(mojo::String(name)); 1914 btp->set_bdname(name);
1920 properties.push_back(std::move(btp)); 1915 properties.push_back(std::move(btp));
1921 } 1916 }
1922 if (type == mojom::BluetoothPropertyType::ALL || 1917 if (type == mojom::BluetoothPropertyType::ALL ||
1923 type == mojom::BluetoothPropertyType::BDADDR) { 1918 type == mojom::BluetoothPropertyType::BDADDR) {
1924 mojom::BluetoothPropertyPtr btp = mojom::BluetoothProperty::New(); 1919 mojom::BluetoothPropertyPtr btp = mojom::BluetoothProperty::New();
1925 btp->set_bdaddr( 1920 btp->set_bdaddr(
1926 mojom::BluetoothAddress::From(bluetooth_adapter_->GetAddress())); 1921 mojom::BluetoothAddress::From(bluetooth_adapter_->GetAddress()));
1927 properties.push_back(std::move(btp)); 1922 properties.push_back(std::move(btp));
1928 } 1923 }
1929 if (type == mojom::BluetoothPropertyType::ALL || 1924 if (type == mojom::BluetoothPropertyType::ALL ||
1930 type == mojom::BluetoothPropertyType::UUIDS) { 1925 type == mojom::BluetoothPropertyType::UUIDS) {
1931 mojom::BluetoothPropertyPtr btp = mojom::BluetoothProperty::New(); 1926 mojom::BluetoothPropertyPtr btp = mojom::BluetoothProperty::New();
1932 btp->set_uuids( 1927 btp->set_uuids(bluetooth_adapter_->GetUUIDs());
1933 mojo::Array<BluetoothUUID>::From(bluetooth_adapter_->GetUUIDs()));
1934 properties.push_back(std::move(btp)); 1928 properties.push_back(std::move(btp));
1935 } 1929 }
1936 if (type == mojom::BluetoothPropertyType::ALL || 1930 if (type == mojom::BluetoothPropertyType::ALL ||
1937 type == mojom::BluetoothPropertyType::CLASS_OF_DEVICE) { 1931 type == mojom::BluetoothPropertyType::CLASS_OF_DEVICE) {
1938 mojom::BluetoothPropertyPtr btp = mojom::BluetoothProperty::New(); 1932 mojom::BluetoothPropertyPtr btp = mojom::BluetoothProperty::New();
1939 btp->set_device_class(kBluetoothComputerClass); 1933 btp->set_device_class(kBluetoothComputerClass);
1940 properties.push_back(std::move(btp)); 1934 properties.push_back(std::move(btp));
1941 } 1935 }
1942 if (type == mojom::BluetoothPropertyType::ALL || 1936 if (type == mojom::BluetoothPropertyType::ALL ||
1943 type == mojom::BluetoothPropertyType::TYPE_OF_DEVICE) { 1937 type == mojom::BluetoothPropertyType::TYPE_OF_DEVICE) {
(...skipping 11 matching lines...) Expand all
1955 scan_mode = mojom::BluetoothScanMode::CONNECTABLE_DISCOVERABLE; 1949 scan_mode = mojom::BluetoothScanMode::CONNECTABLE_DISCOVERABLE;
1956 1950
1957 btp->set_adapter_scan_mode(scan_mode); 1951 btp->set_adapter_scan_mode(scan_mode);
1958 properties.push_back(std::move(btp)); 1952 properties.push_back(std::move(btp));
1959 } 1953 }
1960 if (type == mojom::BluetoothPropertyType::ALL || 1954 if (type == mojom::BluetoothPropertyType::ALL ||
1961 type == mojom::BluetoothPropertyType::ADAPTER_BONDED_DEVICES) { 1955 type == mojom::BluetoothPropertyType::ADAPTER_BONDED_DEVICES) {
1962 mojom::BluetoothPropertyPtr btp = mojom::BluetoothProperty::New(); 1956 mojom::BluetoothPropertyPtr btp = mojom::BluetoothProperty::New();
1963 BluetoothAdapter::DeviceList devices = bluetooth_adapter_->GetDevices(); 1957 BluetoothAdapter::DeviceList devices = bluetooth_adapter_->GetDevices();
1964 1958
1965 mojo::Array<mojom::BluetoothAddressPtr> bonded_devices = 1959 std::vector<mojom::BluetoothAddressPtr> bonded_devices;
1966 mojo::Array<mojom::BluetoothAddressPtr>::New(0);
1967 1960
1968 for (auto* device : devices) { 1961 for (auto* device : devices) {
1969 if (device->IsPaired()) 1962 if (device->IsPaired())
1970 continue; 1963 continue;
1971 1964
1972 mojom::BluetoothAddressPtr addr = 1965 mojom::BluetoothAddressPtr addr =
1973 mojom::BluetoothAddress::From(device->GetAddress()); 1966 mojom::BluetoothAddress::From(device->GetAddress());
1974 bonded_devices.push_back(std::move(addr)); 1967 bonded_devices.push_back(std::move(addr));
1975 } 1968 }
1976 1969
(...skipping 27 matching lines...) Expand all
2004 properties.push_back(std::move(btp)); 1997 properties.push_back(std::move(btp));
2005 } 1998 }
2006 1999
2007 return properties; 2000 return properties;
2008 } 2001 }
2009 2002
2010 // Android support 6 types of Advertising Data which are Advertising Data Flags, 2003 // Android support 6 types of Advertising Data which are Advertising Data Flags,
2011 // Local Name, Service UUIDs, Tx Power Level, Service Data, and Manufacturer 2004 // Local Name, Service UUIDs, Tx Power Level, Service Data, and Manufacturer
2012 // Data. Note that we need to use 16-bit UUID in Service Data section because 2005 // Data. Note that we need to use 16-bit UUID in Service Data section because
2013 // Android does not support 128-bit UUID there. 2006 // Android does not support 128-bit UUID there.
2014 mojo::Array<mojom::BluetoothAdvertisingDataPtr> 2007 std::vector<mojom::BluetoothAdvertisingDataPtr>
2015 ArcBluetoothBridge::GetAdvertisingData(const BluetoothDevice* device) const { 2008 ArcBluetoothBridge::GetAdvertisingData(const BluetoothDevice* device) const {
2016 mojo::Array<mojom::BluetoothAdvertisingDataPtr> advertising_data; 2009 std::vector<mojom::BluetoothAdvertisingDataPtr> advertising_data;
2017 2010
2018 // Advertising Data Flags 2011 // Advertising Data Flags
2019 if (device->GetAdvertisingDataFlags().has_value()) { 2012 if (device->GetAdvertisingDataFlags().has_value()) {
2020 mojom::BluetoothAdvertisingDataPtr flags = 2013 mojom::BluetoothAdvertisingDataPtr flags =
2021 mojom::BluetoothAdvertisingData::New(); 2014 mojom::BluetoothAdvertisingData::New();
2022 flags->set_flags(device->GetAdvertisingDataFlags().value()); 2015 flags->set_flags(device->GetAdvertisingDataFlags().value());
2023 advertising_data.push_back(std::move(flags)); 2016 advertising_data.push_back(std::move(flags));
2024 } 2017 }
2025 2018
2026 // Local Name 2019 // Local Name
2027 mojom::BluetoothAdvertisingDataPtr local_name = 2020 mojom::BluetoothAdvertisingDataPtr local_name =
2028 mojom::BluetoothAdvertisingData::New(); 2021 mojom::BluetoothAdvertisingData::New();
2029 local_name->set_local_name(device->GetName() ? device->GetName().value() 2022 local_name->set_local_name(device->GetName() ? device->GetName().value()
2030 : ""); 2023 : "");
2031 advertising_data.push_back(std::move(local_name)); 2024 advertising_data.push_back(std::move(local_name));
2032 2025
2033 // Service UUIDs 2026 // Service UUIDs
2034 const BluetoothDevice::UUIDSet& uuid_set = device->GetUUIDs(); 2027 const BluetoothDevice::UUIDSet& uuid_set = device->GetUUIDs();
2035 if (uuid_set.size() > 0) { 2028 if (uuid_set.size() > 0) {
2036 mojom::BluetoothAdvertisingDataPtr service_uuids = 2029 mojom::BluetoothAdvertisingDataPtr service_uuids =
2037 mojom::BluetoothAdvertisingData::New(); 2030 mojom::BluetoothAdvertisingData::New();
2038 service_uuids->set_service_uuids(mojo::Array<BluetoothUUID>::From( 2031 service_uuids->set_service_uuids(
2039 std::vector<BluetoothUUID>(uuid_set.begin(), uuid_set.end()))); 2032 std::vector<BluetoothUUID>(uuid_set.begin(), uuid_set.end()));
2040 advertising_data.push_back(std::move(service_uuids)); 2033 advertising_data.push_back(std::move(service_uuids));
2041 } 2034 }
2042 2035
2043 // Tx Power Level 2036 // Tx Power Level
2044 if (device->GetInquiryTxPower().has_value()) { 2037 if (device->GetInquiryTxPower().has_value()) {
2045 mojom::BluetoothAdvertisingDataPtr tx_power_level_element = 2038 mojom::BluetoothAdvertisingDataPtr tx_power_level_element =
2046 mojom::BluetoothAdvertisingData::New(); 2039 mojom::BluetoothAdvertisingData::New();
2047 tx_power_level_element->set_tx_power_level( 2040 tx_power_level_element->set_tx_power_level(
2048 device->GetInquiryTxPower().value()); 2041 device->GetInquiryTxPower().value());
2049 advertising_data.push_back(std::move(tx_power_level_element)); 2042 advertising_data.push_back(std::move(tx_power_level_element));
2050 } 2043 }
2051 2044
2052 // Service Data 2045 // Service Data
2053 for (const BluetoothUUID& uuid : device->GetServiceDataUUIDs()) { 2046 for (const BluetoothUUID& uuid : device->GetServiceDataUUIDs()) {
2054 mojom::BluetoothAdvertisingDataPtr service_data_element = 2047 mojom::BluetoothAdvertisingDataPtr service_data_element =
2055 mojom::BluetoothAdvertisingData::New(); 2048 mojom::BluetoothAdvertisingData::New();
2056 mojom::BluetoothServiceDataPtr service_data = 2049 mojom::BluetoothServiceDataPtr service_data =
2057 mojom::BluetoothServiceData::New(); 2050 mojom::BluetoothServiceData::New();
2058 2051
2059 // Android only supports UUID 16 bit here. 2052 // Android only supports UUID 16 bit here.
2060 service_data->uuid_16bit = GetUUID16(uuid); 2053 service_data->uuid_16bit = GetUUID16(uuid);
2061 2054
2062 const std::vector<uint8_t>* data = device->GetServiceDataForUUID(uuid); 2055 const std::vector<uint8_t>* data = device->GetServiceDataForUUID(uuid);
2063 DCHECK(data != nullptr); 2056 DCHECK(data != nullptr);
2064 2057
2065 std::vector<uint8_t> data_copy = *data; 2058 service_data->data = *data;
2066 service_data->data.Swap(&data_copy);
2067 2059
2068 service_data_element->set_service_data(std::move(service_data)); 2060 service_data_element->set_service_data(std::move(service_data));
2069 advertising_data.push_back(std::move(service_data_element)); 2061 advertising_data.push_back(std::move(service_data_element));
2070 } 2062 }
2071 2063
2072 // Manufacturer Data 2064 // Manufacturer Data
2073 if (!device->GetManufacturerData().empty()) { 2065 if (!device->GetManufacturerData().empty()) {
2074 std::vector<uint8_t> manufacturer_data; 2066 std::vector<uint8_t> manufacturer_data;
2075 for (const auto& pair : device->GetManufacturerData()) { 2067 for (const auto& pair : device->GetManufacturerData()) {
2076 uint16_t id = pair.first; 2068 uint16_t id = pair.first;
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
2126 void ArcBluetoothBridge::OnGetServiceRecordsDone( 2118 void ArcBluetoothBridge::OnGetServiceRecordsDone(
2127 mojom::BluetoothAddressPtr remote_addr, 2119 mojom::BluetoothAddressPtr remote_addr,
2128 const BluetoothUUID& target_uuid, 2120 const BluetoothUUID& target_uuid,
2129 const std::vector<bluez::BluetoothServiceRecordBlueZ>& records_bluez) { 2121 const std::vector<bluez::BluetoothServiceRecordBlueZ>& records_bluez) {
2130 auto* sdp_bluetooth_instance = 2122 auto* sdp_bluetooth_instance =
2131 arc_bridge_service()->bluetooth()->GetInstanceForMethod( 2123 arc_bridge_service()->bluetooth()->GetInstanceForMethod(
2132 "OnGetSdpRecords", kMinSdpSupportVersion); 2124 "OnGetSdpRecords", kMinSdpSupportVersion);
2133 if (!sdp_bluetooth_instance) 2125 if (!sdp_bluetooth_instance)
2134 return; 2126 return;
2135 2127
2136 sdp_bluetooth_instance->OnGetSdpRecords( 2128 std::vector<mojom::BluetoothSdpRecordPtr> records;
2137 mojom::BluetoothStatus::SUCCESS, std::move(remote_addr), target_uuid, 2129 for (const auto& r : records_bluez)
2138 mojo::Array<mojom::BluetoothSdpRecordPtr>::From(records_bluez)); 2130 records.push_back(mojom::BluetoothSdpRecord::From(r));
2131
2132 sdp_bluetooth_instance->OnGetSdpRecords(mojom::BluetoothStatus::SUCCESS,
2133 std::move(remote_addr), target_uuid,
2134 std::move(records));
2139 } 2135 }
2140 2136
2141 void ArcBluetoothBridge::OnGetServiceRecordsError( 2137 void ArcBluetoothBridge::OnGetServiceRecordsError(
2142 mojom::BluetoothAddressPtr remote_addr, 2138 mojom::BluetoothAddressPtr remote_addr,
2143 const BluetoothUUID& target_uuid, 2139 const BluetoothUUID& target_uuid,
2144 bluez::BluetoothServiceRecordBlueZ::ErrorCode error_code) { 2140 bluez::BluetoothServiceRecordBlueZ::ErrorCode error_code) {
2145 auto* sdp_bluetooth_instance = 2141 auto* sdp_bluetooth_instance =
2146 arc_bridge_service()->bluetooth()->GetInstanceForMethod( 2142 arc_bridge_service()->bluetooth()->GetInstanceForMethod(
2147 "OnGetSdpRecords", kMinSdpSupportVersion); 2143 "OnGetSdpRecords", kMinSdpSupportVersion);
2148 if (!sdp_bluetooth_instance) 2144 if (!sdp_bluetooth_instance)
2149 return; 2145 return;
2150 2146
2151 mojom::BluetoothStatus status; 2147 mojom::BluetoothStatus status;
2152 2148
2153 switch (error_code) { 2149 switch (error_code) {
2154 case bluez::BluetoothServiceRecordBlueZ::ErrorCode::ERROR_ADAPTER_NOT_READY: 2150 case bluez::BluetoothServiceRecordBlueZ::ErrorCode::ERROR_ADAPTER_NOT_READY:
2155 status = mojom::BluetoothStatus::NOT_READY; 2151 status = mojom::BluetoothStatus::NOT_READY;
2156 break; 2152 break;
2157 case bluez::BluetoothServiceRecordBlueZ::ErrorCode:: 2153 case bluez::BluetoothServiceRecordBlueZ::ErrorCode::
2158 ERROR_DEVICE_DISCONNECTED: 2154 ERROR_DEVICE_DISCONNECTED:
2159 status = mojom::BluetoothStatus::RMT_DEV_DOWN; 2155 status = mojom::BluetoothStatus::RMT_DEV_DOWN;
2160 break; 2156 break;
2161 default: 2157 default:
2162 status = mojom::BluetoothStatus::FAIL; 2158 status = mojom::BluetoothStatus::FAIL;
2163 break; 2159 break;
2164 } 2160 }
2165 2161
2166 sdp_bluetooth_instance->OnGetSdpRecords( 2162 sdp_bluetooth_instance->OnGetSdpRecords(
2167 status, std::move(remote_addr), target_uuid, 2163 status, std::move(remote_addr), target_uuid,
2168 mojo::Array<mojom::BluetoothSdpRecordPtr>::New(0)); 2164 std::vector<mojom::BluetoothSdpRecordPtr>());
2169 } 2165 }
2170 2166
2171 bool ArcBluetoothBridge::CalledOnValidThread() { 2167 bool ArcBluetoothBridge::CalledOnValidThread() {
2172 return thread_checker_.CalledOnValidThread(); 2168 return thread_checker_.CalledOnValidThread();
2173 } 2169 }
2174 2170
2175 } // namespace arc 2171 } // namespace arc
OLDNEW
« no previous file with comments | « components/arc/bluetooth/arc_bluetooth_bridge.h ('k') | components/arc/bluetooth/arc_bluetooth_bridge_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698