| 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/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 175 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 186 SimulateGattCharacteristicSetNotifyWillFailSynchronouslyOnce( | 186 SimulateGattCharacteristicSetNotifyWillFailSynchronouslyOnce( |
| 187 BluetoothGattCharacteristic* characteristic) { | 187 BluetoothGattCharacteristic* characteristic) { |
| 188 BluetoothRemoteGattCharacteristicAndroid* characteristic_android = | 188 BluetoothRemoteGattCharacteristicAndroid* characteristic_android = |
| 189 static_cast<BluetoothRemoteGattCharacteristicAndroid*>(characteristic); | 189 static_cast<BluetoothRemoteGattCharacteristicAndroid*>(characteristic); |
| 190 JNIEnv* env = base::android::AttachCurrentThread(); | 190 JNIEnv* env = base::android::AttachCurrentThread(); |
| 191 | 191 |
| 192 Java_FakeBluetoothGattCharacteristic_setCharacteristicNotificationWillFailSync
hronouslyOnce( | 192 Java_FakeBluetoothGattCharacteristic_setCharacteristicNotificationWillFailSync
hronouslyOnce( |
| 193 env, characteristic_android->GetJavaObject().obj()); | 193 env, characteristic_android->GetJavaObject().obj()); |
| 194 } | 194 } |
| 195 | 195 |
| 196 void BluetoothTestAndroid::SimulateGattCharacteristicChanged( |
| 197 BluetoothGattCharacteristic* characteristic, |
| 198 const std::vector<uint8_t>& value) { |
| 199 BluetoothRemoteGattCharacteristicAndroid* characteristic_android = |
| 200 static_cast<BluetoothRemoteGattCharacteristicAndroid*>(characteristic); |
| 201 JNIEnv* env = base::android::AttachCurrentThread(); |
| 202 |
| 203 Java_FakeBluetoothGattCharacteristic_valueChanged( |
| 204 env, |
| 205 characteristic_android ? characteristic_android->GetJavaObject().obj() |
| 206 : nullptr, |
| 207 base::android::ToJavaByteArray(env, value).obj()); |
| 208 } |
| 209 |
| 196 void BluetoothTestAndroid::SimulateGattCharacteristicRead( | 210 void BluetoothTestAndroid::SimulateGattCharacteristicRead( |
| 197 BluetoothGattCharacteristic* characteristic, | 211 BluetoothGattCharacteristic* characteristic, |
| 198 const std::vector<uint8_t>& value) { | 212 const std::vector<uint8_t>& value) { |
| 199 BluetoothRemoteGattCharacteristicAndroid* characteristic_android = | 213 BluetoothRemoteGattCharacteristicAndroid* characteristic_android = |
| 200 static_cast<BluetoothRemoteGattCharacteristicAndroid*>(characteristic); | 214 static_cast<BluetoothRemoteGattCharacteristicAndroid*>(characteristic); |
| 201 JNIEnv* env = base::android::AttachCurrentThread(); | 215 JNIEnv* env = base::android::AttachCurrentThread(); |
| 202 | 216 |
| 203 Java_FakeBluetoothGattCharacteristic_valueRead( | 217 Java_FakeBluetoothGattCharacteristic_valueRead( |
| 204 env, | 218 env, |
| 205 characteristic_android ? characteristic_android->GetJavaObject().obj() | 219 characteristic_android ? characteristic_android->GetJavaObject().obj() |
| (...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 326 | 340 |
| 327 void BluetoothTestAndroid::OnFakeBluetoothGattWriteDescriptor( | 341 void BluetoothTestAndroid::OnFakeBluetoothGattWriteDescriptor( |
| 328 JNIEnv* env, | 342 JNIEnv* env, |
| 329 const JavaParamRef<jobject>& caller, | 343 const JavaParamRef<jobject>& caller, |
| 330 const JavaParamRef<jbyteArray>& value) { | 344 const JavaParamRef<jbyteArray>& value) { |
| 331 gatt_write_descriptor_attempts_++; | 345 gatt_write_descriptor_attempts_++; |
| 332 base::android::JavaByteArrayToByteVector(env, value, &last_write_value_); | 346 base::android::JavaByteArrayToByteVector(env, value, &last_write_value_); |
| 333 } | 347 } |
| 334 | 348 |
| 335 } // namespace device | 349 } // namespace device |
| OLD | NEW |