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

Unified Diff: chromeos/dbus/fake_bluetooth_device_client.cc

Issue 910433002: Fix crash on second failed connect to a paired device (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: bugfix unit tests Created 5 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chromeos/dbus/fake_bluetooth_device_client.h ('k') | device/bluetooth/bluetooth_adapter_chromeos.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chromeos/dbus/fake_bluetooth_device_client.cc
diff --git a/chromeos/dbus/fake_bluetooth_device_client.cc b/chromeos/dbus/fake_bluetooth_device_client.cc
index 325d95e69e94eeb90ae84de5e2fba40cf4c70691..089aa386a9483f8a19fe73b417274adb7839ac96 100644
--- a/chromeos/dbus/fake_bluetooth_device_client.cc
+++ b/chromeos/dbus/fake_bluetooth_device_client.cc
@@ -185,6 +185,15 @@ const char FakeBluetoothDeviceClient::kLowEnergyName[] =
const uint32 FakeBluetoothDeviceClient::kLowEnergyClass =
0x000918; // Major class "Health", Minor class "Heart/Pulse Rate Monitor."
+const char FakeBluetoothDeviceClient::kPairedUnconnectableDevicePath[] =
+ "/fake/hci0/devD";
+const char FakeBluetoothDeviceClient::kPairedUnconnectableDeviceAddress[] =
+ "20:7D:74:00:00:04";
+const char FakeBluetoothDeviceClient::kPairedUnconnectableDeviceName[] =
+ "Paired Unconnectable Device";
+const uint32 FakeBluetoothDeviceClient::kPairedUnconnectableDeviceClass =
+ 0x000104;
+
FakeBluetoothDeviceClient::Properties::Properties(
const PropertyChangedCallback& callback)
: BluetoothDeviceClient::Properties(
@@ -249,6 +258,26 @@ FakeBluetoothDeviceClient::FakeBluetoothDeviceClient()
properties_map_[dbus::ObjectPath(kPairedDevicePath)] = properties;
device_list_.push_back(dbus::ObjectPath(kPairedDevicePath));
+
+ properties = new Properties(base::Bind(
+ &FakeBluetoothDeviceClient::OnPropertyChanged, base::Unretained(this),
+ dbus::ObjectPath(kPairedUnconnectableDevicePath)));
+ properties->address.ReplaceValue(kPairedUnconnectableDeviceAddress);
+ properties->bluetooth_class.ReplaceValue(kPairedUnconnectableDeviceClass);
+ properties->name.ReplaceValue("Fake Device 2 (Unconnectable)");
+ properties->alias.ReplaceValue(kPairedUnconnectableDeviceName);
+ properties->paired.ReplaceValue(true);
+ properties->trusted.ReplaceValue(true);
+ properties->adapter.ReplaceValue(
+ dbus::ObjectPath(FakeBluetoothAdapterClient::kAdapterPath));
+
+ properties->uuids.ReplaceValue(uuids);
+
+ properties->modalias.ReplaceValue("usb:v05ACp030Dd0306");
+
+ properties_map_[dbus::ObjectPath(kPairedUnconnectableDevicePath)] =
+ properties;
+ device_list_.push_back(dbus::ObjectPath(kPairedUnconnectableDevicePath));
}
FakeBluetoothDeviceClient::~FakeBluetoothDeviceClient() {
@@ -304,7 +333,9 @@ void FakeBluetoothDeviceClient::Connect(
error_callback.Run(bluetooth_device::kErrorFailed, "Not paired");
return;
} else if (properties->paired.value() == true &&
- object_path == dbus::ObjectPath(kUnconnectableDevicePath)) {
+ (object_path == dbus::ObjectPath(kUnconnectableDevicePath) ||
+ object_path ==
+ dbus::ObjectPath(kPairedUnconnectableDevicePath))) {
// Must not be paired
error_callback.Run(bluetooth_device::kErrorFailed,
"Connection fails while paired");
@@ -368,6 +399,11 @@ void FakeBluetoothDeviceClient::ConnectProfile(
return;
}
+ if (object_path == dbus::ObjectPath(kPairedUnconnectableDevicePath)) {
+ error_callback.Run(bluetooth_device::kErrorFailed, "unconnectable");
+ return;
+ }
+
// Make a socket pair of a compatible type with the type used by Bluetooth;
// spin up a thread to simulate the server side and wrap the client side in
// a D-Bus file descriptor object.
« no previous file with comments | « chromeos/dbus/fake_bluetooth_device_client.h ('k') | device/bluetooth/bluetooth_adapter_chromeos.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698