From 00a299926919a2f871bd3748bedde1cf5c9cc3b1 Mon Sep 17 00:00:00 2001 From: hai007 Date: Thu, 24 Jul 2025 16:23:51 -0700 Subject: [PATCH] Format all the files in CL786733783 PiperOrigin-RevId: 786873870 --- connections/BUILD | 1 - connections/c/nc.cc | 3 +- connections/core_test.cc | 1 - connections/dart/nc_adapter_dart.cc | 45 +-- .../analytics/analytics_recorder.cc | 101 +++-- .../analytics/throughput_recorder.cc | 13 +- .../implementation/base_bwu_handler.cc | 9 +- .../implementation/base_endpoint_channel.cc | 44 +- .../base_endpoint_channel_test.cc | 2 +- .../implementation/base_pcp_handler.cc | 382 ++++++++---------- .../implementation/base_pcp_handler_test.cc | 7 +- .../implementation/bluetooth_bwu_handler.cc | 42 +- .../implementation/bluetooth_bwu_test.cc | 2 +- connections/implementation/bwu_manager.cc | 368 ++++++++--------- connections/implementation/client_proxy.cc | 151 ++++--- .../connections_authentication_transport.cc | 4 +- .../implementation/encryption_runner.cc | 55 ++- .../endpoint_channel_manager_test.cc | 19 +- .../implementation/endpoint_manager.cc | 4 +- .../implementation/mediums/awdl_test.cc | 6 +- connections/implementation/mediums/ble.cc | 102 +++-- .../implementation/mediums/ble_test.cc | 14 +- .../ble_v2/ble_advertisement_header.cc | 2 +- .../mediums/ble_v2/bloom_filter.cc | 4 +- .../ble_v2/instant_on_lost_advertisement.cc | 12 +- .../implementation/mediums/ble_v2_test.cc | 10 +- .../mediums/bluetooth_classic_test.cc | 16 +- .../mediums/multiplex/multiplex_frames.cc | 48 ++- .../multiplex/multiplex_output_stream.cc | 22 +- .../multiplex/multiplex_output_stream_test.cc | 40 +- .../mediums/multiplex/multiplex_socket.cc | 211 +++++----- .../multiplex/multiplex_socket_test.cc | 38 +- connections/implementation/mediums/webrtc.cc | 113 +++--- .../mediums/webrtc/connection_flow.cc | 54 ++- .../mediums/webrtc/webrtc_socket_impl.cc | 26 +- .../implementation/mediums/wifi_direct.cc | 33 +- .../implementation/mediums/wifi_hotspot.cc | 32 +- .../implementation/mediums/wifi_lan.cc | 141 +++---- .../implementation/mediums/wifi_lan_test.cc | 8 +- .../offline_service_controller.cc | 75 ++-- .../offline_service_controller_test.cc | 9 +- .../implementation/offline_simulation_user.cc | 3 +- .../p2p_cluster_pcp_handler_test.cc | 27 +- .../p2p_point_to_point_pcp_handler_test.cc | 11 +- .../implementation/payload_manager_test.cc | 8 +- connections/implementation/pcp_manager.cc | 2 +- .../implementation/reconnect_manager_test.cc | 21 +- .../service_controller_router.cc | 9 +- .../implementation/webrtc_bwu_handler.cc | 38 +- .../implementation/wifi_direct_bwu_handler.cc | 15 +- .../implementation/wifi_lan_bwu_handler.cc | 39 +- .../wifi_lan_endpoint_channel.cc | 7 +- internal/network/http_client_impl.cc | 121 +++--- internal/platform/awdl.h | 2 +- internal/platform/ble.cc | 18 +- internal/platform/ble_test.cc | 18 +- internal/platform/blocking_queue_stream.cc | 12 +- internal/platform/bluetooth_classic_test.cc | 3 +- internal/platform/implementation/g3/ble.cc | 48 +-- .../implementation/g3/bluetooth_classic.cc | 36 +- .../g3/credential_storage_impl.cc | 27 +- .../platform/implementation/g3/wifi_direct.cc | 26 +- .../implementation/g3/wifi_hotspot.cc | 32 +- .../platform/implementation/g3/wifi_lan.cc | 51 ++- .../implementation/windows/wifi_lan_mdns.cc | 2 +- internal/platform/medium_environment.cc | 3 +- internal/platform/pending_job_registry.cc | 10 +- internal/platform/socket.h | 4 +- internal/platform/wifi_direct.cc | 6 +- internal/platform/wifi_direct.h | 3 +- internal/platform/wifi_lan.cc | 57 ++- internal/platform/wifi_lan.h | 4 +- internal/weave/base_socket_test.cc | 4 +- internal/weave/sockets/client_socket_test.cc | 3 +- internal/weave/sockets/server_socket.cc | 17 +- presence/fpp/fpp_manager.cc | 7 +- presence/implementation/action_factory.cc | 2 +- .../advertisement_decoder_impl.cc | 20 +- .../advertisement_decoder_rust_impl.cc | 5 +- .../implementation/advertisement_factory.cc | 4 +- .../implementation/advertisement_filter.cc | 9 +- .../implementation/base_broadcast_request.cc | 3 +- presence/implementation/broadcast_manager.cc | 20 +- .../implementation/credential_manager_impl.cc | 38 +- presence/implementation/scan_manager.cc | 14 +- presence/implementation/scan_manager_test.cc | 27 +- presence/presence_device_provider.cc | 20 +- 87 files changed, 1406 insertions(+), 1719 deletions(-) diff --git a/connections/BUILD b/connections/BUILD index 683e9c55..b9075fed 100644 --- a/connections/BUILD +++ b/connections/BUILD @@ -121,7 +121,6 @@ cc_test( "//internal/platform/implementation/g3", # build_cleaner: keep "@com_github_protobuf_matchers//protobuf-matchers", "@com_google_absl//absl/strings", - "@com_google_absl//absl/time", "@com_google_googletest//:gtest_main", ], ) diff --git a/connections/c/nc.cc b/connections/c/nc.cc index 3c3b0a86..e7e683be 100644 --- a/connections/c/nc.cc +++ b/connections/c/nc.cc @@ -283,8 +283,7 @@ void NcCloseService(NC_INSTANCE instance) { } nc_context->core->StopAllEndpoints([](::nearby::connections::Status status) { - LOG(INFO) << "Stopping all endpoints with status " - << status.ToString(); + LOG(INFO) << "Stopping all endpoints with status " << status.ToString(); }); kNcContextMap->erase(nc_context->core); diff --git a/connections/core_test.cc b/connections/core_test.cc index af6c8313..b579dbe5 100644 --- a/connections/core_test.cc +++ b/connections/core_test.cc @@ -167,7 +167,6 @@ TEST(CoreTest, DisconnectFailsWithEmptyEndpoint) { EXPECT_EQ(final_status.value, Status::kEndpointUnknown); } - TEST(CoreTest, SendPayloadCallsScRouter) { MockServiceControllerRouter mock_controller; // Called when Core is destroyed. diff --git a/connections/dart/nc_adapter_dart.cc b/connections/dart/nc_adapter_dart.cc index f33ebe84..a6b3b60a 100644 --- a/connections/dart/nc_adapter_dart.cc +++ b/connections/dart/nc_adapter_dart.cc @@ -93,8 +93,7 @@ void ListenerInitiatedCB( NC_INSTANCE instance, int endpoint_id, const NC_CONNECTION_RESPONSE_INFO *connection_response_info, void *context) { - LOG(INFO) << "Advertising initiated: id=" - << GetEndpointIdString(endpoint_id); + LOG(INFO) << "Advertising initiated: id=" << GetEndpointIdString(endpoint_id); Dart_CObject dart_object_endpoint_id = { .type = Dart_CObject_Type::Dart_CObject_kInt32, @@ -127,8 +126,7 @@ void ListenerInitiatedCB( } void ListenerAcceptedCB(NC_INSTANCE instance, int endpoint_id, void *context) { - LOG(INFO) << "Advertising accepted: id=" - << GetEndpointIdString(endpoint_id); + LOG(INFO) << "Advertising accepted: id=" << GetEndpointIdString(endpoint_id); Dart_CObject dart_object_accepted; dart_object_accepted.type = Dart_CObject_kInt32; dart_object_accepted.value.as_int32 = endpoint_id; @@ -142,8 +140,7 @@ void ListenerAcceptedCB(NC_INSTANCE instance, int endpoint_id, void *context) { void ListenerRejectedCB(NC_INSTANCE instance, int endpoint_id, NC_STATUS status, void *context) { - LOG(INFO) << "Advertising rejected: id=" - << GetEndpointIdString(endpoint_id); + LOG(INFO) << "Advertising rejected: id=" << GetEndpointIdString(endpoint_id); Dart_CObject dart_object_rejected; dart_object_rejected.type = Dart_CObject_kInt32; dart_object_rejected.value.as_int32 = endpoint_id; @@ -158,7 +155,7 @@ void ListenerRejectedCB(NC_INSTANCE instance, int endpoint_id, NC_STATUS status, void ListenerDisconnectedCB(NC_INSTANCE instance, int endpoint_id, void *context) { LOG(INFO) << "Advertising disconnected: id=" - << GetEndpointIdString(endpoint_id); + << GetEndpointIdString(endpoint_id); Dart_CObject dart_object_disconnected; dart_object_disconnected.type = Dart_CObject_kInt32; dart_object_disconnected.value.as_int32 = endpoint_id; @@ -173,7 +170,7 @@ void ListenerDisconnectedCB(NC_INSTANCE instance, int endpoint_id, void ListenerBandwidthChangedCB(NC_INSTANCE instance, int endpoint_id, NC_MEDIUM medium, void *context) { LOG(INFO) << "Advertising bandwidth changed: id=" - << GetEndpointIdString(endpoint_id); + << GetEndpointIdString(endpoint_id); Dart_CObject dart_object_bandwidth_changed; dart_object_bandwidth_changed.type = Dart_CObject_kInt32; @@ -189,10 +186,9 @@ void ListenerBandwidthChangedCB(NC_INSTANCE instance, int endpoint_id, void ListenerEndpointFoundCB(NC_INSTANCE instance, int endpoint_id, const NC_DATA *endpoint_info, const NC_DATA *service_id, void *context) { - LOG(INFO) << "Device discovered: id=" - << GetEndpointIdString(endpoint_id); + LOG(INFO) << "Device discovered: id=" << GetEndpointIdString(endpoint_id); LOG(INFO) << "Device discovered: service_id=" - << std::string(service_id->data, service_id->size); + << std::string(service_id->data, service_id->size); std::string endpoint_info_str = absl::BytesToHexString( absl::string_view(endpoint_info->data, endpoint_info->size)); @@ -244,7 +240,7 @@ void ListenerEndpointDistanceChangedCB(NC_INSTANCE instance, int endpoint_id, void *context) { (void)distance_info; // Avoid unused parameter warning LOG(INFO) << "Device distance changed: id=" - << GetEndpointIdString(endpoint_id); + << GetEndpointIdString(endpoint_id); Dart_CObject dart_object_distance_changed; dart_object_distance_changed.type = Dart_CObject_kInt32; dart_object_distance_changed.value.as_int32 = endpoint_id; @@ -259,9 +255,8 @@ void ListenerEndpointDistanceChangedCB(NC_INSTANCE instance, int endpoint_id, void ListenerPayloadCB(NC_INSTANCE instance, int endpoint_id, const NC_PAYLOAD *payload, void *context) { LOG(INFO) << "Payload callback called. id: " - << GetEndpointIdString(endpoint_id) - << ", payload_id: " << payload->id - << ", type: " << payload->type; + << GetEndpointIdString(endpoint_id) + << ", payload_id: " << payload->id << ", type: " << payload->type; Dart_CObject dart_object_endpoint_id; dart_object_endpoint_id.type = Dart_CObject_kInt32; @@ -361,12 +356,12 @@ void ListenerPayloadProgressCB( NC_INSTANCE instance, int endpoint_id, const NC_PAYLOAD_PROGRESS_INFO *payload_progress_info, void *context) { LOG(INFO) << "Payload progress callback called. id: " - << GetEndpointIdString(endpoint_id) - << ", payload_id: " << payload_progress_info->id - << ", bytes transferred: " - << payload_progress_info->bytes_transferred - << ", total: " << payload_progress_info->total_bytes - << ", status: " << payload_progress_info->status; + << GetEndpointIdString(endpoint_id) + << ", payload_id: " << payload_progress_info->id + << ", bytes transferred: " + << payload_progress_info->bytes_transferred + << ", total: " << payload_progress_info->total_bytes + << ", status: " << payload_progress_info->status; Dart_CObject dart_object_endpoint_id; dart_object_endpoint_id.type = Dart_CObject_kInt32; dart_object_endpoint_id.value.as_int32 = endpoint_id; @@ -449,8 +444,7 @@ void EnableBleV2Dart(NC_INSTANCE instance, int64_t enable, status); }, nullptr); - LOG(INFO) << "EnableBleV2Dart callback is called with enable=" - << enable; + LOG(INFO) << "EnableBleV2Dart callback is called with enable=" << enable; } void StartAdvertisingDart(NC_INSTANCE instance, DataDart service_id, @@ -784,9 +778,8 @@ void SendPayloadDart(NC_INSTANCE instance, int endpoint_id, } case PAYLOAD_TYPE_FILE: LOG(INFO) << "File name: " - << std::string(payload_dart.data.data, - payload_dart.data.size) - << ", size " << payload_dart.size; + << std::string(payload_dart.data.data, payload_dart.data.size) + << ", size " << payload_dart.size; std::string file_name_str(payload_dart.data.data, payload_dart.data.size); NC_PAYLOAD payload{}; diff --git a/connections/implementation/analytics/analytics_recorder.cc b/connections/implementation/analytics/analytics_recorder.cc index 06078011..ba33a9cd 100644 --- a/connections/implementation/analytics/analytics_recorder.cc +++ b/connections/implementation/analytics/analytics_recorder.cc @@ -45,7 +45,7 @@ namespace analytics { namespace { // const char kVersion_1_0_0[] = "v1.0.0"; -const char kVersion [] = "v1.5.0"; +const char kVersion[] = "v1.5.0"; constexpr absl::string_view kOnStartClientSession = "OnStartClientSession"; const absl::Duration kConnectionTokenMaxLife = absl::Hours(24); @@ -164,8 +164,7 @@ OperationResultCategory ConvertToOperationResultCategory( AnalyticsRecorder::AnalyticsRecorder(EventLogger *event_logger) : event_logger_(event_logger) { - LOG(INFO) << "Start AnalyticsRecorder ctor event_logger_=" - << event_logger_; + LOG(INFO) << "Start AnalyticsRecorder ctor event_logger_=" << event_logger_; LogStartSession(); } @@ -173,13 +172,11 @@ AnalyticsRecorder::AnalyticsRecorder(EventLogger *event_logger, bool no_record_time_millis) : event_logger_(event_logger), no_record_time_millis_(no_record_time_millis) { - LOG(INFO) << "Start AnalyticsRecorder ctor event_logger_=" - << event_logger_; + LOG(INFO) << "Start AnalyticsRecorder ctor event_logger_=" << event_logger_; LogStartSession(); } -AnalyticsRecorder::~AnalyticsRecorder() { -} +AnalyticsRecorder::~AnalyticsRecorder() = default; bool AnalyticsRecorder::IsSessionLogged() { MutexLock lock(&mutex_); @@ -206,7 +203,7 @@ void AnalyticsRecorder::OnStartAdvertising( } if (!strategy.IsValid()) { LOG(INFO) << "AnalyticsRecorder OnStartAdvertising with unknown " - "strategy, bail out."; + "strategy, bail out."; return; } // Initialize/update a StrategySession. @@ -268,7 +265,7 @@ void AnalyticsRecorder::OnStartDiscovery( } if (!strategy.IsValid()) { LOG(INFO) << "AnalyticsRecorder OnStartDiscovery unknown " - "strategy enter, bail out."; + "strategy enter, bail out."; return; } @@ -347,7 +344,7 @@ void AnalyticsRecorder::OnEndpointFound(Medium medium) { } if (current_discovery_phase_ == nullptr) { LOG(INFO) << "Unable to record discovered endpoint due to null " - "current_discovery_phase_"; + "current_discovery_phase_"; return; } ConnectionsLog::DiscoveredEndpoint *discovered_endpoint = @@ -454,7 +451,7 @@ void AnalyticsRecorder::OnIncomingConnectionAttempt( } if (current_strategy_session_ == nullptr) { LOG(INFO) << "Unable to record incoming connection attempt due to " - "null current_strategy_session_"; + "null current_strategy_session_"; return; } @@ -533,7 +530,7 @@ void AnalyticsRecorder::OnOutgoingConnectionAttempt( } if (current_strategy_session_ == nullptr) { LOG(INFO) << "Unable to record outgoing connection attempt due to " - "null current_strategy_session_"; + "null current_strategy_session_"; return; } @@ -649,10 +646,10 @@ void AnalyticsRecorder::OnConnectionClosed(const std::string &endpoint_id, SafeDisconnectionResult result) { MutexLock lock(&mutex_); LOG(INFO) << __func__ - << ": OnConnectionClosed is called with endpoint_id:" - << endpoint_id << ", medium:" << Medium_Name(medium) - << ", reason:" << DisconnectionReason_Name(reason) - << ", result:" << result; + << ": OnConnectionClosed is called with endpoint_id:" << endpoint_id + << ", medium:" << Medium_Name(medium) + << ", reason:" << DisconnectionReason_Name(reason) + << ", result:" << result; if (!CanRecordAnalyticsLocked("OnConnectionClosed")) { return; @@ -660,8 +657,7 @@ void AnalyticsRecorder::OnConnectionClosed(const std::string &endpoint_id, if (current_strategy_session_ == nullptr) { VLOG(1) << "AnalyticsRecorder CanRecordAnalytics Unexpected call " - << __func__ - << " since current_strategy_session_ is required."; + << __func__ << " since current_strategy_session_ is required."; return; } @@ -887,7 +883,7 @@ void AnalyticsRecorder::OnErrorCode(const ErrorCodeParams ¶ms) { connections_log.set_allocated_error_code(error_code.release()); VLOG(1) << "AnalyticsRecorder LogErrorCode connections_log=" - << connections_log.DebugString(); // NOLINT + << connections_log.DebugString(); // NOLINT event_logger_->Log(connections_log); } @@ -895,10 +891,9 @@ void AnalyticsRecorder::OnErrorCode(const ErrorCodeParams ¶ms) { void AnalyticsRecorder::LogStartSession() { MutexLock lock(&mutex_); if (start_client_session_was_logged_) { - LOG(WARNING) - << "AnalyticsRecorder CanRecordAnalytics Unexpected call " - << kOnStartClientSession - << " after start client session has already been logged."; + LOG(WARNING) << "AnalyticsRecorder CanRecordAnalytics Unexpected call " + << kOnStartClientSession + << " after start client session has already been logged."; return; } @@ -1011,15 +1006,14 @@ OperationResultCode AnalyticsRecorder::GetChannelIoErrorResultCodeFromMedium( bool AnalyticsRecorder::CanRecordAnalyticsLocked( absl::string_view method_name) { - VLOG(1) << "AnalyticsRecorder LogEvent " << method_name - << " is calling."; + VLOG(1) << "AnalyticsRecorder LogEvent " << method_name << " is calling."; if (event_logger_ == nullptr) { return false; } if (session_was_logged_) { VLOG(1) << "AnalyticsRecorder CanRecordAnalytics Unexpected call " - << method_name << " after session has already been logged."; + << method_name << " after session has already been logged."; return false; } @@ -1036,7 +1030,7 @@ void AnalyticsRecorder::LogClientSessionLocked() { connections_log.set_version(kVersion); VLOG(1) << "AnalyticsRecorder LogClientSession connections_log=" - << connections_log.DebugString(); // NOLINT + << connections_log.DebugString(); // NOLINT event_logger_->Log(connections_log); client_session_ = nullptr; @@ -1048,7 +1042,7 @@ void AnalyticsRecorder::LogEvent(EventType event_type) { connections_log.set_version(kVersion); VLOG(1) << "AnalyticsRecorder LogEvent connections_log=" - << connections_log.DebugString(); // NOLINT + << connections_log.DebugString(); // NOLINT event_logger_->Log(connections_log); } @@ -1092,7 +1086,7 @@ void AnalyticsRecorder::RecordAdvertisingPhaseDurationAndReasonLocked( bool on_stop) const { if (current_advertising_phase_ == nullptr) { LOG(INFO) << "Unable to record advertising phase duration due to " - "null current_advertising_phase_"; + "null current_advertising_phase_"; return; } if (!current_advertising_phase_->has_duration_millis() && @@ -1123,7 +1117,7 @@ void AnalyticsRecorder::FinishAdvertisingPhaseLocked() { *std::move(current_advertising_phase_); } else { LOG(INFO) << "Unable to record advertising phase due to null " - "current_strategy_session_"; + "current_strategy_session_"; } } incoming_connection_requests_.clear(); @@ -1133,7 +1127,7 @@ void AnalyticsRecorder::RecordDiscoveryPhaseDurationAndReasonLocked( bool on_stop) const { if (current_discovery_phase_ == nullptr) { LOG(INFO) << "Unable to record discovery phase duration due to " - "null current_discovery_phase_"; + "null current_discovery_phase_"; return; } if (!current_discovery_phase_->has_duration_millis() && @@ -1165,7 +1159,7 @@ void AnalyticsRecorder::FinishDiscoveryPhaseLocked() { *std::move(current_discovery_phase_); } else { LOG(INFO) << "Unable to record discovery phase due to null " - "current_strategy_session_"; + "current_strategy_session_"; } } outgoing_connection_requests_.clear(); @@ -1174,9 +1168,8 @@ void AnalyticsRecorder::FinishDiscoveryPhaseLocked() { bool AnalyticsRecorder::UpdateAdvertiserConnectionRequestLocked( ConnectionsLog::ConnectionRequest *request) { if (current_advertising_phase_ == nullptr) { - LOG(INFO) - << "Unable to record advertiser connection request due to null " - "current_advertising_phase_"; + LOG(INFO) << "Unable to record advertiser connection request due to null " + "current_advertising_phase_"; return false; } if (BothEndpointsRespondedLocked(request)) { @@ -1195,7 +1188,7 @@ bool AnalyticsRecorder::UpdateDiscovererConnectionRequestLocked( ConnectionsLog::ConnectionRequest *request) { if (current_discovery_phase_ == nullptr) { LOG(INFO) << "Unable to record discoverer connection request due " - "to null current_discovery_phase_."; + "to null current_discovery_phase_."; return false; } if (BothEndpointsRespondedLocked(request) || @@ -1324,7 +1317,7 @@ void AnalyticsRecorder::FinishUpgradeAttemptLocked( OperationResultCode operation_result_code, bool erase_item) { if (current_strategy_session_ == nullptr) { LOG(INFO) << "Unable to record upgrade attempt due to null " - "current_strategy_session_"; + "current_strategy_session_"; return; } // Add the BandwidthUpgradeAttempt in the current StrategySession. @@ -1455,9 +1448,8 @@ ConnectionsLog::Payload AnalyticsRecorder::PendingPayload::GetProtoPayload( void AnalyticsRecorder::LogicalConnection::PhysicalConnectionEstablished( Medium medium, const std::string &connection_token) { if (current_medium_ != UNKNOWN_MEDIUM) { - LOG(WARNING) - << "Unexpected call to PhysicalConnectionEstablished while " - "AnalyticsRecorder still has an active current medium."; + LOG(WARNING) << "Unexpected call to PhysicalConnectionEstablished while " + "AnalyticsRecorder still has an active current medium."; } auto established_connection = @@ -1483,15 +1475,14 @@ void AnalyticsRecorder::LogicalConnection::PhysicalConnectionEstablished( void AnalyticsRecorder::LogicalConnection::PhysicalConnectionClosed( Medium medium, DisconnectionReason reason, SafeDisconnectionResult result) { if (current_medium_ == UNKNOWN_MEDIUM) { - LOG(WARNING) - << "Unexpected call to PhysicalConnectionClosed() for medium " - << Medium_Name(medium) - << " while AnalyticsRecorder has no active current medium"; + LOG(WARNING) << "Unexpected call to PhysicalConnectionClosed() for medium " + << Medium_Name(medium) + << " while AnalyticsRecorder has no active current medium"; } else if (current_medium_ != medium) { - LOG(WARNING) - << "Unexpected call to PhysicalConnectionClosed() for medium " - << Medium_Name(medium) << "while AnalyticsRecorder has active medium " - << Medium_Name(current_medium_); + LOG(WARNING) << "Unexpected call to PhysicalConnectionClosed() for medium " + << Medium_Name(medium) + << "while AnalyticsRecorder has active medium " + << Medium_Name(current_medium_); } auto it = physical_connections_.find(medium); @@ -1506,11 +1497,11 @@ void AnalyticsRecorder::LogicalConnection::PhysicalConnectionClosed( ConnectionsLog::EstablishedConnection *established_connection = it->second.get(); if (established_connection->has_disconnection_reason()) { - LOG(WARNING) - << "Unexpected call to physicalConnectionClosed() for medium " - << Medium_Name(medium) << " which already has disconnection reason " - << DisconnectionReason_Name( - established_connection->disconnection_reason()); + LOG(WARNING) << "Unexpected call to physicalConnectionClosed() for medium " + << Medium_Name(medium) + << " which already has disconnection reason " + << DisconnectionReason_Name( + established_connection->disconnection_reason()); return; } FinishPhysicalConnection(established_connection, reason, result); @@ -1582,7 +1573,7 @@ void AnalyticsRecorder::LogicalConnection::IncomingPayloadDone( OperationResultCode operation_result_code) { if (current_medium_ == UNKNOWN_MEDIUM) { LOG(WARNING) << "Unexpected call to incomingPayloadDone() while " - "AnalyticsRecorder has no active current medium."; + "AnalyticsRecorder has no active current medium."; return; } auto it = physical_connections_.find(current_medium_); @@ -1621,7 +1612,7 @@ void AnalyticsRecorder::LogicalConnection::OutgoingPayloadDone( OperationResultCode operation_result_code) { if (current_medium_ == UNKNOWN_MEDIUM) { LOG(WARNING) << "Unexpected call to outgoingPayloadDone() while " - "AnalyticsRecorder has no active current medium."; + "AnalyticsRecorder has no active current medium."; return; } auto it = physical_connections_.find(current_medium_); diff --git a/connections/implementation/analytics/throughput_recorder.cc b/connections/implementation/analytics/throughput_recorder.cc index 546356b5..6a006554 100644 --- a/connections/implementation/analytics/throughput_recorder.cc +++ b/connections/implementation/analytics/throughput_recorder.cc @@ -56,12 +56,10 @@ void ThroughputRecorder::Start(PayloadType payload_type, (payload_direction == PayloadDirection::INCOMING_PAYLOAD) ? "; Receive" : "; Send"; - LOG(INFO) << "Start TP profiling for payload_id:" << payload_id_ - << direction; + LOG(INFO) << "Start TP profiling for payload_id:" << payload_id_ << direction; if (payload_type == PayloadType::kUnknown) { - LOG(INFO) - << "Ignore ThroughputRecorder::start for Unknown Payload type"; + LOG(INFO) << "Ignore ThroughputRecorder::start for Unknown Payload type"; return; } @@ -277,7 +275,7 @@ std::string ThroughputRecorder::ToString(PayloadType type) { void ThroughputRecorderContainer::Shutdown() { MutexLock lock(&mutex_); LOG(INFO) << __func__ - << ". Num of Instance:" << throughput_recorders_.size(); + << ". Num of Instance:" << throughput_recorders_.size(); for (auto& throughput_recorder : throughput_recorders_) { LOG(INFO) << "Stop instance: " << throughput_recorder.second; throughput_recorder.second->Stop(); @@ -297,7 +295,7 @@ ThroughputRecorder* ThroughputRecorderContainer::GetTPRecorder( (payload_direction == PayloadDirection::INCOMING_PAYLOAD) ? "; Receive" : "; Send"; LOG(INFO) << "Add ThroughputRecorder instance : " << instance - << " for payload_id:" << payload_id << direction; + << " for payload_id:" << payload_id << direction; throughput_recorders_.emplace( std::pair(payload_id, payload_direction), instance); @@ -317,8 +315,7 @@ void ThroughputRecorderContainer::StopTPRecorder( std::pair(payload_id, payload_direction)); if (it != throughput_recorders_.end()) { LOG(INFO) << "Found and stop/delete ThroughputRecorder instance : " - << &(it->second) << " for payload_id:" << payload_id - << direction; + << &(it->second) << " for payload_id:" << payload_id << direction; it->second->Stop(); delete it->second; throughput_recorders_.erase( diff --git a/connections/implementation/base_bwu_handler.cc b/connections/implementation/base_bwu_handler.cc index 52495276..3242976c 100644 --- a/connections/implementation/base_bwu_handler.cc +++ b/connections/implementation/base_bwu_handler.cc @@ -54,9 +54,9 @@ void BaseBwuHandler::RevertInitiatorState() { void BaseBwuHandler::RevertInitiatorState(const std::string& upgrade_service_id, const std::string& endpoint_id) { if (!IsInitiatorUpgradeServiceId(upgrade_service_id)) { - LOG(ERROR) - << "BaseBwuHandler::RevertInitiatorState: input service ID " - << upgrade_service_id << " is not an BWU initiator ID; ignoring."; + LOG(ERROR) << "BaseBwuHandler::RevertInitiatorState: input service ID " + << upgrade_service_id + << " is not an BWU initiator ID; ignoring."; return; } @@ -82,8 +82,7 @@ void BaseBwuHandler::RevertResponderState(const std::string& service_id) { void BaseBwuHandler::NotifyOnIncomingConnection( ClientProxy* client, std::unique_ptr connection) { if (!incoming_connection_callback_) { - LOG(WARNING) - << "Ignoring incoming connection, no callback registered"; + LOG(WARNING) << "Ignoring incoming connection, no callback registered"; return; } incoming_connection_callback_(client, std::move(connection)); diff --git a/connections/implementation/base_endpoint_channel.cc b/connections/implementation/base_endpoint_channel.cc index 61cfed92..2ee8b642 100644 --- a/connections/implementation/base_endpoint_channel.cc +++ b/connections/implementation/base_endpoint_channel.cc @@ -137,7 +137,7 @@ ExceptionOr BaseEndpointChannel::Read( if (read_int.result() < 0 || read_int.result() > max_allowed_read_bytes_) { LOG(WARNING) << __func__ << ": Read an invalid number of bytes: " - << read_int.result(); + << read_int.result(); return ExceptionOr(Exception::kIo); } @@ -173,19 +173,18 @@ ExceptionOr BaseEndpointChannel::Read( if (parsed.ok()) { if (parser::GetFrameType(parsed.result()) == location::nearby::connections::V1Frame::KEEP_ALIVE) { - LOG(INFO) - << __func__ - << ": Read unencrypted KEEP_ALIVE on encrypted channel."; + LOG(INFO) << __func__ + << ": Read unencrypted KEEP_ALIVE on encrypted channel."; result = ByteArray(input); } else { - LOG(WARNING) - << __func__ << ": Read unexpected unencrypted frame of type " - << parser::GetFrameType(parsed.result()); + LOG(WARNING) << __func__ + << ": Read unexpected unencrypted frame of type " + << parser::GetFrameType(parsed.result()); } } else { message_exception.value = parsed.exception(); - LOG(WARNING) - << __func__ << ": Unable to parse data as unencrypted message."; + LOG(WARNING) << __func__ + << ": Unable to parse data as unencrypted message."; } } packet_meta_data.StopEncryption(); @@ -244,8 +243,8 @@ Exception BaseEndpointChannel::Write(const ByteArray& data, size_t data_size = data_to_write->size(); if (data_size < 0 || data_size > max_allowed_read_bytes_) { - LOG(WARNING) << __func__ << ": Write an invalid number of bytes: " - << data_size; + LOG(WARNING) << __func__ + << ": Write an invalid number of bytes: " << data_size; return {Exception::kIo}; } @@ -253,20 +252,20 @@ Exception BaseEndpointChannel::Write(const ByteArray& data, Exception write_exception = WriteInt(writer_, static_cast(data_size)); if (write_exception.Raised()) { - LOG(WARNING) << __func__ << ": Failed to write header: " - << write_exception.value; + LOG(WARNING) << __func__ + << ": Failed to write header: " << write_exception.value; return write_exception; } write_exception = writer_->Write(*data_to_write); if (write_exception.Raised()) { - LOG(WARNING) << __func__ << ": Failed to write data: " - << write_exception.value; + LOG(WARNING) << __func__ + << ": Failed to write data: " << write_exception.value; return write_exception; } Exception flush_exception = writer_->Flush(); if (flush_exception.Raised()) { - LOG(WARNING) << __func__ << ": Failed to flush writer: " - << flush_exception.value; + LOG(WARNING) << __func__ + << ": Failed to flush writer: " << flush_exception.value; return flush_exception; } packet_meta_data.StopSocketIo(); @@ -304,7 +303,7 @@ void BaseEndpointChannel::CloseIo() { Exception exception = reader_->Close(); if (!exception.Ok()) { LOG(WARNING) << __func__ - << ": Exception closing reader: " << exception.value; + << ": Exception closing reader: " << exception.value; } } { @@ -314,7 +313,7 @@ void BaseEndpointChannel::CloseIo() { Exception exception = writer_->Close(); if (!exception.Ok()) { LOG(WARNING) << __func__ - << ": Exception closing writer: " << exception.value; + << ": Exception closing writer: " << exception.value; } } } @@ -339,8 +338,7 @@ void BaseEndpointChannel::Close( void BaseEndpointChannel::Close( location::nearby::proto::connections::DisconnectionReason reason, SafeDisconnectionResult result) { - LOG(INFO) << __func__ - << ": Closing endpoint channel, reason: " << reason; + LOG(INFO) << __func__ << ": Closing endpoint channel, reason: " << reason; Close(); if (analytics_recorder_ != nullptr && !endpoint_id_.empty()) { @@ -477,8 +475,8 @@ void BaseEndpointChannel::BlockUntilUnpaused() { while (is_paused_) { Exception wait_succeeded = is_paused_cond_.Wait(); if (!wait_succeeded.Ok()) { - LOG(WARNING) << __func__ << ": Failure waiting to unpause: " - << wait_succeeded.value; + LOG(WARNING) << __func__ + << ": Failure waiting to unpause: " << wait_succeeded.value; return; } } diff --git a/connections/implementation/base_endpoint_channel_test.cc b/connections/implementation/base_endpoint_channel_test.cc index 11f2ec31..6ea7dca5 100644 --- a/connections/implementation/base_endpoint_channel_test.cc +++ b/connections/implementation/base_endpoint_channel_test.cc @@ -98,7 +98,7 @@ std::function MakeDataMonitor(const std::string& label, *capture += s; } LOG(INFO) << "source='" << label << "'" - << "; message='" << s << "'"; + << "; message='" << s << "'"; }; } diff --git a/connections/implementation/base_pcp_handler.cc b/connections/implementation/base_pcp_handler.cc index 8f8c6c5a..bd81360e 100644 --- a/connections/implementation/base_pcp_handler.cc +++ b/connections/implementation/base_pcp_handler.cc @@ -130,12 +130,12 @@ BasePcpHandler::~BasePcpHandler() { void BasePcpHandler::Shutdown() { if (closed_.Set(true)) return; - LOG(INFO) << "Initiating shutdown of BasePcpHandler(" - << strategy_.GetName() << ")"; + LOG(INFO) << "Initiating shutdown of BasePcpHandler(" << strategy_.GetName() + << ")"; DisconnectFromEndpointManager(); // Stop all the ongoing Runnables (as gracefully as possible). LOG(INFO) << "BasePcpHandler(" << strategy_.GetName() - << ") is bringing down executors."; + << ") is bringing down executors."; encryption_runner_.Shutdown(); @@ -144,14 +144,13 @@ void BasePcpHandler::Shutdown() { serial_executor_.Shutdown(); alarm_executor_.Shutdown(); - LOG(INFO) << "BasePcpHandler(" << strategy_.GetName() - << ") has shut down."; + LOG(INFO) << "BasePcpHandler(" << strategy_.GetName() << ") has shut down."; } void BasePcpHandler::DisconnectFromEndpointManager() { if (stop_.Set(true)) return; LOG(INFO) << "BasePcpHandler(" << strategy_.GetName() - << ") unregister from EPM."; + << ") unregister from EPM."; // Unregister ourselves from EPM message dispatcher. endpoint_manager_->UnregisterFrameProcessor(V1Frame::CONNECTION_RESPONSE, this); @@ -228,8 +227,7 @@ Status BasePcpHandler::StartAdvertising( advertising_options.CompatibleOptions(); StripOutUnavailableMediums(compatible_advertising_options); LOG(INFO) << "StartAdvertising with supported mediums: " - << GetStringValueOfSupportedMediums( - compatible_advertising_options); + << GetStringValueOfSupportedMediums(compatible_advertising_options); RunOnPcpHandlerThread( "start-advertising", @@ -297,7 +295,7 @@ Status BasePcpHandler::StartAdvertising( void BasePcpHandler::StopAdvertising(ClientProxy* client) { LOG(INFO) << "StopAdvertising local_endpoint_id=" - << client->GetLocalEndpointId(); + << client->GetLocalEndpointId(); CountDownLatch latch(1); RunOnPcpHandlerThread("stop-advertising", [this, client, &latch]() RUN_ON_PCP_HANDLER_THREAD() { @@ -396,8 +394,7 @@ BooleanMediumSelector BasePcpHandler::ComputeIntersectionOfSupportedMediums( if (pending_connection_info.is_incoming) { for (auto medium : their_mediums) { LOG(INFO) << "Their supported medium name: " - << location::nearby::proto::connections::Medium_Name( - medium); + << location::nearby::proto::connections::Medium_Name(medium); } } else { LOG(INFO) @@ -407,8 +404,7 @@ BooleanMediumSelector BasePcpHandler::ComputeIntersectionOfSupportedMediums( for (Medium my_medium : GetConnectionMediumsByPriority()) { LOG(INFO) << "Our supported medium name: " - << location::nearby::proto::connections::Medium_Name( - my_medium); + << location::nearby::proto::connections::Medium_Name(my_medium); if (std::find(their_mediums.begin(), their_mediums.end(), my_medium) != their_mediums.end()) { // We use advertising options as a proxy to whether or not the local @@ -450,8 +446,7 @@ Status BasePcpHandler::StartDiscovery(ClientProxy* client, DiscoveryOptions stripped_discovery_options = discovery_options; StripOutUnavailableMediums(stripped_discovery_options); LOG(INFO) << "StartDiscovery with supported mediums:" - << GetStringValueOfSupportedMediums( - stripped_discovery_options); + << GetStringValueOfSupportedMediums(stripped_discovery_options); RunOnPcpHandlerThread( "start-discovery", [this, client, service_id, stripped_discovery_options, @@ -529,11 +524,11 @@ Status BasePcpHandler::WaitForResult(const std::string& method_name, ExceptionOr result = future->Get(); if (!result.ok()) { LOG(INFO) << "Future:[" << method_name - << "] completed with exception:" << result.exception(); + << "] completed with exception:" << result.exception(); return {Status::kError}; } LOG(INFO) << "Future:[" << method_name - << "] completed with status:" << result.result().value; + << "] completed with status:" << result.result().value; return result.result(); } @@ -541,7 +536,7 @@ void BasePcpHandler::RunOnPcpHandlerThread(const std::string& name, Runnable runnable) { if (closed_.Get()) { LOG(WARNING) << "Skip to run PCP Handler task " << name - << " due to PCP Handler is closed"; + << " due to PCP Handler is closed"; return; } @@ -659,14 +654,12 @@ void BasePcpHandler::OnEncryptionSuccessRunnableV3( // TODO(b/305004353): Authenticate the connection in the responder role for // outgoing connections. if (!pending_connection_info.is_incoming) { - LOG(ERROR) << __func__ - << ": only outgoing connections are supported"; + LOG(ERROR) << __func__ << ": only outgoing connections are supported"; return; } - VLOG(1) - << __func__ - << ": beginning authentication to the remote device as an initiator"; + VLOG(1) << __func__ + << ": beginning authentication to the remote device as an initiator"; ConnectionsAuthenticationTransport connections_authentication_transport = ConnectionsAuthenticationTransport(endpoint_channel); pending_connection_info.authentication_status = @@ -675,8 +668,8 @@ void BasePcpHandler::OnEncryptionSuccessRunnableV3( /*shared_secret=*/auth_token, /*authentication_transport=*/connections_authentication_transport); LOG(INFO) << __func__ << ": authentication result = " - << AuthenticationStatusToString( - pending_connection_info.authentication_status); + << AuthenticationStatusToString( + pending_connection_info.authentication_status); RegisterDeviceAfterEncryptionSuccess( /*endpoint_id=*/remote_device.GetEndpointId(), @@ -727,9 +720,8 @@ void BasePcpHandler::RegisterDeviceAfterEncryptionSuccess( pending_connection_info.SetCryptoContext(std::move(ukey2)); pending_connection_info.connection_token = GetHashedConnectionToken(raw_auth_token); - LOG(INFO) - << "Register encrypted connection; wait for response; endpoint_id=" - << endpoint_id; + LOG(INFO) << "Register encrypted connection; wait for response; endpoint_id=" + << endpoint_id; // Set ourselves up so that we receive all acceptance/rejection messages endpoint_manager_->RegisterFrameProcessor(V1Frame::CONNECTION_RESPONSE, this); @@ -784,8 +776,8 @@ void BasePcpHandler::OnEncryptionFailureRunnable( // it too by accident. if (*endpoint_channel != *pending_connection_info.channel) { LOG(INFO) << "Not destroying channel [mismatch]: passed=" - << endpoint_channel->GetName() << "; expected=" - << pending_connection_info.channel->GetName(); + << endpoint_channel->GetName() + << "; expected=" << pending_connection_info.channel->GetName(); return; } @@ -824,11 +816,11 @@ ConnectionInfo BasePcpHandler::FillConnectionInfo( connection_info.medium_role.emplace(medium_role_info); } LOG(INFO) << "Query for WIFI information: is_supports_5_ghz=" - << connection_info.supports_5_ghz - << "; bssid=" << connection_info.bssid - << "; ap_frequency=" << connection_info.ap_frequency - << "Mhz; ip_address in bytes format=" - << absl::BytesToHexString(connection_info.ip_address); + << connection_info.supports_5_ghz + << "; bssid=" << connection_info.bssid + << "; ap_frequency=" << connection_info.ap_frequency + << "Mhz; ip_address in bytes format=" + << absl::BytesToHexString(connection_info.ip_address); } connection_info.supported_mediums = GetSupportedConnectionMediumsByPriority(connection_options); @@ -861,8 +853,8 @@ Status BasePcpHandler::RequestConnection( DiscoveredEndpoint* endpoint = GetDiscoveredEndpoint(endpoint_id); if (endpoint == nullptr) { - LOG(INFO) - << "Discovered endpoint not found: endpoint_id=" << endpoint_id; + LOG(INFO) << "Discovered endpoint not found: endpoint_id=" + << endpoint_id; result->Set({Status::kEndpointUnknown}); return; } @@ -873,9 +865,8 @@ Status BasePcpHandler::RequestConnection( if (AppendRemoteBluetoothMacAddressEndpoint( endpoint_id, remote_bluetooth_mac_address, client->GetDiscoveryOptions())) - LOG(INFO) - << "Appended remote Bluetooth MAC Address endpoint [" - << remote_bluetooth_mac_address << "]"; + LOG(INFO) << "Appended remote Bluetooth MAC Address endpoint [" + << remote_bluetooth_mac_address << "]"; } if (AppendWebRTCEndpoint(endpoint_id, client->GetDiscoveryOptions())) @@ -899,8 +890,8 @@ Status BasePcpHandler::RequestConnection( Medium channel_medium = channel ? channel->GetMedium() : Medium::UNKNOWN_MEDIUM; if (channel == nullptr) { - LOG(INFO) - << "Endpoint channel not available: endpoint_id=" << endpoint_id; + LOG(INFO) << "Endpoint channel not available: endpoint_id=" + << endpoint_id; ProcessPreConnectionInitiationFailure( client, channel_medium, endpoint_id, channel.get(), /* is_incoming = */ false, start_time, connect_impl_result.status, @@ -908,10 +899,9 @@ Status BasePcpHandler::RequestConnection( return; } - LOG(INFO) - << "In requestConnection(), wrote ConnectionRequestFrame " - "to endpoint_id=" - << endpoint_id; + LOG(INFO) << "In requestConnection(), wrote ConnectionRequestFrame " + "to endpoint_id=" + << endpoint_id; client->OnRequestConnection(GetStrategy(), endpoint_id, connection_options); @@ -925,7 +915,7 @@ Status BasePcpHandler::RequestConnection( connection_info, channel.get()); if (!write_exception.Ok()) { LOG(INFO) << "Failed to send connection request: endpoint_id=" - << endpoint_id; + << endpoint_id; ProcessPreConnectionInitiationFailure( client, channel_medium, endpoint_id, channel.get(), /* is_incoming = */ false, start_time, {Status::kEndpointIoError}, @@ -936,7 +926,7 @@ Status BasePcpHandler::RequestConnection( } LOG(INFO) << "Adding connection to pending set: endpoint_id=" - << endpoint_id; + << endpoint_id; // We've successfully connected to the device, and are now about to jump // on to the EncryptionRunner thread to start running our encryption @@ -965,19 +955,19 @@ Status BasePcpHandler::RequestConnection( .first->second.channel.get(); LOG(INFO) << "Initiating secure connection: endpoint_id=" - << endpoint_id; + << endpoint_id; // Next, we'll set up encryption. When it's done, our future will return // and RequestConnection() will finish. encryption_runner_.StartClient(client, endpoint_id, endpoint_channel, GetResultListener()); }); LOG(INFO) << "Waiting for connection to complete: endpoint_id=" - << endpoint_id; + << endpoint_id; auto status = WaitForResult(absl::StrCat("RequestConnection(", endpoint_id, ")"), client->GetClientId(), result.get()); LOG(INFO) << "Wait is complete: endpoint_id=" << endpoint_id - << "; status=" << status.value; + << "; status=" << status.value; return status; } @@ -1003,8 +993,8 @@ Status BasePcpHandler::RequestConnectionV3( DiscoveredEndpoint* endpoint = GetDiscoveredEndpoint(endpoint_id); if (endpoint == nullptr) { - LOG(INFO) - << "Discovered endpoint not found: endpoint_id=" << endpoint_id; + LOG(INFO) << "Discovered endpoint not found: endpoint_id=" + << endpoint_id; result->Set({Status::kEndpointUnknown}); return; } @@ -1015,9 +1005,8 @@ Status BasePcpHandler::RequestConnectionV3( if (AppendRemoteBluetoothMacAddressEndpoint( endpoint_id, remote_bluetooth_mac_address, client->GetDiscoveryOptions())) - LOG(INFO) - << "Appended remote Bluetooth MAC Address endpoint [" - << remote_bluetooth_mac_address << "]"; + LOG(INFO) << "Appended remote Bluetooth MAC Address endpoint [" + << remote_bluetooth_mac_address << "]"; } if (AppendWebRTCEndpoint(endpoint_id, client->GetDiscoveryOptions())) @@ -1031,11 +1020,10 @@ Status BasePcpHandler::RequestConnectionV3( if (!MediumSupportedByClientOptions(connect_endpoint->medium, connection_options)) continue; - LOG(INFO) - << "Try to connect with endpoint(id=" << endpoint_id - << ") by Medium: " - << location::nearby::proto::connections::Medium_Name( - connect_endpoint->medium); + LOG(INFO) << "Try to connect with endpoint(id=" << endpoint_id + << ") by Medium: " + << location::nearby::proto::connections::Medium_Name( + connect_endpoint->medium); connect_impl_result = ConnectImpl(client, connect_endpoint); if (connect_impl_result.status.Ok()) { channel = std::move(connect_impl_result.endpoint_channel); @@ -1046,8 +1034,8 @@ Status BasePcpHandler::RequestConnectionV3( Medium channel_medium = channel ? channel->GetMedium() : Medium::UNKNOWN_MEDIUM; if (channel == nullptr) { - LOG(INFO) - << "Endpoint channel not available: endpoint_id=" << endpoint_id; + LOG(INFO) << "Endpoint channel not available: endpoint_id=" + << endpoint_id; ProcessPreConnectionInitiationFailure( client, channel_medium, endpoint_id, channel.get(), /* is_incoming = */ false, start_time, connect_impl_result.status, @@ -1055,10 +1043,9 @@ Status BasePcpHandler::RequestConnectionV3( return; } - LOG(INFO) - << "In requestConnectionV3(), wrote ConnectionRequestFrame " - "to endpoint_id=" - << endpoint_id; + LOG(INFO) << "In requestConnectionV3(), wrote ConnectionRequestFrame " + "to endpoint_id=" + << endpoint_id; client->OnRequestConnection(GetStrategy(), endpoint_id, connection_options); @@ -1073,7 +1060,7 @@ Status BasePcpHandler::RequestConnectionV3( if (!write_exception.Ok()) { LOG(INFO) << "Failed to send connection request: endpoint_id=" - << endpoint_id; + << endpoint_id; ProcessPreConnectionInitiationFailure( client, channel_medium, endpoint_id, channel.get(), /* is_incoming = */ false, start_time, {Status::kEndpointIoError}, @@ -1084,7 +1071,7 @@ Status BasePcpHandler::RequestConnectionV3( } LOG(INFO) << "Adding connection to pending set: endpoint_id=" - << endpoint_id; + << endpoint_id; // We've successfully connected to the device, and are now about to jump // on to the EncryptionRunner thread to start running our encryption @@ -1113,7 +1100,7 @@ Status BasePcpHandler::RequestConnectionV3( .first->second.channel.get(); LOG(INFO) << "Initiating secure connection: endpoint_id=" - << endpoint_id; + << endpoint_id; // Next, we'll set up encryption and authenticate the remote device. // When it's done, our future will return and RequestConnectionV3() // will finish. @@ -1123,12 +1110,12 @@ Status BasePcpHandler::RequestConnectionV3( remote_device, *endpoint_channel)); }); LOG(INFO) << "Waiting for connection to complete: endpoint_id=" - << endpoint_id; + << endpoint_id; auto status = WaitForResult(absl::StrCat("RequestConnectionV3(", endpoint_id, ")"), client->GetClientId(), result.get()); LOG(INFO) << "Wait is complete: endpoint_id=" << endpoint_id - << "; status=" << status.value; + << "; status=" << status.value; return status; } @@ -1466,8 +1453,8 @@ Status BasePcpHandler::AcceptConnection(ClientProxy* client, channel_manager_->GetChannelForEndpoint(endpoint_id); if (channel == nullptr) { LOG(ERROR) << "Channel destroyed before Accept; bring down " - "connection: endpoint_id=" - << endpoint_id; + "connection: endpoint_id=" + << endpoint_id; ProcessPreConnectionResultFailure( client, endpoint_id, /* should_call_disconnect_endpoint= */ true, DisconnectionReason::IO_ERROR); @@ -1480,9 +1467,8 @@ Status BasePcpHandler::AcceptConnection(ClientProxy* client, Status::kSuccess, client->GetLocalOsInfo(), client->GetLocalMultiplexSocketBitmask())); if (!write_exception.Ok()) { - LOG(INFO) - << "AcceptConnection: failed to send response: endpoint_id=" - << endpoint_id; + LOG(INFO) << "AcceptConnection: failed to send response: endpoint_id=" + << endpoint_id; ProcessPreConnectionResultFailure( client, endpoint_id, /* should_call_disconnect_endpoint= */ true, DisconnectionReason::IO_ERROR); @@ -1491,7 +1477,7 @@ Status BasePcpHandler::AcceptConnection(ClientProxy* client, } LOG(INFO) << "AcceptConnection: accepting locally: endpoint_id=" - << endpoint_id; + << endpoint_id; connection_info.LocalEndpointAcceptedConnection( endpoint_id, std::move(payload_listener)); EvaluateConnectionResult(client, endpoint_id, @@ -1543,9 +1529,8 @@ Status BasePcpHandler::RejectConnection(ClientProxy* client, Status::kConnectionRejected, client->GetLocalOsInfo(), client->GetLocalMultiplexSocketBitmask())); if (!write_exception.Ok()) { - LOG(INFO) - << "RejectConnection: failed to send response: endpoint_id=" - << endpoint_id; + LOG(INFO) << "RejectConnection: failed to send response: endpoint_id=" + << endpoint_id; ProcessPreConnectionResultFailure( client, endpoint_id, /* should_call_disconnect_endpoint= */ true, DisconnectionReason::IO_ERROR); @@ -1554,7 +1539,7 @@ Status BasePcpHandler::RejectConnection(ClientProxy* client, } LOG(INFO) << "RejectConnection: rejecting locally: endpoint_id=" - << endpoint_id; + << endpoint_id; connection_info.LocalEndpointRejectedConnection(endpoint_id); EvaluateConnectionResult(client, endpoint_id, false /* can_close_immediately */); @@ -1573,13 +1558,11 @@ void BasePcpHandler::OnIncomingFrame( RunOnPcpHandlerThread( "incoming-frame", [this, client, endpoint_id, frame, &latch]() RUN_ON_PCP_HANDLER_THREAD() { - LOG(INFO) << "OnConnectionResponse: endpoint_id=" - << endpoint_id; + LOG(INFO) << "OnConnectionResponse: endpoint_id=" << endpoint_id; if (client->HasRemoteEndpointResponded(endpoint_id)) { - LOG(INFO) - << "OnConnectionResponse: already handled; endpoint_id=" - << endpoint_id; + LOG(INFO) << "OnConnectionResponse: already handled; endpoint_id=" + << endpoint_id; return; } @@ -1597,14 +1580,13 @@ void BasePcpHandler::OnIncomingFrame( accepted = connection_response.status() == Status::kSuccess; } if (accepted) { - LOG(INFO) - << "OnConnectionResponse: remote accepted; endpoint_id=" - << endpoint_id; + LOG(INFO) << "OnConnectionResponse: remote accepted; endpoint_id=" + << endpoint_id; client->RemoteEndpointAcceptedConnection(endpoint_id); } else { - LOG(INFO) - << "OnConnectionResponse: remote rejected; endpoint_id=" - << endpoint_id << "; status=" << connection_response.status(); + LOG(INFO) << "OnConnectionResponse: remote rejected; endpoint_id=" + << endpoint_id + << "; status=" << connection_response.status(); client->RemoteEndpointRejectedConnection(endpoint_id); } @@ -1618,10 +1600,9 @@ void BasePcpHandler::OnIncomingFrame( } if (connection_response.has_safe_to_disconnect_version()) { - LOG(INFO) - << "[safe-to-disconnect]: endpoint_id=" << endpoint_id - << "; Version = " - << connection_response.safe_to_disconnect_version(); + LOG(INFO) << "[safe-to-disconnect]: endpoint_id=" << endpoint_id + << "; Version = " + << connection_response.safe_to_disconnect_version(); client->SetRemoteSafeToDisconnectVersion( endpoint_id, connection_response.safe_to_disconnect_version()); } @@ -1671,9 +1652,9 @@ void BasePcpHandler::OnEndpointFound( // Check if we've seen this endpoint ID before. std::string& endpoint_id = endpoint->endpoint_id; LOG(INFO) << "OnEndpointFound: id=" << endpoint_id << ", medium=" - << location::nearby::proto::connections::Medium_Name( - endpoint->medium) - << " [enter]"; + << location::nearby::proto::connections::Medium_Name( + endpoint->medium) + << " [enter]"; MutexLock lock(&discovered_endpoint_mutex_); auto range = discovered_endpoints_.equal_range(endpoint->endpoint_id); bool is_range_empty = range.first == range.second; @@ -1685,8 +1666,8 @@ void BasePcpHandler::OnEndpointFound( // handle it to avoid device refresh between different mediums. if (discovered_endpoint->medium == endpoint->medium) { LOG(INFO) << "Ignore the dup endpoint info on medium " - << location::nearby::proto::connections::Medium_Name( - endpoint->medium); + << location::nearby::proto::connections::Medium_Name( + endpoint->medium); return; } } else { @@ -1695,9 +1676,9 @@ void BasePcpHandler::OnEndpointFound( // we should reset discovered endpoints of the endpoint ID, and use the // new endpoint info and medium as discovered endpoint. LOG(INFO) << "Endpoint info of endpoint " << endpoint_id - << " changed on medium " - << location::nearby::proto::connections::Medium_Name( - endpoint->medium); + << " changed on medium " + << location::nearby::proto::connections::Medium_Name( + endpoint->medium); // Report endpoint lost client->OnEndpointLost(endpoint->service_id, endpoint->endpoint_id); // Reset discovered endpoints @@ -1715,8 +1696,8 @@ void BasePcpHandler::OnEndpointFound( } if (discovered_endpoint->medium == endpoint->medium) { LOG(INFO) << "Ignore the dup endpoint info on medium " - << location::nearby::proto::connections::Medium_Name( - endpoint->medium); + << location::nearby::proto::connections::Medium_Name( + endpoint->medium); return; } } @@ -1726,10 +1707,10 @@ void BasePcpHandler::OnEndpointFound( discovered_endpoints_.emplace(endpoint_id, std::move(endpoint)) ->second.get(); - LOG(INFO) << "Adding new medium for endpoint: endpoint_id=" - << endpoint_id << "; medium=" - << location::nearby::proto::connections::Medium_Name( - owned_endpoint->medium); + LOG(INFO) << "Adding new medium for endpoint: endpoint_id=" << endpoint_id + << "; medium=" + << location::nearby::proto::connections::Medium_Name( + owned_endpoint->medium); // Range is empty: this is the first endpoint we discovered so far. // Report this endpoint_id to client. @@ -1744,16 +1725,15 @@ void BasePcpHandler::OnEndpointFound( void BasePcpHandler::OnEndpointLost( ClientProxy* client, const BasePcpHandler::DiscoveredEndpoint& endpoint) { // Look up the DiscoveredEndpoint we have in our cache. - LOG(INFO) << "OnEndpointLost: id=" << endpoint.endpoint_id - << " on medium=" - << location::nearby::proto::connections::Medium_Name( - endpoint.medium); + LOG(INFO) << "OnEndpointLost: id=" << endpoint.endpoint_id << " on medium=" + << location::nearby::proto::connections::Medium_Name( + endpoint.medium); MutexLock lock(&discovered_endpoint_mutex_); auto range = discovered_endpoints_.equal_range(endpoint.endpoint_id); bool is_range_empty = range.first == range.second; if (is_range_empty) { LOG(INFO) << "No previous endpoint (nothing to lose): endpoint_id=" - << endpoint.endpoint_id; + << endpoint.endpoint_id; return; } int count = discovered_endpoints_.count(endpoint.endpoint_id); @@ -1769,15 +1749,14 @@ void BasePcpHandler::OnEndpointLost( // new info and are just now figuring out that we lost the old info. if (discovered_endpoint->endpoint_info != endpoint.endpoint_info) { LOG(INFO) << "Previous endpoint name mismatch; passed=" - << absl::BytesToHexString(endpoint.endpoint_info.data()) - << "; expected=" - << absl::BytesToHexString( - discovered_endpoint->endpoint_info.data()); + << absl::BytesToHexString(endpoint.endpoint_info.data()) + << "; expected=" + << absl::BytesToHexString( + discovered_endpoint->endpoint_info.data()); } - LOG(INFO) << "Erase Endpoint " << endpoint.endpoint_id - << " on Medium " - << location::nearby::proto::connections::Medium_Name( - discovered_endpoint->medium); + LOG(INFO) << "Erase Endpoint " << endpoint.endpoint_id << " on Medium " + << location::nearby::proto::connections::Medium_Name( + discovered_endpoint->medium); if (--count == 0) { client->OnEndpointLost(endpoint.service_id, endpoint.endpoint_id); } @@ -1802,8 +1781,7 @@ void BasePcpHandler::OnInstantLost(ClientProxy* client, } } - LOG(INFO) << "Reported lost endpoint " << endpoint_id - << " on all mediums."; + LOG(INFO) << "Reported lost endpoint " << endpoint_id << " on all mediums."; } Status BasePcpHandler::UpdateAdvertisingOptions( @@ -1895,11 +1873,11 @@ bool BasePcpHandler::IsPreferred( for (const auto& medium : mediums) { absl::StrAppend(&medium_string, medium, "; "); } - LOG(ERROR) << "Failed to find either " << new_endpoint.medium - << " or " << old_endpoint.medium - << " in the list of locally supported mediums despite " - "expecting to find both, when deciding which medium " - << medium_string << " is preferred."; + LOG(ERROR) << "Failed to find either " << new_endpoint.medium << " or " + << old_endpoint.medium + << " in the list of locally supported mediums despite " + "expecting to find both, when deciding which medium " + << medium_string << " is preferred."; return false; } @@ -1916,10 +1894,10 @@ Exception BasePcpHandler::OnIncomingConnection( if (!client->IsAdvertising() && !client->IsListeningForIncomingConnections()) { LOG(WARNING) << "Ignoring incoming connection on medium " - << location::nearby::proto::connections::Medium_Name( - channel->GetMedium()) - << " because client=" << client->GetClientId() - << " is no longer waiting for incoming connections."; + << location::nearby::proto::connections::Medium_Name( + channel->GetMedium()) + << " because client=" << client->GetClientId() + << " is no longer waiting for incoming connections."; return {Exception::kIo}; } @@ -1929,11 +1907,10 @@ Exception BasePcpHandler::OnIncomingConnection( if (!wrapped_frame.ok()) { if (wrapped_frame.exception()) { - LOG(ERROR) - << "Failed to parse incoming connection request; client=" - << client->GetClientId() - << "; device=" << absl::BytesToHexString(remote_endpoint_info.data()) - << "with error: " << wrapped_frame.exception(); + LOG(ERROR) << "Failed to parse incoming connection request; client=" + << client->GetClientId() << "; device=" + << absl::BytesToHexString(remote_endpoint_info.data()) + << "with error: " << wrapped_frame.exception(); ProcessPreConnectionInitiationFailure( client, medium, /*endpoint_id=*/"", channel.get(), /*is_incoming=*/true, start_time, {Status::kError}, @@ -1948,18 +1925,18 @@ Exception BasePcpHandler::OnIncomingConnection( const ConnectionRequestFrame& connection_request = frame.v1().connection_request(); LOG(INFO) << "In onIncomingConnection(" - << location::nearby::proto::connections::Medium_Name( - channel->GetMedium()) - << ") for client=" << client->GetClientId() - << ", read ConnectionRequestFrame from endpoint(id=" - << connection_request.endpoint_id() << ")"; + << location::nearby::proto::connections::Medium_Name( + channel->GetMedium()) + << ") for client=" << client->GetClientId() + << ", read ConnectionRequestFrame from endpoint(id=" + << connection_request.endpoint_id() << ")"; if (client->IsConnectedToEndpoint(connection_request.endpoint_id())) { LOG(ERROR) << "Incoming connection on medium " - << location::nearby::proto::connections::Medium_Name( - channel->GetMedium()) - << " was denied because we're " - "already connected to endpoint(id=" - << connection_request.endpoint_id() << ")."; + << location::nearby::proto::connections::Medium_Name( + channel->GetMedium()) + << " was denied because we're " + "already connected to endpoint(id=" + << connection_request.endpoint_id() << ")."; return {Exception::kIo}; } @@ -1989,8 +1966,8 @@ Exception BasePcpHandler::OnIncomingConnection( : NearbyDevice::Type::kConnectionsDevice; if (listening_device_type != incoming_type) { LOG(WARNING) << "Device requesting a connection is the wrong type." - << "Expected type: " << listening_device_type - << ", got type: " << incoming_type; + << "Expected type: " << listening_device_type + << ", got type: " << incoming_type; return {Exception::kIo}; } @@ -2019,11 +1996,10 @@ Exception BasePcpHandler::OnIncomingConnection( connection_options.keep_alive_timeout_millis == 0 || connection_options.keep_alive_interval_millis >= connection_options.keep_alive_timeout_millis) { - LOG(WARNING) - << "Incoming connection has wrong keep-alive frame interval=" - << connection_options.keep_alive_interval_millis - << ", timeout=" << connection_options.keep_alive_timeout_millis - << " values; correct them as default.", + LOG(WARNING) << "Incoming connection has wrong keep-alive frame interval=" + << connection_options.keep_alive_interval_millis + << ", timeout=" << connection_options.keep_alive_timeout_millis + << " values; correct them as default.", connection_options.keep_alive_interval_millis = FeatureFlags::GetInstance().GetFlags().keep_alive_interval_millis; connection_options.keep_alive_timeout_millis = @@ -2065,13 +2041,13 @@ Exception BasePcpHandler::OnIncomingConnection( << medium_metadata.medium_role().support_awdl_subscriber(); } else { LOG(INFO) << connection_request.endpoint_id() - << "'s WIFI information: is_supports_5_ghz=" - << connection_info.supports_5_ghz - << "; bssid=" << connection_info.bssid - << "; ap_frequency=" << connection_info.ap_frequency - << "Mhz; ip_address in bytes format=" - << absl::BytesToHexString(connection_info.ip_address) - << "; has no mediumRole"; + << "'s WIFI information: is_supports_5_ghz=" + << connection_info.supports_5_ghz + << "; bssid=" << connection_info.bssid + << "; ap_frequency=" << connection_info.ap_frequency + << "Mhz; ip_address in bytes format=" + << absl::BytesToHexString(connection_info.ip_address) + << "; has no mediumRole"; } // We've successfully connected to the device, and are now about to jump on to @@ -2113,16 +2089,15 @@ bool BasePcpHandler::BreakTie(ClientProxy* client, if (it != pending_connections_.end()) { BasePcpHandler::PendingConnectionInfo& pending_connection_info = it->second; - LOG(INFO) - << "In onIncomingConnection(" - << location::nearby::proto::connections::Medium_Name( - endpoint_channel->GetMedium()) - << ") for client=" << client->GetClientId() - << ", found a collision with endpoint " << endpoint_id - << ". We've already sent a connection request to them with nonce " - << pending_connection_info.nonce - << ", but they're also trying to connect to us with nonce " - << incoming_nonce; + LOG(INFO) << "In onIncomingConnection(" + << location::nearby::proto::connections::Medium_Name( + endpoint_channel->GetMedium()) + << ") for client=" << client->GetClientId() + << ", found a collision with endpoint " << endpoint_id + << ". We've already sent a connection request to them with nonce " + << pending_connection_info.nonce + << ", but they're also trying to connect to us with nonce " + << incoming_nonce; // Break the lowest connection. In the (extremely) rare case of a tie, break // both. if (pending_connection_info.nonce > incoming_nonce) { @@ -2130,11 +2105,11 @@ bool BasePcpHandler::BreakTie(ClientProxy* client, endpoint_channel->Close(); LOG(INFO) << "In onIncomingConnection(" - << location::nearby::proto::connections::Medium_Name( - endpoint_channel->GetMedium()) - << ") for client=" << client->GetClientId() - << ", cleaned up the collision with endpoint " - << endpoint_id << " by closing their channel."; + << location::nearby::proto::connections::Medium_Name( + endpoint_channel->GetMedium()) + << ") for client=" << client->GetClientId() + << ", cleaned up the collision with endpoint " << endpoint_id + << " by closing their channel."; return true; } else if (pending_connection_info.nonce < incoming_nonce) { // Aw, we lost. Clean up our connection, and then we'll let their @@ -2173,11 +2148,10 @@ Status BasePcpHandler::VerifyConnectionRequest(const std::string& endpoint_id, // If we already have a pending connection, then we shouldn't allow any // more outgoing connections to this endpoint. if (pending_connections_.count(endpoint_id)) { - LOG(INFO) - << "In requestConnection(), connection requested with " - "endpoint(id=" - << endpoint_id - << "), but we already have a pending connection with them."; + LOG(INFO) << "In requestConnection(), connection requested with " + "endpoint(id=" + << endpoint_id + << "), but we already have a pending connection with them."; return {Status::kAlreadyConnectedToEndpoint}; } @@ -2185,11 +2159,9 @@ Status BasePcpHandler::VerifyConnectionRequest(const std::string& endpoint_id, // listen to them. if (client->ShouldEnforceTopologyConstraints() && !CanSendOutgoingConnection(client)) { - LOG(INFO) << "In requestConnection(), client=" - << client->GetClientId() - << " attempted a connection with endpoint(id=" - << endpoint_id - << "), but outgoing connections are disallowed"; + LOG(INFO) << "In requestConnection(), client=" << client->GetClientId() + << " attempted a connection with endpoint(id=" << endpoint_id + << "), but outgoing connections are disallowed"; return {Status::kOutOfOrderApiCall}; } return {Status::kSuccess}; @@ -2313,7 +2285,7 @@ void BasePcpHandler::EvaluateConnectionResult(ClientProxy* client, auto it = pending_connections_.find(endpoint_id); if (it == pending_connections_.end()) { LOG(INFO) << "No pending connection to evaluate; endpoint_id=" - << endpoint_id; + << endpoint_id; return; } @@ -2323,8 +2295,7 @@ void BasePcpHandler::EvaluateConnectionResult(ClientProxy* client, std::shared_ptr endpint_channel = channel_manager_->GetChannelForEndpoint(endpoint_id); if (endpint_channel == nullptr) { - LOG(WARNING) << "No endpint channel for endpoint_id=" - << endpoint_id; + LOG(WARNING) << "No endpint channel for endpoint_id=" << endpoint_id; return; } @@ -2332,8 +2303,7 @@ void BasePcpHandler::EvaluateConnectionResult(ClientProxy* client, Status response_code; if (is_connection_accepted) { - LOG(INFO) << "Pending connection accepted; endpoint_id=" - << endpoint_id; + LOG(INFO) << "Pending connection accepted; endpoint_id=" << endpoint_id; response_code = {Status::kSuccess}; // Both sides have accepted, so we can now start talking over encrypted @@ -2358,24 +2328,21 @@ void BasePcpHandler::EvaluateConnectionResult(ClientProxy* client, if (client->IsMultiplexSocketSupported(endpoint_id, channel->GetMedium())) { if (!channel->EnableMultiplexSocket()) { - LOG(INFO) - << "MultiplexSocket is not implemented for Medium: " - << location::nearby::proto::connections::Medium_Name( - channel->GetMedium()); + LOG(INFO) << "MultiplexSocket is not implemented for Medium: " + << location::nearby::proto::connections::Medium_Name( + channel->GetMedium()); } else { - LOG(INFO) - << "MultiplexSocket is supported for Medium: " - << location::nearby::proto::connections::Medium_Name( - channel->GetMedium()) - << " on both sides."; + LOG(INFO) << "MultiplexSocket is supported for Medium: " + << location::nearby::proto::connections::Medium_Name( + channel->GetMedium()) + << " on both sides."; } } } else { LOG(INFO) << "channel is null"; } } else { - LOG(INFO) << "Pending connection rejected; endpoint_id=" - << endpoint_id; + LOG(INFO) << "Pending connection rejected; endpoint_id=" << endpoint_id; response_code = {Status::kConnectionRejected}; } @@ -2419,8 +2386,7 @@ void BasePcpHandler::EvaluateConnectionResult(ClientProxy* client, client->OnBandwidthChanged(endpoint_id, medium); LOG(INFO) << "Connection accepted on Medium:" - << location::nearby::proto::connections::Medium_Name( - medium); + << location::nearby::proto::connections::Medium_Name(medium); // Kick off the bandwidth upgrade for incoming connections. if (pending_connection_info.is_incoming && client->AutoUpgradeBandwidth()) { @@ -2518,7 +2484,7 @@ void BasePcpHandler::LogConnectionAttemptSuccess( OperationResultCode::DETAIL_SUCCESS; } else { LOG(ERROR) << "PendingConnectionInfo channel is null for " - "LogConnectionAttemptSuccess. Bail out."; + "LogConnectionAttemptSuccess. Bail out."; return; } diff --git a/connections/implementation/base_pcp_handler_test.cc b/connections/implementation/base_pcp_handler_test.cc index 8bd7c126..cdb7df34 100644 --- a/connections/implementation/base_pcp_handler_test.cc +++ b/connections/implementation/base_pcp_handler_test.cc @@ -807,10 +807,9 @@ class BasePcpHandlerTest .endpoint_channel = nullptr, }; } else { - LOG(INFO) - << "Connect with Medium: " - << location::nearby::proto::connections::Medium_Name( - endpoint->medium); + LOG(INFO) << "Connect with Medium: " + << location::nearby::proto::connections::Medium_Name( + endpoint->medium); return MockPcpHandler::ConnectImplResult{ .medium = endpoint->medium, .status = {Status::kSuccess}, diff --git a/connections/implementation/bluetooth_bwu_handler.cc b/connections/implementation/bluetooth_bwu_handler.cc index 7e0fbcc8..7afc3d51 100644 --- a/connections/implementation/bluetooth_bwu_handler.cc +++ b/connections/implementation/bluetooth_bwu_handler.cc @@ -57,8 +57,7 @@ BluetoothBwuHandler::CreateUpgradedEndpointChannel( upgrade_path_info.bluetooth_credentials(); if (!bluetooth_credentials.has_service_name() || !bluetooth_credentials.has_mac_address()) { - LOG(ERROR) - << "BluetoothBwuHandler failed to parse UpgradePathInfo."; + LOG(ERROR) << "BluetoothBwuHandler failed to parse UpgradePathInfo."; return { Error(OperationResultCode::CONNECTIVITY_BLUETOOTH_INVALID_CREDENTIAL)}; } @@ -67,9 +66,9 @@ BluetoothBwuHandler::CreateUpgradedEndpointChannel( const std::string& mac_address = bluetooth_credentials.mac_address(); VLOG(1) << "BluetoothBwuHandler is attempting to connect to " - "available Bluetooth device (" - << service_name << ", " << mac_address << ") for endpoint " - << endpoint_id << " and service ID " << service_id; + "available Bluetooth device (" + << service_name << ", " << mac_address << ") for endpoint " + << endpoint_id << " and service ID " << service_id; BluetoothDevice device = bluetooth_medium_.GetRemoteDevice(mac_address); if (!device.IsValid()) { @@ -91,19 +90,17 @@ BluetoothBwuHandler::CreateUpgradedEndpointChannel( return {Error(socket_result.error().operation_result_code().value())}; } - VLOG(1) - << "BluetoothBwuHandler successfully connected to Bluetooth device (" - << service_id << ", " << mac_address << ") while upgrading endpoint " - << endpoint_id; + VLOG(1) << "BluetoothBwuHandler successfully connected to Bluetooth device (" + << service_id << ", " << mac_address << ") while upgrading endpoint " + << endpoint_id; auto channel = std::make_unique( service_id, /*channel_name=*/service_id, socket_result.value()); if (channel == nullptr) { - LOG(ERROR) - << "BluetoothBwuHandler failed to create Bluetooth endpoint " - "channel to the Bluetooth device (" - << service_name << ", " << mac_address << ") for endpoint " - << endpoint_id << " and service ID " << service_id; + LOG(ERROR) << "BluetoothBwuHandler failed to create Bluetooth endpoint " + "channel to the Bluetooth device (" + << service_name << ", " << mac_address << ") for endpoint " + << endpoint_id << " and service ID " << service_id; socket_result.value().Close(); return {Error( OperationResultCode::NEARBY_BT_ENDPOINT_CHANNEL_CREATION_FAILURE)}; @@ -119,9 +116,9 @@ ByteArray BluetoothBwuHandler::HandleInitializeUpgradedMediumForEndpoint( std::string mac_address = bluetooth_medium_.GetMacAddress(); if (mac_address.empty()) { LOG(ERROR) << "BluetoothBwuHandler couldn't initiate the " - "BLUETOOTH upgrade for service ID " - << upgrade_service_id << " and endpoint " << endpoint_id - << " because MAC address is empty."; + "BLUETOOTH upgrade for service ID " + << upgrade_service_id << " and endpoint " << endpoint_id + << " because MAC address is empty."; return {}; } @@ -132,10 +129,10 @@ ByteArray BluetoothBwuHandler::HandleInitializeUpgradedMediumForEndpoint( &BluetoothBwuHandler::OnIncomingBluetoothConnection, this, client))) { LOG(ERROR) << "BluetoothBwuHandler couldn't initiate the " - "BLUETOOTH upgrade for endpoint " - << endpoint_id - << " because it failed to start listening for " - "incoming Bluetooth connections."; + "BLUETOOTH upgrade for endpoint " + << endpoint_id + << " because it failed to start listening for " + "incoming Bluetooth connections."; return {}; } @@ -151,8 +148,7 @@ ByteArray BluetoothBwuHandler::HandleInitializeUpgradedMediumForEndpoint( void BluetoothBwuHandler::HandleRevertInitiatorStateForService( const std::string& upgrade_service_id) { bluetooth_medium_.StopAcceptingConnections(upgrade_service_id); - LOG(INFO) - << "BluetoothBwuHandler successfully reverted all Bluetooth state."; + LOG(INFO) << "BluetoothBwuHandler successfully reverted all Bluetooth state."; } // Accept Connection Callback. diff --git a/connections/implementation/bluetooth_bwu_test.cc b/connections/implementation/bluetooth_bwu_test.cc index c8b4edb2..2165b47e 100644 --- a/connections/implementation/bluetooth_bwu_test.cc +++ b/connections/implementation/bluetooth_bwu_test.cc @@ -17,8 +17,8 @@ #include "gtest/gtest.h" #include "absl/time/time.h" -#include "connections/implementation/bwu_handler.h" #include "connections/implementation/bluetooth_bwu_handler.h" +#include "connections/implementation/bwu_handler.h" #include "connections/implementation/client_proxy.h" #include "connections/implementation/endpoint_channel.h" #include "connections/implementation/mediums/mediums.h" diff --git a/connections/implementation/bwu_manager.cc b/connections/implementation/bwu_manager.cc index c1cbccd4..4481693e 100644 --- a/connections/implementation/bwu_manager.cc +++ b/connections/implementation/bwu_manager.cc @@ -233,9 +233,9 @@ void BwuManager::InitiateBwuForEndpoint(ClientProxy* client, RunOnBwuManagerThread("bwu-init", [this, client, endpoint_id, proposed_medium]() { LOG(INFO) << "InitiateBwuForEndpoint for endpoint " << endpoint_id - << " with medium " - << location::nearby::proto::connections::Medium_Name( - proposed_medium); + << " with medium " + << location::nearby::proto::connections::Medium_Name( + proposed_medium); if (channel_manager_->isWifiLanConnected() && (proposed_medium == Medium::WIFI_HOTSPOT)) { @@ -282,10 +282,10 @@ void BwuManager::InitiateBwuForEndpoint(ClientProxy* client, // to Bluetooth. if (proposed_medium == channel_medium) { LOG(INFO) << "BwuManager ignoring the upgrade for endpoint " - << endpoint_id - << " because it is already connected over medium " - << location::nearby::proto::connections::Medium_Name( - proposed_medium); + << endpoint_id + << " because it is already connected over medium " + << location::nearby::proto::connections::Medium_Name( + proposed_medium); return; } @@ -329,13 +329,12 @@ void BwuManager::InitiateBwuForEndpoint(ClientProxy* client, CONNECTIVITY_GENERIC_WRITING_CHANNEL_IO_ERROR); return; } - LOG(INFO) - << "BwuManager successfully wrote the " - "BANDWIDTH_UPGRADE_NEGOTIATION.UPGRADE_PATH_REQUEST " - "OfflineFrame while upgrading endpoint " - << endpoint_id << " to medium " - << location::nearby::proto::connections::Medium_Name( - proposed_medium); + LOG(INFO) << "BwuManager successfully wrote the " + "BANDWIDTH_UPGRADE_NEGOTIATION.UPGRADE_PATH_REQUEST " + "OfflineFrame while upgrading endpoint " + << endpoint_id << " to medium " + << location::nearby::proto::connections::Medium_Name( + proposed_medium); return; } } @@ -347,12 +346,12 @@ void BwuManager::InitiateBwuForEndpoint(ClientProxy* client, // Because we grab the endpointChannel first thing, it is possible the // endpointChannel is stale by the time we attempt to write over it. if (bytes.Empty()) { - LOG(ERROR) - << "BwuManager couldn't complete the upgrade for endpoint " - << endpoint_id << " to medium " - << location::nearby::proto::connections::Medium_Name(proposed_medium) - << " because it failed to initialize the " - "BWU_NEGOTIATION.UPGRADE_PATH_AVAILABLE OfflineFrame."; + LOG(ERROR) << "BwuManager couldn't complete the upgrade for endpoint " + << endpoint_id << " to medium " + << location::nearby::proto::connections::Medium_Name( + proposed_medium) + << " because it failed to initialize the " + "BWU_NEGOTIATION.UPGRADE_PATH_AVAILABLE OfflineFrame."; UpgradePathInfo info; info.set_medium(parser::MediumToUpgradePathInfoMedium(proposed_medium)); @@ -368,12 +367,12 @@ void BwuManager::InitiateBwuForEndpoint(ClientProxy* client, return; } if (!channel->Write(bytes).Ok()) { - LOG(ERROR) - << "BwuManager couldn't complete the upgrade for endpoint " - << endpoint_id << " to medium " - << location::nearby::proto::connections::Medium_Name(proposed_medium) - << " because it failed to write the " - "BWU_NEGOTIATION.UPGRADE_PATH_AVAILABLE OfflineFrame."; + LOG(ERROR) << "BwuManager couldn't complete the upgrade for endpoint " + << endpoint_id << " to medium " + << location::nearby::proto::connections::Medium_Name( + proposed_medium) + << " because it failed to write the " + "BWU_NEGOTIATION.UPGRADE_PATH_AVAILABLE OfflineFrame."; UpgradePathInfo info; info.set_medium(parser::MediumToUpgradePathInfoMedium(proposed_medium)); @@ -389,12 +388,12 @@ void BwuManager::InitiateBwuForEndpoint(ClientProxy* client, return; } - LOG(INFO) - << "BwuManager successfully wrote the " - "BWU_NEGOTIATION.UPGRADE_PATH_AVAILABLE OfflineFrame while " - "upgrading endpoint " - << endpoint_id << " to medium " - << location::nearby::proto::connections::Medium_Name(proposed_medium); + LOG(INFO) << "BwuManager successfully wrote the " + "BWU_NEGOTIATION.UPGRADE_PATH_AVAILABLE OfflineFrame while " + "upgrading endpoint " + << endpoint_id << " to medium " + << location::nearby::proto::connections::Medium_Name( + proposed_medium); in_progress_upgrades_.emplace(endpoint_id, client); }); } @@ -408,11 +407,10 @@ void BwuManager::OnIncomingFrame(OfflineFrame& frame, auto bwu_frame = frame.v1().bandwidth_upgrade_negotiation(); LOG(INFO) << "OnIncomingFrame: bwu_frame=" - << BandwidthUpgradeNegotiationFrame::EventType_Name( - bwu_frame.event_type()) - << ", endpoint_id=" << endpoint_id << ", medium=" - << location::nearby::proto::connections::Medium_Name( - medium); + << BandwidthUpgradeNegotiationFrame::EventType_Name( + bwu_frame.event_type()) + << ", endpoint_id=" << endpoint_id << ", medium=" + << location::nearby::proto::connections::Medium_Name(medium); if (FeatureFlags::GetInstance().GetFlags().enable_async_bandwidth_upgrade) { RunOnBwuManagerThread( "bwu-on-incoming-frame", [this, client, endpoint_id, bwu_frame]() { @@ -434,9 +432,9 @@ void BwuManager::OnEndpointDisconnect(ClientProxy* client, const std::string& endpoint_id, CountDownLatch barrier, DisconnectionReason reason) { - LOG(INFO) - << "BwuManager has processed endpoint disconnection for endpoint " - << endpoint_id << " with reason " << DisconnectionReason_Name(reason); + LOG(INFO) << "BwuManager has processed endpoint disconnection for endpoint " + << endpoint_id << " with reason " + << DisconnectionReason_Name(reason); RunOnBwuManagerThread("bwu-on-endpoint-disconnect", [this, client, service_id, endpoint_id, barrier]() mutable { @@ -476,9 +474,8 @@ void BwuManager::RevertBwuMediumForEndpoint(const std::string& service_id, // approach and revert the handler for _all_ endpoints. if (!FeatureFlags::GetInstance().GetFlags().support_multiple_bwu_mediums) { LOG(INFO) << "Reverting medium " - << location::nearby::proto::connections::Medium_Name( - medium) - << " for all endpoints for service " << service_id; + << location::nearby::proto::connections::Medium_Name(medium) + << " for all endpoints for service " << service_id; medium_ = Medium::UNKNOWN_MEDIUM; BwuHandler* handler = GetHandlerForMedium(medium); if (!handler) return; @@ -488,16 +485,15 @@ void BwuManager::RevertBwuMediumForEndpoint(const std::string& service_id, } LOG(INFO) << "Reverting medium " - << location::nearby::proto::connections::Medium_Name(medium) - << " for service ID " << service_id << " and endpoint " - << endpoint_id; + << location::nearby::proto::connections::Medium_Name(medium) + << " for service ID " << service_id << " and endpoint " + << endpoint_id; endpoint_id_to_bwu_medium_.erase(endpoint_id); BwuHandler* handler = GetHandlerForMedium(medium); if (!handler) { LOG(INFO) << "No BWU handler can be found for " - << location::nearby::proto::connections::Medium_Name( - medium); + << location::nearby::proto::connections::Medium_Name(medium); return; } // If |service_id| isn't of the INITIATOR-upgrade format--for example, if this @@ -555,8 +551,8 @@ void BwuManager::OnBwuNegotiationFrame(ClientProxy* client, const BwuNegotiationFrame frame, const std::string& endpoint_id) { LOG(INFO) << "OnBwuNegotiationFrame: processing incoming " - << BwuNegotiationFrame::EventType_Name(frame.event_type()) - << " frame for endpoint " << endpoint_id; + << BwuNegotiationFrame::EventType_Name(frame.event_type()) + << " frame for endpoint " << endpoint_id; if (!client->IsConnectedToEndpoint(endpoint_id)) { LOG(WARNING) @@ -625,41 +621,41 @@ void BwuManager::OnIncomingConnection( } VLOG(1) << "BwuManager successfully created new EndpointChannel for " - "incoming socket"; + "incoming socket"; ClientIntroduction introduction; if (!ReadClientIntroductionFrame(channel, introduction)) { // This was never a fully EstablishedConnection, no need to provide a // closure reason. channel->Close(); - LOG(ERROR) - << "BwuManager failed to read " - "BWU_NEGOTIATION.CLIENT_INTRODUCTION OfflineFrame from " - "newly-created EndpointChannel " - << channel->GetName() << ", so the EndpointChannel was discarded."; + LOG(ERROR) << "BwuManager failed to read " + "BWU_NEGOTIATION.CLIENT_INTRODUCTION OfflineFrame from " + "newly-created EndpointChannel " + << channel->GetName() + << ", so the EndpointChannel was discarded."; return; } VLOG(1) << "BwuManager successfully received " - "BWU_NEGOTIATION.CLIENT_INTRODUCTION " - "OfflineFrame on EndpointChannel " - << channel->GetName(); + "BWU_NEGOTIATION.CLIENT_INTRODUCTION " + "OfflineFrame on EndpointChannel " + << channel->GetName(); if (!WriteClientIntroductionAckFrame(channel)) { // This was never a fully EstablishedConnection, no need to provide a // closure reason. LOG(ERROR) << "BwuManager failed to write" - "BWU_NEGOTIATION.CLIENT_INTRODUCTION_ACK " - "OfflineFrame on EndpointChannel " - << channel->GetName(); + "BWU_NEGOTIATION.CLIENT_INTRODUCTION_ACK " + "OfflineFrame on EndpointChannel " + << channel->GetName(); channel->Close(); return; } VLOG(1) << "BwuManager successfully wrote " - "BWU_NEGOTIATION.CLIENT_INTRODUCTION_ACK " - "OfflineFrame on EndpointChannel " - << channel->GetName(); + "BWU_NEGOTIATION.CLIENT_INTRODUCTION_ACK " + "OfflineFrame on EndpointChannel " + << channel->GetName(); const std::string& endpoint_id = introduction.endpoint_id(); ClientProxy* mapped_client; @@ -716,9 +712,9 @@ void BwuManager::RunUpgradeProtocol( ClientProxy* client, const std::string& endpoint_id, std::unique_ptr new_channel, bool enable_encryption) { LOG(INFO) << "RunUpgradeProtocol new channel @" << new_channel.get() - << " name: " << new_channel->GetName() << ", medium: " - << location::nearby::proto::connections::Medium_Name( - new_channel->GetMedium()); + << " name: " << new_channel->GetName() << ", medium: " + << location::nearby::proto::connections::Medium_Name( + new_channel->GetMedium()); // First, register this new EndpointChannel as *the* EndpointChannel to use // for this endpoint here onwards. NOTE: We pause this new EndpointChannel // until we've completely drained the old EndpointChannel to avoid out of @@ -748,11 +744,10 @@ void BwuManager::RunUpgradeProtocol( // this endpoint by telling the remote device that it will not receive any // more writes over that EndpointChannel. if (!old_channel->Write(parser::ForBwuLastWrite()).Ok()) { - LOG(ERROR) - << "BwuManager failed to write " - "BWU_NEGOTIATION.LAST_WRITE_TO_PRIOR_CHANNEL OfflineFrame to " - "endpoint " - << endpoint_id << ", short-circuiting the upgrade protocol."; + LOG(ERROR) << "BwuManager failed to write " + "BWU_NEGOTIATION.LAST_WRITE_TO_PRIOR_CHANNEL OfflineFrame to " + "endpoint " + << endpoint_id << ", short-circuiting the upgrade protocol."; client->GetAnalyticsRecorder().OnBandwidthUpgradeError( endpoint_id, BandwidthUpgradeResult::RESULT_IO_ERROR, BandwidthUpgradeErrorStage::LAST_WRITE_TO_PRIOR_CHANNEL, @@ -760,9 +755,9 @@ void BwuManager::RunUpgradeProtocol( return; } VLOG(1) << "BwuManager successfully wrote " - "BWU_NEGOTIATION.LAST_WRITE_TO_PRIOR_CHANNEL " - "OfflineFrame while upgrading endpoint " - << endpoint_id; + "BWU_NEGOTIATION.LAST_WRITE_TO_PRIOR_CHANNEL " + "OfflineFrame while upgrading endpoint " + << endpoint_id; // The remainder of this clean shutdown for the previous EndpointChannel will // continue when we receive a corresponding @@ -784,10 +779,10 @@ void BwuManager::ProcessBwuPathAvailableEvent( const UpgradePathInfo& upgrade_path_info) { Medium upgrade_medium = parser::UpgradePathInfoMediumToMedium(upgrade_path_info.medium()); - LOG(INFO) << "ProcessBwuPathAvailableEvent for endpoint " - << endpoint_id << " medium " - << location::nearby::proto::connections::Medium_Name( - upgrade_medium); + LOG(INFO) << "ProcessBwuPathAvailableEvent for endpoint " << endpoint_id + << " medium " + << location::nearby::proto::connections::Medium_Name( + upgrade_medium); if (channel_manager_->isWifiLanConnected() && ((upgrade_medium == Medium::WIFI_HOTSPOT) || @@ -934,29 +929,26 @@ BwuManager::ProcessBwuPathAvailableEventInternal( Medium medium = parser::UpgradePathInfoMediumToMedium(upgrade_path_info.medium()); if (medium != GetBwuMediumForEndpoint(endpoint_id)) { - LOG(ERROR) - << "ProcessBwuPathAvailableEventInternal failed for endpoint " - << endpoint_id << " medium " - << location::nearby::proto::connections::Medium_Name(medium) - << ". Upgrade medium not yet set for endpoint."; + LOG(ERROR) << "ProcessBwuPathAvailableEventInternal failed for endpoint " + << endpoint_id << " medium " + << location::nearby::proto::connections::Medium_Name(medium) + << ". Upgrade medium not yet set for endpoint."; return {Error(OperationResultCode::NEARBY_UPGRADE_PATH_ON_WRONG_MEDIUM)}; } BwuHandler* handler = GetHandlerForMedium(medium); if (!handler) { - LOG(ERROR) - << "ProcessBwuPathAvailableEventInternal failed for endpoint " - << endpoint_id << " medium " - << location::nearby::proto::connections::Medium_Name(medium) - << ". No handler for medium."; + LOG(ERROR) << "ProcessBwuPathAvailableEventInternal failed for endpoint " + << endpoint_id << " medium " + << location::nearby::proto::connections::Medium_Name(medium) + << ". No handler for medium."; return {Error(OperationResultCode::NEARBY_UPGRADE_PATH_ON_WRONG_MEDIUM)}; } LOG(INFO) << "ProcessBwuPathAvailableEventInternal for " - "endpoint " - << endpoint_id << " medium " - << location::nearby::proto::connections::Medium_Name( - medium); + "endpoint " + << endpoint_id << " medium " + << location::nearby::proto::connections::Medium_Name(medium); // Get service ID from the old channel. Don't keep the old channel's shared // pointer in scope longer than necessary. @@ -967,11 +959,10 @@ BwuManager::ProcessBwuPathAvailableEventInternal( std::shared_ptr old_channel = channel_manager_->GetChannelForEndpoint(endpoint_id); if (!old_channel) { - LOG(ERROR) - << "ProcessBwuPathAvailableEventInternal failed for endpoint " - << endpoint_id << " medium " - << location::nearby::proto::connections::Medium_Name(medium) - << ". Old endpoint channel is missing."; + LOG(ERROR) << "ProcessBwuPathAvailableEventInternal failed for endpoint " + << endpoint_id << " medium " + << location::nearby::proto::connections::Medium_Name(medium) + << ". Old endpoint channel is missing."; return { Error(OperationResultCode::NEARBY_GENERIC_OLD_ENDPOINT_CHANNEL_NULL)}; } @@ -989,11 +980,10 @@ BwuManager::ProcessBwuPathAvailableEventInternal( old_medium == Medium::BLE && medium == Medium::WIFI_HOTSPOT) { disable_ble_scanning = true; if (enable_ble_v2) { - LOG(INFO) - << "For Apple OS, if upgrade from BLE_V2 to WIFI_HOTSPOT, " - "we need to pause " - "BLE_V2 scanning because it can interfere with WIFI " - "Hotspot scanning and connection."; + LOG(INFO) << "For Apple OS, if upgrade from BLE_V2 to WIFI_HOTSPOT, " + "we need to pause " + "BLE_V2 scanning because it can interfere with WIFI " + "Hotspot scanning and connection."; ble_v2_medium_.PauseMediumScanning(); } } @@ -1016,8 +1006,8 @@ BwuManager::ProcessBwuPathAvailableEventInternal( if (result.has_error() || !result.has_value()) { LOG(ERROR) << "BwuManager failed to create an endpoint " - "channel to endpoint" - << endpoint_id << ", aborting upgrade."; + "channel to endpoint" + << endpoint_id << ", aborting upgrade."; client->GetAnalyticsRecorder().OnBandwidthUpgradeError( endpoint_id, BandwidthUpgradeResult::RESULT_IO_ERROR, BandwidthUpgradeErrorStage::SOCKET_CREATION, @@ -1058,9 +1048,9 @@ BwuManager::ProcessBwuPathAvailableEventInternal( new_channel->Close(); LOG(ERROR) << "BwuManager failed to read " - "BWU_NEGOTIATION.CLIENT_INTRODUCTION_ACK " - "OfflineFrame to newly-created EndpointChannel " - << new_channel->GetName() << ", aborting upgrade."; + "BWU_NEGOTIATION.CLIENT_INTRODUCTION_ACK " + "OfflineFrame to newly-created EndpointChannel " + << new_channel->GetName() << ", aborting upgrade."; return {Error( OperationResultCode:: NEARBY_GENERIC_READ_CLIENT_INTRODUCTION_ACK_FRAME_TYPE_ERROR)}; @@ -1068,10 +1058,10 @@ BwuManager::ProcessBwuPathAvailableEventInternal( } LOG(INFO) << "BwuManager successfully wrote " - "BWU_NEGOTIATION.CLIENT_INTRODUCTION OfflineFrame to " - "newly-created EndpointChannel " - << new_channel->GetName() << " while upgrading endpoint " - << endpoint_id; + "BWU_NEGOTIATION.CLIENT_INTRODUCTION OfflineFrame to " + "newly-created EndpointChannel " + << new_channel->GetName() << " while upgrading endpoint " + << endpoint_id; // Set the AnalyticsRecorder so that the future closure of this // EndpointChannel will be recorded. @@ -1082,10 +1072,10 @@ void BwuManager::RunUpgradeFailedProtocol( ClientProxy* client, const std::string& endpoint_id, const UpgradePathInfo& upgrade_path_info) { LOG(INFO) << "RunUpgradeFailedProtocol for endpoint " << endpoint_id - << " medium " - << location::nearby::proto::connections::Medium_Name( - parser::UpgradePathInfoMediumToMedium( - upgrade_path_info.medium())); + << " medium " + << location::nearby::proto::connections::Medium_Name( + parser::UpgradePathInfoMediumToMedium( + upgrade_path_info.medium())); // We attempted to connect to the new medium that the remote device has set up // for us but we failed. We need to let the remote device know so that they // can pick another medium for us to try. @@ -1108,10 +1098,9 @@ void BwuManager::RunUpgradeFailedProtocol( if (!channel->Write(parser::ForBwuFailure(upgrade_path_info)).Ok()) { channel->Close(DisconnectionReason::IO_ERROR); - LOG(ERROR) - << "BwuManager failed to write BWU_NEGOTIATION.UPGRADE_FAILURE " - "OfflineFrame to endpoint " - << endpoint_id << ", short-circuiting the upgrade protocol."; + LOG(ERROR) << "BwuManager failed to write BWU_NEGOTIATION.UPGRADE_FAILURE " + "OfflineFrame to endpoint " + << endpoint_id << ", short-circuiting the upgrade protocol."; client->GetAnalyticsRecorder().OnBandwidthUpgradeError( endpoint_id, BandwidthUpgradeResult::RESULT_IO_ERROR, BandwidthUpgradeErrorStage::NETWORK_AVAILABLE, @@ -1125,24 +1114,23 @@ void BwuManager::RunUpgradeFailedProtocol( } in_progress_upgrades_.erase(endpoint_id); LOG(INFO) << "BwuManager has informed endpoint " << endpoint_id - << " that the bandwidth upgrade failed."; + << " that the bandwidth upgrade failed."; } bool BwuManager::ReadClientIntroductionFrame(EndpointChannel* channel, ClientIntroduction& introduction) { LOG(INFO) << "ReadClientIntroductionFrame with channel name: " - << channel->GetName() << ", medium: " - << location::nearby::proto::connections::Medium_Name( - channel->GetMedium()); + << channel->GetName() << ", medium: " + << location::nearby::proto::connections::Medium_Name( + channel->GetMedium()); CancelableAlarm timeout_alarm( "BwuManager::ReadClientIntroductionFrame", [channel]() { LOG(ERROR) << "In BwuManager, failed to read the " - "ClientIntroductionFrame after " - << absl::FormatDuration( - kReadClientIntroductionFrameTimeout) - << ". Timing out and closing EndpointChannel " - << channel->GetType(); + "ClientIntroductionFrame after " + << absl::FormatDuration(kReadClientIntroductionFrameTimeout) + << ". Timing out and closing EndpointChannel " + << channel->GetType(); channel->Close(); }, kReadClientIntroductionFrameTimeout, &alarm_executor_); @@ -1152,17 +1140,16 @@ bool BwuManager::ReadClientIntroductionFrame(EndpointChannel* channel, auto transfer(parser::FromBytes(data.result())); if (!transfer.ok()) { LOG(ERROR) << "In ReadClientIntroductionFrame, attempted to read a " - "ClientIntroductionFrame from EndpointChannel " - << channel->GetType() - << " but was unable to obtain any OfflineFrame."; + "ClientIntroductionFrame from EndpointChannel " + << channel->GetType() + << " but was unable to obtain any OfflineFrame."; return false; } OfflineFrame frame = transfer.result(); if (!frame.has_v1() || !frame.v1().has_bandwidth_upgrade_negotiation()) { - LOG(ERROR) - << "In ReadClientIntroductionFrame, expected a " - "BANDWIDTH_UPGRADE_NEGOTIATION v1 OfflineFrame but got a " - << parser::GetFrameType(frame) << " frame instead."; + LOG(ERROR) << "In ReadClientIntroductionFrame, expected a " + "BANDWIDTH_UPGRADE_NEGOTIATION v1 OfflineFrame but got a " + << parser::GetFrameType(frame) << " frame instead."; return false; } if (frame.v1().bandwidth_upgrade_negotiation().event_type() != @@ -1183,9 +1170,9 @@ bool BwuManager::ReadClientIntroductionFrame(EndpointChannel* channel, bool BwuManager::ReadClientIntroductionAckFrame(EndpointChannel* channel) { LOG(INFO) << "ReadClientIntroductionAckFrame with channel name: " - << channel->GetName() << ", medium: " - << location::nearby::proto::connections::Medium_Name( - channel->GetMedium()); + << channel->GetName() << ", medium: " + << location::nearby::proto::connections::Medium_Name( + channel->GetMedium()); CancelableAlarm timeout_alarm( "BwuManager::ReadClientIntroductionAckFrame", [channel]() { @@ -1214,9 +1201,9 @@ bool BwuManager::ReadClientIntroductionAckFrame(EndpointChannel* channel) { bool BwuManager::WriteClientIntroductionAckFrame(EndpointChannel* channel) { LOG(INFO) << "WriteClientIntroductionAckFrame channel name: " - << channel->GetName() << ", medium: " - << location::nearby::proto::connections::Medium_Name( - channel->GetMedium()); + << channel->GetName() << ", medium: " + << location::nearby::proto::connections::Medium_Name( + channel->GetMedium()); return channel->Write(parser::ForBwuIntroductionAck()).Ok(); } @@ -1243,10 +1230,10 @@ void BwuManager::ProcessLastWriteToPriorChannelEvent( } LOG(INFO) << "ProcessLastWriteToPriorChannelEvent: service_id=" - << previous_endpoint_channel->GetServiceId() - << ", endpoint_id=" << endpoint_id << ", medium=" - << location::nearby::proto::connections::Medium_Name( - previous_endpoint_channel->GetMedium()); + << previous_endpoint_channel->GetServiceId() + << ", endpoint_id=" << endpoint_id << ", medium=" + << location::nearby::proto::connections::Medium_Name( + previous_endpoint_channel->GetMedium()); if (!previous_endpoint_channel->Write(parser::ForBwuSafeToClose()).Ok()) { previous_endpoint_channel->Close(DisconnectionReason::IO_ERROR); @@ -1255,10 +1242,9 @@ void BwuManager::ProcessLastWriteToPriorChannelEvent( previous_endpoint_channels_.erase(endpoint_id); LOG(ERROR) << "BwuManager failed to write " - "BWU_NEGOTIATION.SAFE_TO_CLOSE_PRIOR_CHANNEL " - "OfflineFrame to endpoint " - << endpoint_id - << ", short-circuiting the upgrade protocol."; + "BWU_NEGOTIATION.SAFE_TO_CLOSE_PRIOR_CHANNEL " + "OfflineFrame to endpoint " + << endpoint_id << ", short-circuiting the upgrade protocol."; client->GetAnalyticsRecorder().OnBandwidthUpgradeError( endpoint_id, BandwidthUpgradeResult::RESULT_IO_ERROR, BandwidthUpgradeErrorStage::SAFE_TO_CLOSE_PRIOR_CHANNEL, @@ -1266,9 +1252,9 @@ void BwuManager::ProcessLastWriteToPriorChannelEvent( return; } VLOG(1) << "BwuManager successfully wrote " - "BWU_NEGOTIATION.SAFE_TO_CLOSE_PRIOR_CHANNEL " - "OfflineFrame while trying to upgrade endpoint " - << endpoint_id; + "BWU_NEGOTIATION.SAFE_TO_CLOSE_PRIOR_CHANNEL " + "OfflineFrame while trying to upgrade endpoint " + << endpoint_id; // The upgrade protocol's clean shutdown of the prior EndpointChannel will // conclude when we receive a corresponding @@ -1279,7 +1265,7 @@ void BwuManager::ProcessLastWriteToPriorChannelEvent( void BwuManager::ProcessSafeToClosePriorChannelEvent( ClientProxy* client, const std::string& endpoint_id) { LOG(INFO) << "ProcessSafeToClosePriorChannelEvent for endpoint " - << endpoint_id; + << endpoint_id; // By this point in the upgrade protocol, there's no more writes happening // over the prior EndpointChannel, and the remote device has given us the // go-ahead to close this EndpointChannel [1], so we can safely close it @@ -1302,10 +1288,9 @@ void BwuManager::ProcessSafeToClosePriorChannelEvent( << endpoint_id << ", can't complete the upgrade protocol."; return; } - LOG(INFO) - << "BwuManager successfully received a " - << "BWU_NEGOTIATION.SAFE_TO_CLOSE_PRIOR_CHANNEL OfflineFrame while " - << "trying to upgrade endpoint " << endpoint_id; + LOG(INFO) << "BwuManager successfully received a " + << "BWU_NEGOTIATION.SAFE_TO_CLOSE_PRIOR_CHANNEL OfflineFrame while " + << "trying to upgrade endpoint " << endpoint_id; // Each encrypted message includes the key to decrypt the next message. The // disconnect message is optional and may not be received under normal @@ -1313,7 +1298,7 @@ void BwuManager::ProcessSafeToClosePriorChannelEvent( // serial crypto context does not increment here. previous_endpoint_channel->DisableEncryption(); LOG(INFO) << "[safe-to-disconnect] Sending " - "DISCONNECTION frame with request 0, ack 0"; + "DISCONNECTION frame with request 0, ack 0"; previous_endpoint_channel->Write( parser::ForDisconnection(/* request_safe_to_disconnect */ false, /* ack_safe_to_disconnect */ false)); @@ -1326,11 +1311,10 @@ void BwuManager::ProcessSafeToClosePriorChannelEvent( previous_endpoint_channel->Read(); previous_endpoint_channel->Close(DisconnectionReason::UPGRADED); - VLOG(1) - << "BwuManager cleanly shut down prior " - << previous_endpoint_channel->GetType() - << " EndpointChannel to conclude upgrade protocol for endpoint " - << endpoint_id; + VLOG(1) << "BwuManager cleanly shut down prior " + << previous_endpoint_channel->GetType() + << " EndpointChannel to conclude upgrade protocol for endpoint " + << endpoint_id; // Now the upgrade protocol has completed, record analytics for this new // upgraded bandwidth connection... @@ -1346,8 +1330,8 @@ void BwuManager::ProcessSafeToClosePriorChannelEvent( if (!channel) { LOG(ERROR) << "BwuManager attempted to resume the current " - "EndpointChannel with endpoint " - << endpoint_id << ", but none was found."; + "EndpointChannel with endpoint " + << endpoint_id << ", but none was found."; return; } @@ -1371,10 +1355,10 @@ void BwuManager::ProcessUpgradeFailureEvent( const UpgradePathInfo& upgrade_info, BandwidthUpgradeResult result, bool record_analytic, OperationResultCode operation_result_code) { LOG(INFO) << "ProcessUpgradeFailureEvent for endpoint " << endpoint_id - << " from medium: " - << location::nearby::proto::connections::Medium_Name( - parser::UpgradePathInfoMediumToMedium( - upgrade_info.medium())); + << " from medium: " + << location::nearby::proto::connections::Medium_Name( + parser::UpgradePathInfoMediumToMedium( + upgrade_info.medium())); // The remote device failed to upgrade to the new medium we set up for them. // That's alright! We'll just try the next available medium (if there is one). in_progress_upgrades_.erase(endpoint_id); @@ -1440,9 +1424,8 @@ void BwuManager::TryNextBestUpgradeMediums( std::vector upgrade_mediums) { Medium next_medium = ChooseBestUpgradeMedium(endpoint_id, upgrade_mediums); LOG(INFO) << "Try Next Best Medium for endpoint " << endpoint_id - << " after ChooseBestUpgradeMedium: " - << location::nearby::proto::connections::Medium_Name( - next_medium); + << " after ChooseBestUpgradeMedium: " + << location::nearby::proto::connections::Medium_Name(next_medium); // If current medium is not WiFi and we have not succeeded with upgrading yet, // retry upgrade. @@ -1451,8 +1434,7 @@ void BwuManager::TryNextBestUpgradeMediums( Medium current_medium = channel ? channel->GetMedium() : Medium::UNKNOWN_MEDIUM; VLOG(1) << "current_medium: " - << location::nearby::proto::connections::Medium_Name( - current_medium); + << location::nearby::proto::connections::Medium_Name(current_medium); if (current_medium != Medium::WIFI_LAN && (next_medium == current_medium || next_medium == Medium::UNKNOWN_MEDIUM || upgrade_mediums.empty())) { @@ -1473,9 +1455,8 @@ void BwuManager::TryNextBestUpgradeMediums( // Now that we've successfully picked a new upgrade medium to try, // re-initiate the bandwidth upgrade. - LOG(INFO) << "BwuManager is attempting to upgrade endpoint " - << endpoint_id - << " again with a new bandwidth upgrade medium."; + LOG(INFO) << "BwuManager is attempting to upgrade endpoint " << endpoint_id + << " again with a new bandwidth upgrade medium."; InitiateBwuForEndpoint(client, endpoint_id, next_medium); } @@ -1561,11 +1542,11 @@ Medium BwuManager::ChooseBestUpgradeMedium( location::nearby::proto::connections::Medium_Name(medium), "; "); } - LOG(INFO) - << "Current upgrade medium " - << location::nearby::proto::connections::Medium_Name(current_medium) - << " is not supported by the remote endpoint (supported mediums: " - << mediums_string << ")"; + LOG(INFO) << "Current upgrade medium " + << location::nearby::proto::connections::Medium_Name( + current_medium) + << " is not supported by the remote endpoint (supported mediums: " + << mediums_string << ")"; } return Medium::UNKNOWN_MEDIUM; @@ -1593,8 +1574,7 @@ void BwuManager::RetryUpgradesAfterDelay(ClientProxy* client, retry_upgrade_alarms_.emplace(endpoint_id, std::make_pair(std::move(alarm), delay)); retry_delays_[endpoint_id] = delay; - LOG(INFO) << "Retry bandwidth upgrade after " - << absl::FormatDuration(delay); + LOG(INFO) << "Retry bandwidth upgrade after " << absl::FormatDuration(delay); } void BwuManager::AttemptToRecordBandwidthUpgradeErrorForUnknownEndpoint( @@ -1611,18 +1591,16 @@ void BwuManager::AttemptToRecordBandwidthUpgradeErrorForUnknownEndpoint( // make for them. client->GetAnalyticsRecorder().OnBandwidthUpgradeError( endpoint_id, result, error_stage, operation_result_code); - LOG(INFO) << "BwuManager got error " - << BandwidthUpgradeResult_Name(result) << " at stage " - << BandwidthUpgradeErrorStage_Name(error_stage) - << " when upgrading endpoint " << endpoint_id; + LOG(INFO) << "BwuManager got error " << BandwidthUpgradeResult_Name(result) + << " at stage " << BandwidthUpgradeErrorStage_Name(error_stage) + << " when upgrading endpoint " << endpoint_id; } // Otherwise, we have no way of knowing which endpoint was trying to connect // to us :( - LOG(INFO) << "BwuManager got error " - << BandwidthUpgradeResult_Name(result) << " at stage " - << BandwidthUpgradeErrorStage_Name(error_stage) - << ", but we don't know which endpoint was trying to " - "connect to us, so skipping analytics for his error."; + LOG(INFO) << "BwuManager got error " << BandwidthUpgradeResult_Name(result) + << " at stage " << BandwidthUpgradeErrorStage_Name(error_stage) + << ", but we don't know which endpoint was trying to " + "connect to us, so skipping analytics for his error."; } bool BwuManager::NeedToSwitchRole( diff --git a/connections/implementation/client_proxy.cc b/connections/implementation/client_proxy.cc index 54a459e7..4913a147 100644 --- a/connections/implementation/client_proxy.cc +++ b/connections/implementation/client_proxy.cc @@ -109,8 +109,8 @@ ClientProxy::ClientProxy(::nearby::analytics::EventLogger* event_logger) config_package_nearby::nearby_connections_feature:: kSafeToDisconnectVersion); LOG(INFO) << "[safe-to-disconnect]: Local enabled: " - << supports_safe_to_disconnect_ - << "; Version: " << local_safe_to_disconnect_version_; + << supports_safe_to_disconnect_ + << "; Version: " << local_safe_to_disconnect_version_; // Generate a 7 bits dedup value. absl::BitGen bitgen; dct_dedup_ = absl::Uniform(bitgen, 0, 1 << 7); @@ -127,21 +127,20 @@ std::string ClientProxy::GetLocalEndpointId() { return GetEndpointIdForDct().value(); } else { if (!local_endpoint_id_.empty()) { - LOG(INFO) << __func__ << ": Reusing cached endpoint id: " - << local_endpoint_id_; + LOG(INFO) << __func__ + << ": Reusing cached endpoint id: " << local_endpoint_id_; return local_endpoint_id_; } if (external_device_provider_ == nullptr) { local_endpoint_id_ = GenerateLocalEndpointId(); - LOG(INFO) << __func__ << ": Locally generating endpoint id: " - << local_endpoint_id_; + LOG(INFO) << __func__ + << ": Locally generating endpoint id: " << local_endpoint_id_; } else { local_endpoint_id_ = external_device_provider_->GetLocalDevice()->GetEndpointId(); - LOG(INFO) - << __func__ - << ": From external device provider, populating endpoint id: " - << local_endpoint_id_; + LOG(INFO) << __func__ + << ": From external device provider, populating endpoint id: " + << local_endpoint_id_; } return local_endpoint_id_; } @@ -184,10 +183,10 @@ std::string ClientProxy::GenerateLocalEndpointId() { if (!cached_endpoint_id_.empty()) { if (stable_endpoint_id_mode_) { LOG(INFO) << "ClientProxy [Local Endpoint Re-using cached " - "endpoint id due to in stable endpoint id mode]: " - "client=" - << GetClientId() - << "; cached_endpoint_id_=" << cached_endpoint_id_; + "endpoint id due to in stable endpoint id mode]: " + "client=" + << GetClientId() + << "; cached_endpoint_id_=" << cached_endpoint_id_; return cached_endpoint_id_; } } @@ -195,9 +194,9 @@ std::string ClientProxy::GenerateLocalEndpointId() { if (high_vis_mode_) { if (!cached_endpoint_id_.empty()) { LOG(INFO) << "ClientProxy [Local Endpoint Re-using cached " - "endpoint id]: client=" - << GetClientId() - << "; cached_endpoint_id_=" << cached_endpoint_id_; + "endpoint id]: client=" + << GetClientId() + << "; cached_endpoint_id_=" << cached_endpoint_id_; return cached_endpoint_id_; } } @@ -231,8 +230,7 @@ void ClientProxy::StartedAdvertising( operation_result_with_mediums, const AdvertisingOptions& advertising_options) { MutexLock lock(&mutex_); - LOG(INFO) << "ClientProxy [StartedAdvertising]: client=" - << GetClientId(); + LOG(INFO) << "ClientProxy [StartedAdvertising]: client=" << GetClientId(); if (IsFeatureUseStableEndpointIdEnabled()) { if (stable_endpoint_id_mode_) { @@ -268,8 +266,7 @@ void ClientProxy::StartedAdvertising( void ClientProxy::StoppedAdvertising() { MutexLock lock(&mutex_); - LOG(INFO) << "ClientProxy [StoppedAdvertising]: client=" - << GetClientId(); + LOG(INFO) << "ClientProxy [StoppedAdvertising]: client=" << GetClientId(); if (IsAdvertising()) { advertising_info_.Clear(); @@ -436,16 +433,14 @@ void ClientProxy::OnEndpointFound( location::nearby::proto::connections::Medium medium) { MutexLock lock(&mutex_); - LOG(INFO) << "ClientProxy [Endpoint Found]: [enter] id=" - << endpoint_id << "; service=" << service_id - << "; info=" << absl::BytesToHexString(endpoint_info.data()) - << "; medium=" - << location::nearby::proto::connections::Medium_Name( - medium); + LOG(INFO) << "ClientProxy [Endpoint Found]: [enter] id=" << endpoint_id + << "; service=" << service_id + << "; info=" << absl::BytesToHexString(endpoint_info.data()) + << "; medium=" + << location::nearby::proto::connections::Medium_Name(medium); if (!IsDiscoveringServiceId(service_id)) { LOG(INFO) << "ClientProxy [Endpoint Found]: Ignoring event for id=" - << endpoint_id - << " because this client is not discovering."; + << endpoint_id << " because this client is not discovering."; return; } @@ -467,11 +462,10 @@ void ClientProxy::OnEndpointLost(const std::string& service_id, MutexLock lock(&mutex_); LOG(INFO) << "ClientProxy [Endpoint Lost]: [enter] id=" << endpoint_id - << "; service=" << service_id; + << "; service=" << service_id; if (!IsDiscoveringServiceId(service_id)) { LOG(INFO) << "ClientProxy [Endpoint Lost]: Ignoring event for id=" - << endpoint_id - << " because this client is not discovering."; + << endpoint_id << " because this client is not discovering."; return; } @@ -520,10 +514,9 @@ void ClientProxy::OnConnectionInitiated( // (can not use c++17 features, until chromium does) we unpack manually. auto& pair_iter = result.first; bool inserted = result.second; - LOG(INFO) - << "ClientProxy [Connection Initiated]: add Connection: client=" - << GetClientId() << "; endpoint_id=" << endpoint_id - << "; inserted=" << inserted; + LOG(INFO) << "ClientProxy [Connection Initiated]: add Connection: client=" + << GetClientId() << "; endpoint_id=" << endpoint_id + << "; inserted=" << inserted; DCHECK(inserted); const ConnectionPair& item = pair_iter->second; // Notify the client. @@ -547,8 +540,8 @@ void ClientProxy::OnConnectionAccepted(const std::string& endpoint_id) { if (!HasPendingConnectionToEndpoint(endpoint_id)) { LOG(INFO) << "ClientProxy [Connection Accepted]: no pending " - "connection; endpoint_id=" - << endpoint_id; + "connection; endpoint_id=" + << endpoint_id; return; } @@ -567,8 +560,8 @@ void ClientProxy::OnConnectionRejected(const std::string& endpoint_id, if (!HasPendingConnectionToEndpoint(endpoint_id)) { LOG(INFO) << "ClientProxy [Connection Rejected]: no pending " - "connection; endpoint_id=" - << endpoint_id; + "connection; endpoint_id=" + << endpoint_id; return; } @@ -591,7 +584,7 @@ void ClientProxy::OnBandwidthChanged(const std::string& endpoint_id, item->first.connection_listener.bandwidth_changed_cb(endpoint_id, new_medium); LOG(INFO) << "ClientProxy [reporting onBandwidthChanged]: client=" - << GetClientId() << "; endpoint_id=" << endpoint_id; + << GetClientId() << "; endpoint_id=" << endpoint_id; } } @@ -1040,9 +1033,9 @@ void ClientProxy::OnPayload(const std::string& endpoint_id, Payload payload) { LookupConnection(endpoint_id); if (item != nullptr) { LOG(INFO) << "ClientProxy [reporting onPayloadReceived]: client=" - << GetClientId() << "; endpoint_id=" << endpoint_id - << " ; payload {id:" << payload.GetId() - << ", type:" << payload.GetType() << "}"; + << GetClientId() << "; endpoint_id=" << endpoint_id + << " ; payload {id:" << payload.GetId() + << ", type:" << payload.GetType() << "}"; item->second.payload_cb(endpoint_id, std::move(payload)); } } @@ -1072,15 +1065,14 @@ void ClientProxy::OnPayloadProgress(const std::string& endpoint_id, if (info.status == PayloadProgressInfo::Status::kInProgress) { VLOG(1) << "ClientProxy [reporting onPayloadProgress]: client=" - << GetClientId() << "; endpoint_id=" << endpoint_id - << "; payload_id=" << info.payload_id - << ", payload_status=" << ToString(info.status); + << GetClientId() << "; endpoint_id=" << endpoint_id + << "; payload_id=" << info.payload_id + << ", payload_status=" << ToString(info.status); } else { - LOG(INFO) - << "ClientProxy [reporting onPayloadProgress]: client=" - << GetClientId() << "; endpoint_id=" << endpoint_id - << "; payload_id=" << info.payload_id - << ", payload_status=" << ToString(info.status); + LOG(INFO) << "ClientProxy [reporting onPayloadProgress]: client=" + << GetClientId() << "; endpoint_id=" << endpoint_id + << "; payload_id=" << info.payload_id + << ", payload_status=" << ToString(info.status); } } } @@ -1142,15 +1134,14 @@ v3::ConnectionListeningOptions ClientProxy::GetListeningOptions() const { void ClientProxy::EnterHighVisibilityMode() { MutexLock lock(&mutex_); LOG(INFO) << "ClientProxy [EnterHighVisibilityMode]: client=" - << GetClientId(); + << GetClientId(); high_vis_mode_ = true; } void ClientProxy::ExitHighVisibilityMode() { MutexLock lock(&mutex_); - LOG(INFO) << "ClientProxy [ExitHighVisibilityMode]: client=" - << GetClientId(); + LOG(INFO) << "ClientProxy [ExitHighVisibilityMode]: client=" << GetClientId(); high_vis_mode_ = false; ScheduleClearCachedEndpointIdAlarm(); @@ -1159,7 +1150,7 @@ void ClientProxy::ExitHighVisibilityMode() { void ClientProxy::EnterStableEndpointIdMode() { MutexLock lock(&mutex_); LOG(INFO) << "ClientProxy [EnterStableEndpointIdMode]: client=" - << GetClientId(); + << GetClientId(); stable_endpoint_id_mode_ = true; } @@ -1167,7 +1158,7 @@ void ClientProxy::EnterStableEndpointIdMode() { void ClientProxy::ExitStableEndpointIdMode() { MutexLock lock(&mutex_); LOG(INFO) << "ClientProxy [ExitStableEndpointIdMode]: client=" - << GetClientId(); + << GetClientId(); stable_endpoint_id_mode_ = false; ScheduleClearCachedEndpointIdAlarm(); @@ -1178,38 +1169,34 @@ void ClientProxy::ScheduleClearCachedEndpointIdAlarm() { if (cached_endpoint_id_.empty()) { VLOG(1) << "ClientProxy [There is no cached local high power " - "advertising endpoint Id]: client=" - << GetClientId(); + "advertising endpoint Id]: client=" + << GetClientId(); return; } if (IsFeatureUseStableEndpointIdEnabled() && HasOngoingConnection()) { VLOG(1) << "ClientProxy [Handle clearing cached endpoint ID " - "during disconnection]: client=" - << GetClientId(); + "during disconnection]: client=" + << GetClientId(); return; } // Schedule to clear cache high visibility mode advertisement endpoint id in // 30s. LOG(INFO) << "ClientProxy [High Visibility Mode Adv, Schedule to " - "Clear Cache EndpointId]: client=" - << GetClientId() - << "; cached_endpoint_id_=" << cached_endpoint_id_; - cached_endpoint_id_alarm_ = - std::make_unique( - "clear_high_power_endpoint_id_cache", - [this]() { - MutexLock lock(&mutex_); - LOG(INFO) - << "ClientProxy [Cleared cached local high power advertising " - "endpoint Id.]: client=" - << GetClientId() - << "; cached_endpoint_id_=" << cached_endpoint_id_; - cached_endpoint_id_.clear(); - }, - kHighPowerAdvertisementEndpointIdCacheTimeout, - &single_thread_executor_); + "Clear Cache EndpointId]: client=" + << GetClientId() << "; cached_endpoint_id_=" << cached_endpoint_id_; + cached_endpoint_id_alarm_ = std::make_unique( + "clear_high_power_endpoint_id_cache", + [this]() { + MutexLock lock(&mutex_); + LOG(INFO) << "ClientProxy [Cleared cached local high power advertising " + "endpoint Id.]: client=" + << GetClientId() + << "; cached_endpoint_id_=" << cached_endpoint_id_; + cached_endpoint_id_.clear(); + }, + kHighPowerAdvertisementEndpointIdCacheTimeout, &single_thread_executor_); } void ClientProxy::CancelClearCachedEndpointIdAlarm() { @@ -1250,7 +1237,7 @@ std::int32_t ClientProxy::GetLocalMultiplexSocketBitmask() const { ? kWifiLanMultiplexEnabled : 0); LOG(INFO) << "ClientProxy [GetLocalMultiplexSocketBitmask]: " - << multiplex_bitmask; + << multiplex_bitmask; return multiplex_bitmask; } return 0; @@ -1263,7 +1250,7 @@ void ClientProxy::SetRemoteMultiplexSocketBitmask( item->first.remote_multiplex_socket_bitmask = remote_multiplex_socket_bitmask; LOG(INFO) << "ClientProxy [SetRemoteMultiplexSocketBitmask]: " - << remote_multiplex_socket_bitmask; + << remote_multiplex_socket_bitmask; } } @@ -1272,7 +1259,7 @@ bool ClientProxy::IsLocalMultiplexSocketSupported(Medium medium) { switch (medium) { case Medium::BLUETOOTH: LOG(INFO) << "ClientProxy [IsLocalMultiplexSocketSupported]: " - << (bitmask & kBtMultiplexEnabled); + << (bitmask & kBtMultiplexEnabled); return (bitmask & kBtMultiplexEnabled) != 0; case Medium::WIFI_LAN: return (bitmask & kWifiLanMultiplexEnabled) != 0; @@ -1315,7 +1302,7 @@ void ClientProxy::SetWebRtcNonCellular(bool webrtc_non_cellular) { std::string allow_webrtc_cellular_str = webrtc_non_cellular ? "disallow" : "allow"; LOG(INFO) << "ClientProxy: client=" << GetClientId() - << allow_webrtc_cellular_str << " to use mobile data.", + << allow_webrtc_cellular_str << " to use mobile data.", webrtc_non_cellular_ = webrtc_non_cellular; } diff --git a/connections/implementation/connections_authentication_transport.cc b/connections/implementation/connections_authentication_transport.cc index 7ddbb001..c98edbbe 100644 --- a/connections/implementation/connections_authentication_transport.cc +++ b/connections/implementation/connections_authentication_transport.cc @@ -44,8 +44,8 @@ std::string ConnectionsAuthenticationTransport::ReadMessage() const { return response.result().string_data(); } LOG(WARNING) << "ConnectionsAuthenticationTransport: read failed " - "with exception/result: " - << response.exception(); + "with exception/result: " + << response.exception(); return ""; } diff --git a/connections/implementation/encryption_runner.cc b/connections/implementation/encryption_runner.cc index 032589fb..a74a4b8e 100644 --- a/connections/implementation/encryption_runner.cc +++ b/connections/implementation/encryption_runner.cc @@ -73,10 +73,9 @@ bool HandleEncryptionSuccess(const std::string& endpoint_id, void CancelableAlarmRunnable(ClientProxy* client, const std::string& endpoint_id, EndpointChannel* endpoint_channel) { - LOG(INFO) << "Timing out encryption for client " - << client->GetClientId() - << " to endpoint_id=" << endpoint_id << " after " - << absl::FormatDuration(kTimeout); + LOG(INFO) << "Timing out encryption for client " << client->GetClientId() + << " to endpoint_id=" << endpoint_id << " after " + << absl::FormatDuration(kTimeout); endpoint_channel->Close(); } @@ -126,9 +125,8 @@ class ServerRunnable final { return; } - LOG(INFO) - << "In StartServer(), read UKEY2 Message 1 from endpoint(id=" - << endpoint_id_ << ")."; + LOG(INFO) << "In StartServer(), read UKEY2 Message 1 from endpoint(id=" + << endpoint_id_ << ")."; // Message 2 (Server Init) std::unique_ptr server_init = @@ -149,9 +147,8 @@ class ServerRunnable final { return; } - LOG(INFO) - << "In StartServer(), wrote UKEY2 Message 2 to endpoint(id=" - << endpoint_id_ << ")."; + LOG(INFO) << "In StartServer(), wrote UKEY2 Message 2 to endpoint(id=" + << endpoint_id_ << ")."; // Message 3 (Client Finish) ExceptionOr client_finish = channel_->Read(); @@ -175,9 +172,8 @@ class ServerRunnable final { return; } - LOG(INFO) - << "In StartServer(), read UKEY2 Message 3 from endpoint(id=" - << endpoint_id_ << ")."; + LOG(INFO) << "In StartServer(), read UKEY2 Message 3 from endpoint(id=" + << endpoint_id_ << ")."; timeout_alarm.Cancel(); @@ -191,7 +187,7 @@ class ServerRunnable final { private: void LogException() const { LOG(ERROR) << "In StartServer(), UKEY2 failed with endpoint(id=" - << endpoint_id_ << ")."; + << endpoint_id_ << ")."; } void HandleHandshakeOrIoException(CancelableAlarm* timeout_alarm) { @@ -204,10 +200,9 @@ class ServerRunnable final { Exception write_exception = channel_->Write(ByteArray(*parse_result.alert_to_send)); if (!write_exception.Ok()) { - LOG(WARNING) - << "In StartServer(), client " << client_->GetClientId() - << " failed to pass the alert error message to endpoint(id=" - << endpoint_id_ << ")."; + LOG(WARNING) << "In StartServer(), client " << client_->GetClientId() + << " failed to pass the alert error message to endpoint(id=" + << endpoint_id_ << ")."; } } @@ -263,9 +258,8 @@ class ClientRunnable final { return; } - LOG(INFO) - << "In StartClient(), wrote UKEY2 Message 1 to endpoint(id=" - << endpoint_id_ << ")."; + LOG(INFO) << "In StartClient(), wrote UKEY2 Message 1 to endpoint(id=" + << endpoint_id_ << ")."; // Message 2 (Server Init) ExceptionOr server_init = channel_->Read(); @@ -289,9 +283,8 @@ class ClientRunnable final { return; } - LOG(INFO) - << "In StartClient(), read UKEY2 Message 2 from endpoint(id=" - << endpoint_id_ << ")."; + LOG(INFO) << "In StartClient(), read UKEY2 Message 2 from endpoint(id=" + << endpoint_id_ << ")."; // Message 3 (Client Finish) std::unique_ptr client_finish = @@ -312,9 +305,8 @@ class ClientRunnable final { return; } - LOG(INFO) - << "In StartClient(), wrote UKEY2 Message 3 to endpoint(id=" - << endpoint_id_ << ")."; + LOG(INFO) << "In StartClient(), wrote UKEY2 Message 3 to endpoint(id=" + << endpoint_id_ << ")."; timeout_alarm.Cancel(); @@ -328,7 +320,7 @@ class ClientRunnable final { private: void LogException() const { LOG(ERROR) << "In StartClient(), UKEY2 failed with endpoint(id=" - << endpoint_id_ << ")."; + << endpoint_id_ << ")."; } void HandleHandshakeOrIoException(CancelableAlarm* timeout_alarm) { @@ -341,10 +333,9 @@ class ClientRunnable final { Exception write_exception = channel_->Write(ByteArray(*parse_result.alert_to_send)); if (!write_exception.Ok()) { - LOG(WARNING) - << "In StartClient(), client " << client_->GetClientId() - << " failed to pass the alert error message to endpoint(id=" - << endpoint_id_ << ")."; + LOG(WARNING) << "In StartClient(), client " << client_->GetClientId() + << " failed to pass the alert error message to endpoint(id=" + << endpoint_id_ << ")."; } } diff --git a/connections/implementation/endpoint_channel_manager_test.cc b/connections/implementation/endpoint_channel_manager_test.cc index 2f7a83cd..ce1d030f 100644 --- a/connections/implementation/endpoint_channel_manager_test.cc +++ b/connections/implementation/endpoint_channel_manager_test.cc @@ -103,7 +103,7 @@ std::function MakeDataMonitor(absl::string_view label, *capture += s; } LOG(INFO) << "source='" << label << "'" - << "; message='" << s << "'"; + << "; message='" << s << "'"; }; } @@ -243,11 +243,11 @@ TEST(BaseEndpointChannelManagerTest, RegisterChannelEncryptedReadwrite) { channel_a_raw->Close(DisconnectionReason::LOCAL_DISCONNECTION); channel_b_raw->Close(DisconnectionReason::REMOTE_DISCONNECTION); ecm_a.UnregisterChannelForEndpoint( - std::string(kEndpointId), DisconnectionReason::LOCAL_DISCONNECTION, - ConnectionsLog::EstablishedConnection::SAFE_DISCONNECTION); + std::string(kEndpointId), DisconnectionReason::LOCAL_DISCONNECTION, + ConnectionsLog::EstablishedConnection::SAFE_DISCONNECTION); ecm_b.UnregisterChannelForEndpoint( - std::string(kEndpointId), DisconnectionReason::REMOTE_DISCONNECTION, - ConnectionsLog::EstablishedConnection::SAFE_DISCONNECTION); + std::string(kEndpointId), DisconnectionReason::REMOTE_DISCONNECTION, + ConnectionsLog::EstablishedConnection::SAFE_DISCONNECTION); } TEST(BaseEndpointChannelManagerTest, ReplaceChannelNoEncrypted) { @@ -311,11 +311,12 @@ TEST(BaseEndpointChannelManagerTest, ReplaceChannelNoEncrypted) { channel_a_raw->Close(DisconnectionReason::LOCAL_DISCONNECTION); channel_b_raw->Close(DisconnectionReason::REMOTE_DISCONNECTION); ecm_a.UnregisterChannelForEndpoint( - std::string(kEndpointId), DisconnectionReason::LOCAL_DISCONNECTION, - ConnectionsLog::EstablishedConnection::SAFE_DISCONNECTION); + std::string(kEndpointId), DisconnectionReason::LOCAL_DISCONNECTION, + ConnectionsLog::EstablishedConnection::SAFE_DISCONNECTION); ecm_b.UnregisterChannelForEndpoint( - std::string(kEndpointId), DisconnectionReason::REMOTE_DISCONNECTION, - ConnectionsLog::EstablishedConnection::SAFE_DISCONNECTION);} + std::string(kEndpointId), DisconnectionReason::REMOTE_DISCONNECTION, + ConnectionsLog::EstablishedConnection::SAFE_DISCONNECTION); +} } // namespace } // namespace connections diff --git a/connections/implementation/endpoint_manager.cc b/connections/implementation/endpoint_manager.cc index 28bb6ffb..ecca6b82 100644 --- a/connections/implementation/endpoint_manager.cc +++ b/connections/implementation/endpoint_manager.cc @@ -206,7 +206,7 @@ ExceptionOr EndpointManager::TryDecryptFrame( ExceptionOr decrypted = endpoint_channel->TryDecrypt(data); if (decrypted.ok()) { VLOG(1) << "Message decrypted after " - << SystemClock::ElapsedRealtime() - start_time; + << SystemClock::ElapsedRealtime() - start_time; return parser::FromBytes(decrypted.result()); } if (decrypted.exception() == Exception::kExecution) { @@ -608,7 +608,7 @@ void EndpointManager::RegisterEndpoint( // and they will happily keep writing to /dev/null. This is why we // listen for the pong. VLOG(1) << "EndpointManager enabling KeepAlive for endpoint " - << endpoint_id; + << endpoint_id; endpoint_state.StartEndpointKeepAliveManager( [this, client, endpoint_id, keep_alive_interval, keep_alive_timeout](Mutex* keep_alive_waiter_mutex, diff --git a/connections/implementation/mediums/awdl_test.cc b/connections/implementation/mediums/awdl_test.cc index e500e906..b7e21ea6 100644 --- a/connections/implementation/mediums/awdl_test.cc +++ b/connections/implementation/mediums/awdl_test.cc @@ -93,8 +93,7 @@ TEST_P(AwdlTest, CanConnect) { .service_discovered_cb = [&discovered_latch, &discovered_service_info]( NsdServiceInfo service_info, const std::string& service_id) { - LOG(INFO) - << "Discovered service_info=" << &service_info; + LOG(INFO) << "Discovered service_info=" << &service_info; discovered_service_info = service_info; discovered_latch.CountDown(); }, @@ -146,8 +145,7 @@ TEST_P(AwdlTest, CanCancelConnect) { .service_discovered_cb = [&discovered_latch, &discovered_service_info]( NsdServiceInfo service_info, const std::string& service_id) { - LOG(INFO) - << "Discovered service_info=" << &service_info; + LOG(INFO) << "Discovered service_info=" << &service_info; discovered_service_info = service_info; discovered_latch.CountDown(); }, diff --git a/connections/implementation/mediums/ble.cc b/connections/implementation/mediums/ble.cc index 8b2012f8..50cf1e39 100644 --- a/connections/implementation/mediums/ble.cc +++ b/connections/implementation/mediums/ble.cc @@ -72,17 +72,15 @@ bool Ble::StartAdvertising(const std::string& service_id, } if (advertisement_bytes.size() > kMaxAdvertisementLength) { - LOG(INFO) - << "Refusing to start BLE advertising because the advertisement " - "was too long. Expected at most " - << kMaxAdvertisementLength << " bytes but received " - << advertisement_bytes.size(); + LOG(INFO) << "Refusing to start BLE advertising because the advertisement " + "was too long. Expected at most " + << kMaxAdvertisementLength << " bytes but received " + << advertisement_bytes.size(); return false; } if (IsAdvertisingLocked(service_id)) { - LOG(INFO) - << "Failed to BLE advertise because we're already advertising."; + LOG(INFO) << "Failed to BLE advertise because we're already advertising."; return false; } @@ -98,10 +96,10 @@ bool Ble::StartAdvertising(const std::string& service_id, } LOG(INFO) << "Turning on BLE advertising (advertisement size=" - << advertisement_bytes.size() << ")" - << ", service id=" << service_id - << ", fast advertisement service uuid=" - << absl::BytesToHexString(fast_advertisement_service_uuid); + << advertisement_bytes.size() << ")" + << ", service id=" << service_id + << ", fast advertisement service uuid=" + << absl::BytesToHexString(fast_advertisement_service_uuid); // Wrap the connections advertisement to the medium advertisement. const bool fast_advertisement = !fast_advertisement_service_uuid.empty(); @@ -114,18 +112,17 @@ bool Ble::StartAdvertising(const std::string& service_id, GenerateDeviceToken()}}; if (medium_advertisement_bytes.Empty()) { LOG(INFO) << "Failed to BLE advertise because we could not " - "create a medium advertisement."; + "create a medium advertisement."; return false; } if (!medium_.StartAdvertising(service_id, medium_advertisement_bytes, fast_advertisement_service_uuid)) { - LOG(ERROR) - << "Failed to turn on BLE advertising with advertisement bytes=" - << absl::BytesToHexString(advertisement_bytes.data()) - << ", size=" << advertisement_bytes.size() - << ", fast advertisement service uuid=" - << fast_advertisement_service_uuid; + LOG(ERROR) << "Failed to turn on BLE advertising with advertisement bytes=" + << absl::BytesToHexString(advertisement_bytes.data()) + << ", size=" << advertisement_bytes.size() + << ", fast advertisement service uuid=" + << fast_advertisement_service_uuid; return false; } @@ -141,8 +138,7 @@ bool Ble::StopAdvertising(const std::string& service_id) { return false; } - LOG(INFO) << "Turned off BLE advertising with service id=" - << service_id; + LOG(INFO) << "Turned off BLE advertising with service id=" << service_id; bool ret = medium_.StopAdvertising(service_id); // Reset our bundle of advertising state to mark that we're no longer // advertising. @@ -154,7 +150,7 @@ bool Ble::StartLegacyAdvertising( const std::string& input_service_id, const std::string& local_endpoint_id, const std::string& fast_advertisement_service_uuid) { LOG(INFO) << "StartLegacyAdvertising: " << input_service_id - << ", local_endpoint_id: " << local_endpoint_id; + << ", local_endpoint_id: " << local_endpoint_id; MutexLock lock(&mutex_); std::string service_id = input_service_id + "-Legacy"; @@ -166,13 +162,12 @@ bool Ble::StartLegacyAdvertising( if (!radio_.IsEnabled()) { LOG(INFO) << "Can't start BLE legacy advertising because Bluetooth " - "was never turned on"; + "was never turned on"; return false; } if (!IsAvailableLocked()) { - LOG(INFO) - << "Can't turn on BLE legacy advertising. BLE is not available."; + LOG(INFO) << "Can't turn on BLE legacy advertising. BLE is not available."; return false; } // TODO(hais) improve working dummy set to feed proper hash value. @@ -182,20 +177,19 @@ bool Ble::StartLegacyAdvertising( ByteArray encoded_bytes{encoded_legacy_char_array}; LOG(INFO) << "Turning on BLE advertising (advertisement size=" - << encoded_bytes.size() - << "): " << absl::BytesToHexString(encoded_bytes.data()) - << ", service id=" << service_id - << ", fast advertisement service uuid=" - << fast_advertisement_service_uuid; + << encoded_bytes.size() + << "): " << absl::BytesToHexString(encoded_bytes.data()) + << ", service id=" << service_id + << ", fast advertisement service uuid=" + << fast_advertisement_service_uuid; if (!medium_.StartAdvertising(service_id, encoded_bytes, fast_advertisement_service_uuid)) { - LOG(ERROR) - << "Failed to turn on BLE advertising with advertisement bytes=" - << absl::BytesToHexString(encoded_bytes.data()) - << ", size=" << encoded_bytes.size() - << ", fast advertisement service uuid=" - << fast_advertisement_service_uuid; + LOG(ERROR) << "Failed to turn on BLE advertising with advertisement bytes=" + << absl::BytesToHexString(encoded_bytes.data()) + << ", size=" << encoded_bytes.size() + << ", fast advertisement service uuid=" + << fast_advertisement_service_uuid; return false; } @@ -209,13 +203,12 @@ bool Ble::StopLegacyAdvertising(const std::string& input_service_id) { std::string service_id = input_service_id + "-Legacy"; if (!IsAdvertisingLocked(service_id)) { - LOG(INFO) - << "Can't turn off BLE legacy advertising; it is already off"; + LOG(INFO) << "Can't turn off BLE legacy advertising; it is already off"; return false; } LOG(INFO) << "Turned off BLE legacy advertising with service id=" - << service_id; + << service_id; bool ret = medium_.StopAdvertising(service_id); // Reset our bundle of advertising state to mark that we're no longer // advertising. @@ -241,14 +234,13 @@ bool Ble::StartScanning(const std::string& service_id, discovered_peripheral_callback_ = std::move(callback); if (service_id.empty()) { - LOG(INFO) - << "Refusing to start BLE scanning with empty service id."; + LOG(INFO) << "Refusing to start BLE scanning with empty service id."; return false; } if (IsScanningLocked(service_id)) { LOG(INFO) << "Refusing to start scan of BLE peripherals because " - "another scanning is already in-progress."; + "another scanning is already in-progress."; return false; } @@ -259,8 +251,7 @@ bool Ble::StartScanning(const std::string& service_id, } if (!IsAvailableLocked()) { - LOG(INFO) - << "Can't scan BLE peripherals because BLE isn't available."; + LOG(INFO) << "Can't scan BLE peripherals because BLE isn't available."; return false; } @@ -275,7 +266,7 @@ bool Ble::StartScanning(const std::string& service_id, // Don't bother trying to parse zero byte advertisements. if (medium_advertisement_bytes.size() == 0) { LOG(INFO) << "Skipping zero byte advertisement " - << "with service_id: " << service_id; + << "with service_id: " << service_id; return; } // Unwrap connection BleAdvertisement from medium @@ -308,7 +299,7 @@ bool Ble::StopScanning(const std::string& service_id) { if (!IsScanningLocked(service_id)) { LOG(INFO) << "Can't turn off BLE scanning because we never " - "started scanning."; + "started scanning."; return false; } @@ -346,20 +337,20 @@ bool Ble::StartAcceptingConnections(const std::string& service_id, } if (!radio_.IsEnabled()) { - LOG(INFO) << "Can't start accepting BLE connections for " - << service_id << " because Bluetooth isn't enabled."; + LOG(INFO) << "Can't start accepting BLE connections for " << service_id + << " because Bluetooth isn't enabled."; return false; } if (!IsAvailableLocked()) { - LOG(INFO) << "Can't start accepting BLE connections for " - << service_id << " because BLE isn't available."; + LOG(INFO) << "Can't start accepting BLE connections for " << service_id + << " because BLE isn't available."; return false; } if (!medium_.StartAcceptingConnections(service_id, std::move(callback))) { - LOG(INFO) << "Failed to accept connections callback for " - << service_id << " ."; + LOG(INFO) << "Failed to accept connections callback for " << service_id + << " ."; return false; } @@ -408,13 +399,13 @@ ErrorOr Ble::Connect(BlePeripheral& peripheral, if (!radio_.IsEnabled()) { LOG(INFO) << "Can't create client BLE socket to " << &peripheral - << " because Bluetooth isn't enabled."; + << " because Bluetooth isn't enabled."; return {Error(OperationResultCode::MISCELLEANEOUS_BLE_SYSTEM_SERVICE_NULL)}; } if (!IsAvailableLocked()) { - LOG(INFO) << "Can't create client BLE socket [service_id=" - << service_id << "]; BLE isn't available."; + LOG(INFO) << "Can't create client BLE socket [service_id=" << service_id + << "]; BLE isn't available."; return {Error(OperationResultCode::MEDIUM_UNAVAILABLE_BLE_NOT_AVAILABLE)}; } @@ -426,8 +417,7 @@ ErrorOr Ble::Connect(BlePeripheral& peripheral, socket = medium_.Connect(peripheral, service_id, cancellation_flag); if (!socket.IsValid()) { - LOG(INFO) << "Failed to Connect via BLE [service=" << service_id - << "]"; + LOG(INFO) << "Failed to Connect via BLE [service=" << service_id << "]"; } return socket; diff --git a/connections/implementation/mediums/ble_test.cc b/connections/implementation/mediums/ble_test.cc index beaf00e7..0dfd8712 100644 --- a/connections/implementation/mediums/ble_test.cc +++ b/connections/implementation/mediums/ble_test.cc @@ -88,10 +88,9 @@ TEST_P(BleTest, CanStartAcceptingConnectionsAndConnect) { BlePeripheral& peripheral, const std::string& service_id, const ByteArray& advertisement_bytes, bool fast_advertisement) { - LOG(INFO) - << "Discovered peripheral=" << peripheral.GetName() - << ", impl=" << &peripheral.GetImpl() - << ", fast advertisement=" << fast_advertisement; + LOG(INFO) << "Discovered peripheral=" << peripheral.GetName() + << ", impl=" << &peripheral.GetImpl() + << ", fast advertisement=" << fast_advertisement; atomic_discovered_peripheral.store(peripheral); found_latch.CountDown(); }, @@ -141,10 +140,9 @@ TEST_P(BleTest, CanCancelConnect) { BlePeripheral& peripheral, const std::string& service_id, const ByteArray& advertisement_bytes, bool fast_advertisement) { - LOG(INFO) - << "Discovered peripheral=" << peripheral.GetName() - << ", impl=" << &peripheral.GetImpl() - << ", fast advertisement=" << fast_advertisement; + LOG(INFO) << "Discovered peripheral=" << peripheral.GetName() + << ", impl=" << &peripheral.GetImpl() + << ", fast advertisement=" << fast_advertisement; atomic_discovered_peripheral.store(peripheral); found_latch.CountDown(); }, diff --git a/connections/implementation/mediums/ble_v2/ble_advertisement_header.cc b/connections/implementation/mediums/ble_v2/ble_advertisement_header.cc index 2558292e..bfb904bd 100644 --- a/connections/implementation/mediums/ble_v2/ble_advertisement_header.cc +++ b/connections/implementation/mediums/ble_v2/ble_advertisement_header.cc @@ -69,7 +69,7 @@ BleAdvertisementHeader::BleAdvertisementHeader( advertisement_header_bytes = ble_advertisement_header_bytes; } else { VLOG(1) << "Cannot deserialize BLEAdvertisementHeader. " - "Invalid advertising data."; + "Invalid advertising data."; return; } } else { diff --git a/connections/implementation/mediums/ble_v2/bloom_filter.cc b/connections/implementation/mediums/ble_v2/bloom_filter.cc index 67ef78f6..e389029e 100644 --- a/connections/implementation/mediums/ble_v2/bloom_filter.cc +++ b/connections/implementation/mediums/ble_v2/bloom_filter.cc @@ -39,8 +39,8 @@ BloomFilter::BloomFilter(std::unique_ptr bit_set, // If the size is not matched, fall out. if (bytes.size() * 8 != bit_set_->Size()) { LOG(INFO) << "Cannot construct from bytes since the size is not " - "matched. bytes.size(x8) = " - << bytes.size() << ", bit_set.size=" << bit_set_->Size(); + "matched. bytes.size(x8) = " + << bytes.size() << ", bit_set.size=" << bit_set_->Size(); return; } for (size_t byte_index = 0; byte_index < bytes.size(); byte_index++) { diff --git a/connections/implementation/mediums/ble_v2/instant_on_lost_advertisement.cc b/connections/implementation/mediums/ble_v2/instant_on_lost_advertisement.cc index 160bdebe..43b147f4 100644 --- a/connections/implementation/mediums/ble_v2/instant_on_lost_advertisement.cc +++ b/connections/implementation/mediums/ble_v2/instant_on_lost_advertisement.cc @@ -64,9 +64,9 @@ InstantOnLostAdvertisement::CreateFromHashes( std::string InstantOnLostAdvertisement::ToBytes() const { if (hashes_.empty() || hashes_.size() > kMaxHashCount) { LOG(ERROR) << __func__ - << ": Failed to convert hashes due to hash " - "size is not valid, size = " - << hashes_.size(); + << ": Failed to convert hashes due to hash " + "size is not valid, size = " + << hashes_.size(); return ""; } @@ -80,9 +80,9 @@ std::string InstantOnLostAdvertisement::ToBytes() const { for (const auto& hash : hashes_) { if (hash.length() != kAdvertisementHashLength) { LOG(ERROR) << __func__ - << ": Failed to convert hashes to advertisement due " - "to invalid hash : " - << absl::BytesToHexString(hash); + << ": Failed to convert hashes to advertisement due " + "to invalid hash : " + << absl::BytesToHexString(hash); return ""; } absl::StrAppend(&result, hash); diff --git a/connections/implementation/mediums/ble_v2_test.cc b/connections/implementation/mediums/ble_v2_test.cc index e5c3809d..2372023d 100644 --- a/connections/implementation/mediums/ble_v2_test.cc +++ b/connections/implementation/mediums/ble_v2_test.cc @@ -112,9 +112,8 @@ TEST_P(BleV2Test, CanConnect) { const ByteArray& advertisement_bytes, bool fast_advertisement) { discovered_peripheral = peripheral; - LOG(INFO) - << "Discovered peripheral, fast advertisement=" - << fast_advertisement; + LOG(INFO) << "Discovered peripheral, fast advertisement=" + << fast_advertisement; discovered_latch.CountDown(); }, }); @@ -172,9 +171,8 @@ TEST_P(BleV2Test, CanCancelConnect) { const ByteArray& advertisement_bytes, bool fast_advertisement) { discovered_peripheral = peripheral; - LOG(INFO) - << "Discovered peripheral, fast advertisement=" - << fast_advertisement; + LOG(INFO) << "Discovered peripheral, fast advertisement=" + << fast_advertisement; discovered_latch.CountDown(); }, }); diff --git a/connections/implementation/mediums/bluetooth_classic_test.cc b/connections/implementation/mediums/bluetooth_classic_test.cc index a2b0defb..8cf61969 100644 --- a/connections/implementation/mediums/bluetooth_classic_test.cc +++ b/connections/implementation/mediums/bluetooth_classic_test.cc @@ -269,7 +269,7 @@ TEST_P(BluetoothClassicTest, CanConnect) { [&latch, &discovered_device](BluetoothDevice& device) { discovered_device = device; LOG(INFO) << "Discovered device=" << device.GetName() - << ", impl=" << &device.GetImpl(); + << ", impl=" << &device.GetImpl(); latch.CountDown(); }, })); @@ -319,7 +319,7 @@ TEST_P(BluetoothClassicTest, CanCancelBeforeConnect) { .device_discovered_cb = [&latch, &discovered_device](BluetoothDevice& device) { LOG(INFO) << "Discovered device=" << device.GetName() - << ", impl=" << &device.GetImpl(); + << ", impl=" << &device.GetImpl(); discovered_device = device; latch.CountDown(); }, @@ -387,7 +387,7 @@ TEST_P(BluetoothClassicTest, CanCancelDuringConnect) { [&latch, &discovered_device](BluetoothDevice& device) { discovered_device = device; LOG(INFO) << "Discovered device=" << device.GetName() - << ", impl=" << &device.GetImpl(); + << ", impl=" << &device.GetImpl(); latch.CountDown(); }, })); @@ -453,7 +453,7 @@ TEST_P(BluetoothClassicTest, CanCancelDuringConnect_MultipleEndpoints) { [&latch, &discovered_device](BluetoothDevice& device) { discovered_device = device; LOG(INFO) << "Discovered device=" << device.GetName() - << ", impl=" << &device.GetImpl(); + << ", impl=" << &device.GetImpl(); latch.CountDown(); }, })); @@ -599,21 +599,21 @@ TEST_F(BluetoothClassicTest, CanDiscoverDeviceChanges) { [&discovered_latch, &discovered_device](BluetoothDevice& device) { discovered_device = device; LOG(INFO) << "Discovered device=" << device.GetName() - << ", impl=" << &device.GetImpl(); + << ", impl=" << &device.GetImpl(); discovered_latch.CountDown(); }, .device_name_changed_cb = [&rename_latch, &discovered_device](BluetoothDevice& device) { discovered_device = device; LOG(INFO) << "Rename device=" << device.GetName() - << ", impl=" << &device.GetImpl(); + << ", impl=" << &device.GetImpl(); rename_latch.CountDown(); }, .device_lost_cb = [&lost_latch, &discovered_device](BluetoothDevice& device) { discovered_device = device; LOG(INFO) << "Lost device=" << device.GetName() - << ", impl=" << &device.GetImpl(); + << ", impl=" << &device.GetImpl(); lost_latch.CountDown(); }, })); @@ -645,7 +645,7 @@ TEST_F(BluetoothClassicTest, CanStartAcceptingConnections) { [&latch, &discovered_device](BluetoothDevice& device) { discovered_device = device; LOG(INFO) << "Discovered device=" << device.GetName() - << ",impl=" << &device.GetImpl(); + << ",impl=" << &device.GetImpl(); latch.CountDown(); }, })); diff --git a/connections/implementation/mediums/multiplex/multiplex_frames.cc b/connections/implementation/mediums/multiplex/multiplex_frames.cc index 60fd8b27..7e70cc52 100644 --- a/connections/implementation/mediums/multiplex/multiplex_frames.cc +++ b/connections/implementation/mediums/multiplex/multiplex_frames.cc @@ -23,15 +23,14 @@ #include "internal/platform/exception.h" #include "internal/platform/logging.h" - namespace nearby { namespace connections { namespace mediums { namespace multiplex { -using ::location::nearby::mediums::MultiplexFrame; -using ::location::nearby::mediums::MultiplexControlFrame; using ::location::nearby::mediums::ConnectionResponseFrame; +using ::location::nearby::mediums::MultiplexControlFrame; +using ::location::nearby::mediums::MultiplexFrame; ByteArray GenerateServiceIdHash(const std::string& service_id) { return Utils::Sha256Hash(service_id, kServiceIdHashLength); @@ -115,8 +114,7 @@ ByteArray ForDisconnection(const std::string& service_id, header->set_service_id_hash_salt(service_id_hash_salt); auto* control_frame = frame.mutable_control_frame(); - control_frame->set_control_frame_type( - MultiplexControlFrame::DISCONNECTION); + control_frame->set_control_frame_type(MultiplexControlFrame::DISCONNECTION); return ToBytes(std::move(frame)); } @@ -140,7 +138,7 @@ ByteArray ForData(const std::string& service_id, return ToBytes(std::move(frame)); } -ExceptionOr FromBytes(const ByteArray& multiplex_frame_bytes){ +ExceptionOr FromBytes(const ByteArray& multiplex_frame_bytes) { MultiplexFrame frame; if (frame.ParseFromString(std::string(multiplex_frame_bytes))) { @@ -173,24 +171,24 @@ bool IsValid(const MultiplexFrame& frame) { } bool IsValidControlFrame(const MultiplexFrame& frame) { - if (!frame.has_control_frame()) { - return false; - } - - switch (frame.control_frame().control_frame_type()) { - case MultiplexControlFrame::CONNECTION_REQUEST: - case MultiplexControlFrame::CONNECTION_RESPONSE: - case MultiplexControlFrame::DISCONNECTION: - if (frame.header().salted_service_id_hash().size() == - kServiceIdHashLength) { - return true; - } - break; - default: - break; - } - + if (!frame.has_control_frame()) { return false; + } + + switch (frame.control_frame().control_frame_type()) { + case MultiplexControlFrame::CONNECTION_REQUEST: + case MultiplexControlFrame::CONNECTION_RESPONSE: + case MultiplexControlFrame::DISCONNECTION: + if (frame.header().salted_service_id_hash().size() == + kServiceIdHashLength) { + return true; + } + break; + default: + break; + } + + return false; } bool IsValidDataFrame(const MultiplexFrame& frame) { @@ -204,8 +202,8 @@ bool IsMultiplexFrame(const ByteArray& data) { return false; } else { LOG(INFO) << "Checked data is a multiplex frame. Is Control ? " - << frame.result().has_control_frame() << ", is data ? " - << frame.result().has_data_frame(); + << frame.result().has_control_frame() << ", is data ? " + << frame.result().has_data_frame(); return true; } } diff --git a/connections/implementation/mediums/multiplex/multiplex_output_stream.cc b/connections/implementation/mediums/multiplex/multiplex_output_stream.cc index f8e0e87c..20957ded 100644 --- a/connections/implementation/mediums/multiplex/multiplex_output_stream.cc +++ b/connections/implementation/mediums/multiplex/multiplex_output_stream.cc @@ -63,16 +63,14 @@ Exception MultiplexOutputStream::WaitForResult(const std::string& method_name, .mediums_frame_write_timeout_millis); if (!result.ok()) { LOG(INFO) << "Future:[" << method_name - << "] completed with exception:" << result.exception(); + << "] completed with exception:" << result.exception(); return {Exception::kFailed}; } if (result.result()) { - LOG(INFO) << "Future:[" << method_name - << "] completed with success."; + LOG(INFO) << "Future:[" << method_name << "] completed with success."; return {Exception::kSuccess}; } - LOG(INFO) << "Future:[" << method_name - << "] completed with failure."; + LOG(INFO) << "Future:[" << method_name << "] completed with failure."; return {Exception::kFailed}; } @@ -111,8 +109,8 @@ bool MultiplexOutputStream::WriteConnectionResponseFrame( bool MultiplexOutputStream::Close(const std::string& service_id) { auto item = virtual_output_streams_.find(service_id); if (item == virtual_output_streams_.end()) { - LOG(INFO) << "Don't need to close VirtualOutputStream(" - << service_id << ") because it's already gone."; + LOG(INFO) << "Don't need to close VirtualOutputStream(" << service_id + << ") because it's already gone."; return false; } @@ -230,8 +228,7 @@ void MultiplexOutputStream::MultiplexWriter::StartWriting() { LOG(INFO) << "Waiting for data_queue_ has data."; Exception wait_succeeded = is_writing_cond_.Wait(); if (!wait_succeeded.Ok()) { - LOG(WARNING) - << "Failure waiting to wait: " << wait_succeeded.value; + LOG(WARNING) << "Failure waiting to wait: " << wait_succeeded.value; return; } } @@ -306,9 +303,8 @@ MultiplexOutputStream::VirtualOutputStream::VirtualOutputStream( Exception MultiplexOutputStream::VirtualOutputStream::Write( const ByteArray& data) { if (is_closed_.Get()) { - LOG(WARNING) - << "Failed to write data because the VirtualOutputStream for " - << service_id_ << " closed"; + LOG(WARNING) << "Failed to write data because the VirtualOutputStream for " + << service_id_ << " closed"; return {Exception::kIo}; } if (multiplex_output_stream_.is_enabled_.Get()) { @@ -327,7 +323,7 @@ Exception MultiplexOutputStream::VirtualOutputStream::Write( if ((service_id_hash_salt_ == kFakeSalt) && !should_pass_salt) { should_pass_salt = true; LOG(INFO) << "service_idHashSalt is still a fake one and " - "not changed yet; continue to pass salt."; + "not changed yet; continue to pass salt."; } } ByteArray data_frame = diff --git a/connections/implementation/mediums/multiplex/multiplex_output_stream_test.cc b/connections/implementation/mediums/multiplex/multiplex_output_stream_test.cc index ab75a37c..96f54ddd 100644 --- a/connections/implementation/mediums/multiplex/multiplex_output_stream_test.cc +++ b/connections/implementation/mediums/multiplex/multiplex_output_stream_test.cc @@ -75,8 +75,8 @@ class MultiplexOutputStreamTest : public ::testing::Test { }; TEST_F(MultiplexOutputStreamTest, SendConnectionRequestFrame) { - multiplex_output_stream_ = std::make_unique( - writer_.get(), enabled_); + multiplex_output_stream_ = + std::make_unique(writer_.get(), enabled_); EXPECT_TRUE(multiplex_output_stream_->WriteConnectionRequestFrame( std::string(kServiceId_1), std::string(kNoSalt))); @@ -94,8 +94,8 @@ TEST_F(MultiplexOutputStreamTest, SendConnectionRequestFrame) { TEST_F(MultiplexOutputStreamTest, SendConnectionRequestFrameDisabled) { enabled_.Set(false); - multiplex_output_stream_ = std::make_unique( - writer_.get(), enabled_); + multiplex_output_stream_ = + std::make_unique(writer_.get(), enabled_); EXPECT_FALSE(multiplex_output_stream_->WriteConnectionRequestFrame( std::string(kServiceId_1), std::string(kNoSalt))); @@ -103,8 +103,8 @@ TEST_F(MultiplexOutputStreamTest, SendConnectionRequestFrameDisabled) { } TEST_F(MultiplexOutputStreamTest, SendConnectionResponseFrame) { - multiplex_output_stream_ = std::make_unique( - writer_.get(), enabled_); + multiplex_output_stream_ = + std::make_unique(writer_.get(), enabled_); EXPECT_TRUE(multiplex_output_stream_->WriteConnectionResponseFrame( GenerateServiceIdHash(std::string(kServiceId_1)), std::string(kNoSalt), ConnectionResponseFrame::CONNECTION_ACCEPTED)); @@ -127,8 +127,8 @@ TEST_F(MultiplexOutputStreamTest, SendConnectionResponseFrame) { TEST_F(MultiplexOutputStreamTest, SendConnectionResponseFrameDisabled) { enabled_.Set(false); - multiplex_output_stream_ = std::make_unique( - writer_.get(), enabled_); + multiplex_output_stream_ = + std::make_unique(writer_.get(), enabled_); EXPECT_FALSE(multiplex_output_stream_->WriteConnectionResponseFrame( GenerateServiceIdHash(std::string(kServiceId_1)), std::string(kNoSalt), ConnectionResponseFrame::CONNECTION_ACCEPTED)); @@ -137,16 +137,16 @@ TEST_F(MultiplexOutputStreamTest, SendConnectionResponseFrameDisabled) { } TEST_F(MultiplexOutputStreamTest, CloseVirtualStreamFailed) { - multiplex_output_stream_ = std::make_unique( - writer_.get(), enabled_); + multiplex_output_stream_ = + std::make_unique(writer_.get(), enabled_); EXPECT_FALSE(multiplex_output_stream_->Close(std::string(kServiceId_1))); multiplex_output_stream_->Shutdown(); } TEST_F(MultiplexOutputStreamTest, CloseVirtualStreamSuccess) { - multiplex_output_stream_ = std::make_unique( - writer_.get(), enabled_); + multiplex_output_stream_ = + std::make_unique(writer_.get(), enabled_); EXPECT_FALSE(multiplex_output_stream_->Close(std::string(kServiceId_1))); multiplex_output_stream_->CreateVirtualOutputStream(std::string(kServiceId_1), @@ -166,8 +166,8 @@ TEST_F(MultiplexOutputStreamTest, CloseVirtualStreamSuccess) { } TEST_F(MultiplexOutputStreamTest, CreateVirtualStream_SendData) { - multiplex_output_stream_ = std::make_unique( - writer_.get(), enabled_); + multiplex_output_stream_ = + std::make_unique(writer_.get(), enabled_); auto virtual_output_stream = multiplex_output_stream_->CreateVirtualOutputStream( @@ -189,8 +189,8 @@ TEST_F(MultiplexOutputStreamTest, CreateVirtualStream_SendData) { } TEST_F(MultiplexOutputStreamTest, CreateTwoVirtualStreams_SendData) { - multiplex_output_stream_ = std::make_unique( - writer_.get(), enabled_); + multiplex_output_stream_ = + std::make_unique(writer_.get(), enabled_); auto virtual_output_stream_1 = multiplex_output_stream_->CreateVirtualOutputStreamForFirstVirtualSocket( @@ -222,14 +222,14 @@ TEST_F(MultiplexOutputStreamTest, CreateTwoVirtualStreams_SendData) { EXPECT_EQ(frame.frame_type(), MultiplexFrame::DATA_FRAME); bool first_frame_is_data_1 = true; if (frame.header().salted_service_id_hash() == - std::string(GenerateServiceIdHashWithSalt(std::string(kServiceId_1), - std::string(kSalt_1)))) { + std::string(GenerateServiceIdHashWithSalt(std::string(kServiceId_1), + std::string(kSalt_1)))) { EXPECT_EQ(frame.data_frame().data(), std::string(data_1)); LOG(INFO) << "Read first virtual stream frame first."; } else { EXPECT_EQ(frame.header().salted_service_id_hash(), - std::string(GenerateServiceIdHashWithSalt(std::string(kServiceId_2), - std::string(kSalt_2)))); + std::string(GenerateServiceIdHashWithSalt( + std::string(kServiceId_2), std::string(kSalt_2)))); EXPECT_EQ(frame.data_frame().data(), std::string(data_2)); first_frame_is_data_1 = false; LOG(INFO) << "Read second virtual stream frame first."; diff --git a/connections/implementation/mediums/multiplex/multiplex_socket.cc b/connections/implementation/mediums/multiplex/multiplex_socket.cc index 40928e62..7b82eabb 100644 --- a/connections/implementation/mediums/multiplex/multiplex_socket.cc +++ b/connections/implementation/mediums/multiplex/multiplex_socket.cc @@ -69,7 +69,7 @@ using ConnectionResponseCode = ConnectionResponseFrame::ConnectionResponseCode; // AtomicBoolean is trivial destructible, so it is safe to use it as a static // variable. -AtomicBoolean MultiplexSocket::is_shutting_down_{false}; // NOLINT +AtomicBoolean MultiplexSocket::is_shutting_down_{false}; // NOLINT void MultiplexSocket::ListenForIncomingConnection( const std::string& service_id, Medium type, @@ -131,14 +131,14 @@ MultiplexSocket* MultiplexSocket::CreateIncomingSocket( new (&storage_wlan) MultiplexSocket(physical_socket); break; default: - LOG(ERROR) << __func__ << "Unsupported medium: " - << physical_socket->GetMedium(); + LOG(ERROR) << __func__ + << "Unsupported medium: " << physical_socket->GetMedium(); multiplex_incoming_socket = nullptr; return multiplex_incoming_socket; } LOG(INFO) << "CreateIncomingSocket with serviceId=" << service_id - << ", serviceIdHashSalt=" << kFakeSalt << " for medium=" - << Medium_Name(physical_socket->GetMedium()); + << ", serviceIdHashSalt=" << kFakeSalt + << " for medium=" << Medium_Name(physical_socket->GetMedium()); multiplex_incoming_socket->CreateFirstVirtualSocket(service_id, (std::string)kFakeSalt); @@ -175,14 +175,13 @@ MultiplexSocket* MultiplexSocket::CreateOutgoingSocket( new (&storage_wlan) MultiplexSocket(physical_socket); break; default: - LOG(ERROR) << __func__ << "Unsupported medium: " - << physical_socket->GetMedium(); + LOG(ERROR) << __func__ + << "Unsupported medium: " << physical_socket->GetMedium(); return multiplex_outgoing_socket; } LOG(INFO) << "CreateOutgoingSocket with serviceId=" << service_id - << ", serviceIdHashSalt=" << service_id_hash_salt - << " for medium=" - << Medium_Name(physical_socket->GetMedium()); + << ", serviceIdHashSalt=" << service_id_hash_salt + << " for medium=" << Medium_Name(physical_socket->GetMedium()); multiplex_outgoing_socket->CreateFirstVirtualSocket(service_id, service_id_hash_salt); @@ -207,9 +206,8 @@ MediumSocket* MultiplexSocket::CreateFirstVirtualSocket( std::string salted_service_id_hash_key = GenerateServiceIdHashKeyWithSalt(service_id, service_id_hash_salt); LOG(INFO) << __func__ << " for service_id=" << service_id - << ", salt=" << service_id_hash_salt - << ", salted_service_id_hash_key=" - << salted_service_id_hash_key; + << ", salt=" << service_id_hash_salt + << ", salted_service_id_hash_key=" << salted_service_id_hash_key; MediumSocket* virtual_socket = physical_socket_ptr_->CreateVirtualSocket( salted_service_id_hash_key, output_stream, medium_, &virtual_sockets_); @@ -234,9 +232,8 @@ MediumSocket* MultiplexSocket::CreateVirtualSocket( GenerateServiceIdHashKeyWithSalt(service_id, service_id_hash_salt); LOG(INFO) << __func__ << "service_id=" << service_id - << ", salt=" << service_id_hash_salt - << ", salted_service_id_hash_key=" - << salted_service_id_hash_key; + << ", salt=" << service_id_hash_salt + << ", salted_service_id_hash_key=" << salted_service_id_hash_key; MediumSocket* virtual_socket = physical_socket_ptr_->CreateVirtualSocket( salted_service_id_hash_key, output_stream, medium_, &virtual_sockets_); @@ -251,8 +248,8 @@ MediumSocket* MultiplexSocket::CreateVirtualSocket( MediumSocket* MultiplexSocket::GetVirtualSocket(const std::string& service_id) { MutexLock lock(&virtual_socket_mutex_); LOG(INFO) << __func__ << " service_id=" << service_id << ", Salt=" - << multiplex_output_stream_.GetServiceIdHashSalt(service_id) - << ", virtual_sockets_.size()=" << virtual_sockets_.size(); + << multiplex_output_stream_.GetServiceIdHashSalt(service_id) + << ", virtual_sockets_.size()=" << virtual_sockets_.size(); auto item = virtual_sockets_.find(GenerateServiceIdHashKeyWithSalt( service_id, multiplex_output_stream_.GetServiceIdHashSalt(service_id))); if (item == virtual_sockets_.end()) { @@ -269,11 +266,10 @@ int MultiplexSocket::GetVirtualSocketCount() { void MultiplexSocket::ListVirtualSocket() { LOG(INFO) << __func__ - << " virtual_sockets_.size()=" << virtual_sockets_.size(); + << " virtual_sockets_.size()=" << virtual_sockets_.size(); for (auto& [service_id_hash_key, virtual_socket] : virtual_sockets_) { - LOG(INFO) << __func__ - << " service_id_hash_key=" << service_id_hash_key - << ", virtual_socket=" << virtual_socket; + LOG(INFO) << __func__ << " service_id_hash_key=" << service_id_hash_key + << ", virtual_socket=" << virtual_socket; } } @@ -309,8 +305,8 @@ MediumSocket* MultiplexSocket::EstablishVirtualSocket( .multiplex_socket_connection_response_timeout_millis); if (!result.ok()) { LOG(ERROR) << __func__ - << "EstablishVirtualSocket failed with response code=" - << result.exception(); + << "EstablishVirtualSocket failed with response code=" + << result.exception(); return nullptr; } @@ -318,21 +314,21 @@ MediumSocket* MultiplexSocket::EstablishVirtualSocket( switch (response_code) { case ConnectionResponseFrame::CONNECTION_ACCEPTED: LOG(INFO) << "EstablishVirtualSocket after remote response to" - " accept the connection with service_id=" - << service_id - << ", service_id_hash_salt=" << service_id_hash_salt; + " accept the connection with service_id=" + << service_id + << ", service_id_hash_salt=" << service_id_hash_salt; return CreateVirtualSocket(service_id, service_id_hash_salt); case ConnectionResponseFrame::NOT_LISTENING: LOG(ERROR) << "EstablishVirtualSocket failed for service_id=" - << service_id - << ", service_id_hash_salt=" << service_id_hash_salt - << " with response code=NOT_LISTENING"; + << service_id + << ", service_id_hash_salt=" << service_id_hash_salt + << " with response code=NOT_LISTENING"; break; default: LOG(ERROR) << "EstablishVirtualSocket failed for service_id=" - << service_id - << ", service_id_hash_salt=" << service_id_hash_salt - << " with response code=UNKNOWN_RESPONSE_CODE"; + << service_id + << ", service_id_hash_salt=" << service_id_hash_salt + << " with response code=UNKNOWN_RESPONSE_CODE"; break; } return nullptr; @@ -341,7 +337,7 @@ MediumSocket* MultiplexSocket::EstablishVirtualSocket( void MultiplexSocket::StartReaderThread(std::int32_t first_frame_len) { if (is_shutdown_) { LOG(WARNING) << "Stop to start reader thread since socket is " - "shutdown."; + "shutdown."; return; } reader_thread_shutdown_barrier_ = std::make_unique(1); @@ -359,8 +355,8 @@ void MultiplexSocket::StartReaderThread(std::int32_t first_frame_len) { read_int = Base64Utils::ReadInt(physical_reader_); } if (!read_int.ok()) { - LOG(WARNING) - << __func__ << "Failed to read. Exception:" << read_int.exception(); + LOG(WARNING) << __func__ + << "Failed to read. Exception:" << read_int.exception(); fail = true; } else { auto length = read_int.result(); @@ -371,16 +367,16 @@ void MultiplexSocket::StartReaderThread(std::int32_t first_frame_len) { .connection_max_frame_length) { // Ignore the failure because not only one client use this // connection. - LOG(WARNING) - << __func__ << "Failed to read because received a invalid length " - << length << ", but continue to read."; + LOG(WARNING) << __func__ + << "Failed to read because received a invalid length " + << length << ", but continue to read."; continue; } bytes = physical_reader_->ReadExactly(length); if (!bytes.ok()) { - LOG(WARNING) - << __func__ << "Read data exception:" << bytes.exception(); + LOG(WARNING) << __func__ + << "Read data exception:" << bytes.exception(); fail = true; } } @@ -402,10 +398,9 @@ void MultiplexSocket::StartReaderThread(std::int32_t first_frame_len) { // the remote, it means that the remote and the local both // support multiplex as well. So it is safe to just turn on // the feature at this point. - LOG(INFO) - << __func__ - << " Received a multiplex frame while not enabled, enable " - "multiplex."; + LOG(INFO) << __func__ + << " Received a multiplex frame while not enabled, enable " + "multiplex."; Enable(); } const auto& frame = frame_exc.result(); @@ -425,9 +420,9 @@ void MultiplexSocket::StartReaderThread(std::int32_t first_frame_len) { frame.data_frame()); break; default: - LOG(WARNING) - << __func__ << " Received MultiplexFrame with unknown frame type " - << frame.frame_type(); + LOG(WARNING) << __func__ + << " Received MultiplexFrame with unknown frame type " + << frame.frame_type(); } } }); @@ -435,8 +430,7 @@ void MultiplexSocket::StartReaderThread(std::int32_t first_frame_len) { void MultiplexSocket::HandleOfflineFrame(const ByteArray& bytes) { MutexLock lock(&virtual_socket_mutex_); - LOG(INFO) << __func__ - << " Virtual_socket num:" << virtual_sockets_.size(); + LOG(INFO) << __func__ << " Virtual_socket num:" << virtual_sockets_.size(); if (virtual_sockets_.size() == 1) { auto item = virtual_sockets_.begin(); if (item->second == nullptr) { @@ -461,12 +455,12 @@ void MultiplexSocket::HandleControlFrame( }); break; case MultiplexControlFrame::CONNECTION_RESPONSE: - LOG(INFO) - << __func__ << "Received an CONNECTION_RESPONSE frame." - << " salted_service_id_hash: " << std::string(salted_service_id_hash) - << ", service_id_hash_salt: " << service_id_hash_salt - << ", ConnectionResponseCode: " - << frame.connection_response_frame().connection_response_code(); + LOG(INFO) << __func__ << "Received an CONNECTION_RESPONSE frame." + << " salted_service_id_hash: " + << std::string(salted_service_id_hash) + << ", service_id_hash_salt: " << service_id_hash_salt + << ", ConnectionResponseCode: " + << frame.connection_response_frame().connection_response_code(); RunOffloadThread("CONNECTION_RESPONSE", [this, salted_service_id_hash, service_id_hash_salt, @@ -482,7 +476,7 @@ void MultiplexSocket::HandleControlFrame( break; default: LOG(WARNING) << __func__ << "Received an unknown frame type " - << frame.control_frame_type(); + << frame.control_frame_type(); break; } } @@ -492,8 +486,8 @@ void MultiplexSocket::HandleConnectionRequest( const std::string& service_id_hash_salt) { if (!IsEnabled()) { LOG(WARNING) << "Received a CONNECTION_REQUEST frame on medium " - << Medium_Name(medium_) - << " but status is disabled, ignore it."; + << Medium_Name(medium_) + << " but status is disabled, ignore it."; return; } @@ -513,12 +507,12 @@ void MultiplexSocket::HandleConnectionRequest( if (incoming_connection_callback == nullptr || listening_service_id.empty()) { LOG(INFO) << "There's no client listening for hash salt : " - << service_id_hash_salt - << ", hash key : " << salted_service_id_hash_key - << " on medium " << Medium_Name(medium_); + << service_id_hash_salt + << ", hash key : " << salted_service_id_hash_key << " on medium " + << Medium_Name(medium_); LOG(INFO) << "The size of incomingConnectionCallbacks : " - << GetIncomingConnectionCallbacks().size(); + << GetIncomingConnectionCallbacks().size(); if (!multiplex_output_stream_.WriteConnectionResponseFrame( salted_service_id_hash, service_id_hash_salt, ConnectionResponseFrame::NOT_LISTENING)) { @@ -527,10 +521,9 @@ void MultiplexSocket::HandleConnectionRequest( return; } LOG(INFO) << "Accept new virtual socket request service ID : " - << listening_service_id - << ", hash salt : " << service_id_hash_salt - << ", hash key : " << salted_service_id_hash_key - << " on medium " << Medium_Name(medium_); + << listening_service_id << ", hash salt : " << service_id_hash_salt + << ", hash key : " << salted_service_id_hash_key << " on medium " + << Medium_Name(medium_); if (!multiplex_output_stream_.WriteConnectionResponseFrame( salted_service_id_hash, service_id_hash_salt, @@ -539,10 +532,10 @@ void MultiplexSocket::HandleConnectionRequest( return; } - VLOG(1) - << "EstablishVirtualSocket after local device accept the connection " - "with serviceId=" - << listening_service_id << ", serviceIdHashSalt=" << service_id_hash_salt; + VLOG(1) << "EstablishVirtualSocket after local device accept the connection " + "with serviceId=" + << listening_service_id + << ", serviceIdHashSalt=" << service_id_hash_salt; MediumSocket* virtual_socket = CreateVirtualSocket(listening_service_id, service_id_hash_salt); (*incoming_connection_callback)(std::move(listening_service_id), @@ -553,18 +546,16 @@ void MultiplexSocket::HandleConnectionResponse( const ByteArray& salted_service_id_hash, const std::string& service_id_hash_salt, const ConnectionResponseFrame& frame) { - LOG(INFO) << __func__ << "connection_response_code: " - << frame.connection_response_code(); + LOG(INFO) << __func__ + << "connection_response_code: " << frame.connection_response_code(); for (auto& [service_id, future] : connection_response_futures_) { if (GenerateServiceIdHashWithSalt(service_id, service_id_hash_salt) == salted_service_id_hash) { if (future != nullptr) { future->Set(frame.connection_response_code()); - LOG(INFO) << __func__ - << "Set the future for serviceId=" << service_id - << ", serviceIdHashSalt=" << service_id_hash_salt - << " with response code=" - << frame.connection_response_code(); + LOG(INFO) << __func__ << "Set the future for serviceId=" << service_id + << ", serviceIdHashSalt=" << service_id_hash_salt + << " with response code=" << frame.connection_response_code(); return; } } @@ -639,37 +630,36 @@ void MultiplexSocket::OnVirtualSocketClosed(const std::string& service_id) { LOG(INFO) << __func__ << " for service_id:" << service_id; CountDownLatch latch(1); bool shutdown = false; - RunOffloadThread("VirtualSocketClosed", [this, service_id, &latch, - &shutdown]() { - LOG(INFO) << "Try to close Virtual socket: " << service_id; - MediumSocket* virtual_socket = GetVirtualSocket(service_id); - { - MutexLock lock(&virtual_socket_mutex_); - LOG(INFO) << "virtual_socket:" << virtual_socket; - if (virtual_socket != nullptr) { - auto salted_service_id_hash_key = GenerateServiceIdHashKeyWithSalt( - service_id, - multiplex_output_stream_.GetServiceIdHashSalt(service_id)); - multiplex_output_stream_.Close(service_id); - virtual_sockets_.erase(salted_service_id_hash_key); - LOG(INFO) << "Erase Virtual socket with service_id: " - << service_id - << ", hash_key: " << salted_service_id_hash_key; - ListVirtualSocket(); + RunOffloadThread( + "VirtualSocketClosed", [this, service_id, &latch, &shutdown]() { + LOG(INFO) << "Try to close Virtual socket: " << service_id; + MediumSocket* virtual_socket = GetVirtualSocket(service_id); + { + MutexLock lock(&virtual_socket_mutex_); + LOG(INFO) << "virtual_socket:" << virtual_socket; + if (virtual_socket != nullptr) { + auto salted_service_id_hash_key = GenerateServiceIdHashKeyWithSalt( + service_id, + multiplex_output_stream_.GetServiceIdHashSalt(service_id)); + multiplex_output_stream_.Close(service_id); + virtual_sockets_.erase(salted_service_id_hash_key); + LOG(INFO) << "Erase Virtual socket with service_id: " << service_id + << ", hash_key: " << salted_service_id_hash_key; + ListVirtualSocket(); - if (virtual_sockets_.empty()) { - LOG(INFO) << "Close the physical socket because all virtual " - "sockets disconnected."; - is_shutting_down_.Set(true); - Shutdown(); - shutdown = true; + if (virtual_sockets_.empty()) { + LOG(INFO) << "Close the physical socket because all virtual " + "sockets disconnected."; + is_shutting_down_.Set(true); + Shutdown(); + shutdown = true; + } + } else { + LOG(INFO) << "Virtual socket(" << service_id << ") not found"; + } } - } else { - LOG(INFO) << "Virtual socket(" << service_id << ") not found"; - } - } - latch.CountDown(); - }); + latch.CountDown(); + }); if (!latch.Await(absl::Milliseconds(1000)).result()) { LOG(ERROR) << "Timeout to close virtual socket"; @@ -690,8 +680,8 @@ MediumSocket* MultiplexSocket::ReMapAndGetVirtualSocket( std::string salted_service_id_hash_key = GenerateServiceIdHashKey(salted_service_id_hash); VLOG(1) << "ReMapAndGetVirtualSocket with serviceIdHashSalt=" - << service_id_hash_salt - << ", saltedServiceIdHashKey=" << salted_service_id_hash_key; + << service_id_hash_salt + << ", saltedServiceIdHashKey=" << salted_service_id_hash_key; { MutexLock lock(&virtual_socket_mutex_); for (auto& [hash_key, virtual_socket] : virtual_sockets_) { @@ -779,8 +769,7 @@ void MultiplexSocket::ShutdownAll() { LOG(ERROR) << "Timeout to close virtual socket"; } - LOG(INFO) - << "Shutdown single_thread_offloader_ and physical_reader_thread_"; + LOG(INFO) << "Shutdown single_thread_offloader_ and physical_reader_thread_"; single_thread_offloader_.Shutdown(); physical_reader_thread_.Shutdown(); LOG(INFO) << __func__ << " end"; diff --git a/connections/implementation/mediums/multiplex/multiplex_socket_test.cc b/connections/implementation/mediums/multiplex/multiplex_socket_test.cc index 4a2b9576..e83bd328 100644 --- a/connections/implementation/mediums/multiplex/multiplex_socket_test.cc +++ b/connections/implementation/mediums/multiplex/multiplex_socket_test.cc @@ -50,9 +50,9 @@ namespace multiplex { constexpr absl::string_view SERVICE_ID_1 = "serviceId_1"; constexpr absl::string_view SERVICE_ID_2 = "serviceId_2"; -using location::nearby::mediums::MultiplexFrame; -using location::nearby::mediums::MultiplexControlFrame; using location::nearby::mediums::ConnectionResponseFrame; +using location::nearby::mediums::MultiplexControlFrame; +using location::nearby::mediums::MultiplexFrame; using location::nearby::proto::connections::Medium; using location::nearby::proto::connections::Medium_Name; @@ -66,8 +66,7 @@ class FakeSocket : public MediumSocket { pipe_2_ = CreatePipe(); reader_2_ = std::move(pipe_2_.first); writer_2_ = std::move(pipe_2_.second); - LOG(WARNING) << "Physical Socket Medium:" - << Medium_Name(GetMedium()); + LOG(WARNING) << "Physical Socket Medium:" << Medium_Name(GetMedium()); }; ~FakeSocket() override = default; @@ -117,22 +116,21 @@ class FakeSocket : public MediumSocket { auto virtual_socket = std::make_shared(medium, outputstream); LOG(WARNING) << "Created the virtual socket for Medium: " - << Medium_Name(virtual_socket->GetMedium()); + << Medium_Name(virtual_socket->GetMedium()); if (virtual_sockets_ptr_ == nullptr) { virtual_sockets_ptr_ = virtual_sockets_ptr; } (*virtual_sockets_ptr_)[salted_service_id_hash_key] = virtual_socket; - LOG(INFO) << "virtual_sockets_ size: " - << virtual_sockets_ptr_->size(); + LOG(INFO) << "virtual_sockets_ size: " << virtual_sockets_ptr_->size(); return virtual_socket.get(); } void FeedIncomingData(ByteArray data) override { bytes_read_future_.Set(data); - LOG(INFO) << "FeedIncomingData. Size of receive data: " - << data.size() << ", bytes content:" << std::string(data); + LOG(INFO) << "FeedIncomingData. Size of receive data: " << data.size() + << ", bytes content:" << std::string(data); } bool IsVirtualSocket() override { return is_virtual_socket_; } @@ -155,8 +153,7 @@ class FakeSocket : public MediumSocket { }; TEST(MultiplexSocketTest, CreateSuccessAndReaderThreadStarted) { - auto fake_socket_ptr = - std::make_shared(Medium::BLUETOOTH); + auto fake_socket_ptr = std::make_shared(Medium::BLUETOOTH); MultiplexSocket::StopListeningForIncomingConnection(std::string(SERVICE_ID_1), Medium::BLUETOOTH); MultiplexSocket* multiplex_socket_incoming = @@ -204,8 +201,7 @@ TEST(MultiplexSocketTest, CreateSuccessAndReaderThreadStarted) { EXPECT_EQ(multiplex_socket_incoming->GetVirtualSocketCount(), 0); } TEST(MultiplexSocketTest, CreateFail_MediumNotSupport) { - auto fake_socket_ptr = - std::make_shared(Medium::WEB_RTC); + auto fake_socket_ptr = std::make_shared(Medium::WEB_RTC); MultiplexSocket::StopListeningForIncomingConnection(std::string(SERVICE_ID_1), Medium::WEB_RTC); MultiplexSocket* multiplex_socket_incoming = @@ -231,9 +227,8 @@ TEST(MultiplexSocketTest, multiplex_socket->EstablishVirtualSocket(std::string(SERVICE_ID_2)); EXPECT_EQ(socket, nullptr); absl::SleepFor(absl::Milliseconds(100)); - FakeSocket* virtual_socket = - (FakeSocket*)multiplex_socket->GetVirtualSocket( - std::string(SERVICE_ID_1)); + FakeSocket* virtual_socket = (FakeSocket*)multiplex_socket->GetVirtualSocket( + std::string(SERVICE_ID_1)); if (virtual_socket == nullptr) { LOG(INFO) << "Virtual socket not found for " << SERVICE_ID_1; return; @@ -278,8 +273,7 @@ TEST(MultiplexSocketTest, LOG(INFO) << "reader_2_ Read start"; ExceptionOr read_int = Base64Utils::ReadInt(reader); if (!read_int.ok()) { - ADD_FAILURE() << "Failed to read. Exception:" - << read_int.exception(); + ADD_FAILURE() << "Failed to read. Exception:" << read_int.exception(); } auto length = read_int.result(); LOG(INFO) << " length:" << length; @@ -294,8 +288,7 @@ TEST(MultiplexSocketTest, EXPECT_EQ(multiplex_socket->GetVirtualSocketCount(), 0); } -TEST(MultiplexSocketTest, - EstablishVirtualSocket_RemoteAccepted) { +TEST(MultiplexSocketTest, EstablishVirtualSocket_RemoteAccepted) { auto fake_socket_ptr = std::make_shared(Medium::BLUETOOTH); MultiplexSocket::StopListeningForIncomingConnection(std::string(SERVICE_ID_1), Medium::BLUETOOTH); @@ -339,8 +332,7 @@ TEST(MultiplexSocketTest, ADD_FAILURE() << "Invalid frame length:" << length; } - ExceptionOr frame_exc = - multiplex::FromBytes(bytes.result()); + ExceptionOr frame_exc = multiplex::FromBytes(bytes.result()); if (!frame_exc.ok()) { ADD_FAILURE() << "Failed to parse MultiplexFrame. Exception:" << frame_exc.exception(); @@ -356,7 +348,7 @@ TEST(MultiplexSocketTest, ASSERT_EQ(control_frame.control_frame_type(), MultiplexControlFrame::CONNECTION_REQUEST); LOG(INFO) << "Recieved MultiplexControlFrame::CONNECTION_REQUEST " - "frame, now send CONNECTION_RESPONSE frame."; + "frame, now send CONNECTION_RESPONSE frame."; ByteArray connection_response_frame = ForConnectionResponse(salted_service_id_hash, service_id_hash_salt, diff --git a/connections/implementation/mediums/webrtc.cc b/connections/implementation/mediums/webrtc.cc index 7eaf0743..d26646b8 100644 --- a/connections/implementation/mediums/webrtc.cc +++ b/connections/implementation/mediums/webrtc.cc @@ -103,14 +103,13 @@ bool WebRtc::StartAcceptingConnections(const std::string& service_id, MutexLock lock(&mutex_); if (!IsAvailable()) { LOG(WARNING) << "Cannot start accepting WebRTC connections because " - "WebRTC is not available."; + "WebRTC is not available."; return false; } if (IsAcceptingConnectionsLocked(service_id)) { - LOG(WARNING) - << "Cannot start accepting WebRTC connections because service " - << service_id << "is already accepting WebRTC connections."; + LOG(WARNING) << "Cannot start accepting WebRTC connections because service " + << service_id << "is already accepting WebRTC connections."; return false; } @@ -151,16 +150,15 @@ bool WebRtc::StartAcceptingConnections(const std::string& service_id, // a successful result. accepting_connections_info_.emplace(service_id, std::move(info)); LOG(INFO) << "Started listening for WebRTC connections as " - << self_peer_id.GetId() << " on service " << service_id; + << self_peer_id.GetId() << " on service " << service_id; return true; } void WebRtc::StopAcceptingConnections(const std::string& service_id) { MutexLock lock(&mutex_); if (!IsAcceptingConnectionsLocked(service_id)) { - LOG(WARNING) - << "Cannot stop accepting WebRTC connections because service " - << service_id << "is not accepting WebRTC connections."; + LOG(WARNING) << "Cannot stop accepting WebRTC connections because service " + << service_id << "is not accepting WebRTC connections."; return; } @@ -206,7 +204,7 @@ void WebRtc::StopAcceptingConnections(const std::string& service_id) { // Clean up our state. We're now no longer listening for connections. accepting_connections_info_.erase(service_id); LOG(INFO) << "Stopped listening for WebRTC connections for service " - << service_id; + << service_id; } ErrorOr WebRtc::Connect( @@ -220,18 +218,17 @@ ErrorOr WebRtc::Connect( while (service_id_to_connect_attempts_count_map_[service_id] <= kConnectAttemptsLimit) { if (cancellation_flag->Cancelled()) { - LOG(WARNING) - << "Attempt #" - << service_id_to_connect_attempts_count_map_[service_id] - << ": Cannot Connect with WebRtc due to cancel."; + LOG(WARNING) << "Attempt #" + << service_id_to_connect_attempts_count_map_[service_id] + << ": Cannot Connect with WebRtc due to cancel."; return { Error(OperationResultCode:: CLIENT_CANCELLATION_CANCEL_WEB_RTC_OUTGOING_CONNECTION)}; } LOG(INFO) << "Attempt #" - << service_id_to_connect_attempts_count_map_[service_id] - << ": Beginning connection."; + << service_id_to_connect_attempts_count_map_[service_id] + << ": Beginning connection."; wrapper_result = AttemptToConnect(service_id, remote_peer_id, location_hint, cancellation_flag); if (wrapper_result.has_value()) { @@ -241,8 +238,7 @@ ErrorOr WebRtc::Connect( service_id_to_connect_attempts_count_map_[service_id]++; } - LOG(WARNING) << "Giving up after " << kConnectAttemptsLimit - << " attempts"; + LOG(WARNING) << "Giving up after " << kConnectAttemptsLimit << " attempts"; return {Error(wrapper_result.error().operation_result_code().value())}; } @@ -259,19 +255,17 @@ ErrorOr WebRtc::AttemptToConnect( // is complete. CancellationFlagListener listener( cancellation_flag, [this, &service_id, &socket_future]() { - LOG(WARNING) - << "Attempt # " - << service_id_to_connect_attempts_count_map_[service_id] - << " to connect with WebRtc stopped due to cancel."; + LOG(WARNING) << "Attempt # " + << service_id_to_connect_attempts_count_map_[service_id] + << " to connect with WebRtc stopped due to cancel."; socket_future.SetException({Exception::kFailed}); }); { MutexLock lock(&mutex_); if (!IsAvailable()) { - LOG(WARNING) << "Cannot connect to WebRTC peer " - << remote_peer_id.GetId() - << " because WebRTC is not available."; + LOG(WARNING) << "Cannot connect to WebRTC peer " << remote_peer_id.GetId() + << " because WebRTC is not available."; return { Error(OperationResultCode::MEDIUM_UNAVAILABLE_WEB_RTC_NOT_AVAILABLE)}; } @@ -280,9 +274,8 @@ ErrorOr WebRtc::AttemptToConnect( std::unique_ptr connection_flow = CreateConnectionFlow(service_id, remote_peer_id); if (!connection_flow) { - LOG(INFO) << "Cannot connect to WebRTC peer " - << remote_peer_id.GetId() - << " because we failed to create a ConnectionFlow."; + LOG(INFO) << "Cannot connect to WebRTC peer " << remote_peer_id.GetId() + << " because we failed to create a ConnectionFlow."; return {Error(OperationResultCode::NEARBY_WEB_RTC_CONNECTION_FLOW_NULL)}; } @@ -290,9 +283,8 @@ ErrorOr WebRtc::AttemptToConnect( info.signaling_messenger = medium_->GetSignalingMessenger( info.self_peer_id.GetId(), location_hint); if (!info.signaling_messenger->IsValid()) { - LOG(INFO) << "Cannot connect to WebRTC peer " - << remote_peer_id.GetId() - << " because we failed to create a SignalingMessenger."; + LOG(INFO) << "Cannot connect to WebRTC peer " << remote_peer_id.GetId() + << " because we failed to create a SignalingMessenger."; return { Error(OperationResultCode:: MISCELLEANEOUS_WEB_RTC_TACHYON_SIGNALING_MESSENGER_NULL)}; @@ -320,9 +312,8 @@ ErrorOr WebRtc::AttemptToConnect( if (!info.signaling_messenger->SendMessage( remote_peer_id.GetId(), webrtc_frames::EncodeReadyForSignalingPoke(info.self_peer_id))) { - LOG(INFO) << "Cannot connect to WebRTC peer " - << remote_peer_id.GetId() - << " because we failed to poke the peer over Tachyon."; + LOG(INFO) << "Cannot connect to WebRTC peer " << remote_peer_id.GetId() + << " because we failed to poke the peer over Tachyon."; info.signaling_messenger.reset(); return {Error(OperationResultCode:: CONNECTIVITY_WEB_RTC_CONNECT_TO_TACHYON_FAILURE)}; @@ -352,7 +343,7 @@ ErrorOr WebRtc::AttemptToConnect( // Verify that the connection went through. if (!socket_result.ok()) { LOG(INFO) << "Failed to connect to WebRTC peer " - << remote_peer_id.GetId(); + << remote_peer_id.GetId(); RemoveConnectionFlow(remote_peer_id); info.signaling_messenger.reset(); requesting_connections_info_.erase(remote_peer_id.GetId()); @@ -385,8 +376,7 @@ void WebRtc::ProcessLocalIceCandidate( webrtc_frames::EncodeIceCandidates( connection_request_entry->second.self_peer_id, {ice_candidate}))) { - LOG(INFO) << "Failed to send ice candidate to " - << remote_peer_id.GetId(); + LOG(INFO) << "Failed to send ice candidate to " << remote_peer_id.GetId(); } LOG(INFO) << "Sent ice candidate to " << remote_peer_id.GetId(); @@ -405,8 +395,7 @@ void WebRtc::ProcessLocalIceCandidate( webrtc_frames::EncodeIceCandidates( accepting_connection_entry->second.self_peer_id, {ice_candidate}))) { - LOG(INFO) << "Failed to send ice candidate to " - << remote_peer_id.GetId(); + LOG(INFO) << "Failed to send ice candidate to " << remote_peer_id.GetId(); } LOG(INFO) << "Sent ice candidate to " << remote_peer_id.GetId(); @@ -414,8 +403,8 @@ void WebRtc::ProcessLocalIceCandidate( } LOG(INFO) << "Skipping restart listening for tachyon inbox messages " - "since we are not accepting connections for service " - << service_id; + "since we are not accepting connections for service " + << service_id; } void WebRtc::OnSignalingMessage(const std::string& service_id, @@ -508,23 +497,20 @@ void WebRtc::SendOffer(const std::string& service_id, std::unique_ptr connection_flow = CreateConnectionFlow(service_id, remote_peer_id); if (!connection_flow) { - LOG(INFO) - << "Unable to send offer. Failed to create a ConnectionFlow."; + LOG(INFO) << "Unable to send offer. Failed to create a ConnectionFlow."; return; } SessionDescriptionWrapper offer = connection_flow->CreateOffer(); if (!offer.IsValid()) { - LOG(INFO) - << "Unable to send offer. Failed to create our offer locally."; + LOG(INFO) << "Unable to send offer. Failed to create our offer locally."; RemoveConnectionFlow(remote_peer_id); return; } const webrtc::SessionDescriptionInterface& sdp = offer.GetSdp(); if (!connection_flow->SetLocalSessionDescription(offer)) { - LOG(INFO) - << "Unable to send offer. Failed to register our offer locally."; + LOG(INFO) << "Unable to send offer. Failed to register our offer locally."; RemoveConnectionFlow(remote_peer_id); return; } @@ -552,14 +538,12 @@ void WebRtc::ReceiveOffer(const WebrtcPeerId& remote_peer_id, SessionDescriptionWrapper offer) { const auto& entry = connection_flows_.find(remote_peer_id.GetId()); if (entry == connection_flows_.end()) { - LOG(INFO) - << "Unable to receive offer. Failed to create a ConnectionFlow."; + LOG(INFO) << "Unable to receive offer. Failed to create a ConnectionFlow."; return; } if (!entry->second->OnOfferReceived(offer)) { - LOG(INFO) - << "Unable to receive offer. Failed to process the offer."; + LOG(INFO) << "Unable to receive offer. Failed to process the offer."; RemoveConnectionFlow(remote_peer_id); } } @@ -567,15 +551,13 @@ void WebRtc::ReceiveOffer(const WebrtcPeerId& remote_peer_id, void WebRtc::SendAnswer(const WebrtcPeerId& remote_peer_id) { const auto& entry = connection_flows_.find(remote_peer_id.GetId()); if (entry == connection_flows_.end()) { - LOG(INFO) - << "Unable to send answer. Failed to create a ConnectionFlow."; + LOG(INFO) << "Unable to send answer. Failed to create a ConnectionFlow."; return; } SessionDescriptionWrapper answer = entry->second->CreateAnswer(); if (!answer.IsValid()) { - LOG(INFO) - << "Unable to send answer. Failed to create our answer locally."; + LOG(INFO) << "Unable to send answer. Failed to create our answer locally."; RemoveConnectionFlow(remote_peer_id); return; } @@ -593,7 +575,7 @@ void WebRtc::SendAnswer(const WebrtcPeerId& remote_peer_id) { requesting_connections_info_.find(remote_peer_id.GetId()); if (connection_request_entry == requesting_connections_info_.end()) { LOG(INFO) << "Unable to send answer. Failed to find an outgoing " - "connection request."; + "connection request."; RemoveConnectionFlow(remote_peer_id); return; } @@ -618,14 +600,12 @@ void WebRtc::ReceiveAnswer(const WebrtcPeerId& remote_peer_id, SessionDescriptionWrapper answer) { const auto& entry = connection_flows_.find(remote_peer_id.GetId()); if (entry == connection_flows_.end()) { - LOG(INFO) - << "Unable to receive answer. Failed to create a ConnectionFlow."; + LOG(INFO) << "Unable to receive answer. Failed to create a ConnectionFlow."; return; } if (!entry->second->OnAnswerReceived(answer)) { - LOG(INFO) - << "Unable to receive answer. Failed to process the answer."; + LOG(INFO) << "Unable to receive answer. Failed to process the answer."; RemoveConnectionFlow(remote_peer_id); } } @@ -637,7 +617,7 @@ void WebRtc::ReceiveIceCandidates( const auto& entry = connection_flows_.find(remote_peer_id.GetId()); if (entry == connection_flows_.end()) { LOG(INFO) << "Unable to receive ice candidates. Failed to create a " - "ConnectionFlow."; + "ConnectionFlow."; return; } @@ -677,8 +657,8 @@ void WebRtc::RestartTachyonReceiveMessages(const std::string& service_id) { } LOG(INFO) << "Successfully restarted listening for tachyon inbox " - "messages on service " - << service_id; + "messages on service " + << service_id; } void WebRtc::ProcessDataChannelOpen(const std::string& service_id, @@ -706,15 +686,14 @@ void WebRtc::ProcessDataChannelOpen(const std::string& service_id, // No one to handle the newly created DataChannel, so we'll just close it. socket_wrapper.Close(); LOG(INFO) << "Ignoring new DataChannel because we are not accepting " - "connections for service " - << service_id; + "connections for service " + << service_id; } void WebRtc::ProcessDataChannelClosed(const WebrtcPeerId& remote_peer_id) { MutexLock lock(&mutex_); - LOG(INFO) - << "Data channel has closed, removing connection flow for peer " - << remote_peer_id.GetId(); + LOG(INFO) << "Data channel has closed, removing connection flow for peer " + << remote_peer_id.GetId(); RemoveConnectionFlow(remote_peer_id); } diff --git a/connections/implementation/mediums/webrtc/connection_flow.cc b/connections/implementation/mediums/webrtc/connection_flow.cc index 36fe4112..665fb3d7 100644 --- a/connections/implementation/mediums/webrtc/connection_flow.cc +++ b/connections/implementation/mediums/webrtc/connection_flow.cc @@ -71,7 +71,7 @@ class CreateSessionDescriptionObserverImpl void OnFailure(webrtc::RTCError error) override { LOG(ERROR) << "Error when creating session description: " - << error.message(); + << error.message(); settable_future_.SetException({Exception::kFailed}); } @@ -252,7 +252,7 @@ bool ConnectionFlow::SetLocalSessionDescription(SessionDescriptionWrapper sdp) { bool success = result.ok() && result.result(); if (!success) { LOG(ERROR) << "Failed to set local session description: " - << result.exception(); + << result.exception(); } return success; } @@ -284,8 +284,7 @@ bool ConnectionFlow::SetRemoteSessionDescription(SessionDescriptionWrapper sdp, ExceptionOr result = observer->GetResult(kTimeout); bool success = result.ok() && result.result(); if (!success) { - LOG(ERROR) << "Failed to set remote description: " - << result.exception(); + LOG(ERROR) << "Failed to set remote description: " << result.exception(); } return success; } @@ -330,8 +329,7 @@ void ConnectionFlow::AddIceCandidatesOnSignalingThread( ice_candidates) { CHECK(IsRunningOnSignalingThread()); if (state_ == State::kEnded) { - LOG(WARNING) - << "You cannot add ice candidates to a disconnected session."; + LOG(WARNING) << "You cannot add ice candidates to a disconnected session."; return; } if (state_ != State::kWaitingToConnect && state_ != State::kConnected) { @@ -397,8 +395,7 @@ bool ConnectionFlow::InitPeerConnection(WebRtcMedium& webrtc_medium) { bool success = result.ok() && result.result(); if (!success) { shutdown_latch_.CountDown(); - LOG(ERROR) << "Failed to create peer connection: " - << result.exception(); + LOG(ERROR) << "Failed to create peer connection: " << result.exception(); } return success; } @@ -424,7 +421,7 @@ void ConnectionFlow::CreateSocketFromDataChannel( CHECK(IsRunningOnSignalingThread()); if (!TransitionState(State::kWaitingToConnect, State::kConnected)) { LOG(ERROR) << "Data channel socket is open but connection " - "flow was not in the required state"; + "flow was not in the required state"; socket->Close(); return; } @@ -475,7 +472,7 @@ void ConnectionFlow::OnConnectionChange( new_state == PeerConnectionState::kFailed || new_state == PeerConnectionState::kDisconnected) { LOG(INFO) << "Closing due to peer connection state change: " - << static_cast(new_state); + << static_cast(new_state); CloseOnSignalingThread(); } } @@ -499,13 +496,13 @@ bool ConnectionFlow::TransitionState(State current_state, State new_state) { CHECK(IsRunningOnSignalingThread()); if (current_state != state_) { LOG(WARNING) << "Invalid state transition to " - << static_cast(new_state) << ": current state is " - << static_cast(state_) << " but expected " - << static_cast(current_state); + << static_cast(new_state) << ": current state is " + << static_cast(state_) << " but expected " + << static_cast(current_state); return false; } LOG(INFO) << "Transition: " << static_cast(state_) << "->" - << static_cast(new_state); + << static_cast(new_state); state_ = new_state; return true; } @@ -540,25 +537,24 @@ bool ConnectionFlow::RunOnSignalingThread(Runnable&& runnable) { CHECK(!IsRunningOnSignalingThread()); auto pc = GetPeerConnection(); if (!pc) { - LOG(WARNING) - << "Peer connection not available. Cannot schedule tasks."; + LOG(WARNING) << "Peer connection not available. Cannot schedule tasks."; return false; } // We are off signaling thread, so we can't use peer connection's methods // but we can access the signaling thread handle. - pc->signaling_thread()->PostTask([can_run_tasks = - std::weak_ptr(can_run_tasks_), - task = std::move(runnable)]() mutable { - // Don't run the task if the weak_ptr is no longer valid. - // shared_ptr |can_run_tasks_| is destroyed on the same thread - // (signaling thread). This guarantees that if the weak_ptr is valid - // when this task starts, it will stay valid until the task ends. - if (!can_run_tasks.lock()) { - LOG(INFO) << "Peer connection already closed. Cannot run tasks."; - return; - } - task(); - }); + pc->signaling_thread()->PostTask( + [can_run_tasks = std::weak_ptr(can_run_tasks_), + task = std::move(runnable)]() mutable { + // Don't run the task if the weak_ptr is no longer valid. + // shared_ptr |can_run_tasks_| is destroyed on the same thread + // (signaling thread). This guarantees that if the weak_ptr is valid + // when this task starts, it will stay valid until the task ends. + if (!can_run_tasks.lock()) { + LOG(INFO) << "Peer connection already closed. Cannot run tasks."; + return; + } + task(); + }); return true; } diff --git a/connections/implementation/mediums/webrtc/webrtc_socket_impl.cc b/connections/implementation/mediums/webrtc/webrtc_socket_impl.cc index 0e9af483..bd1b1338 100644 --- a/connections/implementation/mediums/webrtc/webrtc_socket_impl.cc +++ b/connections/implementation/mediums/webrtc/webrtc_socket_impl.cc @@ -67,23 +67,21 @@ WebRtcSocket::WebRtcSocket( const std::string& name, webrtc::scoped_refptr data_channel) : name_(name), data_channel_(std::move(data_channel)) { - LOG(INFO) << "WebRtcSocket::WebRtcSocket(" << name_ - << ") this: " << this; + LOG(INFO) << "WebRtcSocket::WebRtcSocket(" << name_ << ") this: " << this; std::tie(pipe_input_, pipe_output_) = CreatePipe(); data_channel_->RegisterObserver(this); } WebRtcSocket::~WebRtcSocket() { - LOG(INFO) << "WebRtcSocket::~WebRtcSocket(" << name_ - << ") this: " << this; + LOG(INFO) << "WebRtcSocket::~WebRtcSocket(" << name_ << ") this: " << this; if (!IsClosed()) { data_channel_->UnregisterObserver(); Close(); } - LOG(INFO) << "WebRtcSocket::~WebRtcSocket(" << name_ - << ") this: " << this << " done"; + LOG(INFO) << "WebRtcSocket::~WebRtcSocket(" << name_ << ") this: " << this + << " done"; } InputStream& WebRtcSocket::GetInputStream() { return *pipe_input_; } @@ -99,16 +97,15 @@ Exception WebRtcSocket::Close() { // to 'closing' but does not block until 'closed' is sent so the data channel // is not fully closed when this call is done. data_channel_->Close(); - LOG(INFO) << "WebRtcSocket::Close(" << name_ << ") this: " << this - << " done"; + LOG(INFO) << "WebRtcSocket::Close(" << name_ << ") this: " << this << " done"; return {Exception::kSuccess}; } void WebRtcSocket::OnStateChange() { // Running on the signaling thread right now. - LOG(ERROR) - << "WebRtcSocket::OnStateChange() webrtc data channel state: " - << webrtc::DataChannelInterface::DataStateString(data_channel_->state()); + LOG(ERROR) << "WebRtcSocket::OnStateChange() webrtc data channel state: " + << webrtc::DataChannelInterface::DataStateString( + data_channel_->state()); switch (data_channel_->state()) { case webrtc::DataChannelInterface::DataState::kConnecting: break; @@ -121,7 +118,7 @@ void WebRtcSocket::OnStateChange() { break; case webrtc::DataChannelInterface::DataState::kClosed: LOG(ERROR) << "WebRtcSocket::OnStateChange() unregistering data " - "channel observer."; + "channel observer."; // This will trigger a destruction of the owning connection flow // We implicitly depend on the |socket_listener_| to offload from // the signaling thread so it does not get blocked. @@ -163,8 +160,7 @@ bool WebRtcSocket::SendMessage(const ByteArray& data) { bool WebRtcSocket::IsClosed() { return closed_.Get(); } void WebRtcSocket::ClosePipe() { - LOG(INFO) << "WebRtcSocket::ClosePipe(" << name_ - << ") this: " << this; + LOG(INFO) << "WebRtcSocket::ClosePipe(" << name_ << ") this: " << this; // This is thread-safe to close these sockets even if a read or write is in // process on another thread, Close will wait for the exclusive mutex before // setting state. @@ -172,7 +168,7 @@ void WebRtcSocket::ClosePipe() { pipe_output_->Close(); WakeUpWriter(); LOG(INFO) << "WebRtcSocket::ClosePipe(" << name_ << ") this: " << this - << " done"; + << " done"; } // Must not be called on signalling thread. diff --git a/connections/implementation/mediums/wifi_direct.cc b/connections/implementation/mediums/wifi_direct.cc index bad92ebc..4655b116 100644 --- a/connections/implementation/mediums/wifi_direct.cc +++ b/connections/implementation/mediums/wifi_direct.cc @@ -22,8 +22,8 @@ #include "internal/platform/expected.h" #include "internal/platform/logging.h" #include "internal/platform/mutex_lock.h" -#include "internal/platform/wifi_direct.h" #include "internal/platform/wifi_credential.h" +#include "internal/platform/wifi_direct.h" namespace nearby { namespace connections { @@ -106,8 +106,7 @@ bool WifiDirect::ConnectWifiDirect(const std::string& ssid, const std::string& password) { MutexLock lock(&mutex_); if (is_connected_to_go_) { - LOG(INFO) - << "No need to connect to GO because it is already connected."; + LOG(INFO) << "No need to connect to GO because it is already connected."; return true; } is_connected_to_go_ = medium_.ConnectWifiDirect(ssid, password); @@ -117,8 +116,7 @@ bool WifiDirect::ConnectWifiDirect(const std::string& ssid, bool WifiDirect::DisconnectWifiDirect() { MutexLock lock(&mutex_); if (!is_connected_to_go_) { - LOG(INFO) - << "No need to disconnect to GO because it is not connected."; + LOG(INFO) << "No need to disconnect to GO because it is not connected."; return true; } is_connected_to_go_ = false; @@ -134,7 +132,7 @@ WifiDirectCredentials* WifiDirect::GetCredentials( const auto& it = server_sockets_.find(service_id); if (it == server_sockets_.end()) { LOG(INFO) << "No server socket found for service_id:" << service_id - << ". Use default credentials"; + << ". Use default credentials"; return crendential; } crendential->SetGateway(it->second.GetIPAddress()); @@ -149,9 +147,8 @@ bool WifiDirect::StartAcceptingConnections( MutexLock lock(&mutex_); if (service_id.empty()) { - LOG(INFO) - << "Can not to start accepting WifiDirect GC's connections; " - "service_id is empty."; + LOG(INFO) << "Can not to start accepting WifiDirect GC's connections; " + "service_id is empty."; return false; } @@ -211,16 +208,15 @@ bool WifiDirect::StopAcceptingConnections(const std::string& service_id) { MutexLock lock(&mutex_); if (service_id.empty()) { - LOG(INFO) - << "Unable to stop accepting WifiDirect GC's connections because " - "the service_id is empty."; + LOG(INFO) << "Unable to stop accepting WifiDirect GC's connections because " + "the service_id is empty."; return false; } const auto& it = server_sockets_.find(service_id); if (it == server_sockets_.end()) { LOG(INFO) << "Can't stop accepting WifiDirect GC's connections for " - << service_id << " because it was never started."; + << service_id << " because it was never started."; return false; } @@ -241,9 +237,8 @@ bool WifiDirect::StopAcceptingConnections(const std::string& service_id) { // Finally, close the WifiDirectServerSocket. if (!listening_socket.Close().Ok()) { - LOG(INFO) - << "Failed to close WifiDirect server socket for service_id:" - << service_id; + LOG(INFO) << "Failed to close WifiDirect server socket for service_id:" + << service_id; return false; } @@ -268,13 +263,13 @@ ErrorOr WifiDirect::Connect( if (service_id.empty()) { LOG(INFO) << "Refusing to create client WifiDirect socket because " - "service_id is empty."; + "service_id is empty."; return {Error(OperationResultCode::NEARBY_LOCAL_CLIENT_STATE_WRONG)}; } if (!IsGCAvailableLocked()) { LOG(INFO) << "Can't create WifiDirect client socket [service_id=" - << service_id << "]; WifiDirect GC isn't available."; + << service_id << "]; WifiDirect GC isn't available."; return {Error( OperationResultCode::MEDIUM_UNAVAILABLE_WIFI_DIRECT_NOT_AVAILABLE)}; } @@ -289,7 +284,7 @@ ErrorOr WifiDirect::Connect( socket = medium_.ConnectToService(ip_address, port, cancellation_flag); if (!socket.IsValid()) { LOG(INFO) << "Failed to Connect via WifiDirect Server [service_id=" - << service_id << "]"; + << service_id << "]"; return {Error(OperationResultCode:: CONNECTIVITY_WIFI_DIRECT_CLIENT_SOCKET_CREATION_FAILURE)}; } diff --git a/connections/implementation/mediums/wifi_hotspot.cc b/connections/implementation/mediums/wifi_hotspot.cc index d3c064b2..8b5a987e 100644 --- a/connections/implementation/mediums/wifi_hotspot.cc +++ b/connections/implementation/mediums/wifi_hotspot.cc @@ -75,8 +75,7 @@ bool WifiHotspot::IsHotspotStarted() { bool WifiHotspot::StartWifiHotspot() { MutexLock lock(&mutex_); if (is_hotspot_started_) { - LOG(INFO) - << "No need to start Hotspot because it is already started."; + LOG(INFO) << "No need to start Hotspot because it is already started."; return true; } is_hotspot_started_ = medium_.StartWifiHotspot(); @@ -132,7 +131,7 @@ HotspotCredentials* WifiHotspot::GetCredentials(absl::string_view service_id) { const auto& it = server_sockets_.find(service_id); if (it == server_sockets_.end()) { LOG(INFO) << "No server socket found for service_id:" << service_id - << ". Use default credentials"; + << ". Use default credentials"; return crendential; } crendential->SetGateway(it->second.GetIPAddress()); @@ -148,14 +147,13 @@ bool WifiHotspot::StartAcceptingConnections( if (service_id.empty()) { LOG(INFO) << "Can not to start accepting WifiHotspot connections; " - "service_id is empty."; + "service_id is empty."; return false; } if (!IsAPAvailableLocked()) { - LOG(INFO) - << "Can't start accepting WifiHotspot connections [service_id=" - << service_id << "]; WifiHotspot not available."; + LOG(INFO) << "Can't start accepting WifiHotspot connections [service_id=" + << service_id << "]; WifiHotspot not available."; return false; } @@ -208,16 +206,15 @@ bool WifiHotspot::StopAcceptingConnections(const std::string& service_id) { MutexLock lock(&mutex_); if (service_id.empty()) { - LOG(INFO) - << "Unable to stop accepting WifiHotspot connections because " - "the service_id is empty."; + LOG(INFO) << "Unable to stop accepting WifiHotspot connections because " + "the service_id is empty."; return false; } const auto& it = server_sockets_.find(service_id); if (it == server_sockets_.end()) { LOG(INFO) << "Can't stop accepting WifiHotspot connections for " - << service_id << " because it was never started."; + << service_id << " because it was never started."; return false; } @@ -238,9 +235,8 @@ bool WifiHotspot::StopAcceptingConnections(const std::string& service_id) { // Finally, close the WifiHotspotServerSocket. if (!listening_socket.Close().Ok()) { - LOG(INFO) - << "Failed to close WifiHotspot server socket for service_id:" - << service_id; + LOG(INFO) << "Failed to close WifiHotspot server socket for service_id:" + << service_id; return false; } @@ -265,13 +261,13 @@ ErrorOr WifiHotspot::Connect( if (service_id.empty()) { LOG(INFO) << "Refusing to create client WifiHotspot socket because " - "service_id is empty."; + "service_id is empty."; return {Error(OperationResultCode::NEARBY_LOCAL_CLIENT_STATE_WRONG)}; } if (!IsClientAvailableLocked()) { LOG(INFO) << "Can't create client WifiHotspot socket [service_id=" - << service_id << "]; WifiHotspot isn't available."; + << service_id << "]; WifiHotspot isn't available."; return {Error( OperationResultCode::MEDIUM_UNAVAILABLE_WIFI_HOTSPOT_NOT_AVAILABLE)}; } @@ -285,8 +281,8 @@ ErrorOr WifiHotspot::Connect( socket = medium_.ConnectToService(ip_address, port, cancellation_flag); if (!socket.IsValid()) { - LOG(INFO) << "Failed to Connect via WifiHotspot [service_id=" - << service_id << "]"; + LOG(INFO) << "Failed to Connect via WifiHotspot [service_id=" << service_id + << "]"; return { Error(OperationResultCode:: CONNECTIVITY_WIFI_HOTSPOT_CLIENT_SOCKET_CREATION_FAILURE)}; diff --git a/connections/implementation/mediums/wifi_lan.cc b/connections/implementation/mediums/wifi_lan.cc index 54fb4b8d..6be0fca1 100644 --- a/connections/implementation/mediums/wifi_lan.cc +++ b/connections/implementation/mediums/wifi_lan.cc @@ -59,8 +59,8 @@ WifiLan::~WifiLan() { { MutexLock lock(&mutex_); if (is_multiplex_enabled_) { - LOG(INFO) << "Closing multiplex sockets for " - << multiplex_sockets_.size() << " IPs"; + LOG(INFO) << "Closing multiplex sockets for " << multiplex_sockets_.size() + << " IPs"; for (auto& [ip_addr, multiplex_socket] : multiplex_sockets_) { LOG(INFO) << "Closing multiplex sockets for: " << ip_addr; multiplex_socket->~MultiplexSocket(); @@ -87,8 +87,7 @@ ErrorOr WifiLan::StartAdvertising(const std::string& service_id, MutexLock lock(&mutex_); if (!IsAvailableLocked()) { - LOG(INFO) - << "Can't turn on WifiLan advertising. WifiLan is not available."; + LOG(INFO) << "Can't turn on WifiLan advertising. WifiLan is not available."; return {Error(OperationResultCode::MEDIUM_UNAVAILABLE_LAN_NOT_AVAILABLE)}; } @@ -106,12 +105,11 @@ ErrorOr WifiLan::StartAdvertising(const std::string& service_id, } if (!IsAcceptingConnectionsLocked(service_id)) { - LOG(INFO) - << "Failed to turn on WifiLan advertising with nsd_service_info=" - << &nsd_service_info - << ", service_name=" << nsd_service_info.GetServiceName() - << ", service_id=" << service_id - << ". Should accept connections before advertising."; + LOG(INFO) << "Failed to turn on WifiLan advertising with nsd_service_info=" + << &nsd_service_info + << ", service_name=" << nsd_service_info.GetServiceName() + << ", service_id=" << service_id + << ". Should accept connections before advertising."; return {Error(OperationResultCode:: CLIENT_DUPLICATE_ACCEPTING_LAN_CONNECTION_REQUEST)}; } @@ -123,19 +121,18 @@ ErrorOr WifiLan::StartAdvertising(const std::string& service_id, nsd_service_info.SetPort(it->second.GetPort()); } if (!medium_.StartAdvertising(nsd_service_info)) { - LOG(INFO) - << "Failed to turn on WifiLan advertising with nsd_service_info=" - << &nsd_service_info - << ", service_name=" << nsd_service_info.GetServiceName() - << ", service_id=" << service_id; + LOG(INFO) << "Failed to turn on WifiLan advertising with nsd_service_info=" + << &nsd_service_info + << ", service_name=" << nsd_service_info.GetServiceName() + << ", service_id=" << service_id; return {Error( OperationResultCode::CONNECTIVITY_WIFI_LAN_START_ADVERTISING_FAILURE)}; } LOG(INFO) << "Turned on WifiLan advertising with nsd_service_info=" - << &nsd_service_info - << ", service_name=" << nsd_service_info.GetServiceName() - << ", service_id=" << service_id; + << &nsd_service_info + << ", service_name=" << nsd_service_info.GetServiceName() + << ", service_id=" << service_id; advertising_info_.Add(service_id, std::move(nsd_service_info)); return {true}; } @@ -144,13 +141,11 @@ bool WifiLan::StopAdvertising(const std::string& service_id) { MutexLock lock(&mutex_); if (!IsAdvertisingLocked(service_id)) { - LOG(INFO) - << "Can't turn off WifiLan advertising; it is already off"; + LOG(INFO) << "Can't turn off WifiLan advertising; it is already off"; return false; } - LOG(INFO) << "Turned off WifiLan advertising with service_id=" - << service_id; + LOG(INFO) << "Turned off WifiLan advertising with service_id=" << service_id; bool ret = medium_.StopAdvertising(*advertising_info_.GetServiceInfo(service_id)); // Reset our bundle of advertising state to mark that we're no longer @@ -174,8 +169,7 @@ ErrorOr WifiLan::StartDiscovery(const std::string& service_id, MutexLock lock(&mutex_); if (service_id.empty()) { - LOG(INFO) - << "Refusing to start WifiLan discovering with empty service_id."; + LOG(INFO) << "Refusing to start WifiLan discovering with empty service_id."; return {Error(OperationResultCode::NEARBY_LOCAL_CLIENT_STATE_WRONG)}; } @@ -202,8 +196,7 @@ ErrorOr WifiLan::StartDiscovery(const std::string& service_id, OperationResultCode::CONNECTIVITY_WIFI_LAN_START_DISCOVERY_FAILURE)}; } - LOG(INFO) << "Turned on WifiLan discovering with service_id=" - << service_id; + LOG(INFO) << "Turned on WifiLan discovering with service_id=" << service_id; // Mark the fact that we're currently performing a WifiLan discovering. discovering_info_.Add(service_id); return {true}; @@ -213,15 +206,14 @@ bool WifiLan::StopDiscovery(const std::string& service_id) { MutexLock lock(&mutex_); if (!IsDiscoveringLocked(service_id)) { - LOG(INFO) - << "Can't turn off WifiLan discovering because we never started " - "discovering."; + LOG(INFO) << "Can't turn off WifiLan discovering because we never started " + "discovering."; return false; } std::string service_type = GenerateServiceType(service_id); - LOG(INFO) << "Turned off WifiLan discovering with service_id=" - << service_id << ", service_type=" << service_type; + LOG(INFO) << "Turned off WifiLan discovering with service_id=" << service_id + << ", service_type=" << service_type; bool ret = medium_.StopDiscovery(service_type); discovering_info_.Remove(service_id); return ret; @@ -242,23 +234,21 @@ ErrorOr WifiLan::StartAcceptingConnections( if (service_id.empty()) { LOG(INFO) << "Refusing to start accepting WifiLan connections; " - "service_id is empty."; + "service_id is empty."; return {Error(OperationResultCode::NEARBY_LOCAL_CLIENT_STATE_WRONG)}; } if (!IsAvailableLocked()) { - LOG(INFO) - << "Can't start accepting WifiLan connections [service_id=" - << service_id << "]; WifiLan not available."; + LOG(INFO) << "Can't start accepting WifiLan connections [service_id=" + << service_id << "]; WifiLan not available."; return {Error( OperationResultCode::MEDIUM_UNAVAILABLE_WIFI_AWARE_NOT_AVAILABLE)}; } if (IsAcceptingConnectionsLocked(service_id)) { - LOG(INFO) - << "Refusing to start accepting WifiLan connections [service=" - << service_id - << "]; WifiLan server is already in-progress with the same name."; + LOG(INFO) << "Refusing to start accepting WifiLan connections [service=" + << service_id + << "]; WifiLan server is already in-progress with the same name."; return {Error(OperationResultCode:: CLIENT_DUPLICATE_ACCEPTING_LAN_CONNECTION_REQUEST)}; } @@ -275,9 +265,8 @@ ErrorOr WifiLan::StartAcceptingConnections( } WifiLanServerSocket server_socket = medium_.ListenForService(port); if (!server_socket.IsValid()) { - LOG(INFO) - << "Failed to start accepting WifiLan connections for service_id=" - << service_id; + LOG(INFO) << "Failed to start accepting WifiLan connections for service_id=" + << service_id; return {Error(OperationResultCode:: CLIENT_CANCELLATION_WIFI_LAN_SERVER_SOCKET_CREATION)}; } @@ -351,7 +340,7 @@ ErrorOr WifiLan::StartAcceptingConnections( MultiplexSocket::StopListeningForIncomingConnection( service_id, Medium::WIFI_LAN); LOG(INFO) << "Multiplex virtaul socket created for " - << server_socket.GetIPAddress(); + << server_socket.GetIPAddress(); if (callback) { callback( service_id, @@ -377,14 +366,14 @@ bool WifiLan::StopAcceptingConnections(const std::string& service_id) { if (service_id.empty()) { LOG(INFO) << "Unable to stop accepting WifiLan connections because " - "the service_id is empty."; + "the service_id is empty."; return false; } const auto& it = server_sockets_.find(service_id); if (it == server_sockets_.end()) { - LOG(INFO) << "Can't stop accepting WifiLan connections for " - << service_id << " because it was never started."; + LOG(INFO) << "Can't stop accepting WifiLan connections for " << service_id + << " because it was never started."; return false; } if (is_multiplex_enabled_) { @@ -410,7 +399,7 @@ bool WifiLan::StopAcceptingConnections(const std::string& service_id) { // Finally, close the WifiLanServerSocket. if (!listening_socket.Close().Ok()) { LOG(INFO) << "Failed to close WifiLan server socket for service_id=" - << service_id; + << service_id; return false; } @@ -435,13 +424,13 @@ ErrorOr WifiLan::Connect(const std::string& service_id, if (service_id.empty()) { LOG(INFO) << "Refusing to create client WifiLan socket because " - "service_id is empty."; + "service_id is empty."; return {Error(OperationResultCode::NEARBY_LOCAL_CLIENT_STATE_WRONG)}; } if (!IsAvailableLocked()) { - LOG(INFO) << "Can't create client WifiLan socket [service_id=" - << service_id << "]; WifiLan isn't available."; + LOG(INFO) << "Can't create client WifiLan socket [service_id=" << service_id + << "]; WifiLan isn't available."; return {Error(OperationResultCode::MEDIUM_UNAVAILABLE_LAN_NOT_AVAILABLE)}; } @@ -459,8 +448,8 @@ ErrorOr WifiLan::Connect(const std::string& service_id, socket = medium_.ConnectToService(service_info, cancellation_flag); if (!socket.IsValid()) { - LOG(INFO) << "Failed to Connect via WifiLan [service_id=" - << service_id << "]"; + LOG(INFO) << "Failed to Connect via WifiLan [service_id=" << service_id + << "]"; return {Error( OperationResultCode::CONNECTIVITY_LAN_CLIENT_SOCKET_CREATION_FAILURE)}; } else { @@ -468,15 +457,14 @@ ErrorOr WifiLan::Connect(const std::string& service_id, CreateOutgoingMultiplexSocketLocked(socket, service_id, service_info.GetIPAddress()); if (virtual_socket.ok()) { - LOG(INFO) - << "Successfully connected via Multiplex WifiLan [service_id=" - << service_id << "]"; + LOG(INFO) << "Successfully connected via Multiplex WifiLan [service_id=" + << service_id << "]"; return virtual_socket.result(); } } - LOG(INFO) << "Successfully connected via WifiLan [service_id=" - << service_id << "]"; + LOG(INFO) << "Successfully connected via WifiLan [service_id=" << service_id + << "]"; return socket; } @@ -489,13 +477,13 @@ ErrorOr WifiLan::Connect(const std::string& service_id, if (service_id.empty()) { LOG(INFO) << "Refusing to create client WifiLan socket because " - "service_id is empty."; + "service_id is empty."; return {Error(OperationResultCode::NEARBY_LOCAL_CLIENT_STATE_WRONG)}; } if (!IsAvailableLocked()) { - LOG(INFO) << "Can't create client WifiLan socket [service_id=" - << service_id << "]; WifiLan isn't available."; + LOG(INFO) << "Can't create client WifiLan socket [service_id=" << service_id + << "]; WifiLan isn't available."; return {Error(OperationResultCode::MEDIUM_UNAVAILABLE_LAN_NOT_AVAILABLE)}; } @@ -513,38 +501,35 @@ ErrorOr WifiLan::Connect(const std::string& service_id, socket = medium_.ConnectToService(ip_address, port, cancellation_flag); if (!socket.IsValid()) { - LOG(INFO) << "Failed to Connect via WifiLan [service_id=" - << service_id << "]"; + LOG(INFO) << "Failed to Connect via WifiLan [service_id=" << service_id + << "]"; return {Error( OperationResultCode::CONNECTIVITY_LAN_CLIENT_SOCKET_CREATION_FAILURE)}; } else { ExceptionOr virtual_socket = CreateOutgoingMultiplexSocketLocked(socket, service_id, ip_address); if (virtual_socket.ok()) { - LOG(INFO) - << "Successfully connected via Multiplex WifiLan [service_id=" - << service_id << "]"; + LOG(INFO) << "Successfully connected via Multiplex WifiLan [service_id=" + << service_id << "]"; return virtual_socket.result(); } } - LOG(INFO) << "Successfully connected via WifiLan [service_id=" - << service_id << "]"; + LOG(INFO) << "Successfully connected via WifiLan [service_id=" << service_id + << "]"; return socket; } ExceptionOr WifiLan::ConnectWithMultiplexSocketLocked( const std::string& service_id, const std::string& ip_address) { if (is_multiplex_enabled_) { - LOG(INFO) << "multiplex_sockets_ size:" - << multiplex_sockets_.size(); + LOG(INFO) << "multiplex_sockets_ size:" << multiplex_sockets_.size(); auto it = multiplex_sockets_.find(ip_address); if (it != multiplex_sockets_.end()) { MultiplexSocket* multiplex_socket = it->second; if (multiplex_socket->IsShutdown()) { - LOG(INFO) - << "Erase multiplex_socket(already shutdown) for ip_address: " - << WifiUtils::GetHumanReadableIpAddress(ip_address); + LOG(INFO) << "Erase multiplex_socket(already shutdown) for ip_address: " + << WifiUtils::GetHumanReadableIpAddress(ip_address); multiplex_socket->~MultiplexSocket(); multiplex_sockets_.erase(it); return ExceptionOr(Exception::kFailed); @@ -555,9 +540,9 @@ ExceptionOr WifiLan::ConnectWithMultiplexSocketLocked( // Should not happen. auto* wlan_socket = down_cast(virtual_socket); if (wlan_socket == nullptr) { - LOG(INFO) << "Failed to cast to WifiLanSocket for " - << service_id << " with ip_address: " - << WifiUtils::GetHumanReadableIpAddress(ip_address); + LOG(INFO) << "Failed to cast to WifiLanSocket for " << service_id + << " with ip_address: " + << WifiUtils::GetHumanReadableIpAddress(ip_address); return ExceptionOr(Exception::kFailed); } return ExceptionOr(*wlan_socket); @@ -582,12 +567,12 @@ ExceptionOr WifiLan::CreateOutgoingMultiplexSocketLocked( auto* wlan_socket = down_cast(virtual_socket); if (wlan_socket == nullptr) { LOG(INFO) << "Failed to cast to WifiLanSocket for " << service_id - << " with ip_address: " - << WifiUtils::GetHumanReadableIpAddress(ip_address); + << " with ip_address: " + << WifiUtils::GetHumanReadableIpAddress(ip_address); return ExceptionOr(Exception::kFailed); } LOG(INFO) << "Multiplex socket created for ip_address: " - << WifiUtils::GetHumanReadableIpAddress(ip_address); + << WifiUtils::GetHumanReadableIpAddress(ip_address); multiplex_sockets_.emplace(ip_address, multiplex_socket); return ExceptionOr(*wlan_socket); } diff --git a/connections/implementation/mediums/wifi_lan_test.cc b/connections/implementation/mediums/wifi_lan_test.cc index c2d70d42..bc24061c 100644 --- a/connections/implementation/mediums/wifi_lan_test.cc +++ b/connections/implementation/mediums/wifi_lan_test.cc @@ -93,8 +93,7 @@ TEST_P(WifiLanTest, CanConnect) { .service_discovered_cb = [&discovered_latch, &discovered_service_info]( NsdServiceInfo service_info, const std::string& service_id) { - LOG(INFO) - << "Discovered service_info=" << &service_info; + LOG(INFO) << "Discovered service_info=" << &service_info; discovered_service_info = service_info; discovered_latch.CountDown(); }, @@ -162,7 +161,7 @@ TEST_P(WifiLanTest, CanConnectWithMultiplex) { NsdServiceInfo service_info, const std::string& service_id) { LOG(INFO) << "Discovered service_info=" - << &service_info; + << &service_info; discovered_service_info = service_info; discovered_latch.CountDown(); }, @@ -224,8 +223,7 @@ TEST_P(WifiLanTest, CanCancelConnect) { .service_discovered_cb = [&discovered_latch, &discovered_service_info]( NsdServiceInfo service_info, const std::string& service_id) { - LOG(INFO) - << "Discovered service_info=" << &service_info; + LOG(INFO) << "Discovered service_info=" << &service_info; discovered_service_info = service_info; discovered_latch.CountDown(); }, diff --git a/connections/implementation/offline_service_controller.cc b/connections/implementation/offline_service_controller.cc index 87f95472..62ca44e8 100644 --- a/connections/implementation/offline_service_controller.cc +++ b/connections/implementation/offline_service_controller.cc @@ -54,8 +54,7 @@ Status OfflineServiceController::StartAdvertising( const ConnectionRequestInfo& info) { if (stop_) return {Status::kOutOfOrderApiCall}; LOG(INFO) << "Client " << client->GetClientId() - << " requested to start advertising for service_id " - << service_id; + << " requested to start advertising for service_id " << service_id; return pcp_manager_.StartAdvertising(client, service_id, advertising_options, info); } @@ -63,8 +62,8 @@ Status OfflineServiceController::StartAdvertising( void OfflineServiceController::StopAdvertising(ClientProxy* client) { if (stop_) return; LOG(INFO) << "Client " << client->GetClientId() - << " requested to stop advertising for service_id " - << client->GetAdvertisingServiceId(); + << " requested to stop advertising for service_id " + << client->GetAdvertisingServiceId(); pcp_manager_.StopAdvertising(client); } @@ -73,8 +72,7 @@ Status OfflineServiceController::StartDiscovery( const DiscoveryOptions& discovery_options, DiscoveryListener listener) { if (stop_) return {Status::kOutOfOrderApiCall}; LOG(INFO) << "Client " << client->GetClientId() - << " requested to start discovery for service_id " - << service_id; + << " requested to start discovery for service_id " << service_id; return pcp_manager_.StartDiscovery(client, service_id, discovery_options, std::move(listener)); } @@ -82,8 +80,8 @@ Status OfflineServiceController::StartDiscovery( void OfflineServiceController::StopDiscovery(ClientProxy* client) { if (stop_) return; LOG(INFO) << "Client " << client->GetClientId() - << " requested to stop discovery for service_id " - << client->GetDiscoveryServiceId(); + << " requested to stop discovery for service_id " + << client->GetDiscoveryServiceId(); pcp_manager_.StopDiscovery(client); } @@ -93,8 +91,7 @@ OfflineServiceController::StartListeningForIncomingConnections( v3::ConnectionListener listener, const v3::ConnectionListeningOptions& options) { LOG(INFO) << "Client " << client->GetClientId() - << " requested to start listening for service_id " - << service_id; + << " requested to start listening for service_id " << service_id; return pcp_manager_.StartListeningForIncomingConnections( client, service_id, std::move(listener), options); } @@ -102,8 +99,8 @@ OfflineServiceController::StartListeningForIncomingConnections( void OfflineServiceController::StopListeningForIncomingConnections( ClientProxy* client) { LOG(INFO) << "Client " << client->GetClientId() - << " requested to stop listening for service_id " - << client->GetListeningForIncomingConnectionsServiceId(); + << " requested to stop listening for service_id " + << client->GetListeningForIncomingConnectionsServiceId(); pcp_manager_.StopListeningForIncomingConnections(client); } @@ -112,12 +109,12 @@ void OfflineServiceController::InjectEndpoint( const OutOfBandConnectionMetadata& metadata) { if (stop_) return; LOG(INFO) << "Client " << client->GetClientId() - << " requested to inject endpoint {endpoint_id:" - << metadata.endpoint_id << ", endpoint_info:" - << metadata.endpoint_info.AsStringView() - << ",remote_bluetooth_mac_address:" - << metadata.remote_bluetooth_mac_address.AsStringView() - << "} for service_id " << service_id; + << " requested to inject endpoint {endpoint_id:" + << metadata.endpoint_id + << ", endpoint_info:" << metadata.endpoint_info.AsStringView() + << ",remote_bluetooth_mac_address:" + << metadata.remote_bluetooth_mac_address.AsStringView() + << "} for service_id " << service_id; pcp_manager_.InjectEndpoint(client, service_id, metadata); } @@ -127,7 +124,7 @@ Status OfflineServiceController::RequestConnection( const ConnectionOptions& connection_options) { if (stop_) return {Status::kOutOfOrderApiCall}; LOG(INFO) << "Client " << client->GetClientId() - << " requested a connection to endpoint_id " << endpoint_id; + << " requested a connection to endpoint_id " << endpoint_id; return pcp_manager_.RequestConnection(client, endpoint_id, info, connection_options); } @@ -138,8 +135,8 @@ Status OfflineServiceController::RequestConnectionV3( const ConnectionOptions& connection_options) { if (stop_) return {Status::kOutOfOrderApiCall}; LOG(INFO) << "Client " << client->GetClientId() - << " requested a connection to endpoint_id " - << remote_device.GetEndpointId(); + << " requested a connection to endpoint_id " + << remote_device.GetEndpointId(); return pcp_manager_.RequestConnectionV3(client, remote_device, info, connection_options); } @@ -149,8 +146,7 @@ Status OfflineServiceController::AcceptConnection( PayloadListener listener) { if (stop_) return {Status::kOutOfOrderApiCall}; LOG(INFO) << "Client " << client->GetClientId() - << " accepted the connection from endpoint_id " - << endpoint_id; + << " accepted the connection from endpoint_id " << endpoint_id; return pcp_manager_.AcceptConnection(client, endpoint_id, std::move(listener)); } @@ -159,8 +155,7 @@ Status OfflineServiceController::RejectConnection( ClientProxy* client, const std::string& endpoint_id) { if (stop_) return {Status::kOutOfOrderApiCall}; LOG(INFO) << "Client " << client->GetClientId() - << " rejected the connection from endpoint_id " - << endpoint_id; + << " rejected the connection from endpoint_id " << endpoint_id; return pcp_manager_.RejectConnection(client, endpoint_id); } @@ -168,8 +163,8 @@ void OfflineServiceController::InitiateBandwidthUpgrade( ClientProxy* client, const std::string& endpoint_id) { if (stop_) return; LOG(INFO) << "Client " << client->GetClientId() - << " initiated a manual bandwidth upgrade with endpoint_id " - << endpoint_id; + << " initiated a manual bandwidth upgrade with endpoint_id " + << endpoint_id; bwu_manager_.InitiateBwuForEndpoint(client, endpoint_id); } @@ -178,17 +173,17 @@ void OfflineServiceController::SendPayload( Payload payload) { if (stop_) return; LOG(INFO) << "Client " << client->GetClientId() - << " is sending payload {id:" << payload.GetId() - << ", type:" << payload.GetType() << "} to endpoint_ids {" - << absl::StrJoin(endpoint_ids, ",") << "}"; + << " is sending payload {id:" << payload.GetId() + << ", type:" << payload.GetType() << "} to endpoint_ids {" + << absl::StrJoin(endpoint_ids, ",") << "}"; payload_manager_.SendPayload(client, endpoint_ids, std::move(payload)); } Status OfflineServiceController::CancelPayload(ClientProxy* client, std::int64_t payload_id) { if (stop_) return {Status::kOutOfOrderApiCall}; - LOG(INFO) << "Client " << client->GetClientId() - << " cancelled payload " << payload_id; + LOG(INFO) << "Client " << client->GetClientId() << " cancelled payload " + << payload_id; return payload_manager_.CancelPayload(client, payload_id); } @@ -196,8 +191,7 @@ void OfflineServiceController::DisconnectFromEndpoint( ClientProxy* client, const std::string& endpoint_id) { if (stop_) return; LOG(INFO) << "Client " << client->GetClientId() - << " requested a disconnection from endpoint_id " - << endpoint_id; + << " requested a disconnection from endpoint_id " << endpoint_id; endpoint_manager_.UnregisterEndpoint(client, endpoint_id); } @@ -205,10 +199,9 @@ Status OfflineServiceController::UpdateAdvertisingOptions( ClientProxy* client, absl::string_view service_id, const AdvertisingOptions& advertising_options) { if (stop_) return {Status::kOutOfOrderApiCall}; - LOG(INFO) - << "Client " << client->GetClientId() - << " requested to update advertising options for service_id " - << service_id; + LOG(INFO) << "Client " << client->GetClientId() + << " requested to update advertising options for service_id " + << service_id; return pcp_manager_.UpdateAdvertisingOptions(client, service_id, advertising_options); } @@ -218,8 +211,8 @@ Status OfflineServiceController::UpdateDiscoveryOptions( const DiscoveryOptions& discovery_options) { if (stop_) return {Status::kOutOfOrderApiCall}; LOG(INFO) << "Client " << client->GetClientId() - << " requested to update discovery options for service_id " - << service_id; + << " requested to update discovery options for service_id " + << service_id; return pcp_manager_.UpdateDiscoveryOptions(client, service_id, discovery_options); } @@ -228,7 +221,7 @@ void OfflineServiceController::SetCustomSavePath(ClientProxy* client, const std::string& path) { if (stop_) return; LOG(INFO) << "Client " << client->GetClientId() - << " requested to set custom save path to " << path; + << " requested to set custom save path to " << path; payload_manager_.SetCustomSavePath(client, path); } diff --git a/connections/implementation/offline_service_controller_test.cc b/connections/implementation/offline_service_controller_test.cc index aa68043b..b96dce0e 100644 --- a/connections/implementation/offline_service_controller_test.cc +++ b/connections/implementation/offline_service_controller_test.cc @@ -97,7 +97,8 @@ class OfflineServiceControllerTest config_package_nearby::nearby_connections_feature::kEnableBleV2, true); NearbyFlags::GetInstance().OverrideBoolFlagValue( config_package_nearby::nearby_connections_feature:: - kEnableSafeToDisconnect, false); + kEnableSafeToDisconnect, + false); } bool SetupConnection(OfflineSimulationUser& user_a, OfflineSimulationUser& user_b) { @@ -107,13 +108,11 @@ class OfflineServiceControllerTest EXPECT_EQ(user_b.GetDiscovered().service_id, kServiceId); EXPECT_EQ(user_b.GetDiscovered().endpoint_info, user_a.GetInfo()); EXPECT_FALSE(user_b.GetDiscovered().endpoint_id.empty()); - LOG(INFO) << "EP-B: [discovered] " - << user_b.GetDiscovered().endpoint_id; + LOG(INFO) << "EP-B: [discovered] " << user_b.GetDiscovered().endpoint_id; user_b.RequestConnection(&connect_latch_); EXPECT_TRUE(connect_latch_.Await(kLongTimeout)); EXPECT_FALSE(user_a.GetDiscovered().endpoint_id.empty()); - LOG(INFO) << "EP-A: [discovered] " - << user_a.GetDiscovered().endpoint_id; + LOG(INFO) << "EP-A: [discovered] " << user_a.GetDiscovered().endpoint_id; LOG(INFO) << "Both users discovered their peers."; user_a.AcceptConnection(&accept_latch_); user_b.AcceptConnection(&accept_latch_); diff --git a/connections/implementation/offline_simulation_user.cc b/connections/implementation/offline_simulation_user.cc index 53dfd0fb..054413f3 100644 --- a/connections/implementation/offline_simulation_user.cc +++ b/connections/implementation/offline_simulation_user.cc @@ -54,8 +54,7 @@ void OfflineSimulationUser::OnConnectionRejected(const std::string& endpoint_id, void OfflineSimulationUser::OnEndpointDisconnect( const std::string& endpoint_id) { - LOG(INFO) << "OnEndpointDisconnect: self=" << this - << "; id=" << endpoint_id; + LOG(INFO) << "OnEndpointDisconnect: self=" << this << "; id=" << endpoint_id; if (disconnect_latch_) disconnect_latch_->CountDown(); } diff --git a/connections/implementation/p2p_cluster_pcp_handler_test.cc b/connections/implementation/p2p_cluster_pcp_handler_test.cc index 4457f58b..31e96ade 100644 --- a/connections/implementation/p2p_cluster_pcp_handler_test.cc +++ b/connections/implementation/p2p_cluster_pcp_handler_test.cc @@ -213,8 +213,7 @@ TEST_F(P2pClusterPcpHandlerTest, [&latch](const std::string& endpoint_id, const ByteArray& endpoint_info, const std::string& service_id) { - LOG(INFO) - << "Device discovered: id=" << endpoint_id; + LOG(INFO) << "Device discovered: id=" << endpoint_id; latch.CountDown(); }, }), @@ -268,7 +267,7 @@ class P2pClusterPcpHandlerTestWithParam } LOG(INFO) << "SetUp: ble v2 enabled: " << ble_v2_enabled; LOG(INFO) << "SetUp: is_disable_bluetooth_scanning: " - << is_disable_bluetooth_scanning; + << is_disable_bluetooth_scanning; LOG(INFO) << "SetUp: end"; } @@ -562,8 +561,7 @@ TEST_P(P2pClusterPcpHandlerTestWithParam, CanDiscover) { [&latch](const std::string& endpoint_id, const ByteArray& endpoint_info, const std::string& service_id) { - LOG(INFO) - << "Device discovered: id=" << endpoint_id; + LOG(INFO) << "Device discovered: id=" << endpoint_id; latch.CountDown(); }, }), @@ -602,8 +600,7 @@ TEST_P(P2pClusterPcpHandlerTestWithParam, CanDiscoverLegacy) { [&latch](const std::string& endpoint_id, const ByteArray& endpoint_info, const std::string& service_id) { - LOG(INFO) - << "Device discovered: id=" << endpoint_id; + LOG(INFO) << "Device discovered: id=" << endpoint_id; latch.CountDown(); }, }), @@ -687,8 +684,7 @@ TEST_P(P2pClusterPcpHandlerTestWithParam, ResumeBluetoothClassicDiscovery) { [&latch](const std::string& endpoint_id, const ByteArray& endpoint_info, const std::string& service_id) { - LOG(INFO) - << "Device discovered: id=" << endpoint_id; + LOG(INFO) << "Device discovered: id=" << endpoint_id; latch.CountDown(); }, }), @@ -765,8 +761,7 @@ TEST_P(P2pClusterPcpHandlerTestWithParam, CanBluetoothDiscoverChangeName) { [&](const std::string& endpoint_id, const ByteArray& endpoint_info, const std::string& service_id) { - LOG(INFO) - << "Device discovered: id=" << endpoint_id; + LOG(INFO) << "Device discovered: id=" << endpoint_id; if (!first) { first_found_latch.CountDown(); first = true; @@ -1011,10 +1006,9 @@ TEST_P(P2pClusterPcpHandlerTestWithParam, CanConnect) { const std::string& endpoint_id, const ByteArray& endpoint_info, const std::string& service_id) { - LOG(INFO) - << "Device discovered: id=" << endpoint_id - << ", endpoint_info=" - << std::string{endpoint_info}; + LOG(INFO) << "Device discovered: id=" << endpoint_id + << ", endpoint_info=" + << std::string{endpoint_info}; discovered = { .endpoint_id = endpoint_id, .endpoint_info = endpoint_info, @@ -1047,8 +1041,7 @@ TEST_P(P2pClusterPcpHandlerTestWithParam, CanConnect) { .initiated_cb = [&connect_latch](const std::string& endpoint_id, const ConnectionResponseInfo& info) { - LOG(INFO) - << "RequestConnection: initiated_cb called"; + LOG(INFO) << "RequestConnection: initiated_cb called"; connect_latch.CountDown(); }, }}, diff --git a/connections/implementation/p2p_point_to_point_pcp_handler_test.cc b/connections/implementation/p2p_point_to_point_pcp_handler_test.cc index 93af89e0..b2b280bb 100644 --- a/connections/implementation/p2p_point_to_point_pcp_handler_test.cc +++ b/connections/implementation/p2p_point_to_point_pcp_handler_test.cc @@ -21,7 +21,6 @@ #include #include "gtest/gtest.h" - #include "absl/time/time.h" #include "connections/advertising_options.h" #include "connections/connection_options.h" @@ -199,10 +198,9 @@ TEST_P(P2pPointToPointPcpHandlerTest, CanConnect) { const std::string& endpoint_id, const ByteArray& endpoint_info, const std::string& service_id) { - LOG(INFO) - << "Device discovered: id=" << endpoint_id - << ", endpoint_info=" - << endpoint_info.AsStringView(); + LOG(INFO) << "Device discovered: id=" << endpoint_id + << ", endpoint_info=" + << endpoint_info.AsStringView(); discovered = { .endpoint_id = endpoint_id, .endpoint_info = endpoint_info, @@ -235,8 +233,7 @@ TEST_P(P2pPointToPointPcpHandlerTest, CanConnect) { .initiated_cb = [&connect_latch](const std::string& endpoint_id, const ConnectionResponseInfo& info) { - LOG(INFO) - << "RequestConnection: initiated_cb called"; + LOG(INFO) << "RequestConnection: initiated_cb called"; connect_latch.CountDown(); }, }}, diff --git a/connections/implementation/payload_manager_test.cc b/connections/implementation/payload_manager_test.cc index 925a8d42..98d7ceaa 100644 --- a/connections/implementation/payload_manager_test.cc +++ b/connections/implementation/payload_manager_test.cc @@ -41,8 +41,8 @@ namespace connections { namespace { using ::location::nearby::connections::OfflineFrame; using ::location::nearby::connections::PayloadTransferFrame; -using ::nearby::analytics::PacketMetaData; using ::location::nearby::proto::connections::Medium; +using ::nearby::analytics::PacketMetaData; constexpr size_t kChunkSize = 64 * 1024; constexpr absl::string_view kServiceId = "service-id"; @@ -148,13 +148,11 @@ class PayloadManagerTest EXPECT_EQ(user_b.GetDiscovered().service_id, kServiceId); EXPECT_EQ(user_b.GetDiscovered().endpoint_info, user_a.GetInfo()); EXPECT_FALSE(user_b.GetDiscovered().endpoint_id.empty()); - LOG(INFO) << "EP-B: [discovered] " - << user_b.GetDiscovered().endpoint_id; + LOG(INFO) << "EP-B: [discovered] " << user_b.GetDiscovered().endpoint_id; user_b.RequestConnection(&connection_latch_); EXPECT_TRUE(connection_latch_.Await(kDefaultTimeout).result()); EXPECT_FALSE(user_a.GetDiscovered().endpoint_id.empty()); - LOG(INFO) << "EP-A: [discovered] " - << user_a.GetDiscovered().endpoint_id; + LOG(INFO) << "EP-A: [discovered] " << user_a.GetDiscovered().endpoint_id; LOG(INFO) << "Both users discovered their peers."; user_a.AcceptConnection(&accept_latch_); user_b.AcceptConnection(&accept_latch_); diff --git a/connections/implementation/pcp_manager.cc b/connections/implementation/pcp_manager.cc index 236e1b35..eb35652a 100644 --- a/connections/implementation/pcp_manager.cc +++ b/connections/implementation/pcp_manager.cc @@ -216,7 +216,7 @@ bool PcpManager::SetCurrentPcpHandler(Strategy strategy) { if (!current_) { LOG(ERROR) << "Failed to set current PCP handler: strategy=" - << strategy.GetName(); + << strategy.GetName(); } return current_; diff --git a/connections/implementation/reconnect_manager_test.cc b/connections/implementation/reconnect_manager_test.cc index a81c05e3..85c34231 100644 --- a/connections/implementation/reconnect_manager_test.cc +++ b/connections/implementation/reconnect_manager_test.cc @@ -41,9 +41,7 @@ constexpr absl::string_view kDeviceB = "device-b"; constexpr absl::Duration kDefaultTimeout = absl::Milliseconds(1000); constexpr BooleanMediumSelector kTestCases[] = { - BooleanMediumSelector{ - .bluetooth = true - }, + BooleanMediumSelector{.bluetooth = true}, }; class ReconnectSimulatorUser : public SimulationUser { @@ -75,13 +73,11 @@ class ReconnectManagerTest EXPECT_EQ(user_b.GetDiscovered().service_id, kServiceId); EXPECT_EQ(user_b.GetDiscovered().endpoint_info, user_a.GetInfo()); EXPECT_FALSE(user_b.GetDiscovered().endpoint_id.empty()); - LOG(INFO) << "EP-B: [discovered]" - << user_b.GetDiscovered().endpoint_id; + LOG(INFO) << "EP-B: [discovered]" << user_b.GetDiscovered().endpoint_id; user_b.RequestConnection(&connection_latch_); EXPECT_TRUE(connection_latch_.Await(kDefaultTimeout).result()); EXPECT_FALSE(user_a.GetDiscovered().endpoint_id.empty()); - LOG(INFO) << "EP-A: [discovered]" - << user_a.GetDiscovered().endpoint_id; + LOG(INFO) << "EP-A: [discovered]" << user_a.GetDiscovered().endpoint_id; LOG(INFO) << "Both users discovered their peers."; user_a.AcceptConnection(&accept_latch_); user_b.AcceptConnection(&accept_latch_); @@ -98,8 +94,8 @@ class ReconnectManagerTest }; TEST_P(ReconnectManagerTest, AllowReconnect) { - FeatureFlags::Flags feature_flags = { - .enable_cancellation_flag = std::get<1>(GetParam())}; + FeatureFlags::Flags feature_flags = {.enable_cancellation_flag = + std::get<1>(GetParam())}; env_.SetFeatureFlags(feature_flags); env_.Start(); @@ -111,15 +107,14 @@ TEST_P(ReconnectManagerTest, AllowReconnect) { ReconnectManager::AutoReconnectCallback auto_reconnect_callback = { .on_reconnect_success_cb = [&](ClientProxy* client, const std::string& endpoint_id) { - LOG(INFO) - << " Reconnect successfully for endpoint_id: " << endpoint_id; + LOG(INFO) << " Reconnect successfully for endpoint_id: " + << endpoint_id; }, .on_reconnect_failure_cb = [&](ClientProxy* client, const std::string& endpoint_id, bool send_disconnection_notification, DisconnectionReason disconnection_reason) { - LOG(INFO) - << " Reconnect failed for endpoint_id: " << endpoint_id; + LOG(INFO) << " Reconnect failed for endpoint_id: " << endpoint_id; }, }; diff --git a/connections/implementation/service_controller_router.cc b/connections/implementation/service_controller_router.cc index 8aa3294f..96a465e9 100644 --- a/connections/implementation/service_controller_router.cc +++ b/connections/implementation/service_controller_router.cc @@ -511,7 +511,7 @@ void ServiceControllerRouter::RequestConnectionV3( client, remote_device, std::move(old_info), connection_options); if (!status.Ok()) { LOG(WARNING) << "Unable to request connection to endpoint " - << endpoint_id << ": " << status.ToString(); + << endpoint_id << ": " << status.ToString(); client->CancelEndpoint(endpoint_id); } callback(status); @@ -697,8 +697,8 @@ void ServiceControllerRouter::StopAllEndpoints(ClientProxy* client, "scr-stop-all-endpoints", [this, client, callback = std::move(callback)]() mutable { LOG(INFO) << "Client " << client->GetClientId() - << " has requested us to stop all endpoints. We will " - "now reset the client."; + << " has requested us to stop all endpoints. We will " + "now reset the client."; FinishClientSession(client); callback({Status::kSuccess}); }); @@ -711,8 +711,7 @@ void ServiceControllerRouter::SetCustomSavePath(ClientProxy* client, "scr-set-custom-save-path", [this, client, path = std::string(path), callback = std::move(callback)]() mutable { LOG(INFO) << "Client " << client->GetClientId() - << " has requested us to set custom save path to " - << path; + << " has requested us to set custom save path to " << path; GetServiceController()->SetCustomSavePath(client, path); callback({Status::kSuccess}); }); diff --git a/connections/implementation/webrtc_bwu_handler.cc b/connections/implementation/webrtc_bwu_handler.cc index 003988c9..b611cf88 100644 --- a/connections/implementation/webrtc_bwu_handler.cc +++ b/connections/implementation/webrtc_bwu_handler.cc @@ -88,34 +88,31 @@ WebrtcBwuHandler::CreateUpgradedEndpointChannel( if (web_rtc_credentials.has_location_hint()) { location_hint = web_rtc_credentials.location_hint(); } - LOG(INFO) - << "WebRtcBwuHandler is attempting to connect to remote peer " - << peer_id.GetId() << ", location hint " - << absl::StrCat(location_hint.location()); + LOG(INFO) << "WebRtcBwuHandler is attempting to connect to remote peer " + << peer_id.GetId() << ", location hint " + << location_hint.location(); ErrorOr socket_result = webrtc_.Connect( service_id, peer_id, location_hint, client->GetCancellationFlag(endpoint_id), client->GetWebRtcNonCellular()); if (socket_result.has_error()) { LOG(ERROR) << "WebRtcBwuHandler failed to connect to remote peer (" - << peer_id.GetId() << ") on endpoint " << endpoint_id - << ", aborting upgrade."; + << peer_id.GetId() << ") on endpoint " << endpoint_id + << ", aborting upgrade."; return {Error(socket_result.error().operation_result_code().value())}; } LOG(INFO) << "WebRtcBwuHandler successfully connected to remote " - "peer (" - << peer_id.GetId() << ") while upgrading endpoint " - << endpoint_id; + "peer (" + << peer_id.GetId() << ") while upgrading endpoint " << endpoint_id; // Create a new WebRtcEndpointChannel. auto channel = std::make_unique( service_id, /*channel_name=*/service_id, socket_result.value()); if (channel == nullptr) { socket_result.value().Close(); - LOG(ERROR) - << "WebRtcBwuHandler failed to create new EndpointChannel for " - "outgoing socket, aborting upgrade."; + LOG(ERROR) << "WebRtcBwuHandler failed to create new EndpointChannel for " + "outgoing socket, aborting upgrade."; return {Error( OperationResultCode::NEARBY_WEB_RTC_ENDPOINT_CHANNEL_CREATION_FAILURE)}; } @@ -126,9 +123,8 @@ WebrtcBwuHandler::CreateUpgradedEndpointChannel( void WebrtcBwuHandler::HandleRevertInitiatorStateForService( const std::string& upgrade_service_id) { webrtc_.StopAcceptingConnections(upgrade_service_id); - LOG(INFO) - << "WebrtcBwuHandler successfully reverted state for service " - << upgrade_service_id; + LOG(INFO) << "WebrtcBwuHandler successfully reverted state for service " + << upgrade_service_id; } // Called by BWU initiator. Set up WebRTC upgraded medium for this endpoint, @@ -148,15 +144,15 @@ ByteArray WebrtcBwuHandler::HandleInitializeUpgradedMediumForEndpoint( this, client), client->GetWebRtcNonCellular())) { LOG(ERROR) << "WebRtcBwuHandler couldn't initiate the WEB_RTC " - "upgrade for endpoint " - << endpoint_id - << " because it failed to start listening for " - "incoming WebRTC connections."; + "upgrade for endpoint " + << endpoint_id + << " because it failed to start listening for " + "incoming WebRTC connections."; return {}; } LOG(INFO) << "WebRtcBwuHandler successfully started listening for " - "incoming WebRTC connections while upgrading endpoint " - << endpoint_id; + "incoming WebRTC connections while upgrading endpoint " + << endpoint_id; } return parser::ForBwuWebrtcPathAvailable(self_id.GetId(), location_hint); diff --git a/connections/implementation/wifi_direct_bwu_handler.cc b/connections/implementation/wifi_direct_bwu_handler.cc index 44af3c04..a46d17dc 100644 --- a/connections/implementation/wifi_direct_bwu_handler.cc +++ b/connections/implementation/wifi_direct_bwu_handler.cc @@ -84,8 +84,8 @@ ByteArray WifiDirectBwuHandler::HandleInitializeUpgradedMediumForEndpoint( int freq = wifi_direct_crendential->GetFrequency(); LOG(INFO) << "Start WifiDirect GO with SSID: " << ssid - << ", Password: " << password << ", Port: " << port - << ", Gateway: " << gateway << ", Frequency: " << freq; + << ", Password: " << password << ", Port: " << port + << ", Gateway: " << gateway << ", Frequency: " << freq; bool disabling_encryption = (client->GetAdvertisingOptions().strategy == Strategy::kP2pPointToPoint); @@ -100,9 +100,8 @@ void WifiDirectBwuHandler::HandleRevertInitiatorStateForService( wifi_direct_medium_.StopWifiDirect(); wifi_direct_medium_.DisconnectWifiDirect(); - LOG(INFO) - << "WifiDirectBwuHandler successfully reverted all states for " - << "upgrade service ID " << upgrade_service_id; + LOG(INFO) << "WifiDirectBwuHandler successfully reverted all states for " + << "upgrade service ID " << upgrade_service_id; } ErrorOr> @@ -123,8 +122,8 @@ WifiDirectBwuHandler::CreateUpgradedEndpointChannel( const std::string& gateway = upgrade_path_info_credentials.gateway(); LOG(INFO) << "Received WifiDirect credential SSID: " << ssid - << ", Password:" << password << ", Port:" << port - << ", Gateway:" << gateway; + << ", Password:" << password << ", Port:" << port + << ", Gateway:" << gateway; if (!wifi_direct_medium_.ConnectWifiDirect(ssid, password)) { LOG(ERROR) << "Connect to WifiDiret GO failed"; @@ -147,7 +146,7 @@ WifiDirectBwuHandler::CreateUpgradedEndpointChannel( // Create a new WifiDirectEndpointChannel. return {std::make_unique( - service_id, /*channel_name=*/service_id, socket_result.value())}; + service_id, /*channel_name=*/service_id, socket_result.value())}; } void WifiDirectBwuHandler::OnIncomingWifiDirectConnection( diff --git a/connections/implementation/wifi_lan_bwu_handler.cc b/connections/implementation/wifi_lan_bwu_handler.cc index 9f65bba7..93e89a6b 100644 --- a/connections/implementation/wifi_lan_bwu_handler.cc +++ b/connections/implementation/wifi_lan_bwu_handler.cc @@ -66,31 +66,29 @@ WifiLanBwuHandler::CreateUpgradedEndpointChannel( std::int32_t port = upgrade_path_info_socket.wifi_port(); VLOG(1) << "WifiLanBwuHandler is attempting to connect to " - << "available WifiLan service (" << ip_address << ":" << port - << ") for endpoint " << endpoint_id; + << "available WifiLan service (" << ip_address << ":" << port + << ") for endpoint " << endpoint_id; ErrorOr socket_result = wifi_lan_medium_.Connect( service_id, ip_address, port, client->GetCancellationFlag(endpoint_id)); if (socket_result.has_error()) { - LOG(ERROR) - << "WifiLanBwuHandler failed to connect to the WifiLan service (" - << WifiUtils::GetHumanReadableIpAddress(ip_address) << ":" << port - << ") for endpoint " << endpoint_id; + LOG(ERROR) << "WifiLanBwuHandler failed to connect to the WifiLan service (" + << WifiUtils::GetHumanReadableIpAddress(ip_address) << ":" + << port << ") for endpoint " << endpoint_id; return {Error(socket_result.error().operation_result_code().value())}; } - VLOG(1) - << "WifiLanBwuHandler successfully connected to WifiLan service (" - << ip_address << ":" << port << ") while upgrading endpoint " - << endpoint_id; + VLOG(1) << "WifiLanBwuHandler successfully connected to WifiLan service (" + << ip_address << ":" << port << ") while upgrading endpoint " + << endpoint_id; // Create a new WifiLanEndpointChannel. auto channel = std::make_unique( service_id, /*channel_name=*/service_id, socket_result.value()); if (channel == nullptr) { LOG(ERROR) << "WifiLanBwuHandler failed to create WifiLan endpoint " - << "channel to the WifiLan service (" << ip_address - << ":" << port << ") for endpoint " << endpoint_id; + << "channel to the WifiLan service (" << ip_address << ":" + << port << ") for endpoint " << endpoint_id; socket_result.value().Close(); return {Error( OperationResultCode::NEARBY_LAN_ENDPOINT_CHANNEL_CREATION_FAILURE)}; @@ -130,17 +128,16 @@ ByteArray WifiLanBwuHandler::HandleInitializeUpgradedMediumForEndpoint( auto ip_address = credential.first; auto port = credential.second; if (ip_address.empty()) { - LOG(INFO) - << "WifiLanBwuHandler couldn't initiate the wifi_lan upgrade for " - << "service " << upgrade_service_id << " and endpoint " << endpoint_id - << " because the wifi_lan ip address were unable to be obtained."; + LOG(INFO) << "WifiLanBwuHandler couldn't initiate the wifi_lan upgrade for " + << "service " << upgrade_service_id << " and endpoint " + << endpoint_id + << " because the wifi_lan ip address were unable to be obtained."; return {}; } - LOG(INFO) - << "WifiLanBwuHandler retrieved WIFI_LAN credentials. IP addr: " - << ip_address[0] << "." << ip_address[1] << "." << ip_address[2] << "." - << ip_address[3] << ", Port: " << port; + LOG(INFO) << "WifiLanBwuHandler retrieved WIFI_LAN credentials. IP addr: " + << ip_address[0] << "." << ip_address[1] << "." << ip_address[2] + << "." << ip_address[3] << ", Port: " << port; return parser::ForBwuWifiLanPathAvailable(ip_address, port); } @@ -149,7 +146,7 @@ void WifiLanBwuHandler::HandleRevertInitiatorStateForService( const std::string& upgrade_service_id) { wifi_lan_medium_.StopAcceptingConnections(upgrade_service_id); LOG(INFO) << "WifiLanBwuHandler successfully reverted all states for " - << "upgrade service ID " << upgrade_service_id; + << "upgrade service ID " << upgrade_service_id; } // Accept Connection Callback. diff --git a/connections/implementation/wifi_lan_endpoint_channel.cc b/connections/implementation/wifi_lan_endpoint_channel.cc index 62c11a1e..ec3e02b1 100644 --- a/connections/implementation/wifi_lan_endpoint_channel.cc +++ b/connections/implementation/wifi_lan_endpoint_channel.cc @@ -37,15 +37,14 @@ location::nearby::proto::connections::Medium WifiLanEndpointChannel::GetMedium() void WifiLanEndpointChannel::CloseImpl() { auto status = socket_.Close(); if (!status.Ok()) { - LOG(INFO) - << "Failed to close underlying socket for WifiLanEndpointChannel " - << GetName() << " : exception = " << status.value; + LOG(INFO) << "Failed to close underlying socket for WifiLanEndpointChannel " + << GetName() << " : exception = " << status.value; } } bool WifiLanEndpointChannel::EnableMultiplexSocket() { LOG(INFO) << "WifiLanEndpointChannel MultiplexSocket will be " - "enabled if the WifiLan MultiplexSocket is valid"; + "enabled if the WifiLan MultiplexSocket is valid"; socket_.EnableMultiplexSocket(); return true; } diff --git a/internal/network/http_client_impl.cc b/internal/network/http_client_impl.cc index e3bb5b74..75878579 100644 --- a/internal/network/http_client_impl.cc +++ b/internal/network/http_client_impl.cc @@ -39,27 +39,26 @@ void NearbyHttpClient::StartRequest( const HttpRequest& request, absl::AnyInvocable&)> callback) { MutexLock lock(&mutex_); - executor_.Execute( - [request = std::move(request), callback = std::move(callback)]() mutable { - LOG(INFO) << __func__ << ": Start async request to url=" - << request.GetUrl().GetUrlPath(); - absl::StatusOr response = InternalGetResponse(request); - if (response.ok()) { - LOG(INFO) - << __func__ - << ": Got response from url=" << request.GetUrl().GetUrlPath(); - } else { - LOG(ERROR) << __func__ << ": Failed to get response from url=" - << request.GetUrl().GetUrlPath() << ", status" - << response.status(); - } + executor_.Execute([request = std::move(request), + callback = std::move(callback)]() mutable { + LOG(INFO) << __func__ << ": Start async request to url=" + << request.GetUrl().GetUrlPath(); + absl::StatusOr response = InternalGetResponse(request); + if (response.ok()) { + LOG(INFO) << __func__ + << ": Got response from url=" << request.GetUrl().GetUrlPath(); + } else { + LOG(ERROR) << __func__ << ": Failed to get response from url=" + << request.GetUrl().GetUrlPath() << ", status" + << response.status(); + } - if (callback) { - callback(response); - } - LOG(INFO) << __func__ << ": Completed request to url=" - << request.GetUrl().GetUrlPath(); - }); + if (callback) { + callback(response); + } + LOG(INFO) << __func__ + << ": Completed request to url=" << request.GetUrl().GetUrlPath(); + }); } void NearbyHttpClient::StartCancellableRequest( @@ -71,63 +70,55 @@ void NearbyHttpClient::StartCancellableRequest( callback(absl::InvalidArgumentError("invalid cancellable request")); return; } - executor_ - .Execute( - [cancellable_request = std::move(cancellable_request), - callback = std::move(callback)]() mutable { - LOG(INFO) - << __func__ << ": Start async request to url=" + executor_.Execute([cancellable_request = std::move(cancellable_request), + callback = std::move(callback)]() mutable { + LOG(INFO) << __func__ << ": Start async request to url=" + << cancellable_request->http_request().GetUrl().GetUrlPath(); + if (cancellable_request->is_cancelled()) { + LOG(WARNING) << __func__ << ": Async request to url=" + << cancellable_request->http_request().GetUrl().GetUrlPath() + << " is cancelled."; + return; + } + absl::StatusOr response = + InternalGetResponse(cancellable_request->http_request()); + if (response.ok()) { + LOG(INFO) << __func__ << ": Got response from url=" << cancellable_request->http_request().GetUrl().GetUrlPath(); - if (cancellable_request->is_cancelled()) { - LOG(WARNING) - << __func__ << ": Async request to url=" - << cancellable_request->http_request().GetUrl().GetUrlPath() - << " is cancelled."; - return; - } - absl::StatusOr response = - InternalGetResponse(cancellable_request->http_request()); - if (response.ok()) { - LOG(INFO) - << __func__ << ": Got response from url=" - << cancellable_request->http_request().GetUrl().GetUrlPath(); - } else { - LOG(ERROR) - << __func__ << ": Failed to get response from url=" - << cancellable_request->http_request().GetUrl().GetUrlPath() - << ", status" << response.status(); - } + } else { + LOG(ERROR) << __func__ << ": Failed to get response from url=" + << cancellable_request->http_request().GetUrl().GetUrlPath() + << ", status" << response.status(); + } - if (cancellable_request->is_cancelled()) { - LOG(WARNING) - << __func__ << ": Async request to url=" - << cancellable_request->http_request().GetUrl().GetUrlPath() - << " is cancelled."; - return; - } + if (cancellable_request->is_cancelled()) { + LOG(WARNING) << __func__ << ": Async request to url=" + << cancellable_request->http_request().GetUrl().GetUrlPath() + << " is cancelled."; + return; + } - if (callback) { - callback(response); - } - LOG(INFO) - << __func__ << ": Completed request to url=" - << cancellable_request->http_request().GetUrl().GetUrlPath(); - }); + if (callback) { + callback(response); + } + LOG(INFO) << __func__ << ": Completed request to url=" + << cancellable_request->http_request().GetUrl().GetUrlPath(); + }); } absl::StatusOr NearbyHttpClient::GetResponse( const HttpRequest& request) { - LOG(INFO) << __func__ << ": Start request to url=" - << request.GetUrl().GetUrlPath(); + LOG(INFO) << __func__ + << ": Start request to url=" << request.GetUrl().GetUrlPath(); absl::StatusOr response = InternalGetResponse(request); if (response.ok()) { - LOG(INFO) << __func__ << ": Got response from url=" - << request.GetUrl().GetUrlPath(); + LOG(INFO) << __func__ + << ": Got response from url=" << request.GetUrl().GetUrlPath(); } else { LOG(ERROR) << __func__ << ": Failed to get response from url=" - << request.GetUrl().GetUrlPath() << ", status" - << response.status(); + << request.GetUrl().GetUrlPath() << ", status" + << response.status(); } return response; diff --git a/internal/platform/awdl.h b/internal/platform/awdl.h index ddde1a3b..66dc63f4 100644 --- a/internal/platform/awdl.h +++ b/internal/platform/awdl.h @@ -167,7 +167,7 @@ class AwdlServerSocket final { std::unique_ptr socket = impl_->Accept(); if (!socket) { LOG(INFO) << "AwdlServerSocket Accept() failed on server socket: " - << this; + << this; } return AwdlSocket(std::move(socket)); } diff --git a/internal/platform/ble.cc b/internal/platform/ble.cc index ca800f81..7994ab34 100644 --- a/internal/platform/ble.cc +++ b/internal/platform/ble.cc @@ -70,8 +70,8 @@ bool BleMedium::StartScanning( auto context = peripherals_.find(&peripheral); if (context == peripherals_.end()) return; LOG(INFO) << "Removing peripheral=" - << context->second->peripheral.GetName() - << ", impl=" << &peripheral; + << context->second->peripheral.GetName() + << ", impl=" << &peripheral; discovered_peripheral_callback_.peripheral_lost_cb( context->second->peripheral, service_id); }, @@ -103,11 +103,11 @@ bool BleMedium::StartAcceptingConnections(const std::string& service_id, auto& context = *pair.first->second; if (!pair.second) { LOG(INFO) << "Accepting (again) socket=" << &context.socket - << ", impl=" << &socket; + << ", impl=" << &socket; } else { context.socket = BleSocket(&socket); - LOG(INFO) - << "Accepting socket=" << &context.socket << ", impl=" << &socket; + LOG(INFO) << "Accepting socket=" << &context.socket + << ", impl=" << &socket; } if (accepted_connection_callback_) { accepted_connection_callback_(context.socket, service_id); @@ -120,8 +120,7 @@ bool BleMedium::StopAcceptingConnections(const std::string& service_id) { MutexLock lock(&mutex_); accepted_connection_callback_ = nullptr; sockets_.clear(); - LOG(INFO) << "Ble accepted connection disabled: impl=" - << &GetImpl(); + LOG(INFO) << "Ble accepted connection disabled: impl=" << &GetImpl(); } return impl_->StopAcceptingConnections(service_id); } @@ -131,9 +130,8 @@ BleSocket BleMedium::Connect(BlePeripheral& peripheral, CancellationFlag* cancellation_flag) { { MutexLock lock(&mutex_); - LOG(INFO) << "BleMedium::Connect: peripheral=" - << peripheral.GetName() - << ",impl=" << &peripheral.GetImpl(); + LOG(INFO) << "BleMedium::Connect: peripheral=" << peripheral.GetName() + << ",impl=" << &peripheral.GetImpl(); } return BleSocket( impl_->Connect(peripheral.GetImpl(), service_id, cancellation_flag)); diff --git a/internal/platform/ble_test.cc b/internal/platform/ble_test.cc index 853e96e8..3f7466cf 100644 --- a/internal/platform/ble_test.cc +++ b/internal/platform/ble_test.cc @@ -78,10 +78,9 @@ TEST_P(BleMediumTest, CanStartAcceptingConnectionsAndConnect) { BlePeripheral& peripheral, const std::string& service_id, const ByteArray& advertisement_bytes, bool fast_advertisement) { - LOG(INFO) - << "Discovered peripheral=" << peripheral.GetName() - << ", impl=" << &peripheral.GetImpl() - << ", fast advertisement=" << fast_advertisement; + LOG(INFO) << "Discovered peripheral=" << peripheral.GetName() + << ", impl=" << &peripheral.GetImpl() + << ", fast advertisement=" << fast_advertisement; discovered_peripheral = &peripheral; found_latch.CountDown(); }, @@ -91,7 +90,7 @@ TEST_P(BleMediumTest, CanStartAcceptingConnectionsAndConnect) { ble_b.StartAcceptingConnections( service_id, [&](BleSocket socket, const std::string& service_id) { LOG(INFO) << "Connection accepted: socket=" << &socket - << ", service_id=" << service_id; + << ", service_id=" << service_id; accepted_latch.CountDown(); }); EXPECT_TRUE(found_latch.Await(kWaitDuration).result()); @@ -136,10 +135,9 @@ TEST_P(BleMediumTest, CanCancelConnect) { BlePeripheral& peripheral, const std::string& service_id, const ByteArray& advertisement_bytes, bool fast_advertisement) { - LOG(INFO) - << "Discovered peripheral=" << peripheral.GetName() - << ", impl=" << &peripheral.GetImpl() - << ", fast advertisement=" << fast_advertisement; + LOG(INFO) << "Discovered peripheral=" << peripheral.GetName() + << ", impl=" << &peripheral.GetImpl() + << ", fast advertisement=" << fast_advertisement; discovered_peripheral = &peripheral; found_latch.CountDown(); }, @@ -149,7 +147,7 @@ TEST_P(BleMediumTest, CanCancelConnect) { ble_b.StartAcceptingConnections( service_id, [&](BleSocket socket, const std::string& service_id) { LOG(INFO) << "Connection accepted: socket=" << &socket - << ", service_id=" << service_id; + << ", service_id=" << service_id; accepted_latch.CountDown(); }); EXPECT_TRUE(found_latch.Await(kWaitDuration).result()); diff --git a/internal/platform/blocking_queue_stream.cc b/internal/platform/blocking_queue_stream.cc index d31fee93..aa1d6df7 100644 --- a/internal/platform/blocking_queue_stream.cc +++ b/internal/platform/blocking_queue_stream.cc @@ -27,9 +27,9 @@ namespace nearby { BlockingQueueStream::BlockingQueueStream() { LOG(INFO) << "Create a BlockingQueueStream with size " - << FeatureFlags::GetInstance() - .GetFlags() - .blocking_queue_stream_queue_capacity; + << FeatureFlags::GetInstance() + .GetFlags() + .blocking_queue_stream_queue_capacity; } ExceptionOr BlockingQueueStream::Read(std::int64_t size) { @@ -39,8 +39,7 @@ ExceptionOr BlockingQueueStream::Read(std::int64_t size) { } if (is_closed_) { - LOG(INFO) - << "Failed to read BlockingQueueStream because it was closed."; + LOG(INFO) << "Failed to read BlockingQueueStream because it was closed."; return ExceptionOr(Exception::kIo); } @@ -67,8 +66,7 @@ void BlockingQueueStream::Write(const ByteArray& bytes) { return; } if (is_closed_) { - LOG(INFO) - << "Failed to write BlockingQueueStream because it was closed."; + LOG(INFO) << "Failed to write BlockingQueueStream because it was closed."; return; } is_writing_ = true; diff --git a/internal/platform/bluetooth_classic_test.cc b/internal/platform/bluetooth_classic_test.cc index 134a0a79..38864ff9 100644 --- a/internal/platform/bluetooth_classic_test.cc +++ b/internal/platform/bluetooth_classic_test.cc @@ -600,8 +600,7 @@ TEST_F(BluetoothClassicMediumTest, CancelBluetoothPairing) { bt_a_->StartDiscovery( DiscoveryCallback{.device_discovered_cb = [&](BluetoothDevice& device) { LOG(INFO) << "Device discovered: " << device.GetName(); - LOG(INFO) << "Device discovered address: " - << device.GetMacAddress(); + LOG(INFO) << "Device discovered address: " << device.GetMacAddress(); EXPECT_EQ(device.GetName(), adapter_b_->GetName()); discovered_device = &device; found_latch.CountDown(); diff --git a/internal/platform/implementation/g3/ble.cc b/internal/platform/implementation/g3/ble.cc index 65c8d1c8..e847f3a3 100644 --- a/internal/platform/implementation/g3/ble.cc +++ b/internal/platform/implementation/g3/ble.cc @@ -65,8 +65,7 @@ bool BleServerSocket::Connect(BleSocket& socket) { absl::MutexLock lock(&mutex_); if (closed_) return false; if (socket.IsConnected()) { - LOG(ERROR) - << "Failed to connect to Ble server socket: already connected"; + LOG(ERROR) << "Failed to connect to Ble server socket: already connected"; return true; // already connected. } // add client socket to the pending list @@ -128,7 +127,7 @@ BleMedium::~BleMedium() { accept_loops_runner_.Shutdown(); LOG(INFO) << "BleMedium dtor advertising_accept_thread_running_ = " - << acceptance_thread_running_.load(); + << acceptance_thread_running_.load(); // If acceptance thread is still running, wait to finish. if (acceptance_thread_running_) { while (acceptance_thread_running_) { @@ -143,11 +142,11 @@ bool BleMedium::StartAdvertising( const std::string& service_id, const ByteArray& advertisement_bytes, const std::string& fast_advertisement_service_uuid) { LOG(INFO) << "G3 Ble StartAdvertising: service_id=" << service_id - << ", advertisement bytes=" - << absl::BytesToHexString(std::string(advertisement_bytes)) - << "(" << advertisement_bytes.size() << ")," - << ", fast advertisement service uuid=" - << absl::BytesToHexString(fast_advertisement_service_uuid); + << ", advertisement bytes=" + << absl::BytesToHexString(std::string(advertisement_bytes)) << "(" + << advertisement_bytes.size() << ")," + << ", fast advertisement service uuid=" + << absl::BytesToHexString(fast_advertisement_service_uuid); auto& env = MediumEnvironment::Instance(); auto& peripheral = adapter_->GetPeripheral(); peripheral.SetAdvertisementBytes(service_id, advertisement_bytes); @@ -181,7 +180,7 @@ bool BleMedium::StopAdvertising(const std::string& service_id) { absl::MutexLock lock(&mutex_); if (advertising_info_.Empty()) { LOG(INFO) << "G3 Ble StopAdvertising: Can't stop advertising " - "because we never started advertising."; + "because we never started advertising."; return false; } advertising_info_.Clear(); @@ -194,8 +193,8 @@ bool BleMedium::StopAdvertising(const std::string& service_id) { accept_loops_runner_.Shutdown(); if (server_socket_ == nullptr) { LOG(ERROR) << "G3 Ble StopAdvertising: Failed to find Ble Server " - "socket: service_id=" - << service_id; + "socket: service_id=" + << service_id; // Fall through for server socket not found. return true; } @@ -231,7 +230,7 @@ bool BleMedium::StopScanning(const std::string& service_id) { absl::MutexLock lock(&mutex_); if (scanning_info_.Empty()) { LOG(INFO) << "G3 Ble StopDiscovery: Can't stop scanning because " - "we never started scanning."; + "we never started scanning."; return false; } scanning_info_.Clear(); @@ -244,8 +243,7 @@ bool BleMedium::StopScanning(const std::string& service_id) { bool BleMedium::StartAcceptingConnections(const std::string& service_id, AcceptedConnectionCallback callback) { - LOG(INFO) << "G3 Ble StartAcceptingConnections: service_id=" - << service_id; + LOG(INFO) << "G3 Ble StartAcceptingConnections: service_id=" << service_id; auto& env = MediumEnvironment::Instance(); env.UpdateBleMediumForAcceptedConnection(*this, service_id, std::move(callback)); @@ -253,8 +251,7 @@ bool BleMedium::StartAcceptingConnections(const std::string& service_id, } bool BleMedium::StopAcceptingConnections(const std::string& service_id) { - LOG(INFO) << "G3 Ble StopAcceptingConnections: service_id=" - << service_id; + LOG(INFO) << "G3 Ble StopAcceptingConnections: service_id=" << service_id; auto& env = MediumEnvironment::Instance(); env.UpdateBleMediumForAcceptedConnection(*this, service_id, {}); return true; @@ -264,9 +261,9 @@ std::unique_ptr BleMedium::Connect( api::BlePeripheral& remote_peripheral, const std::string& service_id, CancellationFlag* cancellation_flag) { LOG(INFO) << "G3 Ble Connect [self]: medium=" << this - << ", adapter=" << &GetAdapter() - << ", peripheral=" << &GetAdapter().GetPeripheral() - << ", service_id=" << service_id; + << ", adapter=" << &GetAdapter() + << ", peripheral=" << &GetAdapter().GetPeripheral() + << ", service_id=" << service_id; // First, find an instance of remote medium, that exposed this peripheral. auto& adapter = static_cast(remote_peripheral).GetAdapter(); auto* medium = static_cast(adapter.GetBleMedium()); @@ -275,9 +272,8 @@ std::unique_ptr BleMedium::Connect( BleServerSocket* remote_server_socket = nullptr; LOG(INFO) << "G3 Ble Connect [peer]: medium=" << medium - << ", adapter=" << &adapter - << ", peripheral=" << &remote_peripheral - << ", service_id=" << service_id; + << ", adapter=" << &adapter << ", peripheral=" << &remote_peripheral + << ", service_id=" << service_id; // Then, find our server socket context in this medium. { absl::MutexLock medium_lock(&medium->mutex_); @@ -292,8 +288,8 @@ std::unique_ptr BleMedium::Connect( if (cancellation_flag->Cancelled()) { LOG(ERROR) << "G3 BLE Connect: Has been cancelled: " - "service_id=" - << service_id; + "service_id=" + << service_id; return {}; } @@ -307,8 +303,8 @@ std::unique_ptr BleMedium::Connect( // Finally, Request to connect to this socket. if (!remote_server_socket->Connect(*socket)) { LOG(ERROR) << "G3 Ble Connect: Failed to connect to existing Ble " - "Server socket: service_id=" - << service_id; + "Server socket: service_id=" + << service_id; return {}; } diff --git a/internal/platform/implementation/g3/bluetooth_classic.cc b/internal/platform/implementation/g3/bluetooth_classic.cc index 8d399552..5cf2d992 100644 --- a/internal/platform/implementation/g3/bluetooth_classic.cc +++ b/internal/platform/implementation/g3/bluetooth_classic.cc @@ -65,8 +65,7 @@ bool BluetoothServerSocket::Connect(BluetoothSocket& socket) { absl::MutexLock lock(&mutex_); if (closed_) return false; if (socket.IsConnected()) { - LOG(ERROR) - << "Failed to connect to BT server socket: already connected"; + LOG(ERROR) << "Failed to connect to BT server socket: already connected"; return true; // already connected. } // add client socket to the pending list @@ -172,8 +171,8 @@ std::unique_ptr BluetoothClassicMedium::ConnectToService( api::BluetoothDevice& remote_device, const std::string& service_uuid, CancellationFlag* cancellation_flag) { LOG(INFO) << "G3 ConnectToService [self]: medium=" << this - << ", adapter=" << &GetAdapter() - << ", device=" << &GetAdapter().GetDevice(); + << ", adapter=" << &GetAdapter() + << ", device=" << &GetAdapter().GetDevice(); // First, find an instance of remote medium, that exposed this device. auto& adapter = static_cast(remote_device).GetAdapter(); auto* medium = @@ -183,24 +182,23 @@ std::unique_ptr BluetoothClassicMedium::ConnectToService( BluetoothServerSocket* server_socket = nullptr; LOG(INFO) << "G3 ConnectToService [peer]: medium=" << medium - << ", adapter=" << &adapter << ", device=" << &remote_device - << ", uuid=" << service_uuid.c_str(); + << ", adapter=" << &adapter << ", device=" << &remote_device + << ", uuid=" << service_uuid; // Then, find our server socket context in this medium. { absl::MutexLock medium_lock(&medium->mutex_); auto item = medium->sockets_.find(service_uuid); server_socket = item != medium->sockets_.end() ? item->second : nullptr; if (server_socket == nullptr) { - LOG(ERROR) << "Failed to find BT Server socket: uuid=" - << service_uuid; + LOG(ERROR) << "Failed to find BT Server socket: uuid=" << service_uuid; return {}; } } if (cancellation_flag->Cancelled()) { LOG(ERROR) << "G3 Bluetooth Connect: Has been cancelled: " - "service_uuid=" - << service_uuid; + "service_uuid=" + << service_uuid; return {}; } @@ -212,23 +210,20 @@ std::unique_ptr BluetoothClassicMedium::ConnectToService( auto socket = std::make_unique(&GetAdapter()); // Finally, Request to connect to this socket. if (!server_socket->Connect(*socket)) { - LOG(ERROR) - << "Failed to connect to existing BT Server socket: uuid=" - << service_uuid; + LOG(ERROR) << "Failed to connect to existing BT Server socket: uuid=" + << service_uuid; return {}; } if (cancellation_flag->Cancelled()) { - LOG(ERROR) - << "G3 Bluetooth Connect: Has been cancelled after connected: " - "service_uuid=" - << service_uuid; + LOG(ERROR) << "G3 Bluetooth Connect: Has been cancelled after connected: " + "service_uuid=" + << service_uuid; socket->Close(); return {}; } - LOG(INFO) << "G3 ConnectToService: connected: socket=" - << socket.get(); + LOG(INFO) << "G3 ConnectToService: connected: socket=" << socket.get(); return socket; } @@ -240,8 +235,7 @@ BluetoothClassicMedium::ListenForService(const std::string& service_name, absl::MutexLock lock(&mutex_); sockets_.erase(uuid); }); - LOG(INFO) << "Adding service: medium=" << this - << ", uuid=" << service_uuid; + LOG(INFO) << "Adding service: medium=" << this << ", uuid=" << service_uuid; absl::MutexLock lock(&mutex_); sockets_.emplace(service_uuid, socket.get()); return socket; diff --git a/internal/platform/implementation/g3/credential_storage_impl.cc b/internal/platform/implementation/g3/credential_storage_impl.cc index b1705d8d..d60f1e19 100644 --- a/internal/platform/implementation/g3/credential_storage_impl.cc +++ b/internal/platform/implementation/g3/credential_storage_impl.cc @@ -64,24 +64,20 @@ void CredentialStorageImpl::SaveCredentials( } if (private_credentials.empty()) { LOG(INFO) << "There are no Private Credentials for account: [" - << account_name << "], manager app ID:[" << manager_app_id - << "]"; + << account_name << "], manager app ID:[" << manager_app_id << "]"; } else { - LOG(INFO) << "G3 Save Private Credentials for account: [" - << account_name << "], manager app ID:[" << manager_app_id - << "]"; + LOG(INFO) << "G3 Save Private Credentials for account: [" << account_name + << "], manager app ID:[" << manager_app_id << "]"; SaveLocalCredentialsLocked(manager_app_id, account_name, private_credentials); } if (public_credentials.empty()) { LOG(INFO) << "There are no Public Credentials for account: [" - << account_name << "], manager app ID:[" << manager_app_id - << "]"; + << account_name << "], manager app ID:[" << manager_app_id << "]"; } else { - LOG(INFO) << "G3 Save Public Credentials for account: [" - << account_name << "], manager app ID:[" << manager_app_id - << "]"; + LOG(INFO) << "G3 Save Public Credentials for account: [" << account_name + << "], manager app ID:[" << manager_app_id << "]"; PublicCredentialKey key = CreatePublicCredentialKey( manager_app_id, account_name, public_credential_type); auto public_result = @@ -111,9 +107,8 @@ void CredentialStorageImpl::SaveLocalCredentialsLocked( void CredentialStorageImpl::UpdateLocalCredential( absl::string_view manager_app_id, absl::string_view account_name, LocalCredential credential, SaveCredentialsResultCallback callback) { - LOG(INFO) << "G3 Update Private Credential for for account: [" - << account_name << "], manager app ID:[" << manager_app_id - << "]"; + LOG(INFO) << "G3 Update Private Credential for for account: [" << account_name + << "], manager app ID:[" << manager_app_id << "]"; absl::StatusOr> credentials = GetLocalCredentialsLocked(CredentialSelector{ .manager_app_id = std::string(manager_app_id), @@ -150,7 +145,7 @@ CredentialStorageImpl::GetLocalCredentialsLocked( credential_selector.manager_app_id, credential_selector.account_name); if (private_credentials_map_.find(key) == private_credentials_map_.end()) { LOG(WARNING) << "There are no Private Credentials stored for key:" - << std::get<0>(key) << ", " << std::get<1>(key); + << std::get<0>(key) << ", " << std::get<1>(key); return absl::NotFoundError( absl::StrFormat("No private credentials for %v", credential_selector)); } @@ -174,8 +169,8 @@ void CredentialStorageImpl::GetPublicCredentials( public_credential_type); if (public_credentials_map_.find(key) == public_credentials_map_.end()) { LOG(WARNING) << "There are no Public Credentials stored for key:" - << std::get<0>(key) << ", " << std::get<1>(key) << ", " - << std::get<2>(key); + << std::get<0>(key) << ", " << std::get<1>(key) << ", " + << std::get<2>(key); std::move(callback.credentials_fetched_cb)(absl::NotFoundError( absl::StrFormat("No public credentials for %v", credential_selector))); return; diff --git a/internal/platform/implementation/g3/wifi_direct.cc b/internal/platform/implementation/g3/wifi_direct.cc index 2aba37cf..634060ec 100644 --- a/internal/platform/implementation/g3/wifi_direct.cc +++ b/internal/platform/implementation/g3/wifi_direct.cc @@ -131,7 +131,7 @@ bool WifiDirectMedium::StartWifiDirect( wifi_direct_credentials->SetPassword(password); LOG(INFO) << "G3 StartWifiDirect GO: ssid=" << ssid - << ", password:" << password; + << ", password:" << password; auto& env = MediumEnvironment::Instance(); env.UpdateWifiDirectMediumForStartOrConnect(*this, wifi_direct_credentials, @@ -156,8 +156,8 @@ bool WifiDirectMedium::ConnectWifiDirect( absl::MutexLock lock(&mutex_); LOG(INFO) << "G3 ConnectWifiDirect : ssid=" - << wifi_direct_credentials->GetSSID() - << ", password:" << wifi_direct_credentials->GetPassword(); + << wifi_direct_credentials->GetSSID() + << ", password:" << wifi_direct_credentials->GetPassword(); auto& env = MediumEnvironment::Instance(); auto* remote_medium = static_cast( @@ -192,7 +192,7 @@ std::unique_ptr WifiDirectMedium::ConnectToService( CancellationFlag* cancellation_flag) { std::string socket_name = WifiDirectServerSocket::GetName(ip_address, port); LOG(INFO) << "G3 WifiDirect ConnectToService [self]: medium=" << this - << ", ip address + port=" << socket_name; + << ", ip address + port=" << socket_name; // First, find an instance of remote medium, that exposed this service. auto& env = MediumEnvironment::Instance(); auto* remote_medium = @@ -202,9 +202,8 @@ std::unique_ptr WifiDirectMedium::ConnectToService( } WifiDirectServerSocket* server_socket = nullptr; - LOG(INFO) << "G3 WifiDirect ConnectToService [peer]: medium=" - << remote_medium - << ", remote ip address + port=" << socket_name; + LOG(INFO) << "G3 WifiDirect ConnectToService [peer]: medium=" << remote_medium + << ", remote ip address + port=" << socket_name; // Then, find our server socket context in this medium. { absl::MutexLock medium_lock(&remote_medium->mutex_); @@ -213,16 +212,15 @@ std::unique_ptr WifiDirectMedium::ConnectToService( item != remote_medium->server_sockets_.end() ? item->second : nullptr; if (server_socket == nullptr) { LOG(ERROR) << "G3 WifiDirect Failed to find WifiDirect Server " - "socket: socket_name=" - << socket_name; + "socket: socket_name=" + << socket_name; return nullptr; } } if (cancellation_flag->Cancelled()) { - LOG(ERROR) - << "G3 WifiDirect Connect: Has been cancelled: socket_name=" - << socket_name; + LOG(ERROR) << "G3 WifiDirect Connect: Has been cancelled: socket_name=" + << socket_name; return nullptr; } @@ -231,7 +229,7 @@ std::unique_ptr WifiDirectMedium::ConnectToService( server_socket->Connect(*socket); LOG(INFO) << "G3 WifiDirect GC ConnectToService: connected: socket=" - << socket.get(); + << socket.get(); return socket; } @@ -257,7 +255,7 @@ std::unique_ptr WifiDirectMedium::ListenForService( server_sockets_.erase(socket_name); }); LOG(INFO) << "G3 WifiDirect GO Adding server socket: medium=" << this - << ", socket_name=" << socket_name; + << ", socket_name=" << socket_name; absl::MutexLock lock(&mutex_); server_sockets_.insert({socket_name, server_socket.get()}); return server_socket; diff --git a/internal/platform/implementation/g3/wifi_hotspot.cc b/internal/platform/implementation/g3/wifi_hotspot.cc index 70bc5f97..782c4365 100644 --- a/internal/platform/implementation/g3/wifi_hotspot.cc +++ b/internal/platform/implementation/g3/wifi_hotspot.cc @@ -134,7 +134,7 @@ bool WifiHotspotMedium::StartWifiHotspot( hotspot_credentials->SetPassword(password); LOG(INFO) << "G3 StartWifiHotspot: ssid=" << ssid - << ", password:" << password; + << ", password:" << password; auto& env = MediumEnvironment::Instance(); env.UpdateWifiHotspotMediumForStartOrConnect(*this, hotspot_credentials, @@ -161,9 +161,8 @@ bool WifiHotspotMedium::ConnectWifiHotspot( HotspotCredentials* hotspot_credentials) { absl::MutexLock lock(&mutex_); - LOG(INFO) << "G3 ConnectWifiHotspot: ssid=" - << hotspot_credentials->GetSSID() - << ", password:" << hotspot_credentials->GetPassword(); + LOG(INFO) << "G3 ConnectWifiHotspot: ssid=" << hotspot_credentials->GetSSID() + << ", password:" << hotspot_credentials->GetPassword(); auto& env = MediumEnvironment::Instance(); auto* remote_medium = static_cast( @@ -198,7 +197,7 @@ std::unique_ptr WifiHotspotMedium::ConnectToService( CancellationFlag* cancellation_flag) { std::string socket_name = WifiHotspotServerSocket::GetName(ip_address, port); LOG(INFO) << "G3 WifiHotspot ConnectToService [self]: medium=" << this - << ", ip address + port=" << socket_name; + << ", ip address + port=" << socket_name; // First, find an instance of remote medium, that exposed this service. auto& env = MediumEnvironment::Instance(); auto* remote_medium = @@ -209,8 +208,7 @@ std::unique_ptr WifiHotspotMedium::ConnectToService( WifiHotspotServerSocket* server_socket = nullptr; LOG(INFO) << "G3 WifiHotspot ConnectToService [peer]: medium=" - << remote_medium - << ", remote ip address + port=" << socket_name; + << remote_medium << ", remote ip address + port=" << socket_name; // Then, find our server socket context in this medium. { absl::MutexLock medium_lock(&remote_medium->mutex_); @@ -219,16 +217,15 @@ std::unique_ptr WifiHotspotMedium::ConnectToService( item != remote_medium->server_sockets_.end() ? item->second : nullptr; if (server_socket == nullptr) { LOG(ERROR) << "G3 WifiHotspot Failed to find WifiHotspot Server " - "socket: socket_name=" - << socket_name; + "socket: socket_name=" + << socket_name; return {}; } } if (cancellation_flag->Cancelled()) { - LOG(ERROR) - << "G3 WifiHotspot Connect: Has been cancelled: socket_name=" - << socket_name; + LOG(ERROR) << "G3 WifiHotspot Connect: Has been cancelled: socket_name=" + << socket_name; return {}; } @@ -242,14 +239,13 @@ std::unique_ptr WifiHotspotMedium::ConnectToService( auto socket = std::make_unique(); // Finally, Request to connect to this socket. if (!server_socket->Connect(*socket)) { - LOG(ERROR) - << "G3 WifiHotspot Failed to connect to existing WifiHotspot " - "Server socket: name=" - << socket_name; + LOG(ERROR) << "G3 WifiHotspot Failed to connect to existing WifiHotspot " + "Server socket: name=" + << socket_name; return {}; } LOG(INFO) << "G3 WifiHotspot ConnectToService: connected: socket=" - << socket.get(); + << socket.get(); return socket; } @@ -276,7 +272,7 @@ WifiHotspotMedium::ListenForService(int port) { server_sockets_.erase(socket_name); }); LOG(INFO) << "G3 WifiHotspot Adding server socket: medium=" << this - << ", socket_name=" << socket_name; + << ", socket_name=" << socket_name; absl::MutexLock lock(&mutex_); server_sockets_.insert({socket_name, server_socket.get()}); return server_socket; diff --git a/internal/platform/implementation/g3/wifi_lan.cc b/internal/platform/implementation/g3/wifi_lan.cc index 650a3efa..c09fb7b9 100644 --- a/internal/platform/implementation/g3/wifi_lan.cc +++ b/internal/platform/implementation/g3/wifi_lan.cc @@ -130,9 +130,9 @@ WifiLanMedium::~WifiLanMedium() { bool WifiLanMedium::StartAdvertising(const NsdServiceInfo& nsd_service_info) { std::string service_type = nsd_service_info.GetServiceType(); LOG(INFO) << "G3 WifiLan StartAdvertising: nsd_service_info=" - << &nsd_service_info - << ", service_name=" << nsd_service_info.GetServiceName() - << ", service_type=" << service_type; + << &nsd_service_info + << ", service_name=" << nsd_service_info.GetServiceName() + << ", service_type=" << service_type; { absl::MutexLock lock(&mutex_); if (advertising_info_.Existed(service_type)) { @@ -156,16 +156,15 @@ bool WifiLanMedium::StartAdvertising(const NsdServiceInfo& nsd_service_info) { bool WifiLanMedium::StopAdvertising(const NsdServiceInfo& nsd_service_info) { std::string service_type = nsd_service_info.GetServiceType(); LOG(INFO) << "G3 WifiLan StopAdvertising: nsd_service_info=" - << &nsd_service_info - << ", service_name=" << nsd_service_info.GetServiceName() - << ", service_type=" << service_type; + << &nsd_service_info + << ", service_name=" << nsd_service_info.GetServiceName() + << ", service_type=" << service_type; { absl::MutexLock lock(&mutex_); if (!advertising_info_.Existed(service_type)) { - LOG(INFO) - << "G3 WifiLan StopAdvertising: Can't stop advertising because " - "we never started advertising for service_type=" - << service_type; + LOG(INFO) << "G3 WifiLan StopAdvertising: Can't stop advertising because " + "we never started advertising for service_type=" + << service_type; return false; } advertising_info_.Remove(service_type); @@ -178,15 +177,13 @@ bool WifiLanMedium::StopAdvertising(const NsdServiceInfo& nsd_service_info) { bool WifiLanMedium::StartDiscovery(const std::string& service_type, DiscoveredServiceCallback callback) { - LOG(INFO) << "G3 WifiLan StartDiscovery: service_type=" - << service_type; + LOG(INFO) << "G3 WifiLan StartDiscovery: service_type=" << service_type; { absl::MutexLock lock(&mutex_); if (discovering_info_.Existed(service_type)) { - LOG(INFO) - << "G3 WifiLan StartDiscovery: Can't start discovery because " - "service_type=" - << service_type << " has started already."; + LOG(INFO) << "G3 WifiLan StartDiscovery: Can't start discovery because " + "service_type=" + << service_type << " has started already."; return false; } } @@ -201,8 +198,7 @@ bool WifiLanMedium::StartDiscovery(const std::string& service_type, } bool WifiLanMedium::StopDiscovery(const std::string& service_type) { - LOG(INFO) << "G3 WifiLan StopDiscovery: service_type=" - << service_type; + LOG(INFO) << "G3 WifiLan StopDiscovery: service_type=" << service_type; { absl::MutexLock lock(&mutex_); if (!discovering_info_.Existed(service_type)) { @@ -223,7 +219,7 @@ std::unique_ptr WifiLanMedium::ConnectToService( CancellationFlag* cancellation_flag) { std::string service_type = remote_service_info.GetServiceType(); LOG(INFO) << "G3 WifiLan ConnectToService [self]: medium=" << this - << ", service_type=" << service_type; + << ", service_type=" << service_type; return ConnectToService(remote_service_info.GetIPAddress(), remote_service_info.GetPort(), cancellation_flag); } @@ -233,7 +229,7 @@ std::unique_ptr WifiLanMedium::ConnectToService( CancellationFlag* cancellation_flag) { std::string socket_name = WifiLanServerSocket::GetName(ip_address, port); LOG(INFO) << "G3 WifiLan ConnectToService [self]: medium=" << this - << ", ip address + port=" << socket_name; + << ", ip address + port=" << socket_name; // First, find an instance of remote medium, that exposed this service. auto& env = MediumEnvironment::Instance(); auto* remote_medium = @@ -243,9 +239,8 @@ std::unique_ptr WifiLanMedium::ConnectToService( } WifiLanServerSocket* server_socket = nullptr; - LOG(INFO) << "G3 WifiLan ConnectToService [peer]: medium=" - << remote_medium - << ", remote ip address + port=" << socket_name; + LOG(INFO) << "G3 WifiLan ConnectToService [peer]: medium=" << remote_medium + << ", remote ip address + port=" << socket_name; // Then, find our server socket context in this medium. { absl::MutexLock medium_lock(&remote_medium->mutex_); @@ -262,7 +257,7 @@ std::unique_ptr WifiLanMedium::ConnectToService( if (cancellation_flag->Cancelled()) { LOG(ERROR) << "G3 WifiLan Connect: Has been cancelled: socket_name=" - << socket_name; + << socket_name; return {}; } @@ -277,12 +272,12 @@ std::unique_ptr WifiLanMedium::ConnectToService( // Finally, Request to connect to this socket. if (!server_socket->Connect(*socket)) { LOG(ERROR) << "G3 WifiLan Failed to connect to existing WifiLan " - "Server socket: name=" - << socket_name; + "Server socket: name=" + << socket_name; return {}; } LOG(INFO) << "G3 WifiLan ConnectToService: connected: socket=" - << socket.get(); + << socket.get(); return socket; } @@ -299,7 +294,7 @@ std::unique_ptr WifiLanMedium::ListenForService( server_sockets_.erase(socket_name); }); LOG(INFO) << "G3 WifiLan Adding server socket: medium=" << this - << ", socket_name=" << socket_name; + << ", socket_name=" << socket_name; absl::MutexLock lock(&mutex_); server_sockets_.insert({socket_name, server_socket.get()}); return server_socket; diff --git a/internal/platform/implementation/windows/wifi_lan_mdns.cc b/internal/platform/implementation/windows/wifi_lan_mdns.cc index 50dbb498..f0f130af 100644 --- a/internal/platform/implementation/windows/wifi_lan_mdns.cc +++ b/internal/platform/implementation/windows/wifi_lan_mdns.cc @@ -123,7 +123,7 @@ bool WifiLanMdns::StartMdnsService( if (status != DNS_REQUEST_PENDING) { LOG(ERROR) << "Failed to start mDNS advertising for service type =" - << service_type; + << service_type; return false; } diff --git a/internal/platform/medium_environment.cc b/internal/platform/medium_environment.cc index 53c6edb4..c5bb7d35 100644 --- a/internal/platform/medium_environment.cc +++ b/internal/platform/medium_environment.cc @@ -1302,8 +1302,7 @@ void MediumEnvironment::UnregisterGattServer(api::ble_v2::BleMedium& medium) { } auto& context = it->second; LOG(INFO) << "Unregistered GattServer for peripheral id:" - << context.ble_peripheral_id - << " on medium:" << &medium; + << context.ble_peripheral_id << " on medium:" << &medium; context.gatt_server = nullptr; context.ble_peripheral_id = 0LL; latch.CountDown(); diff --git a/internal/platform/pending_job_registry.cc b/internal/platform/pending_job_registry.cc index cfe27ad5..e99ab87c 100644 --- a/internal/platform/pending_job_registry.cc +++ b/internal/platform/pending_job_registry.cc @@ -14,6 +14,8 @@ #include "internal/platform/pending_job_registry.h" +#include "absl/time/time.h" +#include "internal/platform/implementation/system_clock.h" #include "internal/platform/logging.h" #include "internal/platform/mutex_lock.h" #include "internal/platform/system_clock.h" @@ -68,14 +70,14 @@ void PendingJobRegistry::ListJobs() { auto age = current_time - job.second; if (age >= kReportPendingJobsOlderThan) { LOG(INFO) << "Task \"" << job.first << "\" is waiting for " - << absl::ToInt64Seconds(age) << " s"; + << absl::ToInt64Seconds(age) << " s"; } } for (auto& job : running_jobs_) { auto age = current_time - job.second; if (age >= kReportRunningJobsOlderThan) { LOG(INFO) << "Task \"" << job.first << "\" is running for " - << absl::ToInt64Seconds(age) << " s"; + << absl::ToInt64Seconds(age) << " s"; } } list_jobs_time_ = current_time; @@ -87,12 +89,12 @@ void PendingJobRegistry::ListAllJobs() { for (auto& job : pending_jobs_) { auto age = current_time - job.second; LOG(INFO) << "Task \"" << job.first << "\" is waiting for " - << absl::ToInt64Seconds(age) << " s"; + << absl::ToInt64Seconds(age) << " s"; } for (auto& job : running_jobs_) { auto age = current_time - job.second; LOG(INFO) << "Task \"" << job.first << "\" is running for " - << absl::ToInt64Seconds(age) << " s"; + << absl::ToInt64Seconds(age) << " s"; } list_jobs_time_ = current_time; } diff --git a/internal/platform/socket.h b/internal/platform/socket.h index 96674d6b..9dd1f17a 100644 --- a/internal/platform/socket.h +++ b/internal/platform/socket.h @@ -66,9 +66,7 @@ class MediumSocket : public Socket { virtual void FeedIncomingData(ByteArray data) {} /** Returns true if the socket is a virtual socket. */ - virtual bool IsVirtualSocket() { - return false; - } + virtual bool IsVirtualSocket() { return false; } /** Adds a listener to be invoked when the socket is closed. */ void AddOnSocketClosedListener( diff --git a/internal/platform/wifi_direct.cc b/internal/platform/wifi_direct.cc index d7c67197..6ac42e28 100644 --- a/internal/platform/wifi_direct.cc +++ b/internal/platform/wifi_direct.cc @@ -14,17 +14,17 @@ #include "internal/platform/wifi_direct.h" -#include "internal/platform/logging.h" #include "absl/strings/string_view.h" #include "internal/platform/cancellation_flag.h" +#include "internal/platform/logging.h" namespace nearby { WifiDirectSocket WifiDirectMedium::ConnectToService( absl::string_view ip_address, int port, CancellationFlag* cancellation_flag) { - LOG(INFO) << "WifiDirectMedium::ConnectToService: ip address=" - << ip_address << ", port=" << port; + LOG(INFO) << "WifiDirectMedium::ConnectToService: ip address=" << ip_address + << ", port=" << port; return WifiDirectSocket( impl_->ConnectToService(ip_address, port, cancellation_flag)); } diff --git a/internal/platform/wifi_direct.h b/internal/platform/wifi_direct.h index 7c55448c..04f93d95 100644 --- a/internal/platform/wifi_direct.h +++ b/internal/platform/wifi_direct.h @@ -122,8 +122,7 @@ class WifiDirectServerSocket final { WifiDirectSocket Accept() { std::unique_ptr socket = impl_->Accept(); if (!socket) { - LOG(INFO) - << "WifiDirectServerSocket Accept() failed on server socket: "; + LOG(INFO) << "WifiDirectServerSocket Accept() failed on server socket: "; } return WifiDirectSocket(std::move(socket)); } diff --git a/internal/platform/wifi_lan.cc b/internal/platform/wifi_lan.cc index 12ab853e..92b760b4 100644 --- a/internal/platform/wifi_lan.cc +++ b/internal/platform/wifi_lan.cc @@ -20,12 +20,12 @@ #include "absl/container/flat_hash_map.h" #include "internal/platform/cancellation_flag.h" +#include "internal/platform/implementation/wifi_utils.h" #include "internal/platform/logging.h" #include "internal/platform/mutex_lock.h" #include "internal/platform/nsd_service_info.h" #include "internal/platform/output_stream.h" #include "internal/platform/socket.h" -#include "internal/platform/implementation/wifi_utils.h" namespace nearby { using location::nearby::proto::connections::Medium; @@ -44,15 +44,14 @@ MediumSocket* WifiLanSocket::CreateVirtualSocket( auto virtual_socket = std::make_shared(outputstream); virtual_socket->impl_ = this->impl_; LOG(WARNING) << "Created the virtual socket for Medium: " - << Medium_Name(virtual_socket->GetMedium()); + << Medium_Name(virtual_socket->GetMedium()); if (virtual_sockets_ptr_ == nullptr) { virtual_sockets_ptr_ = virtual_sockets_ptr; } (*virtual_sockets_ptr_)[salted_service_id_hash_key] = virtual_socket; - LOG(INFO) << "virtual_sockets_ size: " - << virtual_sockets_ptr_->size(); + LOG(INFO) << "virtual_sockets_ size: " << virtual_sockets_ptr_->size(); return virtual_socket.get(); } @@ -71,7 +70,7 @@ bool WifiLanMedium::StartDiscovery(const std::string& service_id, MutexLock lock(&mutex_); if (service_type_to_callback_map_.contains(service_type)) { LOG(INFO) << "WifiLan Discovery already start with service_type=" - << service_type << "; impl=" << &GetImpl(); + << service_type << "; impl=" << &GetImpl(); return false; } } @@ -84,35 +83,31 @@ bool WifiLanMedium::StartDiscovery(const std::string& service_id, const auto& it = service_type_to_callback_map_.find(service_type); if (it == service_type_to_callback_map_.end()) { - LOG(ERROR) - << "There is no callback found for service_type=" - << service_type; + LOG(ERROR) << "There is no callback found for service_type=" + << service_type; return; } // Check whether service name is in cache. auto services_it = service_type_to_services_map_.find(service_type); if (services_it == service_type_to_services_map_.end()) { - LOG(ERROR) - << "There is no service map found for service_type=" - << service_type; + LOG(ERROR) << "There is no service map found for service_type=" + << service_type; return; } std::string service_name = service_info.GetServiceName(); auto pair = services_it->second.insert(service_name); if (!pair.second) { - LOG(INFO) - << "Discovering (again) service_info=" << &service_info - << ", service_type=" << service_type - << ", service_name=" << service_info.GetServiceName(); + LOG(INFO) << "Discovering (again) service_info=" << &service_info + << ", service_type=" << service_type + << ", service_name=" << service_info.GetServiceName(); return; } - LOG(INFO) - << "Adding service_info=" << &service_info - << ", service_type=" << service_type - << ", service_name=" << service_info.GetServiceName(); + LOG(INFO) << "Adding service_info=" << &service_info + << ", service_type=" << service_type + << ", service_name=" << service_info.GetServiceName(); std::string service_id = it->second->service_id; DiscoveredServiceCallback& medium_callback = @@ -126,17 +121,16 @@ bool WifiLanMedium::StartDiscovery(const std::string& service_id, std::string service_name = service_info.GetServiceName(); auto services_it = service_type_to_services_map_.find(service_type); if (services_it == service_type_to_services_map_.end()) { - LOG(ERROR) - << "There is no service map found for service_type=" - << service_type; + LOG(ERROR) << "There is no service map found for service_type=" + << service_type; return; } auto item = services_it->second.extract(service_name); if (item.empty()) return; LOG(INFO) << "Removing service_info=" << &service_info - << ", service_type=" << service_type - << ", service_info_name=" << service_name; + << ", service_type=" << service_type + << ", service_info_name=" << service_name; // Callback service lost. const auto& it = service_type_to_callback_map_.find(service_type); if (it != service_type_to_callback_map_.end()) { @@ -169,9 +163,8 @@ bool WifiLanMedium::StartDiscovery(const std::string& service_id, service_type_to_callback_map_.erase(service_type); service_type_to_services_map_.erase(service_type); } - LOG(INFO) << "WifiLan Discovery started for service_type=" - << service_type << ", impl=" << &GetImpl() - << ", success=" << success; + LOG(INFO) << "WifiLan Discovery started for service_type=" << service_type + << ", impl=" << &GetImpl() << ", success=" << success; return success; } @@ -184,8 +177,8 @@ bool WifiLanMedium::StopDiscovery(const std::string& service_type) { if (service_type_to_services_map_.contains(service_type)) { service_type_to_services_map_.erase(service_type); } - LOG(INFO) << "WifiLan Discovery disabled for service_type=" - << service_type << ", impl=" << &GetImpl(); + LOG(INFO) << "WifiLan Discovery disabled for service_type=" << service_type + << ", impl=" << &GetImpl(); return impl_->StopDiscovery(service_type); } @@ -193,7 +186,7 @@ WifiLanSocket WifiLanMedium::ConnectToService( const NsdServiceInfo& remote_service_info, CancellationFlag* cancellation_flag) { LOG(INFO) << "WifiLanMedium::ConnectToService: remote_service_name=" - << remote_service_info.GetServiceName(); + << remote_service_info.GetServiceName(); return WifiLanSocket( impl_->ConnectToService(remote_service_info, cancellation_flag)); } @@ -202,8 +195,8 @@ WifiLanSocket WifiLanMedium::ConnectToService( const std::string& ip_address, int port, CancellationFlag* cancellation_flag) { LOG(INFO) << "WifiLanMedium::ConnectToService: ip address=" - << WifiUtils::GetHumanReadableIpAddress(ip_address) - << ", port=" << port; + << WifiUtils::GetHumanReadableIpAddress(ip_address) + << ", port=" << port; return WifiLanSocket( impl_->ConnectToService(ip_address, port, cancellation_flag)); } diff --git a/internal/platform/wifi_lan.h b/internal/platform/wifi_lan.h index e5358e2d..60902d4f 100644 --- a/internal/platform/wifi_lan.h +++ b/internal/platform/wifi_lan.h @@ -164,8 +164,8 @@ class WifiLanServerSocket final { WifiLanSocket Accept() { std::unique_ptr socket = impl_->Accept(); if (!socket) { - LOG(INFO) - << "WifiLanServerSocket Accept() failed on server socket: " << this; + LOG(INFO) << "WifiLanServerSocket Accept() failed on server socket: " + << this; } return WifiLanSocket(std::move(socket)); } diff --git a/internal/weave/base_socket_test.cc b/internal/weave/base_socket_test.cc index 899631da..41f9884f 100644 --- a/internal/weave/base_socket_test.cc +++ b/internal/weave/base_socket_test.cc @@ -94,9 +94,7 @@ class FakeSocket : public BaseSocket { explicit FakeSocket(const Connection& connection, SocketCallback&& socketCallback) : BaseSocket(connection, std::move(socketCallback)) {} - ~FakeSocket() override { - ShutDown(); - } + ~FakeSocket() override { ShutDown(); } MOCK_METHOD(void, Connect, (), (override)); void OnReceiveControlPacket(Packet packet) override { control_packets_.push_back(std::move(packet)); diff --git a/internal/weave/sockets/client_socket_test.cc b/internal/weave/sockets/client_socket_test.cc index 82ced86d..dece90e7 100644 --- a/internal/weave/sockets/client_socket_test.cc +++ b/internal/weave/sockets/client_socket_test.cc @@ -349,8 +349,7 @@ TEST_F(ClientSocketTest, TestSocketWithRandomDataProvider) { MutexLock lock(&mutex_); messages_read_.push_back(message); }, - .on_error_cb = - [](absl::Status status) { LOG(ERROR) << status; }, + .on_error_cb = [](absl::Status status) { LOG(ERROR) << status; }, }, std::move(provider)); socket.Connect(); diff --git a/internal/weave/sockets/server_socket.cc b/internal/weave/sockets/server_socket.cc index 0dde2b13..d84fc9e7 100644 --- a/internal/weave/sockets/server_socket.cc +++ b/internal/weave/sockets/server_socket.cc @@ -87,9 +87,9 @@ void ServerSocket::OnReceiveControlPacket(Packet packet) { // after the initial handshake. if (state_ != State::kClientConnectionRequest) { LOG(ERROR) << "Not in 'Connection Request' state, but " - "incorrectly received control packet of type " - << Packet::ControlPacketTypeToString( - packet.GetControlCommandNumber()); + "incorrectly received control packet of type " + << Packet::ControlPacketTypeToString( + packet.GetControlCommandNumber()); GetSocketCallback().on_error_cb( absl::InvalidArgumentError("Unexpected control packet")); return; @@ -97,9 +97,9 @@ void ServerSocket::OnReceiveControlPacket(Packet packet) { if (packet.GetControlCommandNumber() != Packet::ControlPacketType::kControlConnectionRequest) { LOG(ERROR) << "Expected connection request control packet, " - "received control packet of type " - << Packet::ControlPacketTypeToString( - packet.GetControlCommandNumber()); + "received control packet of type " + << Packet::ControlPacketTypeToString( + packet.GetControlCommandNumber()); DisconnectInternal( absl::InvalidArgumentError("Unexpected control packet type.")); return; @@ -117,8 +117,7 @@ void ServerSocket::OnReceiveControlPacket(Packet packet) { if (min_protocol_version > kProtocolVersion || max_protocol_version < kProtocolVersion) { LOG(ERROR) << "Received unexpected min/max protocol versions: " - << min_protocol_version << " and " - << max_protocol_version; + << min_protocol_version << " and " << max_protocol_version; DisconnectInternal( absl::InvalidArgumentError("unexpected protocol versions")); return; @@ -145,7 +144,7 @@ void ServerSocket::WriteConnectionConfirm() { kProtocolVersion, max_packet_size_, ""); if (!packet.ok()) { LOG(ERROR) << "Failed to create connection confirm packet: " - << packet.status(); + << packet.status(); DisconnectInternal(packet.status()); return; } diff --git a/presence/fpp/fpp_manager.cc b/presence/fpp/fpp_manager.cc index d9cdce31..e7d9efc8 100644 --- a/presence/fpp/fpp_manager.cc +++ b/presence/fpp/fpp_manager.cc @@ -90,7 +90,7 @@ absl::Status FppManager::UpdateBleScanResult(uint64_t device_id, presence_detector_handle_, ble_scan_result, &new_proximity_estimate); if (status_code == kNoComputedProximityEstimate) { LOG(INFO) << "Insufficient number of scan results available to " - "compute proximity state"; + "compute proximity state"; return absl::OkStatus(); } if (status_code == kSuccess) { @@ -142,9 +142,8 @@ void FppManager::CheckPresenceZoneChanged(uint64_t device_id, ProximityEstimate old_estimate, ProximityEstimate new_estimate) { if (old_estimate.proximity_state != new_estimate.proximity_state) { - LOG(WARNING) - << "Updating zone transition callbacks with new zone. Zone=" - << static_cast(new_estimate.proximity_state); + LOG(WARNING) << "Updating zone transition callbacks with new zone. Zone=" + << static_cast(new_estimate.proximity_state); for (auto& pair : zone_transition_callbacks_) { pair.second.on_proximity_zone_changed( device_id, diff --git a/presence/implementation/action_factory.cc b/presence/implementation/action_factory.cc index ad06d329..fe4a6e45 100644 --- a/presence/implementation/action_factory.cc +++ b/presence/implementation/action_factory.cc @@ -67,7 +67,7 @@ int GetMask(const DataElement& element) { } } LOG(WARNING) << "Data Element " << type - << " not supported in base advertisement"; + << " not supported in base advertisement"; return kEmptyMask; } diff --git a/presence/implementation/advertisement_decoder_impl.cc b/presence/implementation/advertisement_decoder_impl.cc index 2b46db3e..fec04c85 100644 --- a/presence/implementation/advertisement_decoder_impl.cc +++ b/presence/implementation/advertisement_decoder_impl.cc @@ -147,8 +147,8 @@ absl::StatusOr ParseDataElement(const absl::string_view input, absl::BytesToHexString(input), input.size(), index)); } VLOG(1) << "Type: " << static_cast(data_type) - << " length: " << static_cast(length) << " DE: " - << absl::BytesToHexString(input.substr(start, length)); + << " length: " << static_cast(length) + << " DE: " << absl::BytesToHexString(input.substr(start, length)); return DataElement(data_type, input.substr(start, length)); } } // namespace @@ -157,9 +157,9 @@ void DecodeBaseAction(absl::string_view serialized_action, Advertisement& decoded_advertisement) { if (serialized_action.empty() || serialized_action.size() > 3) { LOG(WARNING) << "Base NP action \'" - << absl::BytesToHexString(serialized_action) - << "\' has wrong length " << serialized_action.size() - << " , expected size in range [1 - 3]"; + << absl::BytesToHexString(serialized_action) + << "\' has wrong length " << serialized_action.size() + << " , expected size in range [1 - 3]"; return; } // Action, 0-2 bytes in Big Endian order. @@ -213,7 +213,7 @@ absl::Status DecryptDataElements( DecryptLdt(credentials, salt, encrypted, decoded_advertisement); if (!decrypted.ok()) { LOG(WARNING) << "Failed to decrypt advertisement, status: " - << decrypted.status(); + << decrypted.status(); return decrypted.status(); } size_t index = 0; @@ -222,7 +222,7 @@ absl::Status DecryptDataElements( ParseDataElement(*decrypted, index); if (!internal_elem.ok()) { LOG(WARNING) << "Failed to read data element, status: " - << internal_elem.status(); + << internal_elem.status(); return internal_elem.status(); } if (internal_elem->GetType() == DataElement::kActionFieldType) { @@ -238,8 +238,7 @@ absl::StatusOr AdvertisementDecoderImpl::DecodeAdvertisement( absl::string_view advertisement) { Advertisement decoded_advertisement = Advertisement{}; std::vector result; - LOG(INFO) << "Advertisement: " - << absl::BytesToHexString(advertisement); + LOG(INFO) << "Advertisement: " << absl::BytesToHexString(advertisement); if (advertisement.empty()) { return absl::OutOfRangeError("Empty advertisement"); } @@ -255,8 +254,7 @@ absl::StatusOr AdvertisementDecoderImpl::DecodeAdvertisement( while (index < advertisement.size()) { absl::StatusOr elem = ParseDataElement(advertisement, index); if (!elem.ok()) { - LOG(WARNING) << "Failed to read data element, status: " - << elem.status(); + LOG(WARNING) << "Failed to read data element, status: " << elem.status(); return elem.status(); } if (IsIdentity(elem->GetType())) { diff --git a/presence/implementation/advertisement_decoder_rust_impl.cc b/presence/implementation/advertisement_decoder_rust_impl.cc index f48fcf83..415507bd 100644 --- a/presence/implementation/advertisement_decoder_rust_impl.cc +++ b/presence/implementation/advertisement_decoder_rust_impl.cc @@ -57,9 +57,8 @@ void AddActionsToAdvertisement(const nearby_protocol::V0Actions& parsed_actions, for (const auto action : kAllActionBits) { auto action_type = MapAction(action); if (!action_type.ok()) { - LOG(WARNING) - << "Advertisement contains an unsupported action bit: " - << (int)action; + LOG(WARNING) << "Advertisement contains an unsupported action bit: " + << (int)action; continue; } if (parsed_actions.HasAction(*action_type)) { diff --git a/presence/implementation/advertisement_factory.cc b/presence/implementation/advertisement_factory.cc index c29f5b2e..87c74183 100644 --- a/presence/implementation/advertisement_factory.cc +++ b/presence/implementation/advertisement_factory.cc @@ -64,7 +64,7 @@ absl::Status AppendDataElement(unsigned data_type, auto header = CreateDataElementHeader(data_element.size(), data_type); if (!header.ok()) { LOG(WARNING) << "Can't add Data element type: " << data_type - << ", length: " << data_element.size(); + << ", length: " << data_element.size(); return header.status(); } output.push_back(*header); @@ -152,7 +152,7 @@ AdvertisementFactory::CreateBaseNpAdvertisement( return result; } VLOG(1) << "Unencrypted advertisement payload " - << absl::BytesToHexString(unencrypted); + << absl::BytesToHexString(unencrypted); absl::StatusOr encrypted = EncryptDataElements(*credential, request.salt, unencrypted); if (!encrypted.ok()) { diff --git a/presence/implementation/advertisement_filter.cc b/presence/implementation/advertisement_filter.cc index 12a161b9..e3b5bb37 100644 --- a/presence/implementation/advertisement_filter.cc +++ b/presence/implementation/advertisement_filter.cc @@ -65,11 +65,10 @@ bool AdvertisementFilter::MatchesScanFilter( !(std::find( requested_identity_types.begin(), requested_identity_types.end(), advertisement.identity_type) != requested_identity_types.end())) { - LOG(INFO) - << "Skipping advertisement with identity type: " - << advertisement.identity_type - << " because that identity type was not requested in the scan " - "request"; + LOG(INFO) << "Skipping advertisement with identity type: " + << advertisement.identity_type + << " because that identity type was not requested in the scan " + "request"; return false; } diff --git a/presence/implementation/base_broadcast_request.cc b/presence/implementation/base_broadcast_request.cc index b238861d..30dda102 100644 --- a/presence/implementation/base_broadcast_request.cc +++ b/presence/implementation/base_broadcast_request.cc @@ -93,8 +93,7 @@ absl::StatusOr BaseBroadcastRequest::Create( return absl::InvalidArgumentError("Missing broadcast sections"); } if (presence_request.sections.size() > 1) { - LOG(WARNING) - << "Only first section is used in BLE 4.2 advertisement"; + LOG(WARNING) << "Only first section is used in BLE 4.2 advertisement"; } const PresenceBroadcast::BroadcastSection& section = presence_request.sections.front(); diff --git a/presence/implementation/broadcast_manager.cc b/presence/implementation/broadcast_manager.cc index 7a0f38f8..460875b0 100644 --- a/presence/implementation/broadcast_manager.cc +++ b/presence/implementation/broadcast_manager.cc @@ -87,8 +87,7 @@ absl::StatusOr BroadcastManager::StartBroadcast( absl::StatusOr request = BaseBroadcastRequest::Create(broadcast_request); if (!request.ok()) { - LOG(WARNING) << "Invalid broadcast request, reason: " - << request.status(); + LOG(WARNING) << "Invalid broadcast request, reason: " << request.status(); callback.start_broadcast_cb(request.status()); return request.status(); } @@ -124,9 +123,8 @@ void BroadcastManager::FetchCredentials( std::vector<::nearby::internal::LocalCredential>> credentials) { if (!credentials.ok()) { - LOG(WARNING) - << "Failed to fetch credentials, status: " - << credentials.status(); + LOG(WARNING) << "Failed to fetch credentials, status: " + << credentials.status(); NotifyStartCallbackStatus(id, credentials.status()); return; } @@ -143,10 +141,9 @@ void BroadcastManager::FetchCredentials( selector, std::move(*credential), {[](absl::Status status) { if (!status.ok()) { - LOG(WARNING) - << "Failed to update private " - "credential, status: " - << status; + LOG(WARNING) << "Failed to update private " + "credential, status: " + << status; } }}); } @@ -191,7 +188,7 @@ absl::optional BroadcastManager::Advertise( // NOLINT AdvertisementFactory().CreateAdvertisement(broadcast_request, credential); if (!advertisement.ok()) { LOG(WARNING) << "Can't create advertisement, reason: " - << advertisement.status(); + << advertisement.status(); NotifyStartCallbackStatus(id, advertisement.status()); return absl::optional(); // NOLINT } @@ -233,8 +230,7 @@ void BroadcastManager::StopBroadcast(BroadcastSessionId id) { "stop-broadcast", [this, id]() ABSL_EXCLUSIVE_LOCKS_REQUIRED(executor_) { auto it = sessions_.find(id); if (it == sessions_.end()) { - VLOG(1) << absl::StrFormat("BroadcastSession(0x%x) not found", - id); + VLOG(1) << absl::StrFormat("BroadcastSession(0x%x) not found", id); return; } it->second.StopAdvertising(); diff --git a/presence/implementation/credential_manager_impl.cc b/presence/implementation/credential_manager_impl.cc index d8ee2820..d49d2f56 100644 --- a/presence/implementation/credential_manager_impl.cc +++ b/presence/implementation/credential_manager_impl.cc @@ -29,12 +29,12 @@ #include "absl/time/time.h" #include "absl/types/span.h" #include "absl/types/variant.h" -#include "internal/platform/byte_array.h" -#include "internal/platform/count_down_latch.h" #include "internal/crypto_cros/aead.h" #include "internal/crypto_cros/ec_private_key.h" #include "internal/crypto_cros/hkdf.h" #include "internal/platform/base64_utils.h" +#include "internal/platform/byte_array.h" +#include "internal/platform/count_down_latch.h" #include "internal/platform/crypto.h" #include "internal/platform/future.h" #include "internal/platform/implementation/credential_callbacks.h" @@ -147,8 +147,7 @@ void CredentialManagerImpl::GenerateCredentials( callback = std::move(credentials_generated_cb), public_credentials](absl::Status status) mutable { if (!status.ok()) { - LOG(WARNING) - << "Save credentials failed with: " << status; + LOG(WARNING) << "Save credentials failed with: " << status; std::move(callback.credentials_generated_cb)(status); return; } @@ -514,8 +513,8 @@ CredentialManagerImpl::GetSubscribedIdentities( void CredentialManagerImpl::OnCredentialsChanged( absl::string_view manager_app_id, absl::string_view account_name, PublicCredentialType credential_type) { - LOG(INFO) << "OnCredentialsChanged for app " << manager_app_id - << ", account " << account_name; + LOG(INFO) << "OnCredentialsChanged for app " << manager_app_id << ", account " + << account_name; for (IdentityType identity_type : GetSubscribedIdentities(manager_app_id, account_name, credential_type)) { CredentialSelector credential_selector = { @@ -535,9 +534,8 @@ CredentialManagerImpl::CreateNotifySubscribersCallback(SubscriberKey key) { [this, key](absl::StatusOr> credentials) { if (!credentials.ok()) { - LOG(WARNING) - << "Failed to get public credentials: error code: " - << credentials.status(); + LOG(WARNING) << "Failed to get public credentials: error code: " + << credentials.status(); return; } RunOnServiceControllerThread( @@ -555,13 +553,13 @@ void CredentialManagerImpl::NotifySubscribers( // without locking. auto it = subscribers_.find(key); if (it == subscribers_.end()) { - LOG(WARNING) - << "No subscribers for (app: " << key.credential_selector.manager_app_id - << ", account: " << key.credential_selector.account_name - << ", identity type: " - << static_cast(key.credential_selector.identity_type) - << ", credential type: " << static_cast(key.public_credential_type) - << ")"; + LOG(WARNING) << "No subscribers for (app: " + << key.credential_selector.manager_app_id + << ", account: " << key.credential_selector.account_name + << ", identity type: " + << static_cast(key.credential_selector.identity_type) + << ", credential type: " + << static_cast(key.public_credential_type) << ")"; return; } for (auto& subscriber : it->second) { @@ -633,8 +631,7 @@ void CredentialManagerImpl::CheckCredentialsAndRefillIfNeeded( valid_shared_credentials.push_back(credential); } } else { - LOG(ERROR) - << "Bad parameters for CheckCredentialsAndRefillIfNeeded"; + LOG(ERROR) << "Bad parameters for CheckCredentialsAndRefillIfNeeded"; return; } @@ -803,8 +800,7 @@ void CredentialManagerImpl::OnCredentialRefillComplete( std::optional callback_for_shared_credentials) { if (!save_credentials_status.ok()) { - LOG(ERROR) << "Save credentials failed with: " - << save_credentials_status; + LOG(ERROR) << "Save credentials failed with: " << save_credentials_status; if (callback_for_local_credentials.has_value()) { callback_for_local_credentials.value().credentials_fetched_cb( save_credentials_status); @@ -829,7 +825,7 @@ bool CredentialManagerImpl::WaitForLatch(absl::string_view method_name, Exception await_exception = latch->Await(); if (!await_exception.Ok()) { LOG(ERROR) << "Blocked in " << method_name - << " with exeception code: " << await_exception.value; + << " with exeception code: " << await_exception.value; return false; } return true; diff --git a/presence/implementation/scan_manager.cc b/presence/implementation/scan_manager.cc index b4a49815..0a72a2c7 100644 --- a/presence/implementation/scan_manager.cc +++ b/presence/implementation/scan_manager.cc @@ -131,8 +131,7 @@ void ScanManager::NotifyFoundBle(ScanSessionId id, BleAdvertisementData data, std::string remote_address = absl::StrCat(absl::Hex(peripheral_id)); if (it->second.advertisement_filter.MatchesScanFilter(*advert)) { internal::DeviceIdentityMetaData device_identity_metadata; - device_identity_metadata.set_bluetooth_mac_address( - remote_address); + device_identity_metadata.set_bluetooth_mac_address(remote_address); if (!device_unique_id_to_endpoint_id_map_.contains(peripheral_id)) { PresenceDevice device(DeviceMotion(), device_identity_metadata, @@ -150,12 +149,12 @@ void ScanManager::NotifyFoundBle(ScanSessionId id, BleAdvertisementData data, } device_unique_id_to_endpoint_id_map_.emplace(peripheral_id, - device.GetEndpointId()); + device.GetEndpointId()); it->second.callback.on_discovered_cb(std::move(device)); } else { PresenceDevice device( - device_unique_id_to_endpoint_id_map_.at(peripheral_id)); + device_unique_id_to_endpoint_id_map_.at(peripheral_id)); device.SetDeviceIdentityMetaData(device_identity_metadata); // Ok if the advertisement is for trusted/private identity. if (advert->public_credential.ok()) { @@ -187,7 +186,7 @@ void ScanManager::NotifyLostBle(ScanSessionId id, device_identity_metadata.set_bluetooth_mac_address( std::string(remote_address)); PresenceDevice device( - device_unique_id_to_endpoint_id_map_.at(peripheral_id)); + device_unique_id_to_endpoint_id_map_.at(peripheral_id)); device.SetDeviceIdentityMetaData(device_identity_metadata); device_unique_id_to_endpoint_id_map_.erase(peripheral_id); @@ -222,9 +221,8 @@ void ScanManager::FetchCredentials(ScanSessionId id, // Not fetching for PUBLIC. if (selector.identity_type == internal::IDENTITY_TYPE_UNSPECIFIED || selector.identity_type == internal::IDENTITY_TYPE_PUBLIC) { - LOG(INFO) << __func__ - << ": skip feteching creds for identity type: " - << selector.identity_type; + LOG(INFO) << __func__ << ": skip feteching creds for identity type: " + << selector.identity_type; continue; } credential_manager_->GetPublicCredentials( diff --git a/presence/implementation/scan_manager_test.cc b/presence/implementation/scan_manager_test.cc index 4fe9ba7b..53f5ddf1 100644 --- a/presence/implementation/scan_manager_test.cc +++ b/presence/implementation/scan_manager_test.cc @@ -98,18 +98,18 @@ class ScanManagerTest : public testing::Test { } ScanCallback MakeDefaultScanCallback() { - return {.start_scan_cb = - [this](absl::Status status) { - if (status.ok()) { - start_latch_.CountDown(); - } - }, - .on_discovered_cb = - [this](PresenceDevice pd) { found_latch_.CountDown(); }, - .on_updated_cb = - [this](PresenceDevice pd) { updated_latch_.CountDown(); }, - .on_lost_cb = - [this](PresenceDevice pd) { lost_latch_.CountDown(); }}; + return { + .start_scan_cb = + [this](absl::Status status) { + if (status.ok()) { + start_latch_.CountDown(); + } + }, + .on_discovered_cb = + [this](PresenceDevice pd) { found_latch_.CountDown(); }, + .on_updated_cb = + [this](PresenceDevice pd) { updated_latch_.CountDown(); }, + .on_lost_cb = [this](PresenceDevice pd) { lost_latch_.CountDown(); }}; } std::vector MakeDefaultIdentityTypes() { @@ -319,8 +319,7 @@ TEST_F(ScanManagerTest, StopOneSessionFromAnotherDeadlock) { }, .on_discovered_cb = [&](PresenceDevice pd) { - LOG(INFO) - << "scansession2 found"; + LOG(INFO) << "scansession2 found"; found_latch2.CountDown(); manager.StopScan(scan_session); }}; diff --git a/presence/presence_device_provider.cc b/presence/presence_device_provider.cc index 3a262141..1b0d4258 100644 --- a/presence/presence_device_provider.cc +++ b/presence/presence_device_provider.cc @@ -17,6 +17,7 @@ #include #include #include + #include "absl/strings/string_view.h" #include "absl/time/time.h" #include "absl/types/variant.h" @@ -51,7 +52,7 @@ std::string AuthenticationErrorToString(AuthenticationStatus status) { return "AuthenticationStatus::kFailure"; } LOG(ERROR) << "Unexpected value for AuthenticationStatus: " - << static_cast(status); + << static_cast(status); return "AuthenticationStatus::kUnknown"; } @@ -131,16 +132,14 @@ AuthenticationStatus PresenceDeviceProvider::AuthenticateAsInitiator( &shared_secret]( auto status_or_credentials) { if (!status_or_credentials.ok()) { - LOG(INFO) - << __func__ << ": failure to fetch local credentials"; + LOG(INFO) << __func__ << ": failure to fetch local credentials"; response.Set(AuthenticationStatus::kFailure); return; } auto credential = GetValidCredential(status_or_credentials.value()); if (!credential.has_value()) { - LOG(INFO) - << __func__ << ": failure to find a valid local credential"; + LOG(INFO) << __func__ << ": failure to find a valid local credential"; response.Set(AuthenticationStatus::kFailure); return; } @@ -176,7 +175,7 @@ AuthenticationStatus PresenceDeviceProvider::AuthenticateAsInitiator( CHECK(result.ok()); LOG(INFO) << "Future:[" << __func__ << "] completed with status:" - << AuthenticationErrorToString(result.result()); + << AuthenticationErrorToString(result.result()); return result.result(); } @@ -203,8 +202,7 @@ bool PresenceDeviceProvider::WriteToRemoteDevice( /*ukey2_secret=*/shared_secret, /*local_credential=*/local_credential, /*shared_credential=*/shared_credential.value()); if (!status_or_initiator_data.ok()) { - LOG(INFO) << __func__ - << ": failure to build signed message as initiator"; + LOG(INFO) << __func__ << ": failure to build signed message as initiator"; return false; } @@ -232,8 +230,8 @@ bool PresenceDeviceProvider::ReadAndVerifyRemoteDeviceData( &shared_secret]( auto status_or_credentials) { if (!status_or_credentials.ok()) { - LOG(INFO) - << __func__ << ": failure to fetch local public credentials"; + LOG(INFO) << __func__ + << ": failure to fetch local public credentials"; read_and_verify_result.Set(/*success=*/false); return; } @@ -255,7 +253,7 @@ bool PresenceDeviceProvider::ReadAndVerifyRemoteDeviceData( LOG(INFO) << __func__ << ": Waiting for future to complete"; ExceptionOr result = read_and_verify_result.Get(); LOG(INFO) << "Future:[" << __func__ - << "] completed with status:" << result.result(); + << "] completed with status:" << result.result(); return result.result(); }