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

Unified Diff: chromeos/dbus/fake_bluetooth_device_client.cc

Issue 15016004: Bluetooth: Parse the bluez.Error.Failed on pairing error. (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Created 7 years, 7 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
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 3c6e440bed380adf831100881b84d8afa46172d7..4d3e1891a73f5e90e26e319512c44002252b4d8e 100644
--- a/chromeos/dbus/fake_bluetooth_device_client.cc
+++ b/chromeos/dbus/fake_bluetooth_device_client.cc
@@ -112,6 +112,14 @@ const char FakeBluetoothDeviceClient::kUnconnectableDeviceName[] =
"Unconnectable Device";
const uint32 FakeBluetoothDeviceClient::kUnconnectableDeviceClass = 0x7a020c;
+const char FakeBluetoothDeviceClient::kUnpairableDevicePath[] =
+ "/fake/hci0/devA";
+const char FakeBluetoothDeviceClient::kUnpairableDeviceAddress[] =
+ "20:7D:74:00:00:03";
+const char FakeBluetoothDeviceClient::kUnpairableDeviceName[] =
+ "Unpairable Device";
+const uint32 FakeBluetoothDeviceClient::kUnpairableDeviceClass = 0x002540;
+
FakeBluetoothDeviceClient::Properties::Properties(
const PropertyChangedCallback& callback)
: ExperimentalBluetoothDeviceClient::Properties(
@@ -372,6 +380,15 @@ void FakeBluetoothDeviceClient::Pair(
callback,
error_callback));
+ } else if (object_path == dbus::ObjectPath(kUnpairableDevicePath)) {
+ // Fails the pairing with an org.bluez.Error.Failed error.
+ MessageLoop::current()->PostDelayedTask(
+ FROM_HERE,
+ base::Bind(&FakeBluetoothDeviceClient::FailSimulatedPairing,
+ base::Unretained(this),
+ object_path, error_callback),
+ base::TimeDelta::FromMilliseconds(simulation_interval_ms_));
+
} else {
error_callback.Run(kNoResponseError, "No pairing fake");
}
@@ -652,6 +669,27 @@ void FakeBluetoothDeviceClient::DiscoverySimulationTimer() {
DeviceAdded(dbus::ObjectPath(kUnconnectableDevicePath)));
}
+ if (std::find(device_list_.begin(), device_list_.end(),
+ dbus::ObjectPath(kUnpairableDevicePath)) ==
+ device_list_.end()) {
+ Properties* properties = new Properties(base::Bind(
+ &FakeBluetoothDeviceClient::OnPropertyChanged,
+ base::Unretained(this),
+ dbus::ObjectPath(kUnpairableDevicePath)));
+ properties->address.ReplaceValue(kUnpairableDeviceAddress);
+ properties->bluetooth_class.ReplaceValue(kUnpairableDeviceClass);
+ properties->name.ReplaceValue("Fake Unpairable Device");
+ properties->alias.ReplaceValue(kUnpairableDeviceName);
+ properties->adapter.ReplaceValue(
+ dbus::ObjectPath(FakeBluetoothAdapterClient::kAdapterPath));
+
+ properties_map_[dbus::ObjectPath(kUnpairableDevicePath)] = properties;
+ device_list_.push_back(dbus::ObjectPath(kUnpairableDevicePath));
+ FOR_EACH_OBSERVER(
+ ExperimentalBluetoothDeviceClient::Observer, observers_,
+ DeviceAdded(dbus::ObjectPath(kUnpairableDevicePath)));
+ }
+
} else if (discovery_simulation_step_ == 13) {
RemoveDevice(dbus::ObjectPath(FakeBluetoothAdapterClient::kAdapterPath),
dbus::ObjectPath(kVanishingDevicePath));
@@ -717,6 +755,14 @@ void FakeBluetoothDeviceClient::RejectSimulatedPairing(
"Rejected");
}
+void FakeBluetoothDeviceClient::FailSimulatedPairing(
+ const dbus::ObjectPath& object_path,
+ const ErrorCallback& error_callback) {
+ VLOG(1) << "FailSimulatedPairing: " << object_path.value();
+
+ error_callback.Run(bluetooth_adapter::kErrorFailed, "Failed");
+}
+
void FakeBluetoothDeviceClient::AddInputDeviceIfNeeded(
const dbus::ObjectPath& object_path,
Properties* properties) {
« no previous file with comments | « chromeos/dbus/fake_bluetooth_device_client.h ('k') | device/bluetooth/bluetooth_device_experimental_chromeos.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698