| 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 176 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 187 BluetoothRemoteGattCharacteristicAndroid* characteristic_android = | 187 BluetoothRemoteGattCharacteristicAndroid* characteristic_android = |
| 188 static_cast<BluetoothRemoteGattCharacteristicAndroid*>(characteristic); | 188 static_cast<BluetoothRemoteGattCharacteristicAndroid*>(characteristic); |
| 189 JNIEnv* env = base::android::AttachCurrentThread(); | 189 JNIEnv* env = base::android::AttachCurrentThread(); |
| 190 | 190 |
| 191 Java_FakeBluetoothGattCharacteristic_setCharacteristicNotificationWillFailSync
hronouslyOnce( | 191 Java_FakeBluetoothGattCharacteristic_setCharacteristicNotificationWillFailSync
hronouslyOnce( |
| 192 env, characteristic_android->GetJavaObject().obj()); | 192 env, characteristic_android->GetJavaObject().obj()); |
| 193 } | 193 } |
| 194 | 194 |
| 195 void BluetoothTestAndroid::SimulateGattCharacteristicRead( | 195 void BluetoothTestAndroid::SimulateGattCharacteristicRead( |
| 196 BluetoothGattCharacteristic* characteristic, | 196 BluetoothGattCharacteristic* characteristic, |
| 197 const std::vector<uint8>& value) { | 197 const std::vector<uint8_t>& value) { |
| 198 BluetoothRemoteGattCharacteristicAndroid* characteristic_android = | 198 BluetoothRemoteGattCharacteristicAndroid* characteristic_android = |
| 199 static_cast<BluetoothRemoteGattCharacteristicAndroid*>(characteristic); | 199 static_cast<BluetoothRemoteGattCharacteristicAndroid*>(characteristic); |
| 200 JNIEnv* env = base::android::AttachCurrentThread(); | 200 JNIEnv* env = base::android::AttachCurrentThread(); |
| 201 | 201 |
| 202 Java_FakeBluetoothGattCharacteristic_valueRead( | 202 Java_FakeBluetoothGattCharacteristic_valueRead( |
| 203 env, | 203 env, |
| 204 characteristic_android ? characteristic_android->GetJavaObject().obj() | 204 characteristic_android ? characteristic_android->GetJavaObject().obj() |
| 205 : nullptr, | 205 : nullptr, |
| 206 0, // android.bluetooth.BluetoothGatt.GATT_SUCCESS | 206 0, // android.bluetooth.BluetoothGatt.GATT_SUCCESS |
| 207 base::android::ToJavaByteArray(env, value).obj()); | 207 base::android::ToJavaByteArray(env, value).obj()); |
| 208 } | 208 } |
| 209 | 209 |
| 210 void BluetoothTestAndroid::SimulateGattCharacteristicReadError( | 210 void BluetoothTestAndroid::SimulateGattCharacteristicReadError( |
| 211 BluetoothGattCharacteristic* characteristic, | 211 BluetoothGattCharacteristic* characteristic, |
| 212 BluetoothGattService::GattErrorCode error_code) { | 212 BluetoothGattService::GattErrorCode error_code) { |
| 213 BluetoothRemoteGattCharacteristicAndroid* characteristic_android = | 213 BluetoothRemoteGattCharacteristicAndroid* characteristic_android = |
| 214 static_cast<BluetoothRemoteGattCharacteristicAndroid*>(characteristic); | 214 static_cast<BluetoothRemoteGattCharacteristicAndroid*>(characteristic); |
| 215 JNIEnv* env = base::android::AttachCurrentThread(); | 215 JNIEnv* env = base::android::AttachCurrentThread(); |
| 216 std::vector<uint8> empty_value; | 216 std::vector<uint8_t> empty_value; |
| 217 | 217 |
| 218 Java_FakeBluetoothGattCharacteristic_valueRead( | 218 Java_FakeBluetoothGattCharacteristic_valueRead( |
| 219 env, characteristic_android->GetJavaObject().obj(), | 219 env, characteristic_android->GetJavaObject().obj(), |
| 220 BluetoothRemoteGattServiceAndroid::GetAndroidErrorCode(error_code), | 220 BluetoothRemoteGattServiceAndroid::GetAndroidErrorCode(error_code), |
| 221 base::android::ToJavaByteArray(env, empty_value).obj()); | 221 base::android::ToJavaByteArray(env, empty_value).obj()); |
| 222 } | 222 } |
| 223 | 223 |
| 224 void BluetoothTestAndroid:: | 224 void BluetoothTestAndroid:: |
| 225 SimulateGattCharacteristicReadWillFailSynchronouslyOnce( | 225 SimulateGattCharacteristicReadWillFailSynchronouslyOnce( |
| 226 BluetoothGattCharacteristic* characteristic) { | 226 BluetoothGattCharacteristic* characteristic) { |
| (...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 296 | 296 |
| 297 void BluetoothTestAndroid::OnFakeBluetoothGattWriteCharacteristic( | 297 void BluetoothTestAndroid::OnFakeBluetoothGattWriteCharacteristic( |
| 298 JNIEnv* env, | 298 JNIEnv* env, |
| 299 const JavaParamRef<jobject>& caller, | 299 const JavaParamRef<jobject>& caller, |
| 300 const JavaParamRef<jbyteArray>& value) { | 300 const JavaParamRef<jbyteArray>& value) { |
| 301 gatt_write_characteristic_attempts_++; | 301 gatt_write_characteristic_attempts_++; |
| 302 base::android::JavaByteArrayToByteVector(env, value, &last_write_value_); | 302 base::android::JavaByteArrayToByteVector(env, value, &last_write_value_); |
| 303 } | 303 } |
| 304 | 304 |
| 305 } // namespace device | 305 } // namespace device |
| OLD | NEW |