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

Unified Diff: device/bluetooth/bluetooth_remote_gatt_characteristic_android.cc

Issue 1502833002: bluetooth: android: Enable characteristic change notification events. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@bta-check-null-
Patch Set: fix imports Created 4 years, 11 months 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 bb5aeade9950439169f405ca43de48bcc2af59bc..f3ab38516a145d9d17611c67ed8940eab3d07252 100644
--- a/device/bluetooth/bluetooth_remote_gatt_characteristic_android.cc
+++ b/device/bluetooth/bluetooth_remote_gatt_characteristic_android.cc
@@ -136,10 +136,10 @@ bool BluetoothRemoteGattCharacteristicAndroid::UpdateValue(
void BluetoothRemoteGattCharacteristicAndroid::StartNotifySession(
const NotifySessionCallback& callback,
const ErrorCallback& error_callback) {
- // 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())) {
+ // TODO(crbug.com/569664): Wait until descriptor write completes before
+ // reporting success via calling |callback|.
scoped_ptr<device::BluetoothGattNotifySession> notify_session(
new BluetoothGattNotifySessionAndroid(instance_id_));
base::MessageLoop::current()->PostTask(
@@ -203,6 +203,15 @@ void BluetoothRemoteGattCharacteristicAndroid::WriteRemoteCharacteristic(
write_error_callback_ = error_callback;
}
+void BluetoothRemoteGattCharacteristicAndroid::OnChanged(
+ JNIEnv* env,
+ const JavaParamRef<jobject>& jcaller,
+ const JavaParamRef<jbyteArray>& value) {
+ base::android::JavaByteArrayToByteVector(env, value, &value_);
+ FOR_EACH_OBSERVER(BluetoothAdapter::Observer, adapter_->GetObservers(),
+ GattCharacteristicValueChanged(adapter_, this, value_));
+}
+
void BluetoothRemoteGattCharacteristicAndroid::OnRead(
JNIEnv* env,
const JavaParamRef<jobject>& jcaller,
@@ -220,6 +229,7 @@ void BluetoothRemoteGattCharacteristicAndroid::OnRead(
&& !read_callback.is_null()) {
base::android::JavaByteArrayToByteVector(env, value, &value_);
read_callback.Run(value_);
+ // TODO(https://crbug.com/545682): Call GattCharacteristicValueChanged.
} else if (!read_error_callback.is_null()) {
read_error_callback.Run(
BluetoothRemoteGattServiceAndroid::GetGattErrorCode(status));
@@ -241,6 +251,7 @@ void BluetoothRemoteGattCharacteristicAndroid::OnWrite(
if (status == 0 // android.bluetooth.BluetoothGatt.GATT_SUCCESS
&& !write_callback.is_null()) {
write_callback.Run();
+ // TODO(https://crbug.com/545682): Call GattCharacteristicValueChanged.
} else if (!write_error_callback.is_null()) {
write_error_callback.Run(
BluetoothRemoteGattServiceAndroid::GetGattErrorCode(status));

Powered by Google App Engine
This is Rietveld 408576698