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

Side by Side Diff: device/bluetooth/bluez/bluetooth_device_bluez.cc

Issue 2751303002: bluetooth: Stop support of reconnecting devices not supporting pairing (Closed)
Patch Set: Created 3 years, 9 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 unified diff | Download patch
« no previous file with comments | « device/bluetooth/bluez/bluetooth_bluez_unittest.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "device/bluetooth/bluez/bluetooth_device_bluez.h" 5 #include "device/bluetooth/bluez/bluetooth_device_bluez.h"
6 6
7 #include <stdio.h> 7 #include <stdio.h>
8 8
9 #include <algorithm> 9 #include <algorithm>
10 #include <memory> 10 #include <memory>
(...skipping 308 matching lines...) Expand 10 before | Expand all | Expand 10 after
319 else 319 else
320 return base::nullopt; 320 return base::nullopt;
321 } 321 }
322 322
323 bool BluetoothDeviceBlueZ::IsPaired() const { 323 bool BluetoothDeviceBlueZ::IsPaired() const {
324 bluez::BluetoothDeviceClient::Properties* properties = 324 bluez::BluetoothDeviceClient::Properties* properties =
325 bluez::BluezDBusManager::Get()->GetBluetoothDeviceClient()->GetProperties( 325 bluez::BluezDBusManager::Get()->GetBluetoothDeviceClient()->GetProperties(
326 object_path_); 326 object_path_);
327 DCHECK(properties); 327 DCHECK(properties);
328 328
329 // Trusted devices are devices that don't support pairing but that the 329 // The Paired property reflects the successful pairing for BR/EDR/LE. The
330 // user has explicitly connected; it makes no sense for UI purposes to 330 // value of the Paired property is always false for the devices that don't
331 // treat them differently from each other. 331 // support pairing. Once a device is paired successfully, both Paired and
332 return properties->paired.value() || properties->trusted.value(); 332 // Trusted properties will be set to true.
333 return properties->paired.value();
333 } 334 }
334 335
335 bool BluetoothDeviceBlueZ::IsConnected() const { 336 bool BluetoothDeviceBlueZ::IsConnected() const {
336 bluez::BluetoothDeviceClient::Properties* properties = 337 bluez::BluetoothDeviceClient::Properties* properties =
337 bluez::BluezDBusManager::Get()->GetBluetoothDeviceClient()->GetProperties( 338 bluez::BluezDBusManager::Get()->GetBluetoothDeviceClient()->GetProperties(
338 object_path_); 339 object_path_);
339 DCHECK(properties); 340 DCHECK(properties);
340 341
341 return properties->connected.value(); 342 return properties->connected.value();
342 } 343 }
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after
435 void BluetoothDeviceBlueZ::Connect( 436 void BluetoothDeviceBlueZ::Connect(
436 BluetoothDevice::PairingDelegate* pairing_delegate, 437 BluetoothDevice::PairingDelegate* pairing_delegate,
437 const base::Closure& callback, 438 const base::Closure& callback,
438 const ConnectErrorCallback& error_callback) { 439 const ConnectErrorCallback& error_callback) {
439 if (num_connecting_calls_++ == 0) 440 if (num_connecting_calls_++ == 0)
440 adapter()->NotifyDeviceChanged(this); 441 adapter()->NotifyDeviceChanged(this);
441 442
442 VLOG(1) << object_path_.value() << ": Connecting, " << num_connecting_calls_ 443 VLOG(1) << object_path_.value() << ": Connecting, " << num_connecting_calls_
443 << " in progress"; 444 << " in progress";
444 445
445 if (IsPaired() || !pairing_delegate || !IsPairable()) { 446 if (IsPaired() || !pairing_delegate) {
446 // No need to pair, or unable to, skip straight to connection. 447 // No need to pair, or unable to, skip straight to connection.
447 ConnectInternal(false, callback, error_callback); 448 ConnectInternal(false, callback, error_callback);
448 } else { 449 } else {
449 // Initiate high-security connection with pairing. 450 // Initiate high-security connection with pairing.
450 BeginPairing(pairing_delegate); 451 BeginPairing(pairing_delegate);
451 452
452 bluez::BluezDBusManager::Get()->GetBluetoothDeviceClient()->Pair( 453 bluez::BluezDBusManager::Get()->GetBluetoothDeviceClient()->Pair(
453 object_path_, 454 object_path_,
454 base::Bind(&BluetoothDeviceBlueZ::OnPairDuringConnect, 455 base::Bind(&BluetoothDeviceBlueZ::OnPairDuringConnect,
455 weak_ptr_factory_.GetWeakPtr(), callback, error_callback), 456 weak_ptr_factory_.GetWeakPtr(), callback, error_callback),
(...skipping 491 matching lines...) Expand 10 before | Expand all | Expand 10 after
947 void BluetoothDeviceBlueZ::OnForgetError(const ErrorCallback& error_callback, 948 void BluetoothDeviceBlueZ::OnForgetError(const ErrorCallback& error_callback,
948 const std::string& error_name, 949 const std::string& error_name,
949 const std::string& error_message) { 950 const std::string& error_message) {
950 LOG(WARNING) << object_path_.value() 951 LOG(WARNING) << object_path_.value()
951 << ": Failed to remove device: " << error_name << ": " 952 << ": Failed to remove device: " << error_name << ": "
952 << error_message; 953 << error_message;
953 error_callback.Run(); 954 error_callback.Run();
954 } 955 }
955 956
956 } // namespace bluez 957 } // namespace bluez
OLDNEW
« no previous file with comments | « device/bluetooth/bluez/bluetooth_bluez_unittest.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698