| Index: components/proximity_auth/unlock_manager.cc
|
| diff --git a/components/proximity_auth/unlock_manager.cc b/components/proximity_auth/unlock_manager.cc
|
| index abce8b40c4a6db7dc000203335e0880f981d7bb6..e55ad50814ff678267ed6b4f73b051e385a6f75f 100644
|
| --- a/components/proximity_auth/unlock_manager.cc
|
| +++ b/components/proximity_auth/unlock_manager.cc
|
| @@ -80,6 +80,7 @@
|
| ProximityAuthClient* proximity_auth_client)
|
| : screenlock_type_(screenlock_type),
|
| life_cycle_(nullptr),
|
| + messenger_(nullptr),
|
| proximity_monitor_(proximity_monitor.Pass()),
|
| proximity_auth_client_(proximity_auth_client),
|
| is_locked_(false),
|
| @@ -112,8 +113,8 @@
|
| }
|
|
|
| UnlockManager::~UnlockManager() {
|
| - if (GetMessenger())
|
| - GetMessenger()->RemoveObserver(this);
|
| + if (messenger_)
|
| + messenger_->RemoveObserver(this);
|
|
|
| ScreenlockBridge::Get()->RemoveObserver(this);
|
|
|
| @@ -133,13 +134,15 @@
|
| RemoteDeviceLifeCycle::State::SECURE_CHANNEL_ESTABLISHED &&
|
| proximity_monitor_->IsUnlockAllowed() &&
|
| (screenlock_type_ != ScreenlockType::SIGN_IN ||
|
| - (GetMessenger() && GetMessenger()->SupportsSignIn())));
|
| + (messenger_ && messenger_->SupportsSignIn())));
|
| }
|
|
|
| void UnlockManager::SetRemoteDeviceLifeCycle(
|
| RemoteDeviceLifeCycle* life_cycle) {
|
| - if (GetMessenger())
|
| - GetMessenger()->RemoveObserver(this);
|
| + if (messenger_) {
|
| + messenger_->RemoveObserver(this);
|
| + messenger_ = nullptr;
|
| + }
|
|
|
| life_cycle_ = life_cycle;
|
| if (life_cycle_)
|
| @@ -154,8 +157,10 @@
|
| << static_cast<int>(state);
|
|
|
| remote_screenlock_state_.reset();
|
| - if (state == RemoteDeviceLifeCycle::State::SECURE_CHANNEL_ESTABLISHED)
|
| - GetMessenger()->AddObserver(this);
|
| + if (state == RemoteDeviceLifeCycle::State::SECURE_CHANNEL_ESTABLISHED) {
|
| + messenger_ = life_cycle_->GetMessenger();
|
| + messenger_->AddObserver(this);
|
| + }
|
|
|
| if (state == RemoteDeviceLifeCycle::State::AUTHENTICATION_FAILED)
|
| SetWakingUpState(false);
|
| @@ -204,7 +209,7 @@
|
| AcceptAuthAttempt(false);
|
| } else {
|
| sign_in_secret_ = decrypted_bytes.Pass();
|
| - GetMessenger()->DispatchUnlockEvent();
|
| + messenger_->DispatchUnlockEvent();
|
| }
|
| }
|
|
|
| @@ -218,13 +223,14 @@
|
| PA_LOG(INFO) << "[Unlock] Unlock response from remote device: "
|
| << (success ? "success" : "failure");
|
| if (success)
|
| - GetMessenger()->DispatchUnlockEvent();
|
| + messenger_->DispatchUnlockEvent();
|
| else
|
| AcceptAuthAttempt(false);
|
| }
|
|
|
| void UnlockManager::OnDisconnected() {
|
| - GetMessenger()->RemoveObserver(this);
|
| + messenger_->RemoveObserver(this);
|
| + messenger_ = nullptr;
|
| }
|
|
|
| void UnlockManager::OnScreenDidLock(
|
| @@ -310,12 +316,12 @@
|
| if (screenlock_type_ == ScreenlockType::SIGN_IN) {
|
| SendSignInChallenge();
|
| } else {
|
| - if (GetMessenger()->SupportsSignIn()) {
|
| - GetMessenger()->RequestUnlock();
|
| + if (messenger_->SupportsSignIn()) {
|
| + messenger_->RequestUnlock();
|
| } else {
|
| PA_LOG(INFO) << "[Unlock] Protocol v3.1 not supported, skipping "
|
| << "request_unlock.";
|
| - GetMessenger()->DispatchUnlockEvent();
|
| + messenger_->DispatchUnlockEvent();
|
| }
|
| }
|
| }
|
| @@ -343,9 +349,8 @@
|
| if (!bluetooth_adapter_ || !bluetooth_adapter_->IsPowered())
|
| return ScreenlockState::NO_BLUETOOTH;
|
|
|
| - Messenger* messenger = GetMessenger();
|
| - if (screenlock_type_ == ScreenlockType::SIGN_IN && messenger &&
|
| - !messenger->SupportsSignIn())
|
| + if (screenlock_type_ == ScreenlockType::SIGN_IN && messenger_ &&
|
| + !messenger_->SupportsSignIn())
|
| return ScreenlockState::PHONE_UNSUPPORTED;
|
|
|
| // If the RSSI is too low, then the remote device is nowhere near the local
|
| @@ -463,12 +468,4 @@
|
| return RemoteScreenlockState::UNKNOWN;
|
| }
|
|
|
| -Messenger* UnlockManager::GetMessenger() {
|
| - // TODO(tengs): We should use a weak pointer to hold the Messenger instance
|
| - // instead.
|
| - if (!life_cycle_)
|
| - return nullptr;
|
| - return life_cycle_->GetMessenger();
|
| -}
|
| -
|
| } // namespace proximity_auth
|
|
|