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

Side by Side Diff: device/bluetooth/test/bluetooth_test_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: addressed jyasskin 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 unified diff | Download patch
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/test/bluetooth_test_android.h" 5 #include "device/bluetooth/test/bluetooth_test_android.h"
6 6
7 #include <iterator> 7 #include <iterator>
8 #include <sstream> 8 #include <sstream>
9 9
10 #include "base/android/jni_array.h" 10 #include "base/android/jni_array.h"
(...skipping 197 matching lines...) Expand 10 before | Expand all | Expand 10 after
208 SimulateGattCharacteristicSetNotifyWillFailSynchronouslyOnce( 208 SimulateGattCharacteristicSetNotifyWillFailSynchronouslyOnce(
209 BluetoothGattCharacteristic* characteristic) { 209 BluetoothGattCharacteristic* characteristic) {
210 BluetoothRemoteGattCharacteristicAndroid* characteristic_android = 210 BluetoothRemoteGattCharacteristicAndroid* characteristic_android =
211 static_cast<BluetoothRemoteGattCharacteristicAndroid*>(characteristic); 211 static_cast<BluetoothRemoteGattCharacteristicAndroid*>(characteristic);
212 JNIEnv* env = base::android::AttachCurrentThread(); 212 JNIEnv* env = base::android::AttachCurrentThread();
213 213
214 Java_FakeBluetoothGattCharacteristic_setCharacteristicNotificationWillFailSync hronouslyOnce( 214 Java_FakeBluetoothGattCharacteristic_setCharacteristicNotificationWillFailSync hronouslyOnce(
215 env, characteristic_android->GetJavaObject().obj()); 215 env, characteristic_android->GetJavaObject().obj());
216 } 216 }
217 217
218 void BluetoothTestAndroid::SimulateGattCharacteristicChanged(
219 BluetoothGattCharacteristic* characteristic,
220 const std::vector<uint8_t>& value) {
221 BluetoothRemoteGattCharacteristicAndroid* characteristic_android =
222 static_cast<BluetoothRemoteGattCharacteristicAndroid*>(characteristic);
223 JNIEnv* env = base::android::AttachCurrentThread();
224
225 Java_FakeBluetoothGattCharacteristic_valueChanged(
226 env,
227 characteristic_android ? characteristic_android->GetJavaObject().obj()
228 : nullptr,
229 base::android::ToJavaByteArray(env, value).obj());
230 }
231
218 void BluetoothTestAndroid::SimulateGattCharacteristicRead( 232 void BluetoothTestAndroid::SimulateGattCharacteristicRead(
219 BluetoothGattCharacteristic* characteristic, 233 BluetoothGattCharacteristic* characteristic,
220 const std::vector<uint8_t>& value) { 234 const std::vector<uint8_t>& value) {
221 BluetoothRemoteGattCharacteristicAndroid* characteristic_android = 235 BluetoothRemoteGattCharacteristicAndroid* characteristic_android =
222 static_cast<BluetoothRemoteGattCharacteristicAndroid*>(characteristic); 236 static_cast<BluetoothRemoteGattCharacteristicAndroid*>(characteristic);
223 JNIEnv* env = base::android::AttachCurrentThread(); 237 JNIEnv* env = base::android::AttachCurrentThread();
224 238
225 Java_FakeBluetoothGattCharacteristic_valueRead( 239 Java_FakeBluetoothGattCharacteristic_valueRead(
226 env, 240 env,
227 characteristic_android ? characteristic_android->GetJavaObject().obj() 241 characteristic_android ? characteristic_android->GetJavaObject().obj()
(...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after
348 362
349 void BluetoothTestAndroid::OnFakeBluetoothGattWriteDescriptor( 363 void BluetoothTestAndroid::OnFakeBluetoothGattWriteDescriptor(
350 JNIEnv* env, 364 JNIEnv* env,
351 const JavaParamRef<jobject>& caller, 365 const JavaParamRef<jobject>& caller,
352 const JavaParamRef<jbyteArray>& value) { 366 const JavaParamRef<jbyteArray>& value) {
353 gatt_write_descriptor_attempts_++; 367 gatt_write_descriptor_attempts_++;
354 base::android::JavaByteArrayToByteVector(env, value, &last_write_value_); 368 base::android::JavaByteArrayToByteVector(env, value, &last_write_value_);
355 } 369 }
356 370
357 } // namespace device 371 } // namespace device
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698