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

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

Issue 1583583003: bluetooth: android: Implement characteristic GetService. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@bta-descriptors-
Patch Set: Created 4 years, 11 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
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_REMOTE_GATT_CHARACTERISTIC_ANDROID_H_ 5 #ifndef DEVICE_BLUETOOTH_BLUETOOTH_REMOTE_GATT_CHARACTERISTIC_ANDROID_H_
6 #define DEVICE_BLUETOOTH_BLUETOOTH_REMOTE_GATT_CHARACTERISTIC_ANDROID_H_ 6 #define DEVICE_BLUETOOTH_BLUETOOTH_REMOTE_GATT_CHARACTERISTIC_ANDROID_H_
7 7
8 #include <stdint.h> 8 #include <stdint.h>
9 9
10 #include "base/android/jni_android.h" 10 #include "base/android/jni_android.h"
11 #include "base/containers/scoped_ptr_hash_map.h" 11 #include "base/containers/scoped_ptr_hash_map.h"
12 #include "base/macros.h" 12 #include "base/macros.h"
13 #include "device/bluetooth/bluetooth_gatt_characteristic.h" 13 #include "device/bluetooth/bluetooth_gatt_characteristic.h"
14 14
15 namespace device { 15 namespace device {
16 16
17 class BluetoothAdapterAndroid; 17 class BluetoothAdapterAndroid;
18 class BluetoothRemoteGattDescriptorAndroid; 18 class BluetoothRemoteGattDescriptorAndroid;
19 class BluetoothRemoteGattServiceAndroid;
19 20
20 // BluetoothRemoteGattCharacteristicAndroid along with its owned Java class 21 // BluetoothRemoteGattCharacteristicAndroid along with its owned Java class
21 // org.chromium.device.bluetooth.ChromeBluetoothRemoteGattCharacteristic 22 // org.chromium.device.bluetooth.ChromeBluetoothRemoteGattCharacteristic
22 // implement BluetootGattCharacteristic. 23 // implement BluetootGattCharacteristic.
23 // 24 //
24 // TODO(crbug.com/551634): When notifications are enabled characteristic updates 25 // TODO(crbug.com/551634): When notifications are enabled characteristic updates
25 // should call observers' GattCharacteristicValueChanged. 26 // should call observers' GattCharacteristicValueChanged.
26 class DEVICE_BLUETOOTH_EXPORT BluetoothRemoteGattCharacteristicAndroid 27 class DEVICE_BLUETOOTH_EXPORT BluetoothRemoteGattCharacteristicAndroid
27 : public BluetoothGattCharacteristic { 28 : public BluetoothGattCharacteristic {
28 public: 29 public:
29 // Create a BluetoothRemoteGattCharacteristicAndroid instance and associated 30 // Create a BluetoothRemoteGattCharacteristicAndroid instance and associated
30 // Java 31 // Java
31 // ChromeBluetoothRemoteGattCharacteristic using the provided 32 // ChromeBluetoothRemoteGattCharacteristic using the provided
32 // |bluetooth_gatt_characteristic_wrapper|. 33 // |bluetooth_gatt_characteristic_wrapper|.
33 // 34 //
34 // The ChromeBluetoothRemoteGattCharacteristic instance will hold a Java 35 // The ChromeBluetoothRemoteGattCharacteristic instance will hold a Java
35 // reference 36 // reference
36 // to |bluetooth_gatt_characteristic_wrapper|. 37 // to |bluetooth_gatt_characteristic_wrapper|.
37 static scoped_ptr<BluetoothRemoteGattCharacteristicAndroid> Create( 38 static scoped_ptr<BluetoothRemoteGattCharacteristicAndroid> Create(
38 BluetoothAdapterAndroid* adapter, 39 BluetoothAdapterAndroid* adapter,
40 BluetoothRemoteGattServiceAndroid* service,
39 const std::string& instance_id, 41 const std::string& instance_id,
40 jobject /* BluetoothGattCharacteristicWrapper */ 42 jobject /* BluetoothGattCharacteristicWrapper */
41 bluetooth_gatt_characteristic_wrapper, 43 bluetooth_gatt_characteristic_wrapper,
42 jobject /* ChromeBluetoothDevice */ chrome_bluetooth_device); 44 jobject /* ChromeBluetoothDevice */ chrome_bluetooth_device);
43 45
44 ~BluetoothRemoteGattCharacteristicAndroid() override; 46 ~BluetoothRemoteGattCharacteristicAndroid() override;
45 47
46 // Register C++ methods exposed to Java using JNI. 48 // Register C++ methods exposed to Java using JNI.
47 static bool RegisterJNI(JNIEnv* env); 49 static bool RegisterJNI(JNIEnv* env);
48 50
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
89 const base::android::JavaParamRef<jobject>& caller, 91 const base::android::JavaParamRef<jobject>& caller,
90 const base::android::JavaParamRef<jstring>& instanceId, 92 const base::android::JavaParamRef<jstring>& instanceId,
91 const base::android::JavaParamRef< 93 const base::android::JavaParamRef<
92 jobject>& /* BluetoothGattDescriptorWrapper */ 94 jobject>& /* BluetoothGattDescriptorWrapper */
93 bluetooth_gatt_descriptor_wrapper, 95 bluetooth_gatt_descriptor_wrapper,
94 const base::android::JavaParamRef< 96 const base::android::JavaParamRef<
95 jobject>& /* ChromeBluetoothCharacteristic */ 97 jobject>& /* ChromeBluetoothCharacteristic */
96 chrome_bluetooth_characteristic); 98 chrome_bluetooth_characteristic);
97 99
98 private: 100 private:
99 BluetoothRemoteGattCharacteristicAndroid(BluetoothAdapterAndroid* adapter, 101 BluetoothRemoteGattCharacteristicAndroid(
100 const std::string& instance_id); 102 BluetoothAdapterAndroid* adapter,
103 BluetoothRemoteGattServiceAndroid* service,
104 const std::string& instance_id);
101 105
102 // Populates |descriptors_| from Java objects if necessary. 106 // Populates |descriptors_| from Java objects if necessary.
103 void EnsureDescriptorsCreated() const; 107 void EnsureDescriptorsCreated() const;
104 108
105 // The adapter associated with this service. It's ok to store a raw pointer 109 // The adapter and service associated with this characteristic. It's ok to
106 // here since |adapter_| indirectly owns this instance. 110 // store a raw pointers here since they indirectly own this instance.
107 BluetoothAdapterAndroid* adapter_; 111 BluetoothAdapterAndroid* adapter_;
112 BluetoothRemoteGattServiceAndroid* service_;
108 113
109 // Java object 114 // Java object
110 // org.chromium.device.bluetooth.ChromeBluetoothRemoteGattCharacteristic. 115 // org.chromium.device.bluetooth.ChromeBluetoothRemoteGattCharacteristic.
111 base::android::ScopedJavaGlobalRef<jobject> j_characteristic_; 116 base::android::ScopedJavaGlobalRef<jobject> j_characteristic_;
112 117
113 // Adapter unique instance ID. 118 // Adapter unique instance ID.
114 std::string instance_id_; 119 std::string instance_id_;
115 120
116 // ReadRemoteCharacteristic callbacks and pending state. 121 // ReadRemoteCharacteristic callbacks and pending state.
117 bool read_pending_ = false; 122 bool read_pending_ = false;
(...skipping 11 matching lines...) Expand all
129 base::ScopedPtrHashMap<std::string, 134 base::ScopedPtrHashMap<std::string,
130 scoped_ptr<BluetoothRemoteGattDescriptorAndroid>> 135 scoped_ptr<BluetoothRemoteGattDescriptorAndroid>>
131 descriptors_; 136 descriptors_;
132 137
133 DISALLOW_COPY_AND_ASSIGN(BluetoothRemoteGattCharacteristicAndroid); 138 DISALLOW_COPY_AND_ASSIGN(BluetoothRemoteGattCharacteristicAndroid);
134 }; 139 };
135 140
136 } // namespace device 141 } // namespace device
137 142
138 #endif // DEVICE_BLUETOOTH_BLUETOOTH_REMOTE_GATT_CHARACTERISTIC_ANDROID_H_ 143 #endif // DEVICE_BLUETOOTH_BLUETOOTH_REMOTE_GATT_CHARACTERISTIC_ANDROID_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698