| 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 481e9b87a44816fbb39e0c4202ad06b776fba5b4..7cb139a384f2b007d571f618af733550c0c386b9 100644
|
| --- a/components/arc/bluetooth/arc_bluetooth_bridge.cc
|
| +++ b/components/arc/bluetooth/arc_bluetooth_bridge.cc
|
| @@ -54,11 +54,6 @@ using device::BluetoothTransport;
|
| using device::BluetoothUUID;
|
|
|
| namespace {
|
| -constexpr uint32_t kMinBtleVersion = 1;
|
| -constexpr uint32_t kMinBtleNotifyVersion = 2;
|
| -constexpr uint32_t kMinGattServerVersion = 3;
|
| -constexpr uint32_t kMinAddrChangeVersion = 4;
|
| -constexpr uint32_t kMinSdpSupportVersion = 5;
|
| constexpr uint32_t kGattReadPermission =
|
| BluetoothGattCharacteristic::Permission::PERMISSION_READ |
|
| BluetoothGattCharacteristic::Permission::PERMISSION_READ_ENCRYPTED |
|
| @@ -295,7 +290,7 @@ void ArcBluetoothBridge::OnAdapterInitialized(
|
|
|
| void ArcBluetoothBridge::OnInstanceReady() {
|
| mojom::BluetoothInstance* bluetooth_instance =
|
| - arc_bridge_service()->bluetooth()->GetInstanceForMethod("Init");
|
| + ARC_GET_INSTANCE_FOR_METHOD(arc_bridge_service()->bluetooth(), Init);
|
| DCHECK(bluetooth_instance);
|
|
|
| bluetooth_instance->Init(binding_.CreateInterfacePtrAndBind());
|
| @@ -313,8 +308,8 @@ void ArcBluetoothBridge::OnInstanceClosed() {
|
| }
|
|
|
| void ArcBluetoothBridge::SendDevice(const BluetoothDevice* device) const {
|
| - auto* bluetooth_instance =
|
| - arc_bridge_service()->bluetooth()->GetInstanceForMethod("OnDeviceFound");
|
| + auto* bluetooth_instance = ARC_GET_INSTANCE_FOR_METHOD(
|
| + arc_bridge_service()->bluetooth(), OnDeviceFound);
|
| if (!bluetooth_instance)
|
| return;
|
|
|
| @@ -335,9 +330,8 @@ void ArcBluetoothBridge::SendDevice(const BluetoothDevice* device) const {
|
| // that we don't want to send updated advertise data to Android.
|
| // 1) Cached found device and 2) rssi became invalid when we stop scanning.
|
| if (rssi.has_value()) {
|
| - auto* btle_instance =
|
| - arc_bridge_service()->bluetooth()->GetInstanceForMethod(
|
| - "OnLEDeviceFound", kMinBtleVersion);
|
| + auto* btle_instance = ARC_GET_INSTANCE_FOR_METHOD(
|
| + arc_bridge_service()->bluetooth(), OnLEDeviceFound);
|
| if (!btle_instance)
|
| return;
|
| std::vector<mojom::BluetoothAdvertisingDataPtr> adv_data =
|
| @@ -399,8 +393,8 @@ void ArcBluetoothBridge::DeviceAddressChanged(BluetoothAdapter* adapter,
|
| gatt_connection_cache_.erase(it);
|
| gatt_connection_cache_.insert(device->GetAddress());
|
|
|
| - auto* btle_instance = arc_bridge_service()->bluetooth()->GetInstanceForMethod(
|
| - "OnLEDeviceAddressChange", kMinAddrChangeVersion);
|
| + auto* btle_instance = ARC_GET_INSTANCE_FOR_METHOD(
|
| + arc_bridge_service()->bluetooth(), OnLEDeviceAddressChange);
|
| if (!btle_instance)
|
| return;
|
|
|
| @@ -466,8 +460,8 @@ void ArcBluetoothBridge::GattServiceRemoved(
|
|
|
| void ArcBluetoothBridge::GattServicesDiscovered(BluetoothAdapter* adapter,
|
| BluetoothDevice* device) {
|
| - auto* btle_instance = arc_bridge_service()->bluetooth()->GetInstanceForMethod(
|
| - "OnSearchComplete", kMinBtleVersion);
|
| + auto* btle_instance = ARC_GET_INSTANCE_FOR_METHOD(
|
| + arc_bridge_service()->bluetooth(), OnSearchComplete);
|
| if (!btle_instance)
|
| return;
|
|
|
| @@ -518,8 +512,8 @@ void ArcBluetoothBridge::GattCharacteristicValueChanged(
|
| BluetoothAdapter* adapter,
|
| BluetoothRemoteGattCharacteristic* characteristic,
|
| const std::vector<uint8_t>& value) {
|
| - auto* btle_instance = arc_bridge_service()->bluetooth()->GetInstanceForMethod(
|
| - "OnGattNotify", kMinBtleNotifyVersion);
|
| + auto* btle_instance = ARC_GET_INSTANCE_FOR_METHOD(
|
| + arc_bridge_service()->bluetooth(), OnGattNotify);
|
| if (!btle_instance)
|
| return;
|
|
|
| @@ -557,9 +551,8 @@ void ArcBluetoothBridge::OnGattAttributeReadRequest(
|
| const ValueCallback& success_callback,
|
| const ErrorCallback& error_callback) {
|
| DCHECK(CalledOnValidThread());
|
| - auto* bluetooth_instance =
|
| - arc_bridge_service()->bluetooth()->GetInstanceForMethod(
|
| - "RequestGattRead", kMinGattServerVersion);
|
| + auto* bluetooth_instance = ARC_GET_INSTANCE_FOR_METHOD(
|
| + arc_bridge_service()->bluetooth(), RequestGattRead);
|
| if (!bluetooth_instance || !IsGattOffsetValid(offset)) {
|
| error_callback.Run();
|
| return;
|
| @@ -582,9 +575,8 @@ void ArcBluetoothBridge::OnGattAttributeWriteRequest(
|
| const base::Closure& success_callback,
|
| const ErrorCallback& error_callback) {
|
| DCHECK(CalledOnValidThread());
|
| - auto* bluetooth_instance =
|
| - arc_bridge_service()->bluetooth()->GetInstanceForMethod(
|
| - "RequestGattWrite", kMinGattServerVersion);
|
| + auto* bluetooth_instance = ARC_GET_INSTANCE_FOR_METHOD(
|
| + arc_bridge_service()->bluetooth(), RequestGattWrite);
|
| if (!bluetooth_instance || !IsGattOffsetValid(offset)) {
|
| error_callback.Run();
|
| return;
|
| @@ -674,9 +666,8 @@ void ArcBluetoothBridge::DisableAdapter(
|
|
|
| void ArcBluetoothBridge::GetAdapterProperty(mojom::BluetoothPropertyType type) {
|
| DCHECK(bluetooth_adapter_);
|
| - auto* bluetooth_instance =
|
| - arc_bridge_service()->bluetooth()->GetInstanceForMethod(
|
| - "OnAdapterProperties");
|
| + auto* bluetooth_instance = ARC_GET_INSTANCE_FOR_METHOD(
|
| + arc_bridge_service()->bluetooth(), OnAdapterProperties);
|
| if (!bluetooth_instance)
|
| return;
|
|
|
| @@ -740,9 +731,8 @@ void ArcBluetoothBridge::SetDiscoverable(bool discoverable, uint32_t timeout) {
|
| void ArcBluetoothBridge::OnSetAdapterProperty(
|
| mojom::BluetoothStatus status,
|
| mojom::BluetoothPropertyPtr property) {
|
| - auto* bluetooth_instance =
|
| - arc_bridge_service()->bluetooth()->GetInstanceForMethod(
|
| - "OnAdapterProperties");
|
| + auto* bluetooth_instance = ARC_GET_INSTANCE_FOR_METHOD(
|
| + arc_bridge_service()->bluetooth(), OnAdapterProperties);
|
| DCHECK(bluetooth_instance);
|
|
|
| std::vector<arc::mojom::BluetoothPropertyPtr> properties;
|
| @@ -794,9 +784,8 @@ void ArcBluetoothBridge::GetRemoteDeviceProperty(
|
| mojom::BluetoothAddressPtr remote_addr,
|
| mojom::BluetoothPropertyType type) {
|
| DCHECK(bluetooth_adapter_);
|
| - auto* bluetooth_instance =
|
| - arc_bridge_service()->bluetooth()->GetInstanceForMethod(
|
| - "OnRemoteDeviceProperties");
|
| + auto* bluetooth_instance = ARC_GET_INSTANCE_FOR_METHOD(
|
| + arc_bridge_service()->bluetooth(), OnRemoteDeviceProperties);
|
| if (!bluetooth_instance)
|
| return;
|
|
|
| @@ -820,9 +809,8 @@ void ArcBluetoothBridge::SetRemoteDeviceProperty(
|
| mojom::BluetoothAddressPtr remote_addr,
|
| mojom::BluetoothPropertyPtr property) {
|
| DCHECK(bluetooth_adapter_);
|
| - auto* bluetooth_instance =
|
| - arc_bridge_service()->bluetooth()->GetInstanceForMethod(
|
| - "OnRemoteDeviceProperties");
|
| + auto* bluetooth_instance = ARC_GET_INSTANCE_FOR_METHOD(
|
| + arc_bridge_service()->bluetooth(), OnRemoteDeviceProperties);
|
| if (!bluetooth_instance)
|
| return;
|
|
|
| @@ -899,9 +887,8 @@ void ArcBluetoothBridge::OnDiscoveryStarted(
|
| std::unique_ptr<BluetoothDiscoverySession> session) {
|
| DCHECK(CalledOnValidThread());
|
|
|
| - auto* bluetooth_instance =
|
| - arc_bridge_service()->bluetooth()->GetInstanceForMethod(
|
| - "OnDiscoveryStateChanged");
|
| + auto* bluetooth_instance = ARC_GET_INSTANCE_FOR_METHOD(
|
| + arc_bridge_service()->bluetooth(), OnDiscoveryStateChanged);
|
| if (!bluetooth_instance)
|
| return;
|
|
|
| @@ -921,9 +908,8 @@ void ArcBluetoothBridge::OnDiscoveryStarted(
|
| }
|
|
|
| void ArcBluetoothBridge::OnDiscoveryStopped() {
|
| - auto* bluetooth_instance =
|
| - arc_bridge_service()->bluetooth()->GetInstanceForMethod(
|
| - "OnDiscoveryStateChanged");
|
| + auto* bluetooth_instance = ARC_GET_INSTANCE_FOR_METHOD(
|
| + arc_bridge_service()->bluetooth(), OnDiscoveryStateChanged);
|
| if (!bluetooth_instance)
|
| return;
|
|
|
| @@ -1036,8 +1022,8 @@ void ArcBluetoothBridge::StopLEScan() {
|
| void ArcBluetoothBridge::OnGattConnectStateChanged(
|
| mojom::BluetoothAddressPtr addr,
|
| bool connected) const {
|
| - auto* btle_instance = arc_bridge_service()->bluetooth()->GetInstanceForMethod(
|
| - "OnLEConnectionStateChange", kMinBtleVersion);
|
| + auto* btle_instance = ARC_GET_INSTANCE_FOR_METHOD(
|
| + arc_bridge_service()->bluetooth(), OnLEConnectionStateChange);
|
| if (!btle_instance)
|
| return;
|
|
|
| @@ -1076,9 +1062,8 @@ void ArcBluetoothBridge::OnGattDisconnected(
|
|
|
| void ArcBluetoothBridge::ConnectLEDevice(
|
| mojom::BluetoothAddressPtr remote_addr) {
|
| - auto* bluetooth_instance =
|
| - arc_bridge_service()->bluetooth()->GetInstanceForMethod(
|
| - "OnLEConnectionStateChange", kMinBtleVersion);
|
| + auto* bluetooth_instance = ARC_GET_INSTANCE_FOR_METHOD(
|
| + arc_bridge_service()->bluetooth(), OnLEConnectionStateChange);
|
| if (!bluetooth_instance)
|
| return;
|
|
|
| @@ -1103,9 +1088,8 @@ void ArcBluetoothBridge::ConnectLEDevice(
|
|
|
| void ArcBluetoothBridge::DisconnectLEDevice(
|
| mojom::BluetoothAddressPtr remote_addr) {
|
| - auto* bluetooth_instance =
|
| - arc_bridge_service()->bluetooth()->GetInstanceForMethod(
|
| - "OnLEConnectionStateChange", kMinBtleVersion);
|
| + auto* bluetooth_instance = ARC_GET_INSTANCE_FOR_METHOD(
|
| + arc_bridge_service()->bluetooth(), OnLEConnectionStateChange);
|
| if (!bluetooth_instance)
|
| return;
|
|
|
| @@ -1128,9 +1112,8 @@ void ArcBluetoothBridge::DisconnectLEDevice(
|
| }
|
|
|
| void ArcBluetoothBridge::SearchService(mojom::BluetoothAddressPtr remote_addr) {
|
| - auto* bluetooth_instance =
|
| - arc_bridge_service()->bluetooth()->GetInstanceForMethod(
|
| - "OnSearchComplete", kMinBtleVersion);
|
| + auto* bluetooth_instance = ARC_GET_INSTANCE_FOR_METHOD(
|
| + arc_bridge_service()->bluetooth(), OnSearchComplete);
|
| if (!bluetooth_instance)
|
| return;
|
|
|
| @@ -1206,9 +1189,8 @@ void ArcBluetoothBridge::StopLEListen(const StopLEListenCallback& callback) {
|
| }
|
|
|
| void ArcBluetoothBridge::GetGattDB(mojom::BluetoothAddressPtr remote_addr) {
|
| - auto* bluetooth_instance =
|
| - arc_bridge_service()->bluetooth()->GetInstanceForMethod("OnGetGattDB",
|
| - kMinBtleVersion);
|
| + auto* bluetooth_instance = ARC_GET_INSTANCE_FOR_METHOD(
|
| + arc_bridge_service()->bluetooth(), OnGetGattDB);
|
| if (!bluetooth_instance)
|
| return;
|
|
|
| @@ -1774,9 +1756,8 @@ void ArcBluetoothBridge::OnDiscoveryError() {
|
| }
|
|
|
| void ArcBluetoothBridge::OnPairing(mojom::BluetoothAddressPtr addr) const {
|
| - auto* bluetooth_instance =
|
| - arc_bridge_service()->bluetooth()->GetInstanceForMethod(
|
| - "OnBondStateChanged");
|
| + auto* bluetooth_instance = ARC_GET_INSTANCE_FOR_METHOD(
|
| + arc_bridge_service()->bluetooth(), OnBondStateChanged);
|
| if (!bluetooth_instance)
|
| return;
|
|
|
| @@ -1786,9 +1767,8 @@ void ArcBluetoothBridge::OnPairing(mojom::BluetoothAddressPtr addr) const {
|
| }
|
|
|
| void ArcBluetoothBridge::OnPairedDone(mojom::BluetoothAddressPtr addr) const {
|
| - auto* bluetooth_instance =
|
| - arc_bridge_service()->bluetooth()->GetInstanceForMethod(
|
| - "OnBondStateChanged");
|
| + auto* bluetooth_instance = ARC_GET_INSTANCE_FOR_METHOD(
|
| + arc_bridge_service()->bluetooth(), OnBondStateChanged);
|
| if (!bluetooth_instance)
|
| return;
|
|
|
| @@ -1800,9 +1780,8 @@ void ArcBluetoothBridge::OnPairedDone(mojom::BluetoothAddressPtr addr) const {
|
| void ArcBluetoothBridge::OnPairedError(
|
| mojom::BluetoothAddressPtr addr,
|
| BluetoothDevice::ConnectErrorCode error_code) const {
|
| - auto* bluetooth_instance =
|
| - arc_bridge_service()->bluetooth()->GetInstanceForMethod(
|
| - "OnBondStateChanged");
|
| + auto* bluetooth_instance = ARC_GET_INSTANCE_FOR_METHOD(
|
| + arc_bridge_service()->bluetooth(), OnBondStateChanged);
|
| if (!bluetooth_instance)
|
| return;
|
|
|
| @@ -1812,9 +1791,8 @@ void ArcBluetoothBridge::OnPairedError(
|
| }
|
|
|
| void ArcBluetoothBridge::OnForgetDone(mojom::BluetoothAddressPtr addr) const {
|
| - auto* bluetooth_instance =
|
| - arc_bridge_service()->bluetooth()->GetInstanceForMethod(
|
| - "OnBondStateChanged");
|
| + auto* bluetooth_instance = ARC_GET_INSTANCE_FOR_METHOD(
|
| + arc_bridge_service()->bluetooth(), OnBondStateChanged);
|
| if (!bluetooth_instance)
|
| return;
|
|
|
| @@ -1824,9 +1802,8 @@ void ArcBluetoothBridge::OnForgetDone(mojom::BluetoothAddressPtr addr) const {
|
| }
|
|
|
| void ArcBluetoothBridge::OnForgetError(mojom::BluetoothAddressPtr addr) const {
|
| - auto* bluetooth_instance =
|
| - arc_bridge_service()->bluetooth()->GetInstanceForMethod(
|
| - "OnBondStateChanged");
|
| + auto* bluetooth_instance = ARC_GET_INSTANCE_FOR_METHOD(
|
| + arc_bridge_service()->bluetooth(), OnBondStateChanged);
|
| if (!bluetooth_instance)
|
| return;
|
|
|
| @@ -2120,9 +2097,8 @@ void ArcBluetoothBridge::OnGetServiceRecordsDone(
|
| mojom::BluetoothAddressPtr remote_addr,
|
| const BluetoothUUID& target_uuid,
|
| const std::vector<bluez::BluetoothServiceRecordBlueZ>& records_bluez) {
|
| - auto* sdp_bluetooth_instance =
|
| - arc_bridge_service()->bluetooth()->GetInstanceForMethod(
|
| - "OnGetSdpRecords", kMinSdpSupportVersion);
|
| + auto* sdp_bluetooth_instance = ARC_GET_INSTANCE_FOR_METHOD(
|
| + arc_bridge_service()->bluetooth(), OnGetSdpRecords);
|
| if (!sdp_bluetooth_instance)
|
| return;
|
|
|
| @@ -2139,9 +2115,8 @@ void ArcBluetoothBridge::OnGetServiceRecordsError(
|
| mojom::BluetoothAddressPtr remote_addr,
|
| const BluetoothUUID& target_uuid,
|
| bluez::BluetoothServiceRecordBlueZ::ErrorCode error_code) {
|
| - auto* sdp_bluetooth_instance =
|
| - arc_bridge_service()->bluetooth()->GetInstanceForMethod(
|
| - "OnGetSdpRecords", kMinSdpSupportVersion);
|
| + auto* sdp_bluetooth_instance = ARC_GET_INSTANCE_FOR_METHOD(
|
| + arc_bridge_service()->bluetooth(), OnGetSdpRecords);
|
| if (!sdp_bluetooth_instance)
|
| return;
|
|
|
|
|