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

Side by Side Diff: device/bluetooth/bluetooth_remote_gatt_characteristic_android.cc

Issue 2728623004: Fix getting notified twice after subscribe to notifications and call readValue (Closed)
Patch Set: updated test code Created 3 years, 9 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 unified diff | Download patch
« no previous file with comments | « no previous file | device/bluetooth/bluetooth_remote_gatt_characteristic_mac.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 184 matching lines...) Expand 10 before | Expand all | Expand 10 after
195 195
196 // Clear callbacks before calling to avoid reentrancy issues. 196 // Clear callbacks before calling to avoid reentrancy issues.
197 ValueCallback read_callback = read_callback_; 197 ValueCallback read_callback = read_callback_;
198 ErrorCallback read_error_callback = read_error_callback_; 198 ErrorCallback read_error_callback = read_error_callback_;
199 read_callback_.Reset(); 199 read_callback_.Reset();
200 read_error_callback_.Reset(); 200 read_error_callback_.Reset();
201 201
202 if (status == 0 // android.bluetooth.BluetoothGatt.GATT_SUCCESS 202 if (status == 0 // android.bluetooth.BluetoothGatt.GATT_SUCCESS
203 && !read_callback.is_null()) { 203 && !read_callback.is_null()) {
204 base::android::JavaByteArrayToByteVector(env, value, &value_); 204 base::android::JavaByteArrayToByteVector(env, value, &value_);
205 adapter_->NotifyGattCharacteristicValueChanged(this, value_);
206 read_callback.Run(value_); 205 read_callback.Run(value_);
207 } else if (!read_error_callback.is_null()) { 206 } else if (!read_error_callback.is_null()) {
208 read_error_callback.Run( 207 read_error_callback.Run(
209 BluetoothRemoteGattServiceAndroid::GetGattErrorCode(status)); 208 BluetoothRemoteGattServiceAndroid::GetGattErrorCode(status));
210 } 209 }
211 } 210 }
212 211
213 void BluetoothRemoteGattCharacteristicAndroid::OnWrite( 212 void BluetoothRemoteGattCharacteristicAndroid::OnWrite(
214 JNIEnv* env, 213 JNIEnv* env,
215 const JavaParamRef<jobject>& jcaller, 214 const JavaParamRef<jobject>& jcaller,
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after
299 void BluetoothRemoteGattCharacteristicAndroid::EnsureDescriptorsCreated() 298 void BluetoothRemoteGattCharacteristicAndroid::EnsureDescriptorsCreated()
300 const { 299 const {
301 if (!descriptors_.empty()) 300 if (!descriptors_.empty())
302 return; 301 return;
303 302
304 Java_ChromeBluetoothRemoteGattCharacteristic_createDescriptors( 303 Java_ChromeBluetoothRemoteGattCharacteristic_createDescriptors(
305 AttachCurrentThread(), j_characteristic_); 304 AttachCurrentThread(), j_characteristic_);
306 } 305 }
307 306
308 } // namespace device 307 } // namespace device
OLDNEW
« no previous file with comments | « no previous file | device/bluetooth/bluetooth_remote_gatt_characteristic_mac.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698