| 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_string.h" | 10 #include "base/android/jni_string.h" |
| (...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 136 static_cast<BluetoothDeviceAndroid*>(device); | 136 static_cast<BluetoothDeviceAndroid*>(device); |
| 137 | 137 |
| 138 Java_FakeBluetoothDevice_servicesDiscovered( | 138 Java_FakeBluetoothDevice_servicesDiscovered( |
| 139 AttachCurrentThread(), device_android->GetJavaObject().obj(), | 139 AttachCurrentThread(), device_android->GetJavaObject().obj(), |
| 140 0x00000101, // android.bluetooth.BluetoothGatt.GATT_FAILURE | 140 0x00000101, // android.bluetooth.BluetoothGatt.GATT_FAILURE |
| 141 nullptr); | 141 nullptr); |
| 142 } | 142 } |
| 143 | 143 |
| 144 void BluetoothTestAndroid::SimulateGattCharacteristic( | 144 void BluetoothTestAndroid::SimulateGattCharacteristic( |
| 145 BluetoothGattService* service, | 145 BluetoothGattService* service, |
| 146 const std::string& uuid) { | 146 const std::string& uuid, |
| 147 int properties) { |
| 147 BluetoothRemoteGattServiceAndroid* service_android = | 148 BluetoothRemoteGattServiceAndroid* service_android = |
| 148 static_cast<BluetoothRemoteGattServiceAndroid*>(service); | 149 static_cast<BluetoothRemoteGattServiceAndroid*>(service); |
| 149 JNIEnv* env = base::android::AttachCurrentThread(); | 150 JNIEnv* env = base::android::AttachCurrentThread(); |
| 150 | 151 |
| 151 Java_FakeBluetoothGattService_addCharacteristic( | 152 Java_FakeBluetoothGattService_addCharacteristic( |
| 152 env, service_android->GetJavaObject().obj(), | 153 env, service_android->GetJavaObject().obj(), |
| 153 base::android::ConvertUTF8ToJavaString(env, uuid).obj()); | 154 base::android::ConvertUTF8ToJavaString(env, uuid).obj(), properties); |
| 154 } | 155 } |
| 155 | 156 |
| 156 void BluetoothTestAndroid::OnFakeBluetoothDeviceConnectGattCalled( | 157 void BluetoothTestAndroid::OnFakeBluetoothDeviceConnectGattCalled( |
| 157 JNIEnv* env, | 158 JNIEnv* env, |
| 158 jobject caller) { | 159 jobject caller) { |
| 159 gatt_connection_attempts_++; | 160 gatt_connection_attempts_++; |
| 160 } | 161 } |
| 161 | 162 |
| 162 void BluetoothTestAndroid::OnFakeBluetoothGattDisconnect(JNIEnv* env, | 163 void BluetoothTestAndroid::OnFakeBluetoothGattDisconnect(JNIEnv* env, |
| 163 jobject caller) { | 164 jobject caller) { |
| 164 gatt_disconnection_attempts_++; | 165 gatt_disconnection_attempts_++; |
| 165 } | 166 } |
| 166 | 167 |
| 167 void BluetoothTestAndroid::OnFakeBluetoothGattDiscoverServices(JNIEnv* env, | 168 void BluetoothTestAndroid::OnFakeBluetoothGattDiscoverServices(JNIEnv* env, |
| 168 jobject caller) { | 169 jobject caller) { |
| 169 gatt_discovery_attempts_++; | 170 gatt_discovery_attempts_++; |
| 170 } | 171 } |
| 171 | 172 |
| 172 } // namespace device | 173 } // namespace device |
| OLD | NEW |