| OLD | NEW |
| 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/unlock_manager_impl.h" | 5 #include "components/proximity_auth/unlock_manager_impl.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/location.h" | 8 #include "base/location.h" |
| 9 #include "base/logging.h" | 9 #include "base/logging.h" |
| 10 #include "base/memory/ptr_util.h" | 10 #include "base/memory/ptr_util.h" |
| (...skipping 334 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 345 void UnlockManagerImpl::OnGotSignInChallenge(const std::string& challenge) { | 345 void UnlockManagerImpl::OnGotSignInChallenge(const std::string& challenge) { |
| 346 PA_LOG(INFO) << "Got sign-in challenge, sending for decryption..."; | 346 PA_LOG(INFO) << "Got sign-in challenge, sending for decryption..."; |
| 347 GetMessenger()->RequestDecryption(challenge); | 347 GetMessenger()->RequestDecryption(challenge); |
| 348 } | 348 } |
| 349 | 349 |
| 350 ScreenlockState UnlockManagerImpl::GetScreenlockState() { | 350 ScreenlockState UnlockManagerImpl::GetScreenlockState() { |
| 351 if (!life_cycle_ || | 351 if (!life_cycle_ || |
| 352 life_cycle_->GetState() == RemoteDeviceLifeCycle::State::STOPPED) | 352 life_cycle_->GetState() == RemoteDeviceLifeCycle::State::STOPPED) |
| 353 return ScreenlockState::INACTIVE; | 353 return ScreenlockState::INACTIVE; |
| 354 | 354 |
| 355 if (!bluetooth_adapter_ || !bluetooth_adapter_->IsPowered()) |
| 356 return ScreenlockState::NO_BLUETOOTH; |
| 357 |
| 355 if (IsUnlockAllowed()) | 358 if (IsUnlockAllowed()) |
| 356 return ScreenlockState::AUTHENTICATED; | 359 return ScreenlockState::AUTHENTICATED; |
| 357 | 360 |
| 358 if (life_cycle_->GetState() == | 361 if (life_cycle_->GetState() == |
| 359 RemoteDeviceLifeCycle::State::AUTHENTICATION_FAILED) | 362 RemoteDeviceLifeCycle::State::AUTHENTICATION_FAILED) |
| 360 return ScreenlockState::PHONE_NOT_AUTHENTICATED; | 363 return ScreenlockState::PHONE_NOT_AUTHENTICATED; |
| 361 | 364 |
| 362 if (is_waking_up_ || | 365 if (is_waking_up_ || |
| 363 life_cycle_->GetState() == RemoteDeviceLifeCycle::State::AUTHENTICATING || | 366 life_cycle_->GetState() == RemoteDeviceLifeCycle::State::AUTHENTICATING || |
| 364 life_cycle_->GetState() == | 367 life_cycle_->GetState() == |
| 365 RemoteDeviceLifeCycle::State::FINDING_CONNECTION) | 368 RemoteDeviceLifeCycle::State::FINDING_CONNECTION) |
| 366 return ScreenlockState::BLUETOOTH_CONNECTING; | 369 return ScreenlockState::BLUETOOTH_CONNECTING; |
| 367 | 370 |
| 368 if (!bluetooth_adapter_ || !bluetooth_adapter_->IsPowered()) | |
| 369 return ScreenlockState::NO_BLUETOOTH; | |
| 370 | |
| 371 Messenger* messenger = GetMessenger(); | 371 Messenger* messenger = GetMessenger(); |
| 372 if (screenlock_type_ == ProximityAuthSystem::SIGN_IN && messenger && | 372 if (screenlock_type_ == ProximityAuthSystem::SIGN_IN && messenger && |
| 373 !messenger->SupportsSignIn()) | 373 !messenger->SupportsSignIn()) |
| 374 return ScreenlockState::PHONE_UNSUPPORTED; | 374 return ScreenlockState::PHONE_UNSUPPORTED; |
| 375 | 375 |
| 376 // If the RSSI is too low, then the remote device is nowhere near the local | 376 // If the RSSI is too low, then the remote device is nowhere near the local |
| 377 // device. This message should take priority over messages about screen lock | 377 // device. This message should take priority over messages about screen lock |
| 378 // states. | 378 // states. |
| 379 if (!proximity_monitor_->IsUnlockAllowed()) | 379 if (!proximity_monitor_->IsUnlockAllowed()) |
| 380 return ScreenlockState::RSSI_TOO_LOW; | 380 return ScreenlockState::RSSI_TOO_LOW; |
| (...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 483 | 483 |
| 484 Messenger* UnlockManagerImpl::GetMessenger() { | 484 Messenger* UnlockManagerImpl::GetMessenger() { |
| 485 // TODO(tengs): We should use a weak pointer to hold the Messenger instance | 485 // TODO(tengs): We should use a weak pointer to hold the Messenger instance |
| 486 // instead. | 486 // instead. |
| 487 if (!life_cycle_) | 487 if (!life_cycle_) |
| 488 return nullptr; | 488 return nullptr; |
| 489 return life_cycle_->GetMessenger(); | 489 return life_cycle_->GetMessenger(); |
| 490 } | 490 } |
| 491 | 491 |
| 492 } // namespace proximity_auth | 492 } // namespace proximity_auth |
| OLD | NEW |