Commit 66991186 authored by James Hawkins's avatar James Hawkins Committed by Commit Bot

ProximityAuth/CryptAuth: Clean up logging.

* Added string converters for ScreenlockState and
RemoteDeviceLifeCycleState
* Removed 'generating EIDs' log
* Removed duplicate life cycle log

R=khorimoto@chromium.org

Bug: none
Test: none
Change-Id: I40e8b5e43b1e2dc29d6542aae33b6af8b78ca722
Reviewed-on: https://chromium-review.googlesource.com/1042962Reviewed-by: default avatarKyle Horimoto <khorimoto@chromium.org>
Commit-Queue: James Hawkins <jhawkins@chromium.org>
Cr-Commit-Position: refs/heads/master@{#555875}
parent 1cf6caff
...@@ -35,6 +35,7 @@ static_library("proximity_auth") { ...@@ -35,6 +35,7 @@ static_library("proximity_auth") {
"proximity_monitor_impl.cc", "proximity_monitor_impl.cc",
"proximity_monitor_impl.h", "proximity_monitor_impl.h",
"proximity_monitor_observer.h", "proximity_monitor_observer.h",
"remote_device_life_cycle.cc",
"remote_device_life_cycle.h", "remote_device_life_cycle.h",
"remote_device_life_cycle_impl.cc", "remote_device_life_cycle_impl.cc",
"remote_device_life_cycle_impl.h", "remote_device_life_cycle_impl.h",
...@@ -42,6 +43,7 @@ static_library("proximity_auth") { ...@@ -42,6 +43,7 @@ static_library("proximity_auth") {
"remote_status_update.h", "remote_status_update.h",
"screenlock_bridge.cc", "screenlock_bridge.cc",
"screenlock_bridge.h", "screenlock_bridge.h",
"screenlock_state.cc",
"screenlock_state.h", "screenlock_state.h",
"switches.cc", "switches.cc",
"switches.h", "switches.h",
......
...@@ -158,7 +158,6 @@ bool BluetoothLowEnergyConnectionFinder::IsRightDevice( ...@@ -158,7 +158,6 @@ bool BluetoothLowEnergyConnectionFinder::IsRightDevice(
if (!service_data) if (!service_data)
return false; return false;
PA_LOG(INFO) << "Generating EIDs for: " << device->GetAddress();
std::string service_data_string(service_data->begin(), service_data->end()); std::string service_data_string(service_data->begin(), service_data->end());
std::vector<cryptauth::DataWithTimestamp> nearest_eids = std::vector<cryptauth::DataWithTimestamp> nearest_eids =
eid_generator_->GenerateNearestEids(remote_device_.beacon_seeds); eid_generator_->GenerateNearestEids(remote_device_.beacon_seeds);
......
// Copyright 2018 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "chromeos/components/proximity_auth/remote_device_life_cycle.h"
namespace proximity_auth {
namespace {
using State = RemoteDeviceLifeCycle::State;
} // namespace
std::ostream& operator<<(std::ostream& stream, const State& state) {
switch (state) {
case State::STOPPED:
stream << "[stopped]";
break;
case State::FINDING_CONNECTION:
stream << "[finding connection]";
break;
case State::AUTHENTICATING:
stream << "[authenticating]";
break;
case State::SECURE_CHANNEL_ESTABLISHED:
stream << "[secure channel established]";
break;
case State::AUTHENTICATION_FAILED:
stream << "[authentication failed]";
break;
}
return stream;
}
} // namespace proximity_auth
\ No newline at end of file
...@@ -5,6 +5,8 @@ ...@@ -5,6 +5,8 @@
#ifndef CHROMEOS_COMPONENTS_PROXIMITY_AUTH_REMOTE_DEVICE_LIFE_CYCLE_H_ #ifndef CHROMEOS_COMPONENTS_PROXIMITY_AUTH_REMOTE_DEVICE_LIFE_CYCLE_H_
#define CHROMEOS_COMPONENTS_PROXIMITY_AUTH_REMOTE_DEVICE_LIFE_CYCLE_H_ #define CHROMEOS_COMPONENTS_PROXIMITY_AUTH_REMOTE_DEVICE_LIFE_CYCLE_H_
#include <ostream>
#include "base/macros.h" #include "base/macros.h"
#include "components/cryptauth/connection.h" #include "components/cryptauth/connection.h"
#include "components/cryptauth/remote_device.h" #include "components/cryptauth/remote_device.h"
...@@ -76,6 +78,9 @@ class RemoteDeviceLifeCycle { ...@@ -76,6 +78,9 @@ class RemoteDeviceLifeCycle {
virtual void RemoveObserver(Observer* observer) = 0; virtual void RemoveObserver(Observer* observer) = 0;
}; };
std::ostream& operator<<(std::ostream& stream,
const RemoteDeviceLifeCycle::State& state);
} // namespace proximity_auth } // namespace proximity_auth
#endif // CHROMEOS_COMPONENTS_PROXIMITY_AUTH_REMOTE_DEVICE_LIFE_CYCLE_H_ #endif // CHROMEOS_COMPONENTS_PROXIMITY_AUTH_REMOTE_DEVICE_LIFE_CYCLE_H_
...@@ -87,8 +87,7 @@ RemoteDeviceLifeCycleImpl::CreateAuthenticator() { ...@@ -87,8 +87,7 @@ RemoteDeviceLifeCycleImpl::CreateAuthenticator() {
void RemoteDeviceLifeCycleImpl::TransitionToState( void RemoteDeviceLifeCycleImpl::TransitionToState(
RemoteDeviceLifeCycle::State new_state) { RemoteDeviceLifeCycle::State new_state) {
PA_LOG(INFO) << "Life cycle transition: " << static_cast<int>(state_) PA_LOG(INFO) << "Life cycle transition: " << state_ << " => " << new_state;
<< " => " << static_cast<int>(new_state);
RemoteDeviceLifeCycle::State old_state = state_; RemoteDeviceLifeCycle::State old_state = state_;
state_ = new_state; state_ = new_state;
for (auto& observer : observers_) for (auto& observer : observers_)
......
// Copyright 2018 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "chromeos/components/proximity_auth/screenlock_state.h"
namespace proximity_auth {
std::ostream& operator<<(std::ostream& stream, const ScreenlockState& state) {
switch (state) {
case ScreenlockState::INACTIVE:
stream << "[inactive]";
break;
case ScreenlockState::NO_BLUETOOTH:
stream << "[no bluetooth]";
break;
case ScreenlockState::BLUETOOTH_CONNECTING:
stream << "[bluetooth connecting]";
break;
case ScreenlockState::NO_PHONE:
stream << "[no phone]";
break;
case ScreenlockState::PHONE_NOT_AUTHENTICATED:
stream << "[phone not authenticated]";
break;
case ScreenlockState::PHONE_LOCKED:
stream << "[phone locked]";
break;
case ScreenlockState::PHONE_NOT_LOCKABLE:
stream << "[phone not lockable]";
break;
case ScreenlockState::PHONE_UNSUPPORTED:
stream << "[phone unsupported]";
break;
case ScreenlockState::RSSI_TOO_LOW:
stream << "[rssi too low]";
break;
case ScreenlockState::PHONE_LOCKED_AND_RSSI_TOO_LOW:
stream << "[phone locked and rssi too low]";
break;
case ScreenlockState::AUTHENTICATED:
stream << "[authenticated]";
break;
case ScreenlockState::PASSWORD_REAUTH:
stream << "[password reauth]";
break;
}
return stream;
}
} // namespace proximity_auth
\ No newline at end of file
...@@ -5,6 +5,8 @@ ...@@ -5,6 +5,8 @@
#ifndef CHROMEOS_COMPONENTS_PROXIMITY_AUTH_SCREENLOCK_STATE_H_ #ifndef CHROMEOS_COMPONENTS_PROXIMITY_AUTH_SCREENLOCK_STATE_H_
#define CHROMEOS_COMPONENTS_PROXIMITY_AUTH_SCREENLOCK_STATE_H_ #define CHROMEOS_COMPONENTS_PROXIMITY_AUTH_SCREENLOCK_STATE_H_
#include <ostream>
namespace proximity_auth { namespace proximity_auth {
// Possible user states of the proximity auth feature on the lock or sign-in // Possible user states of the proximity auth feature on the lock or sign-in
...@@ -46,6 +48,8 @@ enum class ScreenlockState { ...@@ -46,6 +48,8 @@ enum class ScreenlockState {
PASSWORD_REAUTH, PASSWORD_REAUTH,
}; };
std::ostream& operator<<(std::ostream& stream, const ScreenlockState& state);
} // namespace proximity_auth } // namespace proximity_auth
#endif // CHROMEOS_COMPONENTS_PROXIMITY_AUTH_SCREENLOCK_STATE_H_ #endif // CHROMEOS_COMPONENTS_PROXIMITY_AUTH_SCREENLOCK_STATE_H_
...@@ -151,8 +151,6 @@ void UnlockManagerImpl::SetRemoteDeviceLifeCycle( ...@@ -151,8 +151,6 @@ void UnlockManagerImpl::SetRemoteDeviceLifeCycle(
void UnlockManagerImpl::OnLifeCycleStateChanged() { void UnlockManagerImpl::OnLifeCycleStateChanged() {
RemoteDeviceLifeCycle::State state = life_cycle_->GetState(); RemoteDeviceLifeCycle::State state = life_cycle_->GetState();
PA_LOG(INFO) << "RemoteDeviceLifeCycle state changed: "
<< static_cast<int>(state);
remote_screenlock_state_.reset(); remote_screenlock_state_.reset();
if (state == RemoteDeviceLifeCycle::State::SECURE_CHANNEL_ESTABLISHED) { if (state == RemoteDeviceLifeCycle::State::SECURE_CHANNEL_ESTABLISHED) {
...@@ -419,9 +417,8 @@ void UnlockManagerImpl::UpdateLockScreen() { ...@@ -419,9 +417,8 @@ void UnlockManagerImpl::UpdateLockScreen() {
if (screenlock_state_ == new_state) if (screenlock_state_ == new_state)
return; return;
PA_LOG(INFO) << "Updating screenlock state from " PA_LOG(INFO) << "Updating screenlock state from " << screenlock_state_
<< static_cast<int>(screenlock_state_) << " to " << " to " << new_state;
<< static_cast<int>(new_state);
proximity_auth_client_->UpdateScreenlockState(new_state); proximity_auth_client_->UpdateScreenlockState(new_state);
screenlock_state_ = new_state; screenlock_state_ = new_state;
} }
......
...@@ -207,8 +207,6 @@ void BluetoothLowEnergyWeaveClientConnection::SetConnectionLatency() { ...@@ -207,8 +207,6 @@ void BluetoothLowEnergyWeaveClientConnection::SetConnectionLatency() {
return; return;
} }
PA_LOG(INFO) << "Setting connection latency for " << GetDeviceInfoLogString()
<< ".";
bluetooth_device->SetConnectionLatency( bluetooth_device->SetConnectionLatency(
device::BluetoothDevice::ConnectionLatency::CONNECTION_LATENCY_LOW, device::BluetoothDevice::ConnectionLatency::CONNECTION_LATENCY_LOW,
base::Bind(&BluetoothLowEnergyWeaveClientConnection::CreateGattConnection, base::Bind(&BluetoothLowEnergyWeaveClientConnection::CreateGattConnection,
......
...@@ -116,4 +116,21 @@ std::string Connection::GetDeviceInfoLogString() { ...@@ -116,4 +116,21 @@ std::string Connection::GetDeviceInfoLogString() {
return ss.str(); return ss.str();
} }
std::ostream& operator<<(std::ostream& stream,
const Connection::Status& status) {
switch (status) {
case Connection::Status::DISCONNECTED:
stream << "[disconnected]";
break;
case Connection::Status::IN_PROGRESS:
stream << "[in progress]";
break;
case Connection::Status::CONNECTED:
stream << "[connected]";
break;
}
return stream;
}
} // namespace cryptauth } // namespace cryptauth
...@@ -6,6 +6,7 @@ ...@@ -6,6 +6,7 @@
#define COMPONENTS_CRYPTAUTH_CONNECTION_H_ #define COMPONENTS_CRYPTAUTH_CONNECTION_H_
#include <memory> #include <memory>
#include <ostream>
#include "base/macros.h" #include "base/macros.h"
#include "base/memory/ref_counted.h" #include "base/memory/ref_counted.h"
...@@ -117,6 +118,9 @@ class Connection { ...@@ -117,6 +118,9 @@ class Connection {
DISALLOW_COPY_AND_ASSIGN(Connection); DISALLOW_COPY_AND_ASSIGN(Connection);
}; };
std::ostream& operator<<(std::ostream& stream,
const Connection::Status& status);
} // namespace cryptauth } // namespace cryptauth
#endif // COMPONENTS_CRYPTAUTH_CONNECTION_H_ #endif // COMPONENTS_CRYPTAUTH_CONNECTION_H_
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment