| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 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 | 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_DESCRIPTOR_ANDROID_H_ | 5 #ifndef DEVICE_BLUETOOTH_BLUETOOTH_REMOTE_GATT_DESCRIPTOR_ANDROID_H_ |
| 6 #define DEVICE_BLUETOOTH_BLUETOOTH_REMOTE_GATT_DESCRIPTOR_ANDROID_H_ | 6 #define DEVICE_BLUETOOTH_BLUETOOTH_REMOTE_GATT_DESCRIPTOR_ANDROID_H_ |
| 7 | 7 |
| 8 #include <memory> | 8 #include <memory> |
| 9 | 9 |
| 10 #include "base/android/jni_android.h" | 10 #include "base/android/jni_android.h" |
| 11 #include "base/macros.h" | 11 #include "base/macros.h" |
| 12 #include "device/bluetooth/bluetooth_gatt_descriptor.h" | 12 #include "device/bluetooth/bluetooth_remote_gatt_descriptor.h" |
| 13 | 13 |
| 14 namespace device { | 14 namespace device { |
| 15 | 15 |
| 16 // BluetoothRemoteGattDescriptorAndroid along with its owned Java class | 16 // BluetoothRemoteGattDescriptorAndroid along with its owned Java class |
| 17 // org.chromium.device.bluetooth.ChromeBluetoothRemoteGattDescriptor | 17 // org.chromium.device.bluetooth.ChromeBluetoothRemoteGattDescriptor |
| 18 // implement BluetootGattDescriptor. | 18 // implement BluetootGattDescriptor. |
| 19 class DEVICE_BLUETOOTH_EXPORT BluetoothRemoteGattDescriptorAndroid | 19 class DEVICE_BLUETOOTH_EXPORT BluetoothRemoteGattDescriptorAndroid |
| 20 : public BluetoothGattDescriptor { | 20 : public BluetoothRemoteGattDescriptor { |
| 21 public: | 21 public: |
| 22 // Create a BluetoothRemoteGattDescriptorAndroid instance and associated | 22 // Create a BluetoothRemoteGattDescriptorAndroid instance and associated |
| 23 // Java ChromeBluetoothRemoteGattDescriptor using the provided | 23 // Java ChromeBluetoothRemoteGattDescriptor using the provided |
| 24 // |bluetooth_gatt_descriptor_wrapper|. | 24 // |bluetooth_gatt_descriptor_wrapper|. |
| 25 // | 25 // |
| 26 // The ChromeBluetoothRemoteGattDescriptor instance will hold a Java | 26 // The ChromeBluetoothRemoteGattDescriptor instance will hold a Java |
| 27 // reference to |bluetooth_gatt_descriptor_wrapper|. | 27 // reference to |bluetooth_gatt_descriptor_wrapper|. |
| 28 static std::unique_ptr<BluetoothRemoteGattDescriptorAndroid> Create( | 28 static std::unique_ptr<BluetoothRemoteGattDescriptorAndroid> Create( |
| 29 const std::string& instanceId, | 29 const std::string& instanceId, |
| 30 jobject /* BluetoothGattDescriptorWrapper */ | 30 jobject /* BluetoothGattDescriptorWrapper */ |
| 31 bluetooth_gatt_descriptor_wrapper, | 31 bluetooth_gatt_descriptor_wrapper, |
| 32 jobject /* chromeBluetoothDevice */ chrome_bluetooth_device); | 32 jobject /* chromeBluetoothDevice */ chrome_bluetooth_device); |
| 33 | 33 |
| 34 ~BluetoothRemoteGattDescriptorAndroid() override; | 34 ~BluetoothRemoteGattDescriptorAndroid() override; |
| 35 | 35 |
| 36 // Register C++ methods exposed to Java using JNI. | 36 // Register C++ methods exposed to Java using JNI. |
| 37 static bool RegisterJNI(JNIEnv* env); | 37 static bool RegisterJNI(JNIEnv* env); |
| 38 | 38 |
| 39 // Returns the associated ChromeBluetoothRemoteGattDescriptor Java object. | 39 // Returns the associated ChromeBluetoothRemoteGattDescriptor Java object. |
| 40 base::android::ScopedJavaLocalRef<jobject> GetJavaObject(); | 40 base::android::ScopedJavaLocalRef<jobject> GetJavaObject(); |
| 41 | 41 |
| 42 // BluetoothGattDescriptor interface: | 42 // BluetoothRemoteGattDescriptor interface: |
| 43 std::string GetIdentifier() const override; | 43 std::string GetIdentifier() const override; |
| 44 BluetoothUUID GetUUID() const override; | 44 BluetoothUUID GetUUID() const override; |
| 45 bool IsLocal() const override; | 45 bool IsLocal() const override; |
| 46 const std::vector<uint8_t>& GetValue() const override; | 46 const std::vector<uint8_t>& GetValue() const override; |
| 47 BluetoothGattCharacteristic* GetCharacteristic() const override; | 47 BluetoothRemoteGattCharacteristic* GetCharacteristic() const override; |
| 48 BluetoothGattCharacteristic::Permissions GetPermissions() const override; | 48 BluetoothRemoteGattCharacteristic::Permissions GetPermissions() |
| 49 const override; |
| 49 void ReadRemoteDescriptor(const ValueCallback& callback, | 50 void ReadRemoteDescriptor(const ValueCallback& callback, |
| 50 const ErrorCallback& error_callback) override; | 51 const ErrorCallback& error_callback) override; |
| 51 void WriteRemoteDescriptor(const std::vector<uint8_t>& new_value, | 52 void WriteRemoteDescriptor(const std::vector<uint8_t>& new_value, |
| 52 const base::Closure& callback, | 53 const base::Closure& callback, |
| 53 const ErrorCallback& error_callback) override; | 54 const ErrorCallback& error_callback) override; |
| 54 | 55 |
| 55 // Called when Read operation completes. | 56 // Called when Read operation completes. |
| 56 void OnRead(JNIEnv* env, | 57 void OnRead(JNIEnv* env, |
| 57 const base::android::JavaParamRef<jobject>& jcaller, | 58 const base::android::JavaParamRef<jobject>& jcaller, |
| 58 int32_t status, | 59 int32_t status, |
| (...skipping 25 matching lines...) Expand all Loading... |
| 84 ErrorCallback write_error_callback_; | 85 ErrorCallback write_error_callback_; |
| 85 | 86 |
| 86 std::vector<uint8_t> value_; | 87 std::vector<uint8_t> value_; |
| 87 | 88 |
| 88 DISALLOW_COPY_AND_ASSIGN(BluetoothRemoteGattDescriptorAndroid); | 89 DISALLOW_COPY_AND_ASSIGN(BluetoothRemoteGattDescriptorAndroid); |
| 89 }; | 90 }; |
| 90 | 91 |
| 91 } // namespace device | 92 } // namespace device |
| 92 | 93 |
| 93 #endif // DEVICE_BLUETOOTH_BLUETOOTH_REMOTE_GATT_DESCRIPTOR_ANDROID_H_ | 94 #endif // DEVICE_BLUETOOTH_BLUETOOTH_REMOTE_GATT_DESCRIPTOR_ANDROID_H_ |
| OLD | NEW |