| OLD | NEW |
| (Empty) | |
| 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 |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #ifndef DEVICE_BLUETOOTH_BLUETOOTH_REMOTE_GATT_DESCRIPTOR_ANDROID_H_ |
| 6 #define DEVICE_BLUETOOTH_BLUETOOTH_REMOTE_GATT_DESCRIPTOR_ANDROID_H_ |
| 7 |
| 8 #include "base/android/jni_android.h" |
| 9 #include "base/macros.h" |
| 10 #include "device/bluetooth/bluetooth_gatt_descriptor.h" |
| 11 |
| 12 namespace device { |
| 13 |
| 14 class BluetoothAdapterAndroid; |
| 15 |
| 16 // BluetoothRemoteGattDescriptorAndroid along with its owned Java class |
| 17 // org.chromium.device.bluetooth.ChromeBluetoothRemoteGattDescriptor |
| 18 // implement BluetootGattDescriptor. |
| 19 class DEVICE_BLUETOOTH_EXPORT BluetoothRemoteGattDescriptorAndroid |
| 20 : public BluetoothGattDescriptor { |
| 21 public: |
| 22 // Create a BluetoothRemoteGattDescriptorAndroid instance and associated |
| 23 // Java ChromeBluetoothRemoteGattDescriptor using the provided |
| 24 // |bluetooth_gatt_descriptor_wrapper|. |
| 25 // |
| 26 // The ChromeBluetoothRemoteGattDescriptor instance will hold a Java |
| 27 // reference to |bluetooth_gatt_descriptor_wrapper|. |
| 28 static scoped_ptr<BluetoothRemoteGattDescriptorAndroid> Create( |
| 29 BluetoothAdapterAndroid* adapter, |
| 30 const std::string& instanceId, |
| 31 jobject /* BluetoothGattDescriptorWrapper */ |
| 32 bluetooth_gatt_descriptor_wrapper, |
| 33 jobject /* chromeBluetoothDevice */ chrome_bluetooth_device); |
| 34 |
| 35 ~BluetoothRemoteGattDescriptorAndroid() override; |
| 36 |
| 37 // Register C++ methods exposed to Java using JNI. |
| 38 static bool RegisterJNI(JNIEnv* env); |
| 39 |
| 40 // Returns the associated ChromeBluetoothRemoteGattDescriptor Java object. |
| 41 base::android::ScopedJavaLocalRef<jobject> GetJavaObject(); |
| 42 |
| 43 // BluetoothGattDescriptor interface: |
| 44 std::string GetIdentifier() const override; |
| 45 BluetoothUUID GetUUID() const override; |
| 46 bool IsLocal() const override; |
| 47 const std::vector<uint8_t>& GetValue() const override; |
| 48 BluetoothGattCharacteristic* GetCharacteristic() const override; |
| 49 BluetoothGattCharacteristic::Permissions GetPermissions() const override; |
| 50 void ReadRemoteDescriptor(const ValueCallback& callback, |
| 51 const ErrorCallback& error_callback) override; |
| 52 void WriteRemoteDescriptor(const std::vector<uint8_t>& new_value, |
| 53 const base::Closure& callback, |
| 54 const ErrorCallback& error_callback) override; |
| 55 |
| 56 private: |
| 57 BluetoothRemoteGattDescriptorAndroid(BluetoothAdapterAndroid* adapter, |
| 58 const std::string& instanceId); |
| 59 |
| 60 // The adapter associated with this service. It's ok to store a raw pointer |
| 61 // here since |adapter_| indirectly owns this instance. |
| 62 BluetoothAdapterAndroid* adapter_; |
| 63 |
| 64 // Java object |
| 65 // org.chromium.device.bluetooth.ChromeBluetoothRemoteGattDescriptor. |
| 66 base::android::ScopedJavaGlobalRef<jobject> j_descriptor_; |
| 67 |
| 68 // Adapter unique instance ID. |
| 69 std::string instance_id_; |
| 70 |
| 71 DISALLOW_COPY_AND_ASSIGN(BluetoothRemoteGattDescriptorAndroid); |
| 72 }; |
| 73 |
| 74 } // namespace device |
| 75 |
| 76 #endif // DEVICE_BLUETOOTH_BLUETOOTH_REMOTE_GATT_DESCRIPTOR_ANDROID_H_ |
| OLD | NEW |