Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(249)

Unified Diff: device/bluetooth/bluetooth_remote_gatt_characteristic_android.cc

Issue 1422463012: bluetooth: android: Implement StartNotifySession. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: addressed ortuno Created 5 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: device/bluetooth/bluetooth_remote_gatt_characteristic_android.cc
diff --git a/device/bluetooth/bluetooth_remote_gatt_characteristic_android.cc b/device/bluetooth/bluetooth_remote_gatt_characteristic_android.cc
index f0825f6b360bcf38bc4a3cfedca980fa9290896e..8d5868b5caa368efe8431210acc00a5cf8a39c3b 100644
--- a/device/bluetooth/bluetooth_remote_gatt_characteristic_android.cc
+++ b/device/bluetooth/bluetooth_remote_gatt_characteristic_android.cc
@@ -10,6 +10,7 @@
#include "base/bind.h"
#include "base/logging.h"
#include "base/message_loop/message_loop.h"
+#include "device/bluetooth/bluetooth_gatt_notify_session_android.h"
#include "device/bluetooth/bluetooth_remote_gatt_service_android.h"
#include "jni/ChromeBluetoothRemoteGattCharacteristic_jni.h"
@@ -54,7 +55,7 @@ BluetoothRemoteGattCharacteristicAndroid::GetJavaObject() {
}
std::string BluetoothRemoteGattCharacteristicAndroid::GetIdentifier() const {
- return instanceId_;
+ return instance_id_;
}
BluetoothUUID BluetoothRemoteGattCharacteristicAndroid::GetUUID() const {
@@ -123,7 +124,20 @@ bool BluetoothRemoteGattCharacteristicAndroid::UpdateValue(
void BluetoothRemoteGattCharacteristicAndroid::StartNotifySession(
const NotifySessionCallback& callback,
const ErrorCallback& error_callback) {
- NOTIMPLEMENTED();
+ // TODO(crbug.com/551634): Check characteristic properties and return a better
+ // error code if notifications aren't permitted.
+ if (Java_ChromeBluetoothRemoteGattCharacteristic_startNotifySession(
+ AttachCurrentThread(), j_characteristic_.obj())) {
+ scoped_ptr<device::BluetoothGattNotifySession> notify_session(
+ new BluetoothGattNotifySessionAndroid(instance_id_));
+ base::MessageLoop::current()->PostTask(
+ FROM_HERE, base::Bind(callback, base::Passed(&notify_session)));
+ } else {
+ base::MessageLoop::current()->PostTask(
+ FROM_HERE,
+ base::Bind(error_callback,
+ BluetoothRemoteGattServiceAndroid::GATT_ERROR_FAILED));
+ }
}
void BluetoothRemoteGattCharacteristicAndroid::ReadRemoteCharacteristic(
@@ -215,6 +229,6 @@ void BluetoothRemoteGattCharacteristicAndroid::OnWrite(JNIEnv* env,
BluetoothRemoteGattCharacteristicAndroid::
BluetoothRemoteGattCharacteristicAndroid(const std::string& instanceId)
- : instanceId_(instanceId) {}
+ : instance_id_(instanceId) {}
} // namespace device

Powered by Google App Engine
This is Rietveld 408576698