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