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 134 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
145 BluetoothDeviceAndroid* device_android = | 145 BluetoothDeviceAndroid* device_android = |
146 static_cast<BluetoothDeviceAndroid*>(device); | 146 static_cast<BluetoothDeviceAndroid*>(device); |
147 | 147 |
148 Java_FakeBluetoothDevice_servicesDiscovered( | 148 Java_FakeBluetoothDevice_servicesDiscovered( |
149 AttachCurrentThread(), device_android->GetJavaObject().obj(), | 149 AttachCurrentThread(), device_android->GetJavaObject().obj(), |
150 0x00000101, // android.bluetooth.BluetoothGatt.GATT_FAILURE | 150 0x00000101, // android.bluetooth.BluetoothGatt.GATT_FAILURE |
151 nullptr); | 151 nullptr); |
152 } | 152 } |
153 | 153 |
154 void BluetoothTestAndroid::SimulateGattCharacteristic( | 154 void BluetoothTestAndroid::SimulateGattCharacteristic( |
155 BluetoothGattService* service, | 155 BluetoothRemoteGattService* service, |
156 const std::string& uuid, | 156 const std::string& uuid, |
157 int properties) { | 157 int properties) { |
158 BluetoothRemoteGattServiceAndroid* service_android = | 158 BluetoothRemoteGattServiceAndroid* service_android = |
159 static_cast<BluetoothRemoteGattServiceAndroid*>(service); | 159 static_cast<BluetoothRemoteGattServiceAndroid*>(service); |
160 JNIEnv* env = base::android::AttachCurrentThread(); | 160 JNIEnv* env = base::android::AttachCurrentThread(); |
161 | 161 |
162 Java_FakeBluetoothGattService_addCharacteristic( | 162 Java_FakeBluetoothGattService_addCharacteristic( |
163 env, service_android->GetJavaObject().obj(), | 163 env, service_android->GetJavaObject().obj(), |
164 base::android::ConvertUTF8ToJavaString(env, uuid).obj(), properties); | 164 base::android::ConvertUTF8ToJavaString(env, uuid).obj(), properties); |
165 } | 165 } |
166 | 166 |
167 void BluetoothTestAndroid::RememberCharacteristicForSubsequentAction( | 167 void BluetoothTestAndroid::RememberCharacteristicForSubsequentAction( |
168 BluetoothGattCharacteristic* characteristic) { | 168 BluetoothRemoteGattCharacteristic* characteristic) { |
169 BluetoothRemoteGattCharacteristicAndroid* characteristic_android = | 169 BluetoothRemoteGattCharacteristicAndroid* characteristic_android = |
170 static_cast<BluetoothRemoteGattCharacteristicAndroid*>(characteristic); | 170 static_cast<BluetoothRemoteGattCharacteristicAndroid*>(characteristic); |
171 | 171 |
172 Java_FakeBluetoothGattCharacteristic_rememberCharacteristicForSubsequentAction
( | 172 Java_FakeBluetoothGattCharacteristic_rememberCharacteristicForSubsequentAction
( |
173 base::android::AttachCurrentThread(), | 173 base::android::AttachCurrentThread(), |
174 characteristic_android->GetJavaObject().obj()); | 174 characteristic_android->GetJavaObject().obj()); |
175 } | 175 } |
176 | 176 |
177 void BluetoothTestAndroid::RememberCCCDescriptorForSubsequentAction( | 177 void BluetoothTestAndroid::RememberCCCDescriptorForSubsequentAction( |
178 BluetoothGattCharacteristic* characteristic) { | 178 BluetoothRemoteGattCharacteristic* characteristic) { |
179 remembered_ccc_descriptor_ = | 179 remembered_ccc_descriptor_ = |
180 characteristic | 180 characteristic |
181 ->GetDescriptorsByUUID( | 181 ->GetDescriptorsByUUID(BluetoothRemoteGattDescriptor:: |
182 BluetoothGattDescriptor::ClientCharacteristicConfigurationUuid()) | 182 ClientCharacteristicConfigurationUuid()) |
183 .at(0); | 183 .at(0); |
184 DCHECK(remembered_ccc_descriptor_); | 184 DCHECK(remembered_ccc_descriptor_); |
185 RememberDescriptorForSubsequentAction(remembered_ccc_descriptor_); | 185 RememberDescriptorForSubsequentAction(remembered_ccc_descriptor_); |
186 } | 186 } |
187 | 187 |
188 void BluetoothTestAndroid::SimulateGattNotifySessionStarted( | 188 void BluetoothTestAndroid::SimulateGattNotifySessionStarted( |
189 BluetoothGattCharacteristic* characteristic) { | 189 BluetoothRemoteGattCharacteristic* characteristic) { |
190 BluetoothRemoteGattDescriptorAndroid* descriptor_android = nullptr; | 190 BluetoothRemoteGattDescriptorAndroid* descriptor_android = nullptr; |
191 if (characteristic) { | 191 if (characteristic) { |
192 descriptor_android = static_cast<BluetoothRemoteGattDescriptorAndroid*>( | 192 descriptor_android = static_cast<BluetoothRemoteGattDescriptorAndroid*>( |
193 characteristic | 193 characteristic |
194 ->GetDescriptorsByUUID(BluetoothGattDescriptor:: | 194 ->GetDescriptorsByUUID(BluetoothRemoteGattDescriptor:: |
195 ClientCharacteristicConfigurationUuid()) | 195 ClientCharacteristicConfigurationUuid()) |
196 .at(0)); | 196 .at(0)); |
197 } | 197 } |
198 Java_FakeBluetoothGattDescriptor_valueWrite( | 198 Java_FakeBluetoothGattDescriptor_valueWrite( |
199 base::android::AttachCurrentThread(), | 199 base::android::AttachCurrentThread(), |
200 descriptor_android ? descriptor_android->GetJavaObject().obj() : nullptr, | 200 descriptor_android ? descriptor_android->GetJavaObject().obj() : nullptr, |
201 0); // android.bluetooth.BluetoothGatt.GATT_SUCCESS | 201 0); // android.bluetooth.BluetoothGatt.GATT_SUCCESS |
202 } | 202 } |
203 | 203 |
204 void BluetoothTestAndroid::SimulateGattNotifySessionStartError( | 204 void BluetoothTestAndroid::SimulateGattNotifySessionStartError( |
205 BluetoothGattCharacteristic* characteristic, | 205 BluetoothRemoteGattCharacteristic* characteristic, |
206 BluetoothGattService::GattErrorCode error_code) { | 206 BluetoothRemoteGattService::GattErrorCode error_code) { |
207 BluetoothRemoteGattDescriptorAndroid* descriptor_android = nullptr; | 207 BluetoothRemoteGattDescriptorAndroid* descriptor_android = nullptr; |
208 if (characteristic) { | 208 if (characteristic) { |
209 descriptor_android = static_cast<BluetoothRemoteGattDescriptorAndroid*>( | 209 descriptor_android = static_cast<BluetoothRemoteGattDescriptorAndroid*>( |
210 characteristic | 210 characteristic |
211 ->GetDescriptorsByUUID(BluetoothGattDescriptor:: | 211 ->GetDescriptorsByUUID(BluetoothRemoteGattDescriptor:: |
212 ClientCharacteristicConfigurationUuid()) | 212 ClientCharacteristicConfigurationUuid()) |
213 .at(0)); | 213 .at(0)); |
214 } | 214 } |
215 Java_FakeBluetoothGattDescriptor_valueWrite( | 215 Java_FakeBluetoothGattDescriptor_valueWrite( |
216 base::android::AttachCurrentThread(), | 216 base::android::AttachCurrentThread(), |
217 descriptor_android ? descriptor_android->GetJavaObject().obj() : nullptr, | 217 descriptor_android ? descriptor_android->GetJavaObject().obj() : nullptr, |
218 BluetoothRemoteGattServiceAndroid::GetAndroidErrorCode(error_code)); | 218 BluetoothRemoteGattServiceAndroid::GetAndroidErrorCode(error_code)); |
219 } | 219 } |
220 | 220 |
221 void BluetoothTestAndroid:: | 221 void BluetoothTestAndroid:: |
222 SimulateGattCharacteristicSetNotifyWillFailSynchronouslyOnce( | 222 SimulateGattCharacteristicSetNotifyWillFailSynchronouslyOnce( |
223 BluetoothGattCharacteristic* characteristic) { | 223 BluetoothRemoteGattCharacteristic* characteristic) { |
224 BluetoothRemoteGattCharacteristicAndroid* characteristic_android = | 224 BluetoothRemoteGattCharacteristicAndroid* characteristic_android = |
225 static_cast<BluetoothRemoteGattCharacteristicAndroid*>(characteristic); | 225 static_cast<BluetoothRemoteGattCharacteristicAndroid*>(characteristic); |
226 JNIEnv* env = base::android::AttachCurrentThread(); | 226 JNIEnv* env = base::android::AttachCurrentThread(); |
227 | 227 |
228 Java_FakeBluetoothGattCharacteristic_setCharacteristicNotificationWillFailSync
hronouslyOnce( | 228 Java_FakeBluetoothGattCharacteristic_setCharacteristicNotificationWillFailSync
hronouslyOnce( |
229 env, characteristic_android->GetJavaObject().obj()); | 229 env, characteristic_android->GetJavaObject().obj()); |
230 } | 230 } |
231 | 231 |
232 void BluetoothTestAndroid::SimulateGattCharacteristicChanged( | 232 void BluetoothTestAndroid::SimulateGattCharacteristicChanged( |
233 BluetoothGattCharacteristic* characteristic, | 233 BluetoothRemoteGattCharacteristic* characteristic, |
234 const std::vector<uint8_t>& value) { | 234 const std::vector<uint8_t>& value) { |
235 BluetoothRemoteGattCharacteristicAndroid* characteristic_android = | 235 BluetoothRemoteGattCharacteristicAndroid* characteristic_android = |
236 static_cast<BluetoothRemoteGattCharacteristicAndroid*>(characteristic); | 236 static_cast<BluetoothRemoteGattCharacteristicAndroid*>(characteristic); |
237 JNIEnv* env = base::android::AttachCurrentThread(); | 237 JNIEnv* env = base::android::AttachCurrentThread(); |
238 | 238 |
239 Java_FakeBluetoothGattCharacteristic_valueChanged( | 239 Java_FakeBluetoothGattCharacteristic_valueChanged( |
240 env, | 240 env, |
241 characteristic_android ? characteristic_android->GetJavaObject().obj() | 241 characteristic_android ? characteristic_android->GetJavaObject().obj() |
242 : nullptr, | 242 : nullptr, |
243 base::android::ToJavaByteArray(env, value).obj()); | 243 base::android::ToJavaByteArray(env, value).obj()); |
244 } | 244 } |
245 | 245 |
246 void BluetoothTestAndroid::SimulateGattCharacteristicRead( | 246 void BluetoothTestAndroid::SimulateGattCharacteristicRead( |
247 BluetoothGattCharacteristic* characteristic, | 247 BluetoothRemoteGattCharacteristic* characteristic, |
248 const std::vector<uint8_t>& value) { | 248 const std::vector<uint8_t>& value) { |
249 BluetoothRemoteGattCharacteristicAndroid* characteristic_android = | 249 BluetoothRemoteGattCharacteristicAndroid* characteristic_android = |
250 static_cast<BluetoothRemoteGattCharacteristicAndroid*>(characteristic); | 250 static_cast<BluetoothRemoteGattCharacteristicAndroid*>(characteristic); |
251 JNIEnv* env = base::android::AttachCurrentThread(); | 251 JNIEnv* env = base::android::AttachCurrentThread(); |
252 | 252 |
253 Java_FakeBluetoothGattCharacteristic_valueRead( | 253 Java_FakeBluetoothGattCharacteristic_valueRead( |
254 env, | 254 env, |
255 characteristic_android ? characteristic_android->GetJavaObject().obj() | 255 characteristic_android ? characteristic_android->GetJavaObject().obj() |
256 : nullptr, | 256 : nullptr, |
257 0, // android.bluetooth.BluetoothGatt.GATT_SUCCESS | 257 0, // android.bluetooth.BluetoothGatt.GATT_SUCCESS |
258 base::android::ToJavaByteArray(env, value).obj()); | 258 base::android::ToJavaByteArray(env, value).obj()); |
259 } | 259 } |
260 | 260 |
261 void BluetoothTestAndroid::SimulateGattCharacteristicReadError( | 261 void BluetoothTestAndroid::SimulateGattCharacteristicReadError( |
262 BluetoothGattCharacteristic* characteristic, | 262 BluetoothRemoteGattCharacteristic* characteristic, |
263 BluetoothGattService::GattErrorCode error_code) { | 263 BluetoothRemoteGattService::GattErrorCode error_code) { |
264 BluetoothRemoteGattCharacteristicAndroid* characteristic_android = | 264 BluetoothRemoteGattCharacteristicAndroid* characteristic_android = |
265 static_cast<BluetoothRemoteGattCharacteristicAndroid*>(characteristic); | 265 static_cast<BluetoothRemoteGattCharacteristicAndroid*>(characteristic); |
266 JNIEnv* env = base::android::AttachCurrentThread(); | 266 JNIEnv* env = base::android::AttachCurrentThread(); |
267 std::vector<uint8_t> empty_value; | 267 std::vector<uint8_t> empty_value; |
268 | 268 |
269 Java_FakeBluetoothGattCharacteristic_valueRead( | 269 Java_FakeBluetoothGattCharacteristic_valueRead( |
270 env, characteristic_android->GetJavaObject().obj(), | 270 env, characteristic_android->GetJavaObject().obj(), |
271 BluetoothRemoteGattServiceAndroid::GetAndroidErrorCode(error_code), | 271 BluetoothRemoteGattServiceAndroid::GetAndroidErrorCode(error_code), |
272 base::android::ToJavaByteArray(env, empty_value).obj()); | 272 base::android::ToJavaByteArray(env, empty_value).obj()); |
273 } | 273 } |
274 | 274 |
275 void BluetoothTestAndroid:: | 275 void BluetoothTestAndroid:: |
276 SimulateGattCharacteristicReadWillFailSynchronouslyOnce( | 276 SimulateGattCharacteristicReadWillFailSynchronouslyOnce( |
277 BluetoothGattCharacteristic* characteristic) { | 277 BluetoothRemoteGattCharacteristic* characteristic) { |
278 BluetoothRemoteGattCharacteristicAndroid* characteristic_android = | 278 BluetoothRemoteGattCharacteristicAndroid* characteristic_android = |
279 static_cast<BluetoothRemoteGattCharacteristicAndroid*>(characteristic); | 279 static_cast<BluetoothRemoteGattCharacteristicAndroid*>(characteristic); |
280 JNIEnv* env = base::android::AttachCurrentThread(); | 280 JNIEnv* env = base::android::AttachCurrentThread(); |
281 | 281 |
282 Java_FakeBluetoothGattCharacteristic_setReadCharacteristicWillFailSynchronousl
yOnce( | 282 Java_FakeBluetoothGattCharacteristic_setReadCharacteristicWillFailSynchronousl
yOnce( |
283 env, characteristic_android->GetJavaObject().obj()); | 283 env, characteristic_android->GetJavaObject().obj()); |
284 } | 284 } |
285 | 285 |
286 void BluetoothTestAndroid::SimulateGattCharacteristicWrite( | 286 void BluetoothTestAndroid::SimulateGattCharacteristicWrite( |
287 BluetoothGattCharacteristic* characteristic) { | 287 BluetoothRemoteGattCharacteristic* characteristic) { |
288 BluetoothRemoteGattCharacteristicAndroid* characteristic_android = | 288 BluetoothRemoteGattCharacteristicAndroid* characteristic_android = |
289 static_cast<BluetoothRemoteGattCharacteristicAndroid*>(characteristic); | 289 static_cast<BluetoothRemoteGattCharacteristicAndroid*>(characteristic); |
290 Java_FakeBluetoothGattCharacteristic_valueWrite( | 290 Java_FakeBluetoothGattCharacteristic_valueWrite( |
291 base::android::AttachCurrentThread(), | 291 base::android::AttachCurrentThread(), |
292 characteristic_android ? characteristic_android->GetJavaObject().obj() | 292 characteristic_android ? characteristic_android->GetJavaObject().obj() |
293 : nullptr, | 293 : nullptr, |
294 0); // android.bluetooth.BluetoothGatt.GATT_SUCCESS | 294 0); // android.bluetooth.BluetoothGatt.GATT_SUCCESS |
295 } | 295 } |
296 | 296 |
297 void BluetoothTestAndroid::SimulateGattCharacteristicWriteError( | 297 void BluetoothTestAndroid::SimulateGattCharacteristicWriteError( |
298 BluetoothGattCharacteristic* characteristic, | 298 BluetoothRemoteGattCharacteristic* characteristic, |
299 BluetoothGattService::GattErrorCode error_code) { | 299 BluetoothRemoteGattService::GattErrorCode error_code) { |
300 BluetoothRemoteGattCharacteristicAndroid* characteristic_android = | 300 BluetoothRemoteGattCharacteristicAndroid* characteristic_android = |
301 static_cast<BluetoothRemoteGattCharacteristicAndroid*>(characteristic); | 301 static_cast<BluetoothRemoteGattCharacteristicAndroid*>(characteristic); |
302 Java_FakeBluetoothGattCharacteristic_valueWrite( | 302 Java_FakeBluetoothGattCharacteristic_valueWrite( |
303 base::android::AttachCurrentThread(), | 303 base::android::AttachCurrentThread(), |
304 characteristic_android->GetJavaObject().obj(), | 304 characteristic_android->GetJavaObject().obj(), |
305 BluetoothRemoteGattServiceAndroid::GetAndroidErrorCode(error_code)); | 305 BluetoothRemoteGattServiceAndroid::GetAndroidErrorCode(error_code)); |
306 } | 306 } |
307 | 307 |
308 void BluetoothTestAndroid:: | 308 void BluetoothTestAndroid:: |
309 SimulateGattCharacteristicWriteWillFailSynchronouslyOnce( | 309 SimulateGattCharacteristicWriteWillFailSynchronouslyOnce( |
310 BluetoothGattCharacteristic* characteristic) { | 310 BluetoothRemoteGattCharacteristic* characteristic) { |
311 BluetoothRemoteGattCharacteristicAndroid* characteristic_android = | 311 BluetoothRemoteGattCharacteristicAndroid* characteristic_android = |
312 static_cast<BluetoothRemoteGattCharacteristicAndroid*>(characteristic); | 312 static_cast<BluetoothRemoteGattCharacteristicAndroid*>(characteristic); |
313 Java_FakeBluetoothGattCharacteristic_setWriteCharacteristicWillFailSynchronous
lyOnce( | 313 Java_FakeBluetoothGattCharacteristic_setWriteCharacteristicWillFailSynchronous
lyOnce( |
314 base::android::AttachCurrentThread(), | 314 base::android::AttachCurrentThread(), |
315 characteristic_android->GetJavaObject().obj()); | 315 characteristic_android->GetJavaObject().obj()); |
316 } | 316 } |
317 | 317 |
318 void BluetoothTestAndroid::SimulateGattDescriptor( | 318 void BluetoothTestAndroid::SimulateGattDescriptor( |
319 BluetoothGattCharacteristic* characteristic, | 319 BluetoothRemoteGattCharacteristic* characteristic, |
320 const std::string& uuid) { | 320 const std::string& uuid) { |
321 BluetoothRemoteGattCharacteristicAndroid* characteristic_android = | 321 BluetoothRemoteGattCharacteristicAndroid* characteristic_android = |
322 static_cast<BluetoothRemoteGattCharacteristicAndroid*>(characteristic); | 322 static_cast<BluetoothRemoteGattCharacteristicAndroid*>(characteristic); |
323 JNIEnv* env = base::android::AttachCurrentThread(); | 323 JNIEnv* env = base::android::AttachCurrentThread(); |
324 | 324 |
325 Java_FakeBluetoothGattCharacteristic_addDescriptor( | 325 Java_FakeBluetoothGattCharacteristic_addDescriptor( |
326 env, characteristic_android->GetJavaObject().obj(), | 326 env, characteristic_android->GetJavaObject().obj(), |
327 base::android::ConvertUTF8ToJavaString(env, uuid).obj()); | 327 base::android::ConvertUTF8ToJavaString(env, uuid).obj()); |
328 } | 328 } |
329 | 329 |
330 void BluetoothTestAndroid::RememberDescriptorForSubsequentAction( | 330 void BluetoothTestAndroid::RememberDescriptorForSubsequentAction( |
331 BluetoothGattDescriptor* descriptor) { | 331 BluetoothRemoteGattDescriptor* descriptor) { |
332 BluetoothRemoteGattDescriptorAndroid* descriptor_android = | 332 BluetoothRemoteGattDescriptorAndroid* descriptor_android = |
333 static_cast<BluetoothRemoteGattDescriptorAndroid*>(descriptor); | 333 static_cast<BluetoothRemoteGattDescriptorAndroid*>(descriptor); |
334 | 334 |
335 Java_FakeBluetoothGattDescriptor_rememberDescriptorForSubsequentAction( | 335 Java_FakeBluetoothGattDescriptor_rememberDescriptorForSubsequentAction( |
336 base::android::AttachCurrentThread(), | 336 base::android::AttachCurrentThread(), |
337 descriptor_android->GetJavaObject().obj()); | 337 descriptor_android->GetJavaObject().obj()); |
338 } | 338 } |
339 | 339 |
340 void BluetoothTestAndroid::SimulateGattDescriptorRead( | 340 void BluetoothTestAndroid::SimulateGattDescriptorRead( |
341 BluetoothGattDescriptor* descriptor, | 341 BluetoothRemoteGattDescriptor* descriptor, |
342 const std::vector<uint8_t>& value) { | 342 const std::vector<uint8_t>& value) { |
343 BluetoothRemoteGattDescriptorAndroid* descriptor_android = | 343 BluetoothRemoteGattDescriptorAndroid* descriptor_android = |
344 static_cast<BluetoothRemoteGattDescriptorAndroid*>(descriptor); | 344 static_cast<BluetoothRemoteGattDescriptorAndroid*>(descriptor); |
345 JNIEnv* env = base::android::AttachCurrentThread(); | 345 JNIEnv* env = base::android::AttachCurrentThread(); |
346 | 346 |
347 Java_FakeBluetoothGattDescriptor_valueRead( | 347 Java_FakeBluetoothGattDescriptor_valueRead( |
348 env, | 348 env, |
349 descriptor_android ? descriptor_android->GetJavaObject().obj() : nullptr, | 349 descriptor_android ? descriptor_android->GetJavaObject().obj() : nullptr, |
350 0, // android.bluetooth.BluetoothGatt.GATT_SUCCESS | 350 0, // android.bluetooth.BluetoothGatt.GATT_SUCCESS |
351 base::android::ToJavaByteArray(env, value).obj()); | 351 base::android::ToJavaByteArray(env, value).obj()); |
352 } | 352 } |
353 | 353 |
354 void BluetoothTestAndroid::SimulateGattDescriptorReadError( | 354 void BluetoothTestAndroid::SimulateGattDescriptorReadError( |
355 BluetoothGattDescriptor* descriptor, | 355 BluetoothRemoteGattDescriptor* descriptor, |
356 BluetoothGattService::GattErrorCode error_code) { | 356 BluetoothRemoteGattService::GattErrorCode error_code) { |
357 BluetoothRemoteGattDescriptorAndroid* descriptor_android = | 357 BluetoothRemoteGattDescriptorAndroid* descriptor_android = |
358 static_cast<BluetoothRemoteGattDescriptorAndroid*>(descriptor); | 358 static_cast<BluetoothRemoteGattDescriptorAndroid*>(descriptor); |
359 JNIEnv* env = base::android::AttachCurrentThread(); | 359 JNIEnv* env = base::android::AttachCurrentThread(); |
360 std::vector<uint8_t> empty_value; | 360 std::vector<uint8_t> empty_value; |
361 | 361 |
362 Java_FakeBluetoothGattDescriptor_valueRead( | 362 Java_FakeBluetoothGattDescriptor_valueRead( |
363 env, descriptor_android->GetJavaObject().obj(), | 363 env, descriptor_android->GetJavaObject().obj(), |
364 BluetoothRemoteGattServiceAndroid::GetAndroidErrorCode(error_code), | 364 BluetoothRemoteGattServiceAndroid::GetAndroidErrorCode(error_code), |
365 base::android::ToJavaByteArray(env, empty_value).obj()); | 365 base::android::ToJavaByteArray(env, empty_value).obj()); |
366 } | 366 } |
367 | 367 |
368 void BluetoothTestAndroid::SimulateGattDescriptorReadWillFailSynchronouslyOnce( | 368 void BluetoothTestAndroid::SimulateGattDescriptorReadWillFailSynchronouslyOnce( |
369 BluetoothGattDescriptor* descriptor) { | 369 BluetoothRemoteGattDescriptor* descriptor) { |
370 BluetoothRemoteGattDescriptorAndroid* descriptor_android = | 370 BluetoothRemoteGattDescriptorAndroid* descriptor_android = |
371 static_cast<BluetoothRemoteGattDescriptorAndroid*>(descriptor); | 371 static_cast<BluetoothRemoteGattDescriptorAndroid*>(descriptor); |
372 JNIEnv* env = base::android::AttachCurrentThread(); | 372 JNIEnv* env = base::android::AttachCurrentThread(); |
373 | 373 |
374 Java_FakeBluetoothGattDescriptor_setReadDescriptorWillFailSynchronouslyOnce( | 374 Java_FakeBluetoothGattDescriptor_setReadDescriptorWillFailSynchronouslyOnce( |
375 env, descriptor_android->GetJavaObject().obj()); | 375 env, descriptor_android->GetJavaObject().obj()); |
376 } | 376 } |
377 | 377 |
378 void BluetoothTestAndroid::SimulateGattDescriptorWrite( | 378 void BluetoothTestAndroid::SimulateGattDescriptorWrite( |
379 BluetoothGattDescriptor* descriptor) { | 379 BluetoothRemoteGattDescriptor* descriptor) { |
380 BluetoothRemoteGattDescriptorAndroid* descriptor_android = | 380 BluetoothRemoteGattDescriptorAndroid* descriptor_android = |
381 static_cast<BluetoothRemoteGattDescriptorAndroid*>(descriptor); | 381 static_cast<BluetoothRemoteGattDescriptorAndroid*>(descriptor); |
382 Java_FakeBluetoothGattDescriptor_valueWrite( | 382 Java_FakeBluetoothGattDescriptor_valueWrite( |
383 base::android::AttachCurrentThread(), | 383 base::android::AttachCurrentThread(), |
384 descriptor_android ? descriptor_android->GetJavaObject().obj() : nullptr, | 384 descriptor_android ? descriptor_android->GetJavaObject().obj() : nullptr, |
385 0); // android.bluetooth.BluetoothGatt.GATT_SUCCESS | 385 0); // android.bluetooth.BluetoothGatt.GATT_SUCCESS |
386 } | 386 } |
387 | 387 |
388 void BluetoothTestAndroid::SimulateGattDescriptorWriteError( | 388 void BluetoothTestAndroid::SimulateGattDescriptorWriteError( |
389 BluetoothGattDescriptor* descriptor, | 389 BluetoothRemoteGattDescriptor* descriptor, |
390 BluetoothGattService::GattErrorCode error_code) { | 390 BluetoothRemoteGattService::GattErrorCode error_code) { |
391 BluetoothRemoteGattDescriptorAndroid* descriptor_android = | 391 BluetoothRemoteGattDescriptorAndroid* descriptor_android = |
392 static_cast<BluetoothRemoteGattDescriptorAndroid*>(descriptor); | 392 static_cast<BluetoothRemoteGattDescriptorAndroid*>(descriptor); |
393 Java_FakeBluetoothGattDescriptor_valueWrite( | 393 Java_FakeBluetoothGattDescriptor_valueWrite( |
394 base::android::AttachCurrentThread(), | 394 base::android::AttachCurrentThread(), |
395 descriptor_android->GetJavaObject().obj(), | 395 descriptor_android->GetJavaObject().obj(), |
396 BluetoothRemoteGattServiceAndroid::GetAndroidErrorCode(error_code)); | 396 BluetoothRemoteGattServiceAndroid::GetAndroidErrorCode(error_code)); |
397 } | 397 } |
398 | 398 |
399 void BluetoothTestAndroid::SimulateGattDescriptorWriteWillFailSynchronouslyOnce( | 399 void BluetoothTestAndroid::SimulateGattDescriptorWriteWillFailSynchronouslyOnce( |
400 BluetoothGattDescriptor* descriptor) { | 400 BluetoothRemoteGattDescriptor* descriptor) { |
401 BluetoothRemoteGattDescriptorAndroid* descriptor_android = | 401 BluetoothRemoteGattDescriptorAndroid* descriptor_android = |
402 static_cast<BluetoothRemoteGattDescriptorAndroid*>(descriptor); | 402 static_cast<BluetoothRemoteGattDescriptorAndroid*>(descriptor); |
403 Java_FakeBluetoothGattDescriptor_setWriteDescriptorWillFailSynchronouslyOnce( | 403 Java_FakeBluetoothGattDescriptor_setWriteDescriptorWillFailSynchronouslyOnce( |
404 base::android::AttachCurrentThread(), | 404 base::android::AttachCurrentThread(), |
405 descriptor_android->GetJavaObject().obj()); | 405 descriptor_android->GetJavaObject().obj()); |
406 } | 406 } |
407 | 407 |
408 void BluetoothTestAndroid::OnFakeBluetoothDeviceConnectGattCalled( | 408 void BluetoothTestAndroid::OnFakeBluetoothDeviceConnectGattCalled( |
409 JNIEnv* env, | 409 JNIEnv* env, |
410 const JavaParamRef<jobject>& caller) { | 410 const JavaParamRef<jobject>& caller) { |
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
468 } | 468 } |
469 | 469 |
470 void BluetoothTestAndroid::OnFakeAdapterStateChanged( | 470 void BluetoothTestAndroid::OnFakeAdapterStateChanged( |
471 JNIEnv* env, | 471 JNIEnv* env, |
472 const JavaParamRef<jobject>& caller, | 472 const JavaParamRef<jobject>& caller, |
473 const bool powered) { | 473 const bool powered) { |
474 adapter_->NotifyAdapterStateChanged(powered); | 474 adapter_->NotifyAdapterStateChanged(powered); |
475 } | 475 } |
476 | 476 |
477 } // namespace device | 477 } // namespace device |
OLD | NEW |