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") {
"proximity_monitor_impl.cc",
"proximity_monitor_impl.h",
"proximity_monitor_observer.h",
"remote_device_life_cycle.cc",
"remote_device_life_cycle.h",
"remote_device_life_cycle_impl.cc",
"remote_device_life_cycle_impl.h",
......@@ -42,6 +43,7 @@ static_library("proximity_auth") {
"remote_status_update.h",
"screenlock_bridge.cc",
"screenlock_bridge.h",
"screenlock_state.cc",
"screenlock_state.h",
"switches.cc",
"switches.h",
......
......@@ -158,7 +158,6 @@ bool BluetoothLowEnergyConnectionFinder::IsRightDevice(
if (!service_data)
return false;
PA_LOG(INFO) << "Generating EIDs for: " << device->GetAddress();
std::string service_data_string(service_data->begin(), service_data->end());
std::vector<cryptauth::DataWithTimestamp> nearest_eids =
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 @@
#ifndef 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 "components/cryptauth/connection.h"
#include "components/cryptauth/remote_device.h"
......@@ -76,6 +78,9 @@ class RemoteDeviceLifeCycle {
virtual void RemoveObserver(Observer* observer) = 0;
};
std::ostream& operator<<(std::ostream& stream,
const RemoteDeviceLifeCycle::State& state);
} // namespace proximity_auth
#endif // CHROMEOS_COMPONENTS_PROXIMITY_AUTH_REMOTE_DEVICE_LIFE_CYCLE_H_
......@@ -87,8 +87,7 @@ RemoteDeviceLifeCycleImpl::CreateAuthenticator() {
void RemoteDeviceLifeCycleImpl::TransitionToState(
RemoteDeviceLifeCycle::State new_state) {
PA_LOG(INFO) << "Life cycle transition: " << static_cast<int>(state_)
<< " => " << static_cast<int>(new_state);
PA_LOG(INFO) << "Life cycle transition: " << state_ << " => " << new_state;
RemoteDeviceLifeCycle::State old_state = state_;
state_ = new_state;
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 @@
#ifndef CHROMEOS_COMPONENTS_PROXIMITY_AUTH_SCREENLOCK_STATE_H_
#define CHROMEOS_COMPONENTS_PROXIMITY_AUTH_SCREENLOCK_STATE_H_
#include <ostream>
namespace proximity_auth {
// Possible user states of the proximity auth feature on the lock or sign-in
......@@ -46,6 +48,8 @@ enum class ScreenlockState {
PASSWORD_REAUTH,
};
std::ostream& operator<<(std::ostream& stream, const ScreenlockState& state);
} // namespace proximity_auth
#endif // CHROMEOS_COMPONENTS_PROXIMITY_AUTH_SCREENLOCK_STATE_H_
......@@ -151,8 +151,6 @@ void UnlockManagerImpl::SetRemoteDeviceLifeCycle(
void UnlockManagerImpl::OnLifeCycleStateChanged() {
RemoteDeviceLifeCycle::State state = life_cycle_->GetState();
PA_LOG(INFO) << "RemoteDeviceLifeCycle state changed: "
<< static_cast<int>(state);
remote_screenlock_state_.reset();
if (state == RemoteDeviceLifeCycle::State::SECURE_CHANNEL_ESTABLISHED) {
......@@ -419,9 +417,8 @@ void UnlockManagerImpl::UpdateLockScreen() {
if (screenlock_state_ == new_state)
return;
PA_LOG(INFO) << "Updating screenlock state from "
<< static_cast<int>(screenlock_state_) << " to "
<< static_cast<int>(new_state);
PA_LOG(INFO) << "Updating screenlock state from " << screenlock_state_
<< " to " << new_state;
proximity_auth_client_->UpdateScreenlockState(new_state);
screenlock_state_ = new_state;
}
......
......@@ -207,8 +207,6 @@ void BluetoothLowEnergyWeaveClientConnection::SetConnectionLatency() {
return;
}
PA_LOG(INFO) << "Setting connection latency for " << GetDeviceInfoLogString()
<< ".";
bluetooth_device->SetConnectionLatency(
device::BluetoothDevice::ConnectionLatency::CONNECTION_LATENCY_LOW,
base::Bind(&BluetoothLowEnergyWeaveClientConnection::CreateGattConnection,
......
......@@ -116,4 +116,21 @@ std::string Connection::GetDeviceInfoLogString() {
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
......@@ -6,6 +6,7 @@
#define COMPONENTS_CRYPTAUTH_CONNECTION_H_
#include <memory>
#include <ostream>
#include "base/macros.h"
#include "base/memory/ref_counted.h"
......@@ -117,6 +118,9 @@ class Connection {
DISALLOW_COPY_AND_ASSIGN(Connection);
};
std::ostream& operator<<(std::ostream& stream,
const Connection::Status& status);
} // namespace cryptauth
#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