| 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 |
| 244 void BluetoothTestAndroid:: | 277 void BluetoothTestAndroid:: |
| 245 SimulateGattCharacteristicSetNotifyWillFailSynchronouslyOnce( | 278 SimulateGattCharacteristicSetNotifyWillFailSynchronouslyOnce( |
| 246 BluetoothRemoteGattCharacteristic* characteristic) { | 279 BluetoothRemoteGattCharacteristic* characteristic) { |
| 247 BluetoothRemoteGattCharacteristicAndroid* characteristic_android = | 280 BluetoothRemoteGattCharacteristicAndroid* characteristic_android = |
| 248 static_cast<BluetoothRemoteGattCharacteristicAndroid*>(characteristic); | 281 static_cast<BluetoothRemoteGattCharacteristicAndroid*>(characteristic); |
| 249 JNIEnv* env = base::android::AttachCurrentThread(); | 282 JNIEnv* env = base::android::AttachCurrentThread(); |
| 250 | 283 |
| 251 Java_FakeBluetoothGattCharacteristic_setCharacteristicNotificationWillFailSync
hronouslyOnce( | 284 Java_FakeBluetoothGattCharacteristic_setCharacteristicNotificationWillFailSync
hronouslyOnce( |
| 252 env, characteristic_android->GetJavaObject()); | 285 env, characteristic_android->GetJavaObject()); |
| 253 } | 286 } |
| (...skipping 236 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 490 } | 523 } |
| 491 | 524 |
| 492 void BluetoothTestAndroid::OnFakeAdapterStateChanged( | 525 void BluetoothTestAndroid::OnFakeAdapterStateChanged( |
| 493 JNIEnv* env, | 526 JNIEnv* env, |
| 494 const JavaParamRef<jobject>& caller, | 527 const JavaParamRef<jobject>& caller, |
| 495 const bool powered) { | 528 const bool powered) { |
| 496 adapter_->NotifyAdapterPoweredChanged(powered); | 529 adapter_->NotifyAdapterPoweredChanged(powered); |
| 497 } | 530 } |
| 498 | 531 |
| 499 } // namespace device | 532 } // namespace device |
| OLD | NEW |