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

Side by Side Diff: device/bluetooth/bluetooth_adapter_android.h

Issue 1215303006: bluetooth: android: Initial BluetoothDeviceAndroid implementation. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@bta-discovery-
Patch Set: Merge TOT Created 5 years, 5 months 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
« no previous file with comments | « device/bluetooth/bluetooth.gyp ('k') | device/bluetooth/bluetooth_adapter_android.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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_. The adapter also owns a tree of
31 // additional C++ objects (Devices, Services, Characteristics, Descriptors),
32 // with each 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 |bluetooth_adapter_wrapper|.
41 static base::WeakPtr<BluetoothAdapterAndroid> Create( 43 static base::WeakPtr<BluetoothAdapterAndroid> Create(
42 jobject java_bluetooth_adapter_wrapper); 44 jobject bluetooth_adapter_wrapper); // Java Type: bluetoothAdapterWrapper
43 45
44 // Register C++ methods exposed to Java using JNI. 46 // Register C++ methods exposed to Java using JNI.
45 static bool RegisterJNI(JNIEnv* env); 47 static bool RegisterJNI(JNIEnv* env);
46 48
47 // BluetoothAdapter: 49 // BluetoothAdapter:
48 std::string GetAddress() const override; 50 std::string GetAddress() const override;
49 std::string GetName() const override; 51 std::string GetName() const override;
50 void SetName(const std::string& name, 52 void SetName(const std::string& name,
51 const base::Closure& callback, 53 const base::Closure& callback,
52 const ErrorCallback& error_callback) override; 54 const ErrorCallback& error_callback) override;
(...skipping 21 matching lines...) Expand all
74 void RegisterAudioSink( 76 void RegisterAudioSink(
75 const BluetoothAudioSink::Options& options, 77 const BluetoothAudioSink::Options& options,
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 caller);
87
88 // Creates or updates device with advertised UUID information when a device is
89 // discovered during a scan.
90 void CreateOrUpdateDeviceOnScan(
91 JNIEnv* env,
92 jobject caller,
93 const jstring& address,
94 jobject bluetooth_device_wrapper, // Java Type: bluetoothDeviceWrapper
95 jobject advertised_uuids); // Java Type: List<ParcelUuid>
85 96
86 protected: 97 protected:
87 BluetoothAdapterAndroid(); 98 BluetoothAdapterAndroid();
88 ~BluetoothAdapterAndroid() override; 99 ~BluetoothAdapterAndroid() override;
89 100
90 // BluetoothAdapter: 101 // BluetoothAdapter:
91 void AddDiscoverySession(BluetoothDiscoveryFilter* discovery_filter, 102 void AddDiscoverySession(BluetoothDiscoveryFilter* discovery_filter,
92 const base::Closure& callback, 103 const base::Closure& callback,
93 const ErrorCallback& error_callback) override; 104 const ErrorCallback& error_callback) override;
94 void RemoveDiscoverySession(BluetoothDiscoveryFilter* discovery_filter, 105 void RemoveDiscoverySession(BluetoothDiscoveryFilter* discovery_filter,
(...skipping 14 matching lines...) Expand all
109 // Note: This should remain the last member so it'll be destroyed and 120 // Note: This should remain the last member so it'll be destroyed and
110 // invalidate its weak pointers before any other members are destroyed. 121 // invalidate its weak pointers before any other members are destroyed.
111 base::WeakPtrFactory<BluetoothAdapterAndroid> weak_ptr_factory_; 122 base::WeakPtrFactory<BluetoothAdapterAndroid> weak_ptr_factory_;
112 123
113 DISALLOW_COPY_AND_ASSIGN(BluetoothAdapterAndroid); 124 DISALLOW_COPY_AND_ASSIGN(BluetoothAdapterAndroid);
114 }; 125 };
115 126
116 } // namespace device 127 } // namespace device
117 128
118 #endif // DEVICE_BLUETOOTH_BLUETOOTH_ADAPTER_ANDROID_H_ 129 #endif // DEVICE_BLUETOOTH_BLUETOOTH_ADAPTER_ANDROID_H_
OLDNEW
« no previous file with comments | « device/bluetooth/bluetooth.gyp ('k') | device/bluetooth/bluetooth_adapter_android.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698