OLD | NEW |
---|---|
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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 #ifndef DEVICE_BLUETOOTH_BLUETOOTH_ADAPTER_ANDROID_H_ | 5 #ifndef DEVICE_BLUETOOTH_BLUETOOTH_ADAPTER_ANDROID_H_ |
6 #define DEVICE_BLUETOOTH_BLUETOOTH_ADAPTER_ANDROID_H_ | 6 #define DEVICE_BLUETOOTH_BLUETOOTH_ADAPTER_ANDROID_H_ |
7 | 7 |
8 #include "base/android/jni_android.h" | 8 #include "base/android/jni_android.h" |
9 #include "base/android/scoped_java_ref.h" | 9 #include "base/android/scoped_java_ref.h" |
10 #include "base/memory/weak_ptr.h" | 10 #include "base/memory/weak_ptr.h" |
11 #include "device/bluetooth/bluetooth_adapter.h" | 11 #include "device/bluetooth/bluetooth_adapter.h" |
12 | 12 |
13 namespace base { | 13 namespace base { |
14 class SequencedTaskRunner; | 14 class SequencedTaskRunner; |
15 } // namespace base | 15 } // namespace base |
16 | 16 |
17 using base::android::ScopedJavaLocalRef; | 17 using base::android::ScopedJavaLocalRef; |
18 | 18 |
19 namespace device { | 19 namespace device { |
20 | 20 |
21 // BluetoothAdapterAndroid, along with the Java class | 21 // BluetoothAdapterAndroid, along with the Java class |
22 // org.chromium.device.bluetooth.BluetoothAdapter, implement BluetoothAdapter. | 22 // org.chromium.device.bluetooth.BluetoothAdapter, implement BluetoothAdapter. |
23 // | 23 // |
24 // The GATT Profile over Low Energy is supported, but not Classic Bluetooth at | 24 // The GATT Profile over Low Energy is supported, but not Classic Bluetooth at |
25 // this time. LE GATT support has been initially built out to support Web | 25 // this time. LE GATT support has been initially built out to support Web |
26 // Bluetooth, which does not need other Bluetooth features. There is no | 26 // Bluetooth, which does not need other Bluetooth features. There is no |
27 // technical reason they can not be supported should a need arrise. | 27 // technical reason they can not be supported should a need arrise. |
28 // | 28 // |
29 // BluetoothAdapterAndroid is reference counted, and owns the lifetime of the | 29 // BluetoothAdapterAndroid is reference counted, and owns the lifetime of the |
30 // Java class BluetoothAdapter via j_adapter_. | 30 // Java class BluetoothAdapter via j_adapter_. A tree of additional C++ objects |
Jeffrey Yasskin
2015/07/07 00:11:14
"The adapter also owns a tree of ..."
scheib
2015/07/08 00:49:10
Done.
| |
31 // (Devices, Services, Characteristics, Descriptors) are also owned, with each | |
32 // C++ object owning its associated Java class. | |
31 class DEVICE_BLUETOOTH_EXPORT BluetoothAdapterAndroid final | 33 class DEVICE_BLUETOOTH_EXPORT BluetoothAdapterAndroid final |
32 : public BluetoothAdapter { | 34 : public BluetoothAdapter { |
33 public: | 35 public: |
34 // Create a BluetoothAdapterAndroid instance. | 36 // Create a BluetoothAdapterAndroid instance. |
35 // | 37 // |
36 // |java_bluetooth_adapter_wrapper| is optional. If it is NULL the adapter | 38 // |java_bluetooth_adapter_wrapper| is optional. If it is NULL the adapter |
37 // will return false for |IsPresent()| and not be functional. | 39 // will return false for |IsPresent()| and not be functional. |
38 // | 40 // |
39 // The BluetoothAdapterAndroid instance will indirectly hold a Java reference | 41 // The BluetoothAdapterAndroid instance will indirectly hold a Java reference |
40 // to |java_bluetooth_adapter_wrapper|. | 42 // to |java_bluetooth_adapter_wrapper|. |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
76 const AcquiredCallback& callback, | 78 const AcquiredCallback& callback, |
77 const BluetoothAudioSink::ErrorCallback& error_callback) override; | 79 const BluetoothAudioSink::ErrorCallback& error_callback) override; |
78 void RegisterAdvertisement( | 80 void RegisterAdvertisement( |
79 scoped_ptr<BluetoothAdvertisement::Data> advertisement_data, | 81 scoped_ptr<BluetoothAdvertisement::Data> advertisement_data, |
80 const CreateAdvertisementCallback& callback, | 82 const CreateAdvertisementCallback& callback, |
81 const CreateAdvertisementErrorCallback& error_callback) override; | 83 const CreateAdvertisementErrorCallback& error_callback) override; |
82 | 84 |
83 // Handles a scan error event by invalidating all discovery sessions. | 85 // Handles a scan error event by invalidating all discovery sessions. |
84 void OnScanFailed(JNIEnv* env, jobject obj); | 86 void OnScanFailed(JNIEnv* env, jobject obj); |
85 | 87 |
88 // Creates or updates device with advertised UUID information when a device is | |
89 // discovered during a scan. | |
90 void CreateOrUpdateDeviceOnScan(JNIEnv* env, | |
91 jobject obj, | |
Jeffrey Yasskin
2015/07/07 00:11:14
What's |obj|? Maybe comment the expected types for
scheib
2015/07/08 00:49:10
The first two parameters are standard JNI form. I'
Jeffrey Yasskin
2015/07/08 17:19:38
Cool, thanks.
Should bluetooth_device_wrapper and
scheib
2015/07/08 23:02:34
OK. /shrug/ this is a bit of a mess, and the C++ c
| |
92 const jstring& address, | |
93 jobject bluetooth_device_wrapper, | |
94 jobject advertised_uuids); | |
95 | |
86 protected: | 96 protected: |
87 BluetoothAdapterAndroid(); | 97 BluetoothAdapterAndroid(); |
88 ~BluetoothAdapterAndroid() override; | 98 ~BluetoothAdapterAndroid() override; |
89 | 99 |
90 // BluetoothAdapter: | 100 // BluetoothAdapter: |
91 void AddDiscoverySession(BluetoothDiscoveryFilter* discovery_filter, | 101 void AddDiscoverySession(BluetoothDiscoveryFilter* discovery_filter, |
92 const base::Closure& callback, | 102 const base::Closure& callback, |
93 const ErrorCallback& error_callback) override; | 103 const ErrorCallback& error_callback) override; |
94 void RemoveDiscoverySession(BluetoothDiscoveryFilter* discovery_filter, | 104 void RemoveDiscoverySession(BluetoothDiscoveryFilter* discovery_filter, |
95 const base::Closure& callback, | 105 const base::Closure& callback, |
(...skipping 13 matching lines...) Expand all Loading... | |
109 // Note: This should remain the last member so it'll be destroyed and | 119 // Note: This should remain the last member so it'll be destroyed and |
110 // invalidate its weak pointers before any other members are destroyed. | 120 // invalidate its weak pointers before any other members are destroyed. |
111 base::WeakPtrFactory<BluetoothAdapterAndroid> weak_ptr_factory_; | 121 base::WeakPtrFactory<BluetoothAdapterAndroid> weak_ptr_factory_; |
112 | 122 |
113 DISALLOW_COPY_AND_ASSIGN(BluetoothAdapterAndroid); | 123 DISALLOW_COPY_AND_ASSIGN(BluetoothAdapterAndroid); |
114 }; | 124 }; |
115 | 125 |
116 } // namespace device | 126 } // namespace device |
117 | 127 |
118 #endif // DEVICE_BLUETOOTH_BLUETOOTH_ADAPTER_ANDROID_H_ | 128 #endif // DEVICE_BLUETOOTH_BLUETOOTH_ADAPTER_ANDROID_H_ |
OLD | NEW |