summaryrefslogtreecommitdiffstats
path: root/device/bluetooth
diff options
context:
space:
mode:
authorkeybuk@chromium.org <keybuk@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2014-06-05 19:16:50 +0000
committerkeybuk@chromium.org <keybuk@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2014-06-05 19:16:50 +0000
commit9768fc8d2c4e80402876f0430ef521da60905f50 (patch)
tree9239dcc20049640c9ce260c343239bb2a7b9189d /device/bluetooth
parent14702e4d7662c18b3fea027d33b1be51c3c5ebe4 (diff)
downloadchromium_src-9768fc8d2c4e80402876f0430ef521da60905f50.zip
chromium_src-9768fc8d2c4e80402876f0430ef521da60905f50.tar.gz
chromium_src-9768fc8d2c4e80402876f0430ef521da60905f50.tar.bz2
Bluetooth: Authorize Service when Paired
We mark paired devices as Trusted so this method call should never be called in practice. But there is a race where if the service connection is being made directly (e.g. via l2test or rctest) then BlueZ doesn't process the property change until after its already sent the AuthorizeService method call. So always approve service connections for paired devices, which is the intended effect of Trusted anyway. BUG=None Review URL: https://codereview.chromium.org/310323002 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@275212 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'device/bluetooth')
-rw-r--r--device/bluetooth/bluetooth_adapter_chromeos.cc22
1 files changed, 20 insertions, 2 deletions
diff --git a/device/bluetooth/bluetooth_adapter_chromeos.cc b/device/bluetooth/bluetooth_adapter_chromeos.cc
index 0f60293..4759f04 100644
--- a/device/bluetooth/bluetooth_adapter_chromeos.cc
+++ b/device/bluetooth/bluetooth_adapter_chromeos.cc
@@ -537,8 +537,26 @@ void BluetoothAdapterChromeOS::AuthorizeService(
DCHECK(agent_.get());
VLOG(1) << device_path.value() << ": AuthorizeService: " << uuid;
- // TODO(keybuk): implement
- callback.Run(CANCELLED);
+ BluetoothDeviceChromeOS* device_chromeos = GetDeviceWithPath(device_path);
+ if (!device_chromeos) {
+ callback.Run(CANCELLED);
+ return;
+ }
+
+ // We always set paired devices to Trusted, so the only reason that this
+ // method call would ever be called is in the case of a race condition where
+ // our "Set('Trusted', true)" method call is still pending in the Bluetooth
+ // daemon because it's busy handling the incoming connection.
+ if (device_chromeos->IsPaired()) {
+ callback.Run(SUCCESS);
+ return;
+ }
+
+ // TODO(keybuk): reject service authorizations when not paired, determine
+ // whether this is acceptable long-term.
+ LOG(WARNING) << "Rejecting service connection from unpaired device "
+ << device_chromeos->GetAddress() << " for UUID " << uuid;
+ callback.Run(REJECTED);
}
void BluetoothAdapterChromeOS::Cancel() {