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 223 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
234 ->GetDescriptorsByUUID(BluetoothRemoteGattDescriptor:: | 234 ->GetDescriptorsByUUID(BluetoothRemoteGattDescriptor:: |
235 ClientCharacteristicConfigurationUuid()) | 235 ClientCharacteristicConfigurationUuid()) |
236 .at(0)); | 236 .at(0)); |
237 } | 237 } |
238 Java_FakeBluetoothGattDescriptor_valueWrite( | 238 Java_FakeBluetoothGattDescriptor_valueWrite( |
239 base::android::AttachCurrentThread(), | 239 base::android::AttachCurrentThread(), |
240 descriptor_android ? descriptor_android->GetJavaObject().obj() : nullptr, | 240 descriptor_android ? descriptor_android->GetJavaObject().obj() : nullptr, |
241 BluetoothRemoteGattServiceAndroid::GetAndroidErrorCode(error_code)); | 241 BluetoothRemoteGattServiceAndroid::GetAndroidErrorCode(error_code)); |
242 } | 242 } |
243 | 243 |
244 void BluetoothTestAndroid::SimulateGattNotifySessionStopped( | |
245 BluetoothRemoteGattCharacteristic* characteristic) { | |
246 BluetoothRemoteGattDescriptorAndroid* descriptor_android = nullptr; | |
247 if (characteristic) { | |
248 descriptor_android = static_cast<BluetoothRemoteGattDescriptorAndroid*>( | |
249 characteristic | |
250 ->GetDescriptorsByUUID(BluetoothRemoteGattDescriptor:: | |
251 ClientCharacteristicConfigurationUuid()) | |
252 .at(0)); | |
253 } | |
254 Java_FakeBluetoothGattDescriptor_valueWrite( | |
255 base::android::AttachCurrentThread(), | |
256 descriptor_android ? descriptor_android->GetJavaObject().obj() : nullptr, | |
257 0); // android.bluetooth.BluetoothGatt.GATT_SUCCESS | |
258 } | |
259 | |
260 void BluetoothTestAndroid::SimulateGattNotifySessionStopError( | |
261 BluetoothRemoteGattCharacteristic* characteristic, | |
262 BluetoothRemoteGattService::GattErrorCode error_code) { | |
263 BluetoothRemoteGattDescriptorAndroid* descriptor_android = nullptr; | |
264 if (characteristic) { | |
265 descriptor_android = static_cast<BluetoothRemoteGattDescriptorAndroid*>( | |
266 characteristic | |
267 ->GetDescriptorsByUUID(BluetoothRemoteGattDescriptor:: | |
268 ClientCharacteristicConfigurationUuid()) | |
269 .at(0)); | |
270 } | |
271 Java_FakeBluetoothGattDescriptor_valueWrite( | |
272 base::android::AttachCurrentThread(), | |
273 descriptor_android ? descriptor_android->GetJavaObject().obj() : nullptr, | |
274 BluetoothRemoteGattServiceAndroid::GetAndroidErrorCode(error_code)); | |
275 } | |
276 | |
277 void BluetoothTestAndroid:: | 244 void BluetoothTestAndroid:: |
278 SimulateGattCharacteristicSetNotifyWillFailSynchronouslyOnce( | 245 SimulateGattCharacteristicSetNotifyWillFailSynchronouslyOnce( |
279 BluetoothRemoteGattCharacteristic* characteristic) { | 246 BluetoothRemoteGattCharacteristic* characteristic) { |
280 BluetoothRemoteGattCharacteristicAndroid* characteristic_android = | 247 BluetoothRemoteGattCharacteristicAndroid* characteristic_android = |
281 static_cast<BluetoothRemoteGattCharacteristicAndroid*>(characteristic); | 248 static_cast<BluetoothRemoteGattCharacteristicAndroid*>(characteristic); |
282 JNIEnv* env = base::android::AttachCurrentThread(); | 249 JNIEnv* env = base::android::AttachCurrentThread(); |
283 | 250 |
284 Java_FakeBluetoothGattCharacteristic_setCharacteristicNotificationWillFailSync
hronouslyOnce( | 251 Java_FakeBluetoothGattCharacteristic_setCharacteristicNotificationWillFailSync
hronouslyOnce( |
285 env, characteristic_android->GetJavaObject()); | 252 env, characteristic_android->GetJavaObject()); |
286 } | 253 } |
(...skipping 236 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
523 } | 490 } |
524 | 491 |
525 void BluetoothTestAndroid::OnFakeAdapterStateChanged( | 492 void BluetoothTestAndroid::OnFakeAdapterStateChanged( |
526 JNIEnv* env, | 493 JNIEnv* env, |
527 const JavaParamRef<jobject>& caller, | 494 const JavaParamRef<jobject>& caller, |
528 const bool powered) { | 495 const bool powered) { |
529 adapter_->NotifyAdapterPoweredChanged(powered); | 496 adapter_->NotifyAdapterPoweredChanged(powered); |
530 } | 497 } |
531 | 498 |
532 } // namespace device | 499 } // namespace device |
OLD | NEW |