Commit 6362c17f authored by keybuk@chromium.org's avatar keybuk@chromium.org

Bluetooth: Don't attempt a pairing for devices not supporting it.

Bluetooth mice are not required to be paired, but we attempt to pair
to them anyway because some mice, namely the Apple magic mouse,
require pairing. Some other mice do NOT support pairing or pretend
to support it without doing it properly.

This patch adds a small database of bluetooth mice known to not
support pairing and tries to connect to them without pairing.

BUG=210518
TEST=Attempt to pair with a Verbatim mouse. No pincode should be ask and the mouse should just work.

Review URL: https://codereview.chromium.org/13933012

Patch from Alex Deymo <deymo@chromium.org>.

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@194684 0039d316-1c4b-4281-b951-d872f2087c98
parent c74eef97
......@@ -614,7 +614,7 @@ class SystemTrayDelegate : public ash::SystemTrayDelegate,
device->Disconnect(
base::Bind(&base::DoNothing),
base::Bind(&BluetoothDeviceDisconnectError));
} else if (device->IsPaired()) {
} else if (device->IsPaired() || !device->IsPairable()) {
device->Connect(
NULL,
base::Bind(&base::DoNothing),
......
......@@ -289,11 +289,17 @@ void BluetoothOptionsHandler::UpdateDeviceCallback(
<< ": " << auth_token;
}
} else {
// Determine if the device supports pairing:
PairingDelegate* delegate = NULL;
if (device->IsPairable())
delegate = this;
// Connection request.
VLOG(1) << "Connect: " << address;
device->Connect(
this,
base::Bind(&base::DoNothing),
delegate,
base::Bind(&BluetoothOptionsHandler::DismissDisplayOrConfirm,
weak_ptr_factory_.GetWeakPtr()),
base::Bind(&BluetoothOptionsHandler::ConnectError,
weak_ptr_factory_.GetWeakPtr(),
device->GetAddress()));
......
......@@ -158,6 +158,21 @@ BluetoothDevice::DeviceType BluetoothDevice::GetDeviceType() const {
return DEVICE_UNKNOWN;
}
bool BluetoothDevice::IsPairable() const {
DeviceType type = GetDeviceType();
// Get the vendor part of the address: "00:11:22" for "00:11:22:33:44:55"
std::string vendor = GetAddress().substr(0, 8);
// Verbatim "Bluetooth Mouse", model 96674
if ((type == DEVICE_MOUSE && vendor == "00:12:A1") ||
// Microsoft "Microsoft Bluetooth Notebook Mouse 5000", model X807028-001
(type == DEVICE_MOUSE && vendor == "7C:ED:8D"))
return false;
// TODO: Move this database into a config file.
return true;
}
bool BluetoothDevice::ProvidesServiceWithUUID(
const std::string& uuid) const {
......
......@@ -165,6 +165,10 @@ class BluetoothDevice {
// DEVICE_PERIPHERAL.
DeviceType GetDeviceType() const;
// Indicates whether the device is known to support pairing based on its
// device class and address.
bool IsPairable() const;
// Indicates whether the device is paired with the adapter.
virtual bool IsPaired() const = 0;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment