OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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 #include "device/bluetooth/bluetooth_remote_gatt_characteristic_android.h" | 5 #include "device/bluetooth/bluetooth_remote_gatt_characteristic_android.h" |
6 | 6 |
7 #include <memory> | 7 #include <memory> |
8 | 8 |
9 #include "base/android/jni_android.h" | 9 #include "base/android/jni_android.h" |
10 #include "base/android/jni_array.h" | 10 #include "base/android/jni_array.h" |
(...skipping 266 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
277 | 277 |
278 // Clear callbacks before calling to avoid reentrancy issues. | 278 // Clear callbacks before calling to avoid reentrancy issues. |
279 ValueCallback read_callback = read_callback_; | 279 ValueCallback read_callback = read_callback_; |
280 ErrorCallback read_error_callback = read_error_callback_; | 280 ErrorCallback read_error_callback = read_error_callback_; |
281 read_callback_.Reset(); | 281 read_callback_.Reset(); |
282 read_error_callback_.Reset(); | 282 read_error_callback_.Reset(); |
283 | 283 |
284 if (status == 0 // android.bluetooth.BluetoothGatt.GATT_SUCCESS | 284 if (status == 0 // android.bluetooth.BluetoothGatt.GATT_SUCCESS |
285 && !read_callback.is_null()) { | 285 && !read_callback.is_null()) { |
286 base::android::JavaByteArrayToByteVector(env, value, &value_); | 286 base::android::JavaByteArrayToByteVector(env, value, &value_); |
| 287 adapter_->NotifyGattCharacteristicValueChanged(this, value_); |
287 read_callback.Run(value_); | 288 read_callback.Run(value_); |
288 // TODO(https://crbug.com/545682): Call GattCharacteristicValueChanged. | |
289 } else if (!read_error_callback.is_null()) { | 289 } else if (!read_error_callback.is_null()) { |
290 read_error_callback.Run( | 290 read_error_callback.Run( |
291 BluetoothRemoteGattServiceAndroid::GetGattErrorCode(status)); | 291 BluetoothRemoteGattServiceAndroid::GetGattErrorCode(status)); |
292 } | 292 } |
293 } | 293 } |
294 | 294 |
295 void BluetoothRemoteGattCharacteristicAndroid::OnWrite( | 295 void BluetoothRemoteGattCharacteristicAndroid::OnWrite( |
296 JNIEnv* env, | 296 JNIEnv* env, |
297 const JavaParamRef<jobject>& jcaller, | 297 const JavaParamRef<jobject>& jcaller, |
298 int32_t status) { | 298 int32_t status) { |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
343 void BluetoothRemoteGattCharacteristicAndroid::EnsureDescriptorsCreated() | 343 void BluetoothRemoteGattCharacteristicAndroid::EnsureDescriptorsCreated() |
344 const { | 344 const { |
345 if (!descriptors_.empty()) | 345 if (!descriptors_.empty()) |
346 return; | 346 return; |
347 | 347 |
348 Java_ChromeBluetoothRemoteGattCharacteristic_createDescriptors( | 348 Java_ChromeBluetoothRemoteGattCharacteristic_createDescriptors( |
349 AttachCurrentThread(), j_characteristic_.obj()); | 349 AttachCurrentThread(), j_characteristic_.obj()); |
350 } | 350 } |
351 | 351 |
352 } // namespace device | 352 } // namespace device |
OLD | NEW |