Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(25)

Side by Side Diff: device/bluetooth/test/bluetooth_test_android.cc

Issue 1610053005: bluetooth: android: Fix a couple of crashes when adapter is turned on/off. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fixed issue with failing trybot Created 4 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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
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
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
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698