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 "base/android/jni_android.h" | 7 #include "base/android/jni_android.h" |
8 #include "base/android/jni_array.h" | 8 #include "base/android/jni_array.h" |
9 #include "base/android/jni_string.h" | 9 #include "base/android/jni_string.h" |
10 #include "base/bind.h" | 10 #include "base/bind.h" |
(...skipping 190 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
201 write_pending_ = true; | 201 write_pending_ = true; |
202 write_callback_ = callback; | 202 write_callback_ = callback; |
203 write_error_callback_ = error_callback; | 203 write_error_callback_ = error_callback; |
204 } | 204 } |
205 | 205 |
206 void BluetoothRemoteGattCharacteristicAndroid::OnChanged( | 206 void BluetoothRemoteGattCharacteristicAndroid::OnChanged( |
207 JNIEnv* env, | 207 JNIEnv* env, |
208 const JavaParamRef<jobject>& jcaller, | 208 const JavaParamRef<jobject>& jcaller, |
209 const JavaParamRef<jbyteArray>& value) { | 209 const JavaParamRef<jbyteArray>& value) { |
210 base::android::JavaByteArrayToByteVector(env, value, &value_); | 210 base::android::JavaByteArrayToByteVector(env, value, &value_); |
211 FOR_EACH_OBSERVER(BluetoothAdapter::Observer, adapter_->GetObservers(), | 211 adapter_->NotifyGattCharacteristicValueChanged(this, value_); |
212 GattCharacteristicValueChanged(adapter_, this, value_)); | |
213 } | 212 } |
214 | 213 |
215 void BluetoothRemoteGattCharacteristicAndroid::OnRead( | 214 void BluetoothRemoteGattCharacteristicAndroid::OnRead( |
216 JNIEnv* env, | 215 JNIEnv* env, |
217 const JavaParamRef<jobject>& jcaller, | 216 const JavaParamRef<jobject>& jcaller, |
218 int32_t status, | 217 int32_t status, |
219 const JavaParamRef<jbyteArray>& value) { | 218 const JavaParamRef<jbyteArray>& value) { |
220 read_pending_ = false; | 219 read_pending_ = false; |
221 | 220 |
222 // Clear callbacks before calling to avoid reentrancy issues. | 221 // Clear callbacks before calling to avoid reentrancy issues. |
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
287 void BluetoothRemoteGattCharacteristicAndroid::EnsureDescriptorsCreated() | 286 void BluetoothRemoteGattCharacteristicAndroid::EnsureDescriptorsCreated() |
288 const { | 287 const { |
289 if (!descriptors_.empty()) | 288 if (!descriptors_.empty()) |
290 return; | 289 return; |
291 | 290 |
292 Java_ChromeBluetoothRemoteGattCharacteristic_createDescriptors( | 291 Java_ChromeBluetoothRemoteGattCharacteristic_createDescriptors( |
293 AttachCurrentThread(), j_characteristic_.obj()); | 292 AttachCurrentThread(), j_characteristic_.obj()); |
294 } | 293 } |
295 | 294 |
296 } // namespace device | 295 } // namespace device |
OLD | NEW |