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

Side by Side Diff: components/proximity_auth/remote_device_life_cycle_impl.cc

Issue 2841743003: [EasyUnlock] Update BluetoothLowEnergyConnectionFinder to look for EIDs. (Closed)
Patch Set: [EasyUnlock] Update BluetoothLowEnergyConnectionFinder to look for EIDs. Created 3 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 unified diff | Download patch
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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 "components/proximity_auth/remote_device_life_cycle_impl.h" 5 #include "components/proximity_auth/remote_device_life_cycle_impl.h"
6 6
7 #include <utility> 7 #include <utility>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/command_line.h"
10 #include "base/location.h" 11 #include "base/location.h"
11 #include "base/memory/ptr_util.h" 12 #include "base/memory/ptr_util.h"
12 #include "base/threading/thread_task_runner_handle.h" 13 #include "base/threading/thread_task_runner_handle.h"
13 #include "base/time/default_tick_clock.h" 14 #include "base/time/default_tick_clock.h"
14 #include "components/cryptauth/bluetooth_throttler_impl.h" 15 #include "components/cryptauth/bluetooth_throttler_impl.h"
15 #include "components/cryptauth/connection_finder.h" 16 #include "components/cryptauth/connection_finder.h"
16 #include "components/cryptauth/device_to_device_authenticator.h" 17 #include "components/cryptauth/device_to_device_authenticator.h"
17 #include "components/cryptauth/secure_context.h" 18 #include "components/cryptauth/secure_context.h"
18 #include "components/cryptauth/secure_message_delegate.h" 19 #include "components/cryptauth/secure_message_delegate.h"
19 #include "components/proximity_auth/ble/bluetooth_low_energy_connection.h"
20 #include "components/proximity_auth/ble/bluetooth_low_energy_connection_finder.h "
21 #include "components/proximity_auth/bluetooth_connection.h" 20 #include "components/proximity_auth/bluetooth_connection.h"
22 #include "components/proximity_auth/bluetooth_connection_finder.h" 21 #include "components/proximity_auth/bluetooth_connection_finder.h"
22 #include "components/proximity_auth/bluetooth_low_energy_connection_finder.h"
23 #include "components/proximity_auth/logging/logging.h" 23 #include "components/proximity_auth/logging/logging.h"
24 #include "components/proximity_auth/messenger_impl.h" 24 #include "components/proximity_auth/messenger_impl.h"
25 #include "components/proximity_auth/proximity_auth_client.h" 25 #include "components/proximity_auth/proximity_auth_client.h"
26 #include "components/proximity_auth/switches.h"
26 27
27 namespace proximity_auth { 28 namespace proximity_auth {
28 29
29 namespace { 30 namespace {
30 31
31 // The UUID of the Smart Lock classic Bluetooth service. 32 // The UUID of the Smart Lock classic Bluetooth service.
32 const char kClassicBluetoothServiceUUID[] = 33 const char kClassicBluetoothServiceUUID[] =
33 "704EE561-3782-405A-A14B-2D47A2DDCDDF"; 34 "704EE561-3782-405A-A14B-2D47A2DDCDDF";
34 35
35 // The UUID of the Bluetooth Low Energy service.
36 const char kBLESmartLockServiceUUID[] = "b3b7e28e-a000-3e17-bd86-6e97b9e28c11";
37
38 // The time to wait, in seconds, after authentication fails, before retrying 36 // The time to wait, in seconds, after authentication fails, before retrying
39 // another connection. 37 // another connection.
40 const int kAuthenticationRecoveryTimeSeconds = 10; 38 const int kAuthenticationRecoveryTimeSeconds = 10;
41 39
42 } // namespace 40 } // namespace
43 41
44 RemoteDeviceLifeCycleImpl::RemoteDeviceLifeCycleImpl( 42 RemoteDeviceLifeCycleImpl::RemoteDeviceLifeCycleImpl(
45 const cryptauth::RemoteDevice& remote_device, 43 const cryptauth::RemoteDevice& remote_device,
46 ProximityAuthClient* proximity_auth_client) 44 ProximityAuthClient* proximity_auth_client)
47 : remote_device_(remote_device), 45 : remote_device_(remote_device),
(...skipping 27 matching lines...) Expand all
75 void RemoteDeviceLifeCycleImpl::AddObserver(Observer* observer) { 73 void RemoteDeviceLifeCycleImpl::AddObserver(Observer* observer) {
76 observers_.AddObserver(observer); 74 observers_.AddObserver(observer);
77 } 75 }
78 76
79 void RemoteDeviceLifeCycleImpl::RemoveObserver(Observer* observer) { 77 void RemoteDeviceLifeCycleImpl::RemoveObserver(Observer* observer) {
80 observers_.RemoveObserver(observer); 78 observers_.RemoveObserver(observer);
81 } 79 }
82 80
83 std::unique_ptr<cryptauth::ConnectionFinder> 81 std::unique_ptr<cryptauth::ConnectionFinder>
84 RemoteDeviceLifeCycleImpl::CreateConnectionFinder() { 82 RemoteDeviceLifeCycleImpl::CreateConnectionFinder() {
85 if (remote_device_.bluetooth_address.empty()) { 83 if (base::CommandLine::ForCurrentProcess()->HasSwitch(
84 proximity_auth::switches::kEnableBluetoothLowEnergyDiscovery)) {
86 return base::MakeUnique<BluetoothLowEnergyConnectionFinder>( 85 return base::MakeUnique<BluetoothLowEnergyConnectionFinder>(
87 remote_device_, kBLESmartLockServiceUUID, 86 remote_device_,
88 BluetoothLowEnergyConnectionFinder::FinderStrategy::FIND_PAIRED_DEVICE, 87 base::MakeUnique<cryptauth::RemoteBeaconSeedFetcher>(
89 nullptr, bluetooth_throttler_, 3); 88 proximity_auth_client_->GetCryptAuthDeviceManager()),
89 bluetooth_throttler_);
90 } else { 90 } else {
91 return base::MakeUnique<BluetoothConnectionFinder>( 91 return base::MakeUnique<BluetoothConnectionFinder>(
92 remote_device_, device::BluetoothUUID(kClassicBluetoothServiceUUID), 92 remote_device_, device::BluetoothUUID(kClassicBluetoothServiceUUID),
93 base::TimeDelta::FromSeconds(3)); 93 base::TimeDelta::FromSeconds(3));
94 } 94 }
95 } 95 }
96 96
97 std::unique_ptr<cryptauth::Authenticator> 97 std::unique_ptr<cryptauth::Authenticator>
98 RemoteDeviceLifeCycleImpl::CreateAuthenticator() { 98 RemoteDeviceLifeCycleImpl::CreateAuthenticator() {
99 return base::MakeUnique<cryptauth::DeviceToDeviceAuthenticator>( 99 return base::MakeUnique<cryptauth::DeviceToDeviceAuthenticator>(
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
166 TransitionToState(RemoteDeviceLifeCycle::State::SECURE_CHANNEL_ESTABLISHED); 166 TransitionToState(RemoteDeviceLifeCycle::State::SECURE_CHANNEL_ESTABLISHED);
167 } 167 }
168 168
169 void RemoteDeviceLifeCycleImpl::OnDisconnected() { 169 void RemoteDeviceLifeCycleImpl::OnDisconnected() {
170 DCHECK(state_ == RemoteDeviceLifeCycle::State::SECURE_CHANNEL_ESTABLISHED); 170 DCHECK(state_ == RemoteDeviceLifeCycle::State::SECURE_CHANNEL_ESTABLISHED);
171 messenger_.reset(); 171 messenger_.reset();
172 FindConnection(); 172 FindConnection();
173 } 173 }
174 174
175 } // namespace proximity_auth 175 } // namespace proximity_auth
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698