| 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 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 65 } | 65 } |
| 66 | 66 |
| 67 BluetoothDevice* BluetoothTestAndroid::DiscoverLowEnergyDevice( | 67 BluetoothDevice* BluetoothTestAndroid::DiscoverLowEnergyDevice( |
| 68 int device_ordinal) { | 68 int device_ordinal) { |
| 69 TestBluetoothAdapterObserver observer(adapter_); | 69 TestBluetoothAdapterObserver observer(adapter_); |
| 70 Java_FakeBluetoothAdapter_discoverLowEnergyDevice( | 70 Java_FakeBluetoothAdapter_discoverLowEnergyDevice( |
| 71 AttachCurrentThread(), j_fake_bluetooth_adapter_.obj(), device_ordinal); | 71 AttachCurrentThread(), j_fake_bluetooth_adapter_.obj(), device_ordinal); |
| 72 return observer.last_device(); | 72 return observer.last_device(); |
| 73 } | 73 } |
| 74 | 74 |
| 75 void BluetoothTestAndroid::ForceIllegalStateException() { |
| 76 Java_FakeBluetoothAdapter_forceIllegalStateException( |
| 77 AttachCurrentThread(), j_fake_bluetooth_adapter_.obj()); |
| 78 } |
| 79 |
| 75 void BluetoothTestAndroid::SimulateGattConnection(BluetoothDevice* device) { | 80 void BluetoothTestAndroid::SimulateGattConnection(BluetoothDevice* device) { |
| 76 BluetoothDeviceAndroid* device_android = | 81 BluetoothDeviceAndroid* device_android = |
| 77 static_cast<BluetoothDeviceAndroid*>(device); | 82 static_cast<BluetoothDeviceAndroid*>(device); |
| 78 | 83 |
| 79 Java_FakeBluetoothDevice_connectionStateChange( | 84 Java_FakeBluetoothDevice_connectionStateChange( |
| 80 AttachCurrentThread(), device_android->GetJavaObject().obj(), | 85 AttachCurrentThread(), device_android->GetJavaObject().obj(), |
| 81 0, // android.bluetooth.BluetoothGatt.GATT_SUCCESS | 86 0, // android.bluetooth.BluetoothGatt.GATT_SUCCESS |
| 82 true); // connected | 87 true); // connected |
| 83 } | 88 } |
| 84 | 89 |
| (...skipping 241 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 326 | 331 |
| 327 void BluetoothTestAndroid::OnFakeBluetoothGattWriteDescriptor( | 332 void BluetoothTestAndroid::OnFakeBluetoothGattWriteDescriptor( |
| 328 JNIEnv* env, | 333 JNIEnv* env, |
| 329 const JavaParamRef<jobject>& caller, | 334 const JavaParamRef<jobject>& caller, |
| 330 const JavaParamRef<jbyteArray>& value) { | 335 const JavaParamRef<jbyteArray>& value) { |
| 331 gatt_write_descriptor_attempts_++; | 336 gatt_write_descriptor_attempts_++; |
| 332 base::android::JavaByteArrayToByteVector(env, value, &last_write_value_); | 337 base::android::JavaByteArrayToByteVector(env, value, &last_write_value_); |
| 333 } | 338 } |
| 334 | 339 |
| 335 } // namespace device | 340 } // namespace device |
| OLD | NEW |