summaryrefslogtreecommitdiffstats
path: root/chromeos
diff options
context:
space:
mode:
authorkeybuk@chromium.org <keybuk@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2014-02-27 20:43:20 +0000
committerkeybuk@chromium.org <keybuk@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2014-02-27 20:43:20 +0000
commita4f56a0e5ad11fa145d7590dce2e31942fedd6fb (patch)
treebf74ebc455a857c1a314651b9f007b80dcdb05c9 /chromeos
parent07db4b3c95d4be48eeec3d4e4e209b196c76dd09 (diff)
downloadchromium_src-a4f56a0e5ad11fa145d7590dce2e31942fedd6fb.zip
chromium_src-a4f56a0e5ad11fa145d7590dce2e31942fedd6fb.tar.gz
chromium_src-a4f56a0e5ad11fa145d7590dce2e31942fedd6fb.tar.bz2
Add BluetoothDevice::PairingDelegate::AuthorizePairing
Now that we have the concept of a default pairing agent that may be used to handle incoming pairing requests we need to handle the case of authorizing a Just-Works pairing request from an unknown device. BUG=329583 TEST=device_unittests included Review URL: https://codereview.chromium.org/168603006 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@253919 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chromeos')
-rw-r--r--chromeos/dbus/fake_bluetooth_device_client.cc38
-rw-r--r--chromeos/dbus/fake_bluetooth_device_client.h5
2 files changed, 43 insertions, 0 deletions
diff --git a/chromeos/dbus/fake_bluetooth_device_client.cc b/chromeos/dbus/fake_bluetooth_device_client.cc
index b77a956..f70e2cf 100644
--- a/chromeos/dbus/fake_bluetooth_device_client.cc
+++ b/chromeos/dbus/fake_bluetooth_device_client.cc
@@ -154,6 +154,14 @@ const char FakeBluetoothDeviceClient::kUnpairableDeviceName[] =
"Unpairable Device";
const uint32 FakeBluetoothDeviceClient::kUnpairableDeviceClass = 0x002540;
+const char FakeBluetoothDeviceClient::kBoseSpeakersPath[] =
+ "/fake/hci0/devB";
+const char FakeBluetoothDeviceClient::kBoseSpeakersAddress[] =
+ "00:0C:8A:00:00:00";
+const char FakeBluetoothDeviceClient::kBoseSpeakersName[] =
+ "Bose SoundLink Mobile speaker II";
+const uint32 FakeBluetoothDeviceClient::kBoseSpeakersClass = 0x240428;
+
FakeBluetoothDeviceClient::Properties::Properties(
const PropertyChangedCallback& callback)
: BluetoothDeviceClient::Properties(
@@ -525,6 +533,12 @@ void FakeBluetoothDeviceClient::CreateDevice(
properties->name.ReplaceValue("Fake Unpairable Device");
properties->alias.ReplaceValue(kUnpairableDeviceName);
+ } else if (device_path == dbus::ObjectPath(kBoseSpeakersPath)) {
+ properties->address.ReplaceValue(kBoseSpeakersAddress);
+ properties->bluetooth_class.ReplaceValue(kBoseSpeakersClass);
+ properties->name.ReplaceValue("Fake Bose Speakers");
+ properties->alias.ReplaceValue(kBoseSpeakersName);
+
} else {
NOTREACHED();
@@ -608,6 +622,8 @@ void FakeBluetoothDeviceClient::DiscoverySimulationTimer() {
dbus::ObjectPath(kUnconnectableDevicePath));
CreateDevice(dbus::ObjectPath(FakeBluetoothAdapterClient::kAdapterPath),
dbus::ObjectPath(kUnpairableDevicePath));
+ CreateDevice(dbus::ObjectPath(FakeBluetoothAdapterClient::kAdapterPath),
+ dbus::ObjectPath(kBoseSpeakersPath));
} else if (discovery_simulation_step_ == 13) {
RemoveDevice(dbus::ObjectPath(FakeBluetoothAdapterClient::kAdapterPath),
@@ -725,6 +741,28 @@ void FakeBluetoothDeviceClient::SimulatePairing(
object_path, error_callback),
base::TimeDelta::FromMilliseconds(simulation_interval_ms_));
+ } else if (object_path == dbus::ObjectPath(kBoseSpeakersPath)) {
+ if (incoming_request) {
+ agent_service_provider->RequestAuthorization(
+ object_path,
+ base::Bind(&FakeBluetoothDeviceClient::ConfirmationCallback,
+ base::Unretained(this),
+ object_path,
+ callback,
+ error_callback));
+
+ } else {
+ // No need to call anything on the pairing delegate, just wait 3 times
+ // the interval before acting as if the other end accepted it.
+ base::MessageLoop::current()->PostDelayedTask(
+ FROM_HERE,
+ base::Bind(&FakeBluetoothDeviceClient::CompleteSimulatedPairing,
+ base::Unretained(this),
+ object_path, callback, error_callback),
+ base::TimeDelta::FromMilliseconds(3 * simulation_interval_ms_));
+
+ }
+
} else {
error_callback.Run(kNoResponseError, "No pairing fake");
}
diff --git a/chromeos/dbus/fake_bluetooth_device_client.h b/chromeos/dbus/fake_bluetooth_device_client.h
index e232416..b228a11 100644
--- a/chromeos/dbus/fake_bluetooth_device_client.h
+++ b/chromeos/dbus/fake_bluetooth_device_client.h
@@ -150,6 +150,11 @@ class CHROMEOS_EXPORT FakeBluetoothDeviceClient
static const char kUnpairableDeviceAddress[];
static const uint32 kUnpairableDeviceClass;
+ static const char kBoseSpeakersPath[];
+ static const char kBoseSpeakersName[];
+ static const char kBoseSpeakersAddress[];
+ static const uint32 kBoseSpeakersClass;
+
private:
// Property callback passed when we create Properties* structures.
void OnPropertyChanged(const dbus::ObjectPath& object_path,