Chromium Code Reviews| Index: device/bluetooth/bluetooth_remote_gatt_descriptor_android.cc |
| diff --git a/device/bluetooth/bluetooth_remote_gatt_descriptor_android.cc b/device/bluetooth/bluetooth_remote_gatt_descriptor_android.cc |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..cdeb9c492db4ab1d063801031581c32173b84478 |
| --- /dev/null |
| +++ b/device/bluetooth/bluetooth_remote_gatt_descriptor_android.cc |
| @@ -0,0 +1,117 @@ |
| +// Copyright 2016 The Chromium Authors. All rights reserved. |
| +// Use of this source code is governed by a BSD-style license that can be |
| +// found in the LICENSE file. |
| + |
| +#include "device/bluetooth/bluetooth_remote_gatt_descriptor_android.h" |
| + |
| +#include "base/android/jni_android.h" |
| +#include "base/android/jni_array.h" |
| +#include "base/android/jni_string.h" |
| +#include "base/bind.h" |
| +#include "base/logging.h" |
| +#include "base/message_loop/message_loop.h" |
| +#include "device/bluetooth/bluetooth_adapter_android.h" |
| +#include "device/bluetooth/bluetooth_gatt_notify_session_android.h" |
| +#include "device/bluetooth/bluetooth_remote_gatt_service_android.h" |
| +#include "jni/ChromeBluetoothRemoteGattDescriptor_jni.h" |
| + |
| +using base::android::AttachCurrentThread; |
| + |
| +namespace device { |
| + |
| +// static |
| +scoped_ptr<BluetoothRemoteGattDescriptorAndroid> |
| +BluetoothRemoteGattDescriptorAndroid::Create( |
| + BluetoothAdapterAndroid* adapter, |
| + const std::string& instance_id, |
| + jobject /* BluetoothGattDescriptorWrapper */ |
| + bluetooth_gatt_descriptor_wrapper, |
| + jobject /* chromeBluetoothDevice */ |
| + chrome_bluetooth_device) { |
| + scoped_ptr<BluetoothRemoteGattDescriptorAndroid> descriptor( |
| + new BluetoothRemoteGattDescriptorAndroid(adapter, instance_id)); |
| + |
| + descriptor->j_descriptor_.Reset( |
| + Java_ChromeBluetoothRemoteGattDescriptor_create( |
| + AttachCurrentThread(), |
| + // TODO(scheib) Will eventually need to pass c++ pointer: |
| + // reinterpret_cast<intptr_t>(descriptor.get()), |
| + bluetooth_gatt_descriptor_wrapper, chrome_bluetooth_device)); |
| + |
| + return descriptor; |
| +} |
| + |
| +BluetoothRemoteGattDescriptorAndroid::~BluetoothRemoteGattDescriptorAndroid() { |
| + Java_ChromeBluetoothRemoteGattDescriptor_onBluetoothRemoteGattDescriptorAndroidDestruction( |
| + AttachCurrentThread(), j_descriptor_.obj()); |
| +} |
| + |
| +// static |
| +bool BluetoothRemoteGattDescriptorAndroid::RegisterJNI(JNIEnv* env) { |
| + return RegisterNativesImpl( |
| + env); // Generated in ChromeBluetoothRemoteGattDescriptor_jni.h |
| +} |
| + |
| +base::android::ScopedJavaLocalRef<jobject> |
| +BluetoothRemoteGattDescriptorAndroid::GetJavaObject() { |
| + return base::android::ScopedJavaLocalRef<jobject>(j_descriptor_); |
| +} |
| + |
| +std::string BluetoothRemoteGattDescriptorAndroid::GetIdentifier() const { |
| + return instance_id_; |
| +} |
| + |
| +BluetoothUUID BluetoothRemoteGattDescriptorAndroid::GetUUID() const { |
| + return device::BluetoothUUID( |
| + ConvertJavaStringToUTF8(Java_ChromeBluetoothRemoteGattDescriptor_getUUID( |
| + AttachCurrentThread(), j_descriptor_.obj()))); |
| +} |
| + |
| +bool BluetoothRemoteGattDescriptorAndroid::IsLocal() const { |
| + return false; |
| +} |
| + |
| +const std::vector<uint8_t>& BluetoothRemoteGattDescriptorAndroid::GetValue() |
| + const { |
| + NOTIMPLEMENTED(); |
| + static std::vector<uint8_t> empty_value; |
| + return empty_value; |
| +} |
| + |
| +BluetoothGattCharacteristic* |
| +BluetoothRemoteGattDescriptorAndroid::GetCharacteristic() const { |
| + NOTIMPLEMENTED(); |
| + return nullptr; |
| +} |
| + |
| +BluetoothGattCharacteristic::Permissions |
| +BluetoothRemoteGattDescriptorAndroid::GetPermissions() const { |
| + NOTIMPLEMENTED(); |
| + return 0; |
| +} |
| + |
| +void BluetoothRemoteGattDescriptorAndroid::ReadRemoteDescriptor( |
| + const ValueCallback& callback, |
| + const ErrorCallback& error_callback) { |
| + NOTIMPLEMENTED(); |
| + base::MessageLoop::current()->PostTask( |
| + FROM_HERE, |
| + base::Bind(error_callback, BluetoothGattService::GATT_ERROR_FAILED)); |
| +} |
| + |
| +void BluetoothRemoteGattDescriptorAndroid::WriteRemoteDescriptor( |
| + const std::vector<uint8_t>& new_value, |
| + const base::Closure& callback, |
| + const ErrorCallback& error_callback) { |
| + NOTIMPLEMENTED(); |
| + base::MessageLoop::current()->PostTask( |
| + FROM_HERE, |
| + base::Bind(error_callback, BluetoothGattService::GATT_ERROR_FAILED)); |
| +} |
| + |
| +BluetoothRemoteGattDescriptorAndroid::BluetoothRemoteGattDescriptorAndroid( |
| + BluetoothAdapterAndroid* adapter, |
| + const std::string& instance_id) |
| + : adapter_(adapter), instance_id_(instance_id) {} |
|
Jeffrey Yasskin
2016/01/12 21:53:54
I don't see any uses of adapter_. What's it for?
Jeffrey Yasskin
2016/01/12 23:25:59
Ping.
scheib
2016/01/12 23:54:46
Done (removed). It's for a later patch where we wi
|
| + |
| +} // namespace device |