| 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 // BluetoothRemoteGattDescriptorAndroid along with its owned Java class |
| 15 // org.chromium.device.bluetooth.ChromeBluetoothRemoteGattDescriptor |
| 16 // implement BluetootGattDescriptor. |
| 17 class DEVICE_BLUETOOTH_EXPORT BluetoothRemoteGattDescriptorAndroid |
| 18 : public BluetoothGattDescriptor { |
| 19 public: |
| 20 // Create a BluetoothRemoteGattDescriptorAndroid instance and associated |
| 21 // Java ChromeBluetoothRemoteGattDescriptor using the provided |
| 22 // |bluetooth_gatt_descriptor_wrapper|. |
| 23 // |
| 24 // The ChromeBluetoothRemoteGattDescriptor instance will hold a Java |
| 25 // reference to |bluetooth_gatt_descriptor_wrapper|. |
| 26 static scoped_ptr<BluetoothRemoteGattDescriptorAndroid> Create( |
| 27 const std::string& instanceId, |
| 28 jobject /* BluetoothGattDescriptorWrapper */ |
| 29 bluetooth_gatt_descriptor_wrapper, |
| 30 jobject /* chromeBluetoothDevice */ chrome_bluetooth_device); |
| 31 |
| 32 ~BluetoothRemoteGattDescriptorAndroid() override; |
| 33 |
| 34 // Register C++ methods exposed to Java using JNI. |
| 35 static bool RegisterJNI(JNIEnv* env); |
| 36 |
| 37 // Returns the associated ChromeBluetoothRemoteGattDescriptor Java object. |
| 38 base::android::ScopedJavaLocalRef<jobject> GetJavaObject(); |
| 39 |
| 40 // BluetoothGattDescriptor interface: |
| 41 std::string GetIdentifier() const override; |
| 42 BluetoothUUID GetUUID() const override; |
| 43 bool IsLocal() const override; |
| 44 const std::vector<uint8_t>& GetValue() const override; |
| 45 BluetoothGattCharacteristic* GetCharacteristic() const override; |
| 46 BluetoothGattCharacteristic::Permissions GetPermissions() const override; |
| 47 void ReadRemoteDescriptor(const ValueCallback& callback, |
| 48 const ErrorCallback& error_callback) override; |
| 49 void WriteRemoteDescriptor(const std::vector<uint8_t>& new_value, |
| 50 const base::Closure& callback, |
| 51 const ErrorCallback& error_callback) override; |
| 52 |
| 53 private: |
| 54 BluetoothRemoteGattDescriptorAndroid(const std::string& instanceId); |
| 55 |
| 56 // Java object |
| 57 // org.chromium.device.bluetooth.ChromeBluetoothRemoteGattDescriptor. |
| 58 base::android::ScopedJavaGlobalRef<jobject> j_descriptor_; |
| 59 |
| 60 // Adapter unique instance ID. |
| 61 std::string instance_id_; |
| 62 |
| 63 DISALLOW_COPY_AND_ASSIGN(BluetoothRemoteGattDescriptorAndroid); |
| 64 }; |
| 65 |
| 66 } // namespace device |
| 67 |
| 68 #endif // DEVICE_BLUETOOTH_BLUETOOTH_REMOTE_GATT_DESCRIPTOR_ANDROID_H_ |
| OLD | NEW |