OLD | NEW |
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 <fcntl.h> | 7 #include <fcntl.h> |
8 #include <stddef.h> | 8 #include <stddef.h> |
9 | 9 |
10 #include <iomanip> | 10 #include <iomanip> |
11 #include <string> | 11 #include <string> |
12 | 12 |
13 #include "base/bind.h" | 13 #include "base/bind.h" |
14 #include "base/logging.h" | 14 #include "base/logging.h" |
15 #include "base/posix/eintr_wrapper.h" | 15 #include "base/posix/eintr_wrapper.h" |
16 #include "base/strings/string_number_conversions.h" | 16 #include "base/strings/string_number_conversions.h" |
17 #include "base/strings/utf_string_conversions.h" | 17 #include "base/strings/utf_string_conversions.h" |
18 #include "base/thread_task_runner_handle.h" | 18 #include "base/thread_task_runner_handle.h" |
19 #include "base/time/time.h" | 19 #include "base/time/time.h" |
20 #include "components/arc/arc_bridge_service.h" | 20 #include "components/arc/arc_bridge_service.h" |
21 #include "components/arc/bluetooth/bluetooth_type_converters.h" | 21 #include "components/arc/bluetooth/bluetooth_type_converters.h" |
22 #include "device/bluetooth/bluetooth_adapter_factory.h" | 22 #include "device/bluetooth/bluetooth_adapter_factory.h" |
23 #include "device/bluetooth/bluetooth_device.h" | 23 #include "device/bluetooth/bluetooth_device.h" |
24 #include "device/bluetooth/bluetooth_gatt_characteristic.h" | 24 #include "device/bluetooth/bluetooth_remote_gatt_characteristic.h" |
25 #include "device/bluetooth/bluetooth_gatt_descriptor.h" | 25 #include "device/bluetooth/bluetooth_remote_gatt_descriptor.h" |
26 #include "device/bluetooth/bluetooth_gatt_service.h" | 26 #include "device/bluetooth/bluetooth_remote_gatt_service.h" |
27 | 27 |
28 using device::BluetoothAdapter; | 28 using device::BluetoothAdapter; |
29 using device::BluetoothAdapterFactory; | 29 using device::BluetoothAdapterFactory; |
30 using device::BluetoothDevice; | 30 using device::BluetoothDevice; |
31 using device::BluetoothDiscoverySession; | 31 using device::BluetoothDiscoverySession; |
32 using device::BluetoothGattCharacteristic; | 32 using device::BluetoothRemoteGattCharacteristic; |
33 using device::BluetoothGattDescriptor; | 33 using device::BluetoothRemoteGattDescriptor; |
34 using device::BluetoothGattService; | 34 using device::BluetoothRemoteGattService; |
35 | 35 |
36 namespace arc { | 36 namespace arc { |
37 | 37 |
38 ArcBluetoothBridge::ArcBluetoothBridge(ArcBridgeService* bridge_service) | 38 ArcBluetoothBridge::ArcBluetoothBridge(ArcBridgeService* bridge_service) |
39 : ArcService(bridge_service), binding_(this), weak_factory_(this) { | 39 : ArcService(bridge_service), binding_(this), weak_factory_(this) { |
40 if (BluetoothAdapterFactory::IsBluetoothAdapterAvailable()) { | 40 if (BluetoothAdapterFactory::IsBluetoothAdapterAvailable()) { |
41 VLOG(1) << "registering bluetooth adapter"; | 41 VLOG(1) << "registering bluetooth adapter"; |
42 BluetoothAdapterFactory::GetAdapter(base::Bind( | 42 BluetoothAdapterFactory::GetAdapter(base::Bind( |
43 &ArcBluetoothBridge::OnAdapterInitialized, weak_factory_.GetWeakPtr())); | 43 &ArcBluetoothBridge::OnAdapterInitialized, weak_factory_.GetWeakPtr())); |
44 } else { | 44 } else { |
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
144 DCHECK(adapter); | 144 DCHECK(adapter); |
145 DCHECK(device); | 145 DCHECK(device); |
146 | 146 |
147 mojom::BluetoothAddressPtr addr = | 147 mojom::BluetoothAddressPtr addr = |
148 mojom::BluetoothAddress::From(device->GetAddress()); | 148 mojom::BluetoothAddress::From(device->GetAddress()); |
149 OnForgetDone(std::move(addr)); | 149 OnForgetDone(std::move(addr)); |
150 } | 150 } |
151 | 151 |
152 void ArcBluetoothBridge::GattServiceAdded(BluetoothAdapter* adapter, | 152 void ArcBluetoothBridge::GattServiceAdded(BluetoothAdapter* adapter, |
153 BluetoothDevice* device, | 153 BluetoothDevice* device, |
154 BluetoothGattService* service) { | 154 BluetoothRemoteGattService* service) { |
155 // Placeholder for GATT client functionality | 155 // Placeholder for GATT client functionality |
156 } | 156 } |
157 | 157 |
158 void ArcBluetoothBridge::GattServiceRemoved(BluetoothAdapter* adapter, | 158 void ArcBluetoothBridge::GattServiceRemoved( |
159 BluetoothDevice* device, | 159 BluetoothAdapter* adapter, |
160 BluetoothGattService* service) { | 160 BluetoothDevice* device, |
| 161 BluetoothRemoteGattService* service) { |
161 // Placeholder for GATT client functionality | 162 // Placeholder for GATT client functionality |
162 } | 163 } |
163 | 164 |
164 void ArcBluetoothBridge::GattServicesDiscovered(BluetoothAdapter* adapter, | 165 void ArcBluetoothBridge::GattServicesDiscovered(BluetoothAdapter* adapter, |
165 BluetoothDevice* device) { | 166 BluetoothDevice* device) { |
166 // Placeholder for GATT client functionality | 167 // Placeholder for GATT client functionality |
167 } | 168 } |
168 | 169 |
169 void ArcBluetoothBridge::GattDiscoveryCompleteForService( | 170 void ArcBluetoothBridge::GattDiscoveryCompleteForService( |
170 BluetoothAdapter* adapter, | 171 BluetoothAdapter* adapter, |
171 BluetoothGattService* service) { | 172 BluetoothRemoteGattService* service) { |
172 // Placeholder for GATT client functionality | 173 // Placeholder for GATT client functionality |
173 } | 174 } |
174 | 175 |
175 void ArcBluetoothBridge::GattServiceChanged(BluetoothAdapter* adapter, | 176 void ArcBluetoothBridge::GattServiceChanged( |
176 BluetoothGattService* service) { | 177 BluetoothAdapter* adapter, |
| 178 BluetoothRemoteGattService* service) { |
177 // Placeholder for GATT client functionality | 179 // Placeholder for GATT client functionality |
178 } | 180 } |
179 | 181 |
180 void ArcBluetoothBridge::GattCharacteristicAdded( | 182 void ArcBluetoothBridge::GattCharacteristicAdded( |
181 BluetoothAdapter* adapter, | 183 BluetoothAdapter* adapter, |
182 BluetoothGattCharacteristic* characteristic) { | 184 BluetoothRemoteGattCharacteristic* characteristic) { |
183 // Placeholder for GATT client functionality | 185 // Placeholder for GATT client functionality |
184 } | 186 } |
185 | 187 |
186 void ArcBluetoothBridge::GattCharacteristicRemoved( | 188 void ArcBluetoothBridge::GattCharacteristicRemoved( |
187 BluetoothAdapter* adapter, | 189 BluetoothAdapter* adapter, |
188 BluetoothGattCharacteristic* characteristic) { | 190 BluetoothRemoteGattCharacteristic* characteristic) { |
189 // Placeholder for GATT client functionality | 191 // Placeholder for GATT client functionality |
190 } | 192 } |
191 | 193 |
192 void ArcBluetoothBridge::GattDescriptorAdded( | 194 void ArcBluetoothBridge::GattDescriptorAdded( |
193 BluetoothAdapter* adapter, | 195 BluetoothAdapter* adapter, |
194 BluetoothGattDescriptor* descriptor) { | 196 BluetoothRemoteGattDescriptor* descriptor) { |
195 // Placeholder for GATT client functionality | 197 // Placeholder for GATT client functionality |
196 } | 198 } |
197 | 199 |
198 void ArcBluetoothBridge::GattDescriptorRemoved( | 200 void ArcBluetoothBridge::GattDescriptorRemoved( |
199 BluetoothAdapter* adapter, | 201 BluetoothAdapter* adapter, |
200 BluetoothGattDescriptor* descriptor) { | 202 BluetoothRemoteGattDescriptor* descriptor) { |
201 // Placeholder for GATT client functionality | 203 // Placeholder for GATT client functionality |
202 } | 204 } |
203 | 205 |
204 void ArcBluetoothBridge::GattCharacteristicValueChanged( | 206 void ArcBluetoothBridge::GattCharacteristicValueChanged( |
205 BluetoothAdapter* adapter, | 207 BluetoothAdapter* adapter, |
206 BluetoothGattCharacteristic* characteristic, | 208 BluetoothRemoteGattCharacteristic* characteristic, |
207 const std::vector<uint8_t>& value) { | 209 const std::vector<uint8_t>& value) { |
208 // Placeholder for GATT client functionality | 210 // Placeholder for GATT client functionality |
209 } | 211 } |
210 | 212 |
211 void ArcBluetoothBridge::GattDescriptorValueChanged( | 213 void ArcBluetoothBridge::GattDescriptorValueChanged( |
212 BluetoothAdapter* adapter, | 214 BluetoothAdapter* adapter, |
213 BluetoothGattDescriptor* descriptor, | 215 BluetoothRemoteGattDescriptor* descriptor, |
214 const std::vector<uint8_t>& value) { | 216 const std::vector<uint8_t>& value) { |
215 // Placeholder for GATT client functionality | 217 // Placeholder for GATT client functionality |
216 } | 218 } |
217 | 219 |
218 void ArcBluetoothBridge::EnableAdapter(const EnableAdapterCallback& callback) { | 220 void ArcBluetoothBridge::EnableAdapter(const EnableAdapterCallback& callback) { |
219 DCHECK(bluetooth_adapter_); | 221 DCHECK(bluetooth_adapter_); |
220 if (!bluetooth_adapter_->IsPowered()) { | 222 if (!bluetooth_adapter_->IsPowered()) { |
221 bluetooth_adapter_->SetPowered( | 223 bluetooth_adapter_->SetPowered( |
222 true, base::Bind(&ArcBluetoothBridge::OnPoweredOn, | 224 true, base::Bind(&ArcBluetoothBridge::OnPoweredOn, |
223 weak_factory_.GetWeakPtr(), callback), | 225 weak_factory_.GetWeakPtr(), callback), |
(...skipping 482 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
706 // to | 708 // to |
707 // make sure the bond state machine on Android is ready to take the | 709 // make sure the bond state machine on Android is ready to take the |
708 // pair-done event. Otherwise the pair-done event will be dropped as an | 710 // pair-done event. Otherwise the pair-done event will be dropped as an |
709 // invalid change of paired status. | 711 // invalid change of paired status. |
710 OnPairing(addr->Clone()); | 712 OnPairing(addr->Clone()); |
711 OnPairedDone(std::move(addr)); | 713 OnPairedDone(std::move(addr)); |
712 } | 714 } |
713 } | 715 } |
714 | 716 |
715 } // namespace arc | 717 } // namespace arc |
OLD | NEW |