#ifndef DEVICE_BLUETOOTH_BLUETOOTH_REMOTE_GATT_DESCRIPTOR_ANDROID_H_
#define DEVICE_BLUETOOTH_BLUETOOTH_REMOTE_GATT_DESCRIPTOR_ANDROID_H_
#include <memory>
#include "base/android/jni_android.h"
#include "base/android/scoped_java_ref.h"
#include "device/bluetooth/bluetooth_remote_gatt_characteristic.h"
#include "device/bluetooth/bluetooth_remote_gatt_descriptor.h"
namespace device {
class DEVICE_BLUETOOTH_EXPORT BluetoothRemoteGattDescriptorAndroid
: public BluetoothRemoteGattDescriptor {
public:
static std::unique_ptr<BluetoothRemoteGattDescriptorAndroid> Create(
const std::string& instanceId,
const base::android::JavaRef<jobject>&
*/
bluetooth_gatt_descriptor_wrapper,
const base::android::JavaRef<
jobject>& chrome_bluetooth_device);
BluetoothRemoteGattDescriptorAndroid(
const BluetoothRemoteGattDescriptorAndroid&) = delete;
BluetoothRemoteGattDescriptorAndroid& operator=(
const BluetoothRemoteGattDescriptorAndroid&) = delete;
~BluetoothRemoteGattDescriptorAndroid() override;
base::android::ScopedJavaLocalRef<jobject> GetJavaObject();
std::string GetIdentifier() const override;
BluetoothUUID GetUUID() const override;
const std::vector<uint8_t>& GetValue() const override;
BluetoothRemoteGattCharacteristic* GetCharacteristic() const override;
BluetoothRemoteGattCharacteristic::Permissions GetPermissions()
const override;
void ReadRemoteDescriptor(ValueCallback callback) override;
void WriteRemoteDescriptor(const std::vector<uint8_t>& value,
base::OnceClosure callback,
ErrorCallback error_callback) override;
void OnRead(JNIEnv* env,
const base::android::JavaParamRef<jobject>& jcaller,
int32_t status,
const base::android::JavaParamRef<jbyteArray>& value);
void OnWrite(JNIEnv* env,
const base::android::JavaParamRef<jobject>& jcaller,
int32_t status);
private:
BluetoothRemoteGattDescriptorAndroid(const std::string& instanceId);
base::android::ScopedJavaGlobalRef<jobject> j_descriptor_;
std::string instance_id_;
bool read_pending_ = false;
ValueCallback read_callback_;
bool write_pending_ = false;
base::OnceClosure write_callback_;
ErrorCallback write_error_callback_;
std::vector<uint8_t> value_;
};
}
#endif