| 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 150 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 161 Java_FakeBluetoothGattService_addCharacteristic( | 161 Java_FakeBluetoothGattService_addCharacteristic( |
| 162 env, service_android->GetJavaObject().obj(), | 162 env, service_android->GetJavaObject().obj(), |
| 163 base::android::ConvertUTF8ToJavaString(env, uuid).obj(), properties); | 163 base::android::ConvertUTF8ToJavaString(env, uuid).obj(), properties); |
| 164 } | 164 } |
| 165 | 165 |
| 166 void BluetoothTestAndroid::RememberCharacteristicForSubsequentAction( | 166 void BluetoothTestAndroid::RememberCharacteristicForSubsequentAction( |
| 167 BluetoothGattCharacteristic* characteristic) { | 167 BluetoothGattCharacteristic* characteristic) { |
| 168 BluetoothRemoteGattCharacteristicAndroid* characteristic_android = | 168 BluetoothRemoteGattCharacteristicAndroid* characteristic_android = |
| 169 static_cast<BluetoothRemoteGattCharacteristicAndroid*>(characteristic); | 169 static_cast<BluetoothRemoteGattCharacteristicAndroid*>(characteristic); |
| 170 | 170 |
| 171 Java_FakeBluetoothGattCharacteristic_rememberCharacteristic( | 171 Java_FakeBluetoothGattCharacteristic_rememberCharacteristicForSubsequentAction
( |
| 172 base::android::AttachCurrentThread(), | 172 base::android::AttachCurrentThread(), |
| 173 characteristic_android->GetJavaObject().obj()); | 173 characteristic_android->GetJavaObject().obj()); |
| 174 } | 174 } |
| 175 | 175 |
| 176 void BluetoothTestAndroid::SimulateGattNotifySessionStarted( | 176 void BluetoothTestAndroid::SimulateGattNotifySessionStarted( |
| 177 BluetoothGattCharacteristic* characteristic) { | 177 BluetoothGattCharacteristic* characteristic) { |
| 178 // Android doesn't provide any sort of callback for when notifications have | 178 // Android doesn't provide any sort of callback for when notifications have |
| 179 // been enabled. So, just run the message loop to process the success | 179 // been enabled. So, just run the message loop to process the success |
| 180 // callback. | 180 // callback. |
| 181 base::RunLoop().RunUntilIdle(); | 181 base::RunLoop().RunUntilIdle(); |
| (...skipping 114 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 |