diff --git a/sharing/nearby_sharing_service_impl.cc b/sharing/nearby_sharing_service_impl.cc index 893cb225..d2caf139 100644 --- a/sharing/nearby_sharing_service_impl.cc +++ b/sharing/nearby_sharing_service_impl.cc @@ -258,7 +258,7 @@ NearbySharingServiceImpl::NearbySharingServiceImpl( nearby_fast_initiation_->AddObserver(this); // Setup saving path. std::string custom_save_path = settings_->GetCustomSavePath(); - NL_LOG(INFO) << __func__ << ": Set custom save path: " << custom_save_path; + LOG(INFO) << __func__ << ": Set custom save path: " << custom_save_path; nearby_connections_manager_->SetCustomSavePath(custom_save_path); local_device_data_manager_->Start(); @@ -416,37 +416,35 @@ void NearbySharingServiceImpl::RegisterSendSurface( status_codes_callback = std::move(status_codes_callback)]() { if (state != SendSurfaceState::kForeground && state != SendSurfaceState::kBackground) { - NL_LOG(ERROR) << __func__ << ": Invalid SendSurfaceState: " - << static_cast(state); + LOG(ERROR) << __func__ << ": Invalid SendSurfaceState: " + << static_cast(state); std::move(status_codes_callback)(StatusCodes::kInvalidArgument); return; } - NL_DCHECK(transfer_callback); - NL_DCHECK(discovery_callback); - NL_LOG(INFO) << __func__ - << ": RegisterSendSurface is called with state: " - << (state == SendSurfaceState::kForeground ? "Foreground" - : "Background") - << ", blocked_vendor_id: " - << static_cast(blocked_vendor_id) - << ", disable_wifi_hotspot: " << disable_wifi_hotspot - << ", transfer_callback: " << transfer_callback; + DCHECK(transfer_callback); + DCHECK(discovery_callback); + LOG(INFO) << __func__ << ": RegisterSendSurface is called with state: " + << (state == SendSurfaceState::kForeground ? "Foreground" + : "Background") + << ", blocked_vendor_id: " + << static_cast(blocked_vendor_id) + << ", disable_wifi_hotspot: " << disable_wifi_hotspot + << ", transfer_callback: " << transfer_callback; if (foreground_send_surface_map_.contains(transfer_callback) || background_send_surface_map_.contains(transfer_callback)) { - NL_VLOG(1) - << __func__ - << ": RegisterSendSurface failed. Already registered for a " - "different state."; + VLOG(1) << __func__ + << ": RegisterSendSurface failed. Already registered for a " + "different state."; std::move(status_codes_callback)(StatusCodes::kInvalidArgument); return; } BlockedVendorId sending_id = GetSendingVendorId(); if (ShouldBlockSurfaceRegistration(blocked_vendor_id, sending_id)) { - NL_LOG(INFO) << __func__ - << ": RegisterSendSurface failed. Already registered to " - "block a different vendor ID " - << static_cast(sending_id); + LOG(INFO) << __func__ + << ": RegisterSendSurface failed. Already registered to " + "block a different vendor ID " + << static_cast(sending_id); std::move(status_codes_callback)(StatusCodes::kInvalidArgument); return; } @@ -456,7 +454,7 @@ void NearbySharingServiceImpl::RegisterSendSurface( if (state == SendSurfaceState::kForeground) { // Only check this error case for foreground senders if (!HasAvailableConnectionMediums()) { - NL_VLOG(1) << __func__ << ": No available connection medium."; + VLOG(1) << __func__ << ": No available connection medium."; std::move(status_codes_callback)( StatusCodes::kNoAvailableConnectionMedium); return; @@ -471,7 +469,7 @@ void NearbySharingServiceImpl::RegisterSendSurface( if (is_receiving_files_) { InternalUnregisterSendSurface(transfer_callback); - NL_VLOG(1) + VLOG(1) << __func__ << ": Ignore registering (and unregistering if registered) send " "surface because we're currently receiving files."; @@ -503,10 +501,10 @@ void NearbySharingServiceImpl::RegisterSendSurface( // user to be blocked for hours waiting for a periodic sync. if (state == SendSurfaceState::kForeground && !last_outgoing_metadata_) { - NL_VLOG(1) << __func__ - << ": Downloading local device data, contacts, and " - "certificates from " - << "Nearby server at start of sending flow."; + VLOG(1) << __func__ + << ": Downloading local device data, contacts, and " + "certificates from " + << "Nearby server at start of sending flow."; local_device_data_manager_->DownloadDeviceData(); contact_manager_->DownloadContacts(); certificate_manager_->DownloadPublicCertificates(); @@ -516,9 +514,9 @@ void NearbySharingServiceImpl::RegisterSendSurface( // targets from current scanning session. if (is_scanning_) { for (const auto& item : outgoing_share_target_map_) { - NL_LOG(INFO) << "Reporting discovered target " - << item.second.ToString() - << " when registering send surface"; + LOG(INFO) << "Reporting discovered target " + << item.second.ToString() + << " when registering send surface"; wrapped_callback.OnShareTargetDiscovered(item.second); } } @@ -529,14 +527,13 @@ void NearbySharingServiceImpl::RegisterSendSurface( context_->GetClock()->Now(); } - NL_VLOG(1) << __func__ - << ": A SendSurface has been registered for state: " - << SendSurfaceStateToString(state); + VLOG(1) << __func__ << ": A SendSurface has been registered for state: " + << SendSurfaceStateToString(state); - NL_VLOG(1) << "RegisterSendSurface: foreground_send_surface_map_:" - << foreground_send_surface_map_.size() - << ", background_send_surface_map_:" - << background_send_surface_map_.size(); + VLOG(1) << "RegisterSendSurface: foreground_send_surface_map_:" + << foreground_send_surface_map_.size() + << ", background_send_surface_map_:" + << background_send_surface_map_.size(); InvalidateSendSurfaceState(); std::move(status_codes_callback)(StatusCodes::kOk); @@ -553,10 +550,10 @@ void NearbySharingServiceImpl::UnregisterSendSurface( StatusCodes status_codes = InternalUnregisterSendSurface(transfer_callback); - NL_VLOG(1) << "UnregisterSendSurface: foreground_send_surface_map_:" - << foreground_send_surface_map_.size() - << ", background_send_surface_map_:" - << background_send_surface_map_.size(); + VLOG(1) << "UnregisterSendSurface: foreground_send_surface_map_:" + << foreground_send_surface_map_.size() + << ", background_send_surface_map_:" + << background_send_surface_map_.size(); std::move(status_codes_callback)(status_codes); }); @@ -572,24 +569,23 @@ void NearbySharingServiceImpl::RegisterReceiveSurface( status_codes_callback = std::move(status_codes_callback)]() { if (state != ReceiveSurfaceState::kForeground && state != ReceiveSurfaceState::kBackground) { - NL_LOG(ERROR) << __func__ << ": Invalid ReceiveSurfaceState: " - << static_cast(state); + LOG(ERROR) << __func__ << ": Invalid ReceiveSurfaceState: " + << static_cast(state); std::move(status_codes_callback)(StatusCodes::kInvalidArgument); return; } - NL_DCHECK(transfer_callback); + DCHECK(transfer_callback); - NL_LOG(INFO) << __func__ - << ": RegisterReceiveSurface is called with state: " - << (state == ReceiveSurfaceState::kForeground - ? "Foreground" - : "Background") - << ", transfer_callback: " << transfer_callback - << ", vendor_id: " << static_cast(vendor_id); + LOG(INFO) << __func__ + << ": RegisterReceiveSurface is called with state: " + << (state == ReceiveSurfaceState::kForeground ? "Foreground" + : "Background") + << ", transfer_callback: " << transfer_callback + << ", vendor_id: " << static_cast(vendor_id); // Check available mediums. if (!HasAvailableConnectionMediums()) { - NL_VLOG(1) << __func__ << ": No available connection medium."; + VLOG(1) << __func__ << ": No available connection medium."; std::move(status_codes_callback)( StatusCodes::kNoAvailableConnectionMedium); return; @@ -600,28 +596,28 @@ void NearbySharingServiceImpl::RegisterReceiveSurface( // caller that the transfer_callback is currently registered. if (GetReceiveCallbacksMapFromState(state).contains( transfer_callback)) { - NL_VLOG(1) << __func__ - << ": transfer callback already registered, ignoring"; + VLOG(1) << __func__ + << ": transfer callback already registered, ignoring"; std::move(status_codes_callback)(StatusCodes::kOk); return; } if (foreground_receive_callbacks_map_.contains(transfer_callback) || background_receive_callbacks_map_.contains(transfer_callback)) { - NL_LOG(ERROR) << __func__ - << ": transfer callback already registered but for a " - "different state."; + LOG(ERROR) << __func__ + << ": transfer callback already registered but for a " + "different state."; std::move(status_codes_callback)(StatusCodes::kInvalidArgument); return; } if (ShouldBlockSurfaceRegistration(vendor_id, before_registration_vendor_id)) { // Block alternate vendor ID registration. - NL_LOG(ERROR) << __func__ - << ": disallowing registration of a receive surface " - "that has vendor_id " - << static_cast(vendor_id) - << " because the current vendor_id is " - << static_cast(GetReceivingVendorId()); + LOG(ERROR) << __func__ + << ": disallowing registration of a receive surface " + "that has vendor_id " + << static_cast(vendor_id) + << " because the current vendor_id is " + << static_cast(GetReceivingVendorId()); std::move(status_codes_callback)(StatusCodes::kInvalidArgument); return; } @@ -639,17 +635,17 @@ void NearbySharingServiceImpl::RegisterReceiveSurface( GetReceiveCallbacksMapFromState(state).insert( {transfer_callback, vendor_id}); - NL_VLOG(1) << __func__ << ": A ReceiveSurface(" - << ReceiveSurfaceStateToString(state) - << ") has been registered"; + VLOG(1) << __func__ << ": A ReceiveSurface(" + << ReceiveSurfaceStateToString(state) + << ") has been registered"; if (state == ReceiveSurfaceState::kForeground) { if (!IsBluetoothPresent()) { - NL_LOG(ERROR) << __func__ << ": Bluetooth is not present."; + LOG(ERROR) << __func__ << ": Bluetooth is not present."; } else if (!IsBluetoothPowered()) { - NL_LOG(WARNING) << __func__ << ": Bluetooth is not powered."; + LOG(WARNING) << __func__ << ": Bluetooth is not powered."; } else { - NL_VLOG(1) + VLOG(1) << __func__ << ": This device's MAC address is: " << nearby::device::CanonicalizeBluetoothAddress( context_->GetBluetoothAdapter().GetAddress().value_or( @@ -657,10 +653,10 @@ void NearbySharingServiceImpl::RegisterReceiveSurface( } } - NL_VLOG(1) << "RegisterReceiveSurface: foreground_receive_callbacks_:" - << foreground_receive_callbacks_map_.size() - << ", background_receive_callbacks_:" - << background_receive_callbacks_map_.size(); + VLOG(1) << "RegisterReceiveSurface: foreground_receive_callbacks_:" + << foreground_receive_callbacks_map_.size() + << ", background_receive_callbacks_:" + << background_receive_callbacks_map_.size(); InvalidateReceiveSurfaceState(); std::move(status_codes_callback)(StatusCodes::kOk); @@ -676,10 +672,10 @@ void NearbySharingServiceImpl::UnregisterReceiveSurface( status_codes_callback = std::move(status_codes_callback)]() { StatusCodes status_codes = InternalUnregisterReceiveSurface(transfer_callback); - NL_VLOG(1) << "UnregisterReceiveSurface: foreground_receive_callbacks_:" - << foreground_receive_callbacks_map_.size() - << ", background_receive_callbacks_:" - << background_receive_callbacks_map_.size(); + VLOG(1) << "UnregisterReceiveSurface: foreground_receive_callbacks_:" + << foreground_receive_callbacks_map_.size() + << ", background_receive_callbacks_:" + << background_receive_callbacks_map_.size(); std::move(status_codes_callback)(status_codes); return; }); @@ -724,27 +720,27 @@ void NearbySharingServiceImpl::SendAttachments( attachment_container = std::move(attachment_container), status_codes_callback = std::move(status_codes_callback)]() mutable { if (!is_scanning_) { - NL_LOG(WARNING) << __func__ - << ": Failed to send attachments. Not scanning."; + LOG(WARNING) << __func__ + << ": Failed to send attachments. Not scanning."; std::move(status_codes_callback)(StatusCodes::kOutOfOrderApiCall); return; } // |is_scanning_| means at least one send transfer callback. - NL_DCHECK(!foreground_send_surface_map_.empty() || - !background_send_surface_map_.empty()); + DCHECK(!foreground_send_surface_map_.empty() || + !background_send_surface_map_.empty()); // |is_scanning_| and |is_transferring_| are mutually exclusive. - NL_DCHECK(!is_transferring_); + DCHECK(!is_transferring_); if (!attachment_container || !attachment_container->HasAttachments()) { - NL_LOG(WARNING) << __func__ << ": No attachments to send."; + LOG(WARNING) << __func__ << ": No attachments to send."; std::move(status_codes_callback)(StatusCodes::kInvalidArgument); return; } for (const FileAttachment& attachment : attachment_container->GetFileAttachments()) { if (!attachment.file_path() || attachment.file_path()->empty()) { - NL_LOG(WARNING) << __func__ << ": Got file attachment without path"; + LOG(WARNING) << __func__ << ": Got file attachment without path"; std::move(status_codes_callback)(StatusCodes::kInvalidArgument); return; } @@ -754,8 +750,7 @@ void NearbySharingServiceImpl::SendAttachments( CreateEndpointInfo(DeviceVisibility::DEVICE_VISIBILITY_ALL_CONTACTS, local_device_data_manager_->GetDeviceName()); if (!endpoint_info) { - NL_LOG(WARNING) << __func__ - << ": Could not create local endpoint info."; + LOG(WARNING) << __func__ << ": Could not create local endpoint info."; std::move(status_codes_callback)(StatusCodes::kError); return; } @@ -763,9 +758,8 @@ void NearbySharingServiceImpl::SendAttachments( OutgoingShareSession* session = GetOutgoingShareSession(share_target_id); if (!session) { - NL_LOG(WARNING) - << __func__ - << ": Failed to send attachments. Unknown ShareTarget."; + LOG(WARNING) << __func__ + << ": Failed to send attachments. Unknown ShareTarget."; std::move(status_codes_callback)(StatusCodes::kInvalidArgument); return; } @@ -832,8 +826,7 @@ void NearbySharingServiceImpl::Accept( : StatusCodes::kOutOfOrderApiCall); return; } - NL_LOG(WARNING) << __func__ - << ": Accept invoked for unknown share target"; + LOG(WARNING) << __func__ << ": Accept invoked for unknown share target"; std::move(status_codes_callback)(StatusCodes::kInvalidArgument); }); } @@ -847,14 +840,14 @@ void NearbySharingServiceImpl::Reject( status_codes_callback = std::move(status_codes_callback)]() { ShareSession* session = GetShareSession(share_target_id); if (session == nullptr) { - NL_LOG(WARNING) << __func__ - << ": Reject invoked for unknown share target"; + LOG(WARNING) << __func__ + << ": Reject invoked for unknown share target"; std::move(status_codes_callback)(StatusCodes::kInvalidArgument); return; } if (!session->IsConnected()) { - NL_LOG(WARNING) << __func__ - << ": Reject invoked for unconnected share target"; + LOG(WARNING) << __func__ + << ": Reject invoked for unconnected share target"; std::move(status_codes_callback)(StatusCodes::kOutOfOrderApiCall); return; } @@ -869,8 +862,8 @@ void NearbySharingServiceImpl::Reject( session->set_disconnect_status(TransferMetadata::Status::kUnknown); session->WriteResponseFrame(ConnectionResponseFrame::REJECT); - NL_VLOG(1) << __func__ - << ": Successfully wrote a rejection response frame"; + VLOG(1) << __func__ + << ": Successfully wrote a rejection response frame"; session->UpdateTransferMetadata( TransferMetadataBuilder() @@ -887,9 +880,9 @@ void NearbySharingServiceImpl::Cancel( RunOnAnyThread("api_cancel", [this, share_target_id, status_codes_callback = std::move(status_codes_callback)]() { - NL_LOG(INFO) << __func__ << ": User canceled transfer"; + LOG(INFO) << __func__ << ": User canceled transfer"; if (locally_cancelled_share_target_ids_.contains(share_target_id)) { - NL_LOG(WARNING) << __func__ << ": Cancel is called again."; + LOG(WARNING) << __func__ << ": Cancel is called again."; status_codes_callback(StatusCodes::kOutOfOrderApiCall); return; } @@ -908,7 +901,7 @@ void NearbySharingServiceImpl::DoCancel( bool is_initiator_of_cancellation) { ShareSession* session = GetShareSession(share_target_id); if (session == nullptr) { - NL_LOG(WARNING) << __func__ << ": Cancel invoked for unknown share target"; + LOG(WARNING) << __func__ << ": Cancel invoked for unknown share target"; std::move(status_codes_callback)(StatusCodes::kInvalidArgument); return; } @@ -944,8 +937,8 @@ void NearbySharingServiceImpl::DoCancel( // user before a connection is fully established, in which case, // session->connection() will be null. if (session->IsConnected()) { - NL_LOG(INFO) << "Disconnect fully established endpoint id:" - << session->endpoint_id(); + LOG(INFO) << "Disconnect fully established endpoint id:" + << session->endpoint_id(); if (is_initiator_of_cancellation) { // kCancelled status already sent above, no need to send on disconnect. session->set_disconnect_status(TransferMetadata::Status::kUnknown); @@ -953,7 +946,7 @@ void NearbySharingServiceImpl::DoCancel( RunOnNearbySharingServiceThreadDelayed( "initiator_cancel_delay", kInitiatorCancelDelay, [this, share_target_id]() { - NL_LOG(INFO) << "Close connection after cancellation delay."; + LOG(INFO) << "Close connection after cancellation delay."; CloseConnection(share_target_id); }); @@ -962,7 +955,7 @@ void NearbySharingServiceImpl::DoCancel( session->connection()->Close(); } } else { - NL_LOG(INFO) << "Disconnect endpoint id:" << session->endpoint_id(); + LOG(INFO) << "Disconnect endpoint id:" << session->endpoint_id(); nearby_connections_manager_->Disconnect(session->endpoint_id()); UnregisterShareTarget(share_target_id); } @@ -982,17 +975,16 @@ void NearbySharingServiceImpl::SetVisibility( RunOnNearbySharingServiceThread( "api_set_visibility", [this, visibility, expiration, callback = std::move(callback)]() mutable { - NL_LOG(INFO) << __func__ << ": SetVisibility is called"; + LOG(INFO) << __func__ << ": SetVisibility is called"; if (account_manager_.GetCurrentAccount() == std::nullopt) { switch (visibility) { case proto::DeviceVisibility::DEVICE_VISIBILITY_EVERYONE: case proto::DeviceVisibility::DEVICE_VISIBILITY_HIDDEN: break; default: - NL_LOG(WARNING) - << __func__ - << ": SetVisibility failed for visibility: " << visibility - << ". No account."; + LOG(WARNING) << __func__ + << ": SetVisibility failed for visibility: " + << visibility << ". No account."; std::move(callback)(StatusCodes::kInvalidArgument); return; } @@ -1032,7 +1024,7 @@ AccountManager* NearbySharingServiceImpl::GetAccountManager() { void NearbySharingServiceImpl::OnIncomingConnection( absl::string_view endpoint_id, absl::Span endpoint_info, NearbyConnection* connection) { - NL_DCHECK(connection); + DCHECK(connection); app_info_->SetActiveFlag(); @@ -1041,10 +1033,9 @@ void NearbySharingServiceImpl::OnIncomingConnection( // need to wait for these calls to finish. The periodic server requests will // typically be sufficient, but we don't want the user to be blocked for // hours waiting for a periodic sync. - NL_VLOG(1) - << __func__ - << ": Downloading local device data, contacts, and certificates from " - << "Nearby server at start of receiving flow."; + VLOG(1) << __func__ + << ": Downloading local device data, contacts, and certificates from " + << "Nearby server at start of receiving flow."; local_device_data_manager_->DownloadDeviceData(); contact_manager_->DownloadContacts(); certificate_manager_->DownloadPublicCertificates(); @@ -1069,15 +1060,14 @@ void NearbySharingServiceImpl::OnIncomingConnection( NearbySharingService::StatusCodes NearbySharingServiceImpl::InternalUnregisterSendSurface( TransferUpdateCallback* transfer_callback) { - NL_DCHECK(transfer_callback); - NL_LOG(INFO) << __func__ << ": UnregisterSendSurface is called" - << ", transfer_callback: " << transfer_callback; + DCHECK(transfer_callback); + LOG(INFO) << __func__ << ": UnregisterSendSurface is called" + << ", transfer_callback: " << transfer_callback; if (!foreground_send_surface_map_.contains(transfer_callback) && !background_send_surface_map_.contains(transfer_callback)) { - NL_VLOG(1) - << __func__ - << ": unregisterSendSurface failed. Unknown TransferUpdateCallback"; + VLOG(1) << __func__ + << ": unregisterSendSurface failed. Unknown TransferUpdateCallback"; return StatusCodes::kError; } @@ -1109,8 +1099,8 @@ NearbySharingServiceImpl::InternalUnregisterSendSurface( } } - NL_VLOG(1) << __func__ << ": A SendSurface has been unregistered: " - << SendSurfaceStateToString(state); + VLOG(1) << __func__ << ": A SendSurface has been unregistered: " + << SendSurfaceStateToString(state); InvalidateSurfaceState(); return StatusCodes::kOk; } @@ -1118,18 +1108,18 @@ NearbySharingServiceImpl::InternalUnregisterSendSurface( NearbySharingService::StatusCodes NearbySharingServiceImpl::InternalUnregisterReceiveSurface( TransferUpdateCallback* transfer_callback) { - NL_DCHECK(transfer_callback); + DCHECK(transfer_callback); - NL_LOG(INFO) << __func__ << ": UnregisterReceiveSurface is called" - << ", transfer_callback: " << transfer_callback; + LOG(INFO) << __func__ << ": UnregisterReceiveSurface is called" + << ", transfer_callback: " << transfer_callback; bool is_foreground = foreground_receive_callbacks_map_.contains(transfer_callback); bool is_background = background_receive_callbacks_map_.contains(transfer_callback); if (!is_foreground && !is_background) { - NL_VLOG(1) << __func__ - << ": Unknown transfer callback was un-registered, ignoring."; + VLOG(1) << __func__ + << ": Unknown transfer callback was un-registered, ignoring."; // We intentionally allow this be successful so the caller can be sure // they are not registered anymore. return StatusCodes::kOk; @@ -1160,9 +1150,9 @@ NearbySharingServiceImpl::InternalUnregisterReceiveSurface( } } - NL_VLOG(1) << __func__ << ": A ReceiveSurface(" - << (is_foreground ? "foreground" : "background") - << ") has been unregistered"; + VLOG(1) << __func__ << ": A ReceiveSurface(" + << (is_foreground ? "foreground" : "background") + << ") has been unregistered"; InvalidateSurfaceState(); return StatusCodes::kOk; } @@ -1284,8 +1274,8 @@ void NearbySharingServiceImpl::OnSettingChanged(absl::string_view key, void NearbySharingServiceImpl::OnDataUsageChanged(DataUsage data_usage) { RunOnNearbySharingServiceThread( "on_data_usage_changed", [this, data_usage]() { - NL_LOG(INFO) << __func__ << ": Nearby sharing data usage changed to " - << DataUsage_Name(data_usage); + LOG(INFO) << __func__ << ": Nearby sharing data usage changed to " + << DataUsage_Name(data_usage); StopAdvertisingAndInvalidateSurfaceState(); }); } @@ -1295,9 +1285,8 @@ void NearbySharingServiceImpl::OnCustomSavePathChanged( RunOnNearbySharingServiceThread( "on_custom_save_path_changed", [this, custom_save_path = std::string(custom_save_path)]() { - NL_LOG(INFO) << __func__ - << ": Nearby sharing custom save path changed to " - << custom_save_path; + LOG(INFO) << __func__ << ": Nearby sharing custom save path changed to " + << custom_save_path; nearby_connections_manager_->SetCustomSavePath(custom_save_path); }); } @@ -1306,8 +1295,8 @@ void NearbySharingServiceImpl::OnVisibilityChanged( DeviceVisibility visibility) { RunOnNearbySharingServiceThread( "on_visibility_changed", [this, visibility]() { - NL_LOG(INFO) << __func__ << ": Nearby sharing visibility changed to " - << DeviceVisibility_Name(visibility); + LOG(INFO) << __func__ << ": Nearby sharing visibility changed to " + << DeviceVisibility_Name(visibility); StopAdvertisingAndInvalidateSurfaceState(); }); } @@ -1318,11 +1307,10 @@ void NearbySharingServiceImpl::OnPublicCertificatesDownloaded() { return; } - NL_LOG(INFO) << __func__ - << ": Public certificates downloaded while scanning. " - << "Retrying decryption with " - << discovered_advertisements_to_retry_map_.size() - << " previously discovered advertisements."; + LOG(INFO) << __func__ << ": Public certificates downloaded while scanning. " + << "Retrying decryption with " + << discovered_advertisements_to_retry_map_.size() + << " previously discovered advertisements."; const auto map_copy = discovered_advertisements_to_retry_map_; discovered_advertisements_to_retry_map_.clear(); for (const auto& id_info_pair : map_copy) { @@ -1339,7 +1327,7 @@ void NearbySharingServiceImpl::OnPrivateCertificatesChanged() { void NearbySharingServiceImpl::OnLoginSucceeded(absl::string_view account_id) { RunOnNearbySharingServiceThread("on_login_succeeded", [this]() { - NL_LOG(INFO) << __func__ << ": Account login."; + LOG(INFO) << __func__ << ": Account login."; ResetAllSettings(/*logout=*/false); }); @@ -1349,7 +1337,7 @@ void NearbySharingServiceImpl::OnLogoutSucceeded(absl::string_view account_id, bool credential_error) { RunOnNearbySharingServiceThread( "on_logout_succeeded", [this, credential_error]() { - NL_LOG(INFO) << __func__ << ": Account logout."; + LOG(INFO) << __func__ << ": Account logout."; // Reset all settings. ResetAllSettings(/*logout=*/true); @@ -1389,7 +1377,7 @@ void NearbySharingServiceImpl::OnEndpointLost(absl::string_view endpoint_id) { void NearbySharingServiceImpl::OnLockStateChanged(bool locked) { RunOnNearbySharingServiceThread("on_lock_state_changed", [this, locked]() { - NL_VLOG(1) << __func__ << ": Screen lock state changed. (" << locked << ")"; + VLOG(1) << __func__ << ": Screen lock state changed. (" << locked << ")"; is_screen_locked_ = locked; InvalidateSurfaceState(); }); @@ -1399,8 +1387,8 @@ void NearbySharingServiceImpl::AdapterPresentChanged( sharing::api::BluetoothAdapter* adapter, bool present) { RunOnNearbySharingServiceThread( "bt_adapter_present_changed", [this, adapter, present]() { - NL_VLOG(1) << __func__ << ": Bluetooth adapter present state changed. (" - << present << ")"; + VLOG(1) << __func__ << ": Bluetooth adapter present state changed. (" + << present << ")"; NearbySharingService::Observer::AdapterState state = MapAdapterState(present, adapter->IsPowered()); for (auto& observer : observers_.GetObservers()) { @@ -1414,8 +1402,8 @@ void NearbySharingServiceImpl::AdapterPoweredChanged( sharing::api::BluetoothAdapter* adapter, bool powered) { RunOnNearbySharingServiceThread( "bt_adapter_power_changed", [this, adapter, powered]() { - NL_VLOG(1) << __func__ << ": Bluetooth adapter power state changed. (" - << powered << ")"; + VLOG(1) << __func__ << ": Bluetooth adapter power state changed. (" + << powered << ")"; NearbySharingService::Observer::AdapterState state = MapAdapterState(adapter->IsPresent(), powered); for (auto& observer : observers_.GetObservers()) { @@ -1429,8 +1417,8 @@ void NearbySharingServiceImpl::AdapterPresentChanged( sharing::api::WifiAdapter* adapter, bool present) { RunOnNearbySharingServiceThread( "wifi_adapter_present_changed", [this, adapter, present]() { - NL_VLOG(1) << __func__ << ": Wifi adapter present state changed. (" - << present << ")"; + VLOG(1) << __func__ << ": Wifi adapter present state changed. (" + << present << ")"; NearbySharingService::Observer::AdapterState state = MapAdapterState(present, adapter->IsPowered()); for (auto& observer : observers_.GetObservers()) { @@ -1444,8 +1432,8 @@ void NearbySharingServiceImpl::AdapterPoweredChanged( sharing::api::WifiAdapter* adapter, bool powered) { RunOnNearbySharingServiceThread( "wifi_adapter_power_changed", [this, adapter, powered]() { - NL_VLOG(1) << __func__ << ": Wifi adapter power state changed. (" - << powered << ")"; + VLOG(1) << __func__ << ": Wifi adapter power state changed. (" + << powered << ")"; NearbySharingService::Observer::AdapterState state = MapAdapterState(adapter->IsPresent(), powered); for (auto& observer : observers_.GetObservers()) { @@ -1458,7 +1446,7 @@ void NearbySharingServiceImpl::AdapterPoweredChanged( void NearbySharingServiceImpl::HardwareErrorReported( NearbyFastInitiation* fast_init) { RunOnNearbySharingServiceThread("hardware_error_reported", [this]() { - NL_VLOG(1) << __func__ << ": Hardware error reported, need to restart PC."; + VLOG(1) << __func__ << ": Hardware error reported, need to restart PC."; for (auto& observer : observers_.GetObservers()) { observer->OnIrrecoverableHardwareErrorReported(); } @@ -1467,7 +1455,7 @@ void NearbySharingServiceImpl::HardwareErrorReported( } void NearbySharingServiceImpl::SetupBluetoothAdapter() { - NL_VLOG(1) << __func__ << ": Setup bluetooth adapter."; + VLOG(1) << __func__ << ": Setup bluetooth adapter."; context_->GetBluetoothAdapter().AddObserver(this); InvalidateSurfaceState(); } @@ -1560,9 +1548,9 @@ NearbySharingServiceImpl::CreateEndpointInfo( salt = encrypted_metadata_key->salt(); encrypted_key = encrypted_metadata_key->encrypted_key(); } else { - NL_LOG(WARNING) << __func__ - << ": Failed to encrypt private certificate metadata key " - << "for advertisement."; + LOG(WARNING) << __func__ + << ": Failed to encrypt private certificate metadata key " + << "for advertisement."; } } @@ -1591,7 +1579,7 @@ NearbySharingServiceImpl::CreateEndpointInfo( } void NearbySharingServiceImpl::StartFastInitiationAdvertising() { - NL_VLOG(1) << __func__ << ": Starting fast initiation advertising."; + VLOG(1) << __func__ << ": Starting fast initiation advertising."; if (nearby_fast_initiation_->IsAdvertising()) { return; @@ -1601,22 +1589,22 @@ void NearbySharingServiceImpl::StartFastInitiationAdvertising() { NearbyFastInitiation::FastInitType::kSilent, [this]() { OnStartFastInitiationAdvertising(); }, [this]() { OnStartFastInitiationAdvertisingError(); }); - NL_VLOG(1) << __func__ << ": Fast initiation advertising in kSilent mode."; + VLOG(1) << __func__ << ": Fast initiation advertising in kSilent mode."; // Log analytics event of sending fast initiation. analytics_recorder_.NewSendFastInitialization(); } void NearbySharingServiceImpl::OnStartFastInitiationAdvertising() { - NL_VLOG(1) << __func__ << ": Started fast initiation advertising."; + VLOG(1) << __func__ << ": Started fast initiation advertising."; } void NearbySharingServiceImpl::OnStartFastInitiationAdvertisingError() { - NL_LOG(ERROR) << __func__ << ": Failed to start fast initiation advertising."; + LOG(ERROR) << __func__ << ": Failed to start fast initiation advertising."; } void NearbySharingServiceImpl::StopFastInitiationAdvertising() { - NL_VLOG(1) << __func__ << ": Stopping fast initiation advertising."; + VLOG(1) << __func__ << ": Stopping fast initiation advertising."; if (!nearby_fast_initiation_->IsAdvertising()) { return; @@ -1627,7 +1615,7 @@ void NearbySharingServiceImpl::StopFastInitiationAdvertising() { } void NearbySharingServiceImpl::OnStopFastInitiationAdvertising() { - NL_VLOG(1) << __func__ << ": Stopped fast initiation advertising"; + VLOG(1) << __func__ << ": Stopped fast initiation advertising"; } // Processes endpoint discovered/lost events. We queue up the events to ensure @@ -1651,7 +1639,7 @@ void NearbySharingServiceImpl::HandleEndpointDiscovered( << ", endpoint_info=" << nearby::utils::HexEncode(endpoint_info) << " time: " << context_->GetClock()->Now(); if (!is_scanning_) { - NL_VLOG(1) + VLOG(1) << __func__ << ": Ignoring discovered endpoint because we're no longer scanning"; FinishEndpointDiscoveryEvent(); @@ -1661,8 +1649,7 @@ void NearbySharingServiceImpl::HandleEndpointDiscovered( std::unique_ptr advertisement = DecodeAdvertisement(endpoint_info); if (!advertisement) { - NL_LOG(WARNING) << __func__ - << ": Failed to parse discovered advertisement."; + LOG(WARNING) << __func__ << ": Failed to parse discovered advertisement."; FinishEndpointDiscoveryEvent(); return; } @@ -1716,8 +1703,8 @@ void NearbySharingServiceImpl::HandleEndpointLost( << " time: " << context_->GetClock()->Now(); if (!is_scanning_) { - NL_VLOG(1) << __func__ - << ": Ignoring lost endpoint because we're no longer scanning"; + VLOG(1) << __func__ + << ": Ignoring lost endpoint because we're no longer scanning"; FinishEndpointDiscoveryEvent(); return; } @@ -1735,13 +1722,13 @@ void NearbySharingServiceImpl::HandleEndpointLost( } void NearbySharingServiceImpl::FinishEndpointDiscoveryEvent() { - NL_DCHECK(!endpoint_discovery_events_.empty()); - NL_DCHECK(endpoint_discovery_events_.front() == nullptr); + DCHECK(!endpoint_discovery_events_.empty()); + DCHECK(endpoint_discovery_events_.front() == nullptr); endpoint_discovery_events_.pop(); // Handle the next queued up endpoint discovered/lost event. if (!endpoint_discovery_events_.empty()) { - NL_DCHECK(endpoint_discovery_events_.front() != nullptr); + DCHECK(endpoint_discovery_events_.front() != nullptr); auto discovery_event = std::move(endpoint_discovery_events_.front()); discovery_event(); } @@ -1870,10 +1857,10 @@ void NearbySharingServiceImpl::OnCertificateDownloadDuringDiscoveryTimerFired( } if (!discovered_advertisements_to_retry_map_.empty()) { - NL_VLOG(1) << __func__ << ": Detected " - << discovered_advertisements_to_retry_map_.size() - << " discovered advertisements that could not decrypt any " - << "public certificates. Re-downloading certificates."; + VLOG(1) << __func__ << ": Detected " + << discovered_advertisements_to_retry_map_.size() + << " discovered advertisements that could not decrypt any " + << "public certificates. Re-downloading certificates."; certificate_manager_->DownloadPublicCertificates(); ++attempt_count; } @@ -1936,33 +1923,31 @@ void NearbySharingServiceImpl::InvalidateScanningState() { // Stop scanning when screen is off. if (is_screen_locked_) { StopScanning(); - NL_VLOG(1) << __func__ - << ": Stopping discovery because the screen is locked."; + VLOG(1) << __func__ << ": Stopping discovery because the screen is locked."; return; } if (!HasAvailableConnectionMediums()) { StopScanning(); - NL_VLOG(1) << __func__ - << ": Stopping scanning because both bluetooth and wifi LAN are " - "disabled."; + VLOG(1) << __func__ + << ": Stopping scanning because both bluetooth and wifi LAN are " + "disabled."; return; } if (is_transferring_ || is_connecting_) { StopScanning(); - NL_VLOG(1) - << __func__ - << ": Stopping discovery because we're currently in the midst of a " - "transfer."; + VLOG(1) << __func__ + << ": Stopping discovery because we're currently in the midst of a " + "transfer."; return; } if (foreground_send_surface_map_.empty()) { StopScanning(); - NL_VLOG(1) << __func__ - << ": Stopping discovery because no scanning surface has been " - "registered."; + VLOG(1) << __func__ + << ": Stopping discovery because no scanning surface has been " + "registered."; return; } @@ -1975,32 +1960,32 @@ void NearbySharingServiceImpl::InvalidateFastInitiationAdvertising() { // Screen is off. Do no work. if (is_screen_locked_) { StopFastInitiationAdvertising(); - NL_VLOG(1) << __func__ - << ": Stopping fast initiation advertising because the " - "screen is locked."; + VLOG(1) << __func__ + << ": Stopping fast initiation advertising because the " + "screen is locked."; return; } if (!IsBluetoothPowered()) { StopFastInitiationAdvertising(); - NL_VLOG(1) << __func__ - << ": Stopping fast initiation advertising because " - "bluetooth is disabled due to powered off."; + VLOG(1) << __func__ + << ": Stopping fast initiation advertising because " + "bluetooth is disabled due to powered off."; return; } if (is_transferring_ || is_connecting_) { StopFastInitiationAdvertising(); - NL_VLOG(1) << __func__ - << ": Stopping fast initiation advertising because we're " - "currently in the midst of a " - "transfer."; + VLOG(1) << __func__ + << ": Stopping fast initiation advertising because we're " + "currently in the midst of a " + "transfer."; return; } if (foreground_send_surface_map_.empty()) { StopFastInitiationAdvertising(); - NL_VLOG(1) + VLOG(1) << __func__ << ": Stopping fast initiation advertising because no foreground send " "surface is registered."; @@ -2021,33 +2006,31 @@ void NearbySharingServiceImpl::InvalidateAdvertisingState() { !NearbyFlags::GetInstance().GetBoolFlag( config_package_nearby::nearby_sharing_feature::kEnableSelfShareUi)) { StopAdvertising(); - NL_VLOG(1) << __func__ - << ": Stopping advertising because the screen is locked."; + VLOG(1) << __func__ + << ": Stopping advertising because the screen is locked."; return; } if (!HasAvailableConnectionMediums()) { StopAdvertising(); - NL_VLOG(1) - << __func__ - << ": Stopping advertising because both bluetooth and wifi LAN are " - "disabled."; + VLOG(1) << __func__ + << ": Stopping advertising because both bluetooth and wifi LAN are " + "disabled."; return; } if (is_transferring_) { StopAdvertising(); - NL_VLOG(1) - << __func__ - << ": Stopping advertising because we're currently in the midst of " - "a transfer."; + VLOG(1) << __func__ + << ": Stopping advertising because we're currently in the midst of " + "a transfer."; return; } if (foreground_receive_callbacks_map_.empty() && background_receive_callbacks_map_.empty()) { StopAdvertising(); - NL_VLOG(1) + VLOG(1) << __func__ << ": Stopping advertising because no receive surface is registered."; return; @@ -2057,8 +2040,8 @@ void NearbySharingServiceImpl::InvalidateAdvertisingState() { // other than HIDDEN or UNSPECIFIED. if (!IsVisibleInBackground(settings_->GetVisibility())) { StopAdvertising(); - NL_VLOG(1) << __func__ - << ": Stopping advertising because device is visible to NO_ONE."; + VLOG(1) << __func__ + << ": Stopping advertising because device is visible to NO_ONE."; return; } @@ -2072,18 +2055,16 @@ void NearbySharingServiceImpl::InvalidateAdvertisingState() { DataUsage data_usage = settings_->GetDataUsage(); if (advertising_power_level_ != PowerLevel::kUnknown) { if (power_level == advertising_power_level_) { - NL_VLOG(1) << __func__ - << ": Ignoring, already advertising with power level " - << PowerLevelToString(advertising_power_level_) - << " and data usage preference " - << static_cast(data_usage); + VLOG(1) << __func__ << ": Ignoring, already advertising with power level " + << PowerLevelToString(advertising_power_level_) + << " and data usage preference " << static_cast(data_usage); return; } StopAdvertising(); - NL_VLOG(1) << __func__ << ": Restart advertising with power level " - << PowerLevelToString(power_level) - << " and data usage preference " << static_cast(data_usage); + VLOG(1) << __func__ << ": Restart advertising with power level " + << PowerLevelToString(power_level) << " and data usage preference " + << static_cast(data_usage); } std::optional device_name; @@ -2097,9 +2078,9 @@ void NearbySharingServiceImpl::InvalidateAdvertisingState() { std::optional> endpoint_info = CreateEndpointInfo(visibility, device_name); if (!endpoint_info) { - NL_VLOG(1) << __func__ - << ": Unable to advertise since could not parse the " - "endpoint info from the advertisement."; + VLOG(1) << __func__ + << ": Unable to advertise since could not parse the " + "endpoint info from the advertisement."; return; } if (device_name.has_value()) { @@ -2132,21 +2113,21 @@ void NearbySharingServiceImpl::InvalidateAdvertisingState() { }); advertising_power_level_ = power_level; - NL_VLOG(1) << __func__ - << ": StartAdvertising requested over Nearby Connections: " - << " power level: " << PowerLevelToString(power_level) - << " visibility: " - << DeviceVisibility_Name(settings_->GetVisibility()) - << " data usage: " << DataUsage_Name(data_usage) - << " advertise device name?: " - << (device_name.has_value() ? "yes" : "no"); + VLOG(1) << __func__ + << ": StartAdvertising requested over Nearby Connections: " + << " power level: " << PowerLevelToString(power_level) + << " visibility: " + << DeviceVisibility_Name(settings_->GetVisibility()) + << " data usage: " << DataUsage_Name(data_usage) + << " advertise device name?: " + << (device_name.has_value() ? "yes" : "no"); ScheduleRotateBackgroundAdvertisementTimer(); } void NearbySharingServiceImpl::StopAdvertising() { if (advertising_power_level_ == PowerLevel::kUnknown) { - NL_VLOG(1) << __func__ << ": Not currently advertising, ignoring."; + VLOG(1) << __func__ << ": Not currently advertising, ignoring."; return; } @@ -2156,7 +2137,7 @@ void NearbySharingServiceImpl::StopAdvertising() { OnStopAdvertisingResult(status); }); - NL_VLOG(1) << __func__ << ": Stop advertising requested"; + VLOG(1) << __func__ << ": Stop advertising requested"; // Set power level to unknown immediately instead of waiting for the callback. // In the case of restarting advertising (e.g. turning off high visibility @@ -2167,12 +2148,12 @@ void NearbySharingServiceImpl::StopAdvertising() { } void NearbySharingServiceImpl::StartScanning() { - NL_DCHECK(!is_screen_locked_); - NL_DCHECK(HasAvailableConnectionMediums()); - NL_DCHECK(!foreground_send_surface_map_.empty()); + DCHECK(!is_screen_locked_); + DCHECK(HasAvailableConnectionMediums()); + DCHECK(!foreground_send_surface_map_.empty()); if (is_scanning_) { - NL_VLOG(1) << __func__ << ": We're currently scanning, ignoring."; + VLOG(1) << __func__ << ": We're currently scanning, ignoring."; return; } @@ -2206,12 +2187,12 @@ void NearbySharingServiceImpl::StartScanning() { }); InvalidateSendSurfaceState(); - NL_VLOG(1) << __func__ << ": Scanning has started"; + VLOG(1) << __func__ << ": Scanning has started"; } NearbySharingService::StatusCodes NearbySharingServiceImpl::StopScanning() { if (!is_scanning_) { - NL_VLOG(1) << __func__ << ": Not currently scanning, ignoring."; + VLOG(1) << __func__ << ": Not currently scanning, ignoring."; return StatusCodes::kStatusAlreadyStopped; } @@ -2235,7 +2216,7 @@ NearbySharingService::StatusCodes NearbySharingServiceImpl::StopScanning() { "invalidate_delay", kInvalidateDelay, [this]() { InvalidateSurfaceState(); }); - NL_VLOG(1) << __func__ << ": Scanning has stopped."; + VLOG(1) << __func__ << ": Scanning has stopped."; return StatusCodes::kOk; } @@ -2257,24 +2238,23 @@ void NearbySharingServiceImpl::InvalidateFastInitiationScanning() { if (fast_initiation_scanner_cooldown_timer_ && fast_initiation_scanner_cooldown_timer_->IsRunning()) { - NL_VLOG(1) << __func__ - << ": Stopping background scanning due to post-transfer " - "cooldown period"; + VLOG(1) << __func__ + << ": Stopping background scanning due to post-transfer " + "cooldown period"; StopFastInitiationScanning(); return; } // Screen is off. Do no work. if (is_screen_locked_) { - NL_VLOG(1) - << __func__ - << ": Stopping background scanning because the screen is locked."; + VLOG(1) << __func__ + << ": Stopping background scanning because the screen is locked."; StopFastInitiationScanning(); return; } if (!IsBluetoothPowered()) { - NL_VLOG(1) + VLOG(1) << __func__ << ": Stopping background scanning because bluetooth is powered down."; StopFastInitiationScanning(); @@ -2283,33 +2263,33 @@ void NearbySharingServiceImpl::InvalidateFastInitiationScanning() { // We're scanning for other nearby devices. Don't background scan. if (is_scanning_) { - NL_VLOG(1) << __func__ - << ": Stopping background scanning because we're scanning " - "for other devices."; + VLOG(1) << __func__ + << ": Stopping background scanning because we're scanning " + "for other devices."; StopFastInitiationScanning(); return; } if (is_transferring_) { - NL_VLOG(1) << __func__ - << ": Stopping background scanning because we're currently " - "in the midst of a transfer."; + VLOG(1) << __func__ + << ": Stopping background scanning because we're currently " + "in the midst of a transfer."; StopFastInitiationScanning(); return; } if (advertising_power_level_ == PowerLevel::kHighPower) { - NL_VLOG(1) << __func__ - << ": Stopping background scanning because we're already " - "in high visibility mode."; + VLOG(1) << __func__ + << ": Stopping background scanning because we're already " + "in high visibility mode."; StopFastInitiationScanning(); return; } if (!is_hardware_offloading_supported) { - NL_VLOG(1) << __func__ - << ": Stopping background scanning because hardware " - "support is not available or not ready."; + VLOG(1) << __func__ + << ": Stopping background scanning because hardware " + "support is not available or not ready."; StopFastInitiationScanning(); return; } @@ -2318,7 +2298,7 @@ void NearbySharingServiceImpl::InvalidateFastInitiationScanning() { } void NearbySharingServiceImpl::StartFastInitiationScanning() { - NL_VLOG(1) << __func__ << ": Starting background scanning."; + VLOG(1) << __func__ << ": Starting background scanning."; if (nearby_fast_initiation_->IsScanning()) { return; @@ -2331,7 +2311,7 @@ void NearbySharingServiceImpl::StartFastInitiationScanning() { } void NearbySharingServiceImpl::OnFastInitiationDevicesDetected() { - NL_VLOG(1) << __func__; + VLOG(1) << __func__; for (auto& observer : observers_.GetObservers()) { observer->OnFastInitiationDevicesDetected(); @@ -2339,26 +2319,25 @@ void NearbySharingServiceImpl::OnFastInitiationDevicesDetected() { } void NearbySharingServiceImpl::OnFastInitiationDevicesNotDetected() { - NL_VLOG(1) << __func__; + VLOG(1) << __func__; for (auto& observer : observers_.GetObservers()) { observer->OnFastInitiationDevicesNotDetected(); } } void NearbySharingServiceImpl::StopFastInitiationScanning() { - NL_VLOG(1) << __func__ << ": Stop fast initiation scanning."; + VLOG(1) << __func__ << ": Stop fast initiation scanning."; if (!nearby_fast_initiation_->IsScanning()) { return; } - nearby_fast_initiation_->StopScanning([]() { - NL_VLOG(1) << __func__ << ": Stopped fast initiation scanning."; - }); + nearby_fast_initiation_->StopScanning( + []() { VLOG(1) << __func__ << ": Stopped fast initiation scanning."; }); for (auto& observer : observers_.GetObservers()) { observer->OnFastInitiationScanningStopped(); } - NL_VLOG(1) << __func__ << ": Stopped background scanning."; + VLOG(1) << __func__ << ": Stopped background scanning."; } void NearbySharingServiceImpl::ScheduleRotateBackgroundAdvertisementTimer() { @@ -2374,7 +2353,7 @@ void NearbySharingServiceImpl::ScheduleRotateBackgroundAdvertisementTimer() { } void NearbySharingServiceImpl::OnRotateBackgroundAdvertisementTimerFired() { - NL_LOG(INFO) << __func__ << ": Rotate background advertisement timer fired."; + LOG(INFO) << __func__ << ": Rotate background advertisement timer fired."; if (!foreground_receive_callbacks_map_.empty()) { ScheduleRotateBackgroundAdvertisementTimer(); @@ -2408,7 +2387,7 @@ void NearbySharingServiceImpl::OnTransferComplete() { is_transferring_ = false; is_sending_files_ = false; - NL_VLOG(1) << __func__ << ": NearbySharing state change transfer finished"; + VLOG(1) << __func__ << ": NearbySharing state change transfer finished"; // Files transfer is done! Receivers can immediately cancel, but senders // should add a short delay to ensure the final in-flight packet(s) make // it to the remote device. @@ -2431,8 +2410,7 @@ void NearbySharingServiceImpl::OnTransferStarted(bool is_incoming) { void NearbySharingServiceImpl::OnOutgoingConnection( int64_t share_target_id, NearbyConnection* connection, Status status) { - OutgoingShareSession* session = - GetOutgoingShareSession(share_target_id); + OutgoingShareSession* session = GetOutgoingShareSession(share_target_id); if (session == nullptr) { LOG(WARNING) << "Nearby connection connected, but share target " << share_target_id << " already disconnected."; @@ -2500,9 +2478,9 @@ void NearbySharingServiceImpl::OnCreatePayloads( !session.file_payloads().empty() || !session.wifi_credentials_payloads().empty(); if (!success || !has_payloads) { - NL_LOG(WARNING) << __func__ - << ": Failed to send file to remote ShareTarget. Failed to " - "create payloads."; + LOG(WARNING) << __func__ + << ": Failed to send file to remote ShareTarget. Failed to " + "create payloads."; session.UpdateTransferMetadata( TransferMetadataBuilder() .set_status(TransferMetadata::Status::kMediaUnavailable) @@ -2522,8 +2500,7 @@ void NearbySharingServiceImpl::OnCreatePayloads( session.Connect( std::move(endpoint_info), std::move(bluetooth_mac_address), - settings_->GetDataUsage(), - GetDisableWifiHotspotState(), + settings_->GetDataUsage(), GetDisableWifiHotspotState(), absl::bind_front(&NearbySharingServiceImpl::OnOutgoingConnection, this, share_target_id)); } @@ -2544,9 +2521,9 @@ void NearbySharingServiceImpl::OnIncomingAdvertisementDecoded( int64_t placeholder_share_target_id = session.share_target().id; if (!advertisement) { - NL_LOG(WARNING) << __func__ - << ": Failed to parse incoming connection from endpoint - " - << endpoint_id << ", disconnecting."; + LOG(WARNING) << __func__ + << ": Failed to parse incoming connection from endpoint - " + << endpoint_id << ", disconnecting."; session.Abort(TransferMetadata::Status::kFailed); return; } @@ -2581,10 +2558,10 @@ void NearbySharingServiceImpl::OnIncomingTransferUpdate( const IncomingShareSession& session, const TransferMetadata& metadata) { // kInProgress status is logged extensively elsewhere so avoid the spam. if (metadata.status() != TransferMetadata::Status::kInProgress) { - NL_VLOG(1) << __func__ << ": Nearby Share service: " - << "Incoming transfer update for share target with ID " - << session.share_target().id << ": " - << TransferMetadata::StatusToString(metadata.status()); + VLOG(1) << __func__ << ": Nearby Share service: " + << "Incoming transfer update for share target with ID " + << session.share_target().id << ": " + << TransferMetadata::StatusToString(metadata.status()); } if (metadata.status() != TransferMetadata::Status::kCancelled && metadata.status() != TransferMetadata::Status::kRejected) { @@ -2616,7 +2593,7 @@ void NearbySharingServiceImpl::OnIncomingTransferUpdate( } else { if (!nearby_connections_manager_->GetAndClearUnknownFilePathsToDelete() .empty()) { - NL_LOG(WARNING) << __func__ << ": Unknown file paths are not empty."; + LOG(WARNING) << __func__ << ": Unknown file paths are not empty."; } } } else if (metadata.status() == @@ -2639,10 +2616,10 @@ void NearbySharingServiceImpl::OnOutgoingTransferUpdate( OutgoingShareSession& session, const TransferMetadata& metadata) { // kInProgress status is logged extensively elsewhere so avoid the spam. if (metadata.status() != TransferMetadata::Status::kInProgress) { - NL_VLOG(1) << __func__ << ": Nearby Share service: " - << "Outgoing transfer update for share target with ID " - << session.share_target().id << ": " - << TransferMetadata::StatusToString(metadata.status()); + VLOG(1) << __func__ << ": Nearby Share service: " + << "Outgoing transfer update for share target with ID " + << session.share_target().id << ": " + << TransferMetadata::StatusToString(metadata.status()); } if (metadata.is_final_status()) { @@ -2698,8 +2675,8 @@ void NearbySharingServiceImpl::CloseConnection(int64_t share_target_id) { session->connection()->Close(); return; } - NL_LOG(WARNING) << __func__ << ": Invalid connection for target - " - << share_target_id; + LOG(WARNING) << __func__ << ": Invalid connection for target - " + << share_target_id; } void NearbySharingServiceImpl::OnIncomingDecryptedCertificate( @@ -2708,13 +2685,13 @@ void NearbySharingServiceImpl::OnIncomingDecryptedCertificate( std::optional certificate) { auto it = incoming_share_session_map_.find(placeholder_share_target_id); if (it == incoming_share_session_map_.end()) { - NL_VLOG(1) << __func__ << ": Invalid connection for endpoint id - " - << endpoint_id; + VLOG(1) << __func__ << ": Invalid connection for endpoint id - " + << endpoint_id; return; } if (!it->second.IsConnected()) { - NL_VLOG(1) << __func__ << ": Connection has been closed for endpoint id - " - << endpoint_id; + VLOG(1) << __func__ << ": Connection has been closed for endpoint id - " + << endpoint_id; incoming_share_session_map_.erase(it); return; } @@ -2725,9 +2702,9 @@ void NearbySharingServiceImpl::OnIncomingDecryptedCertificate( CreateShareTarget(endpoint_id, advertisement, certificate, /*is_incoming=*/true); if (!share_target) { - NL_LOG(WARNING) << __func__ - << ": Failed to convert advertisement to share target for " - "incoming connection, disconnecting"; + LOG(WARNING) << __func__ + << ": Failed to convert advertisement to share target for " + "incoming connection, disconnecting"; it->second.Abort(TransferMetadata::Status::kFailed); return; } @@ -2736,8 +2713,8 @@ void NearbySharingServiceImpl::OnIncomingDecryptedCertificate( incoming_share_session_map_.erase(it); int64_t share_target_id = share_target->id; - NL_VLOG(1) << __func__ << ": Received incoming connection from " - << share_target_id; + VLOG(1) << __func__ << ": Received incoming connection from " + << share_target_id; IncomingShareSession& session = CreateIncomingShareSession( *share_target, endpoint_id, std::move(certificate)); @@ -2767,7 +2744,7 @@ void NearbySharingServiceImpl::OnIncomingConnectionKeyVerificationDone( OSType share_target_os_type) { IncomingShareSession* session = GetIncomingShareSession(share_target_id); if (!session || !session->IsConnected()) { - NL_VLOG(1) << __func__ << ": Invalid connection or endpoint id"; + VLOG(1) << __func__ << ": Invalid connection or endpoint id"; return; } if (!session->ProcessKeyVerificationResult( @@ -2792,10 +2769,10 @@ void NearbySharingServiceImpl::OnOutgoingConnectionKeyVerificationDone( return; } - NL_VLOG(1) << __func__ << ": Preparing to send introduction to " - << share_target_id; + VLOG(1) << __func__ << ": Preparing to send introduction to " + << share_target_id; if (!session->SendIntroduction([this, share_target_id]() { - NL_VLOG(1) + VLOG(1) << "Outgoing mutual acceptance timed out, closing connection for " << share_target_id; OutgoingShareSession* session = @@ -2805,8 +2782,8 @@ void NearbySharingServiceImpl::OnOutgoingConnectionKeyVerificationDone( } session->Abort(TransferMetadata::Status::kTimedOut); })) { - NL_LOG(WARNING) << __func__ - << ": No payloads tied to transfer, disconnecting."; + LOG(WARNING) << __func__ + << ": No payloads tied to transfer, disconnecting."; session->Abort(TransferMetadata::Status::kMediaUnavailable); return; } @@ -2829,7 +2806,7 @@ void NearbySharingServiceImpl::OnReceivedIntroduction( int64_t share_target_id, std::optional frame) { IncomingShareSession* session = GetIncomingShareSession(share_target_id); if (!session || !session->IsConnected()) { - NL_LOG(WARNING) + LOG(WARNING) << __func__ << ": Ignore received introduction, due to no connection established."; return; @@ -2837,11 +2814,11 @@ void NearbySharingServiceImpl::OnReceivedIntroduction( if (!frame.has_value()) { session->Abort(TransferMetadata::Status::kFailed); - NL_LOG(WARNING) << __func__ << ": Invalid introduction frame"; + LOG(WARNING) << __func__ << ": Invalid introduction frame"; return; } - NL_LOG(INFO) << __func__ << ": Successfully read the introduction frame."; + LOG(INFO) << __func__ << ": Successfully read the introduction frame."; std::optional status = session->ProcessIntroduction(*frame); @@ -2859,9 +2836,9 @@ void NearbySharingServiceImpl::OnReceivedIntroduction( std::filesystem::u8path(settings_->GetCustomSavePath()), session->attachment_container().GetStorageSize())) { Fail(*session, TransferMetadata::Status::kNotEnoughSpace); - NL_LOG(WARNING) << __func__ - << ": Not enough space on the receiver. We have informed " - << share_target_id; + LOG(WARNING) << __func__ + << ": Not enough space on the receiver. We have informed " + << share_target_id; return; } @@ -2872,9 +2849,9 @@ void NearbySharingServiceImpl::OnReceiveConnectionResponse( int64_t share_target_id, std::optional frame) { OutgoingShareSession* session = GetOutgoingShareSession(share_target_id); if (!session || !session->IsConnected()) { - NL_LOG(WARNING) << __func__ - << ": Ignore received connection response, due to no " - "connection established."; + LOG(WARNING) << __func__ + << ": Ignore received connection response, due to no " + "connection established."; return; } @@ -2900,9 +2877,9 @@ void NearbySharingServiceImpl::OnStorageCheckCompleted( IncomingShareSession& session) { if (!session.ReadyForTransfer( [this, share_target_id = session.share_target().id]() { - NL_VLOG(1) << "Incoming mutual acceptance timed out, closing " - "connection for " - << share_target_id; + VLOG(1) << "Incoming mutual acceptance timed out, closing " + "connection for " + << share_target_id; IncomingShareSession* session = GetIncomingShareSession(share_target_id); if (session != nullptr) { @@ -2914,7 +2891,7 @@ void NearbySharingServiceImpl::OnStorageCheckCompleted( return; } // Don't need to wait for user to accept for Self share. - NL_LOG(INFO) << __func__ << ": Auto-accepting self share."; + LOG(INFO) << __func__ << ": Auto-accepting self share."; session.AcceptTransfer(absl::bind_front( &NearbySharingServiceImpl::IncomingPayloadTransferUpdate, this)); OnTransferStarted(/*is_incoming=*/true); @@ -2932,8 +2909,7 @@ void NearbySharingServiceImpl::OnFrameRead( switch (frame->type()) { case nearby::sharing::service::proto::V1Frame::CANCEL: RunOnAnyThread("cancel_transfer", [this, share_target_id]() { - NL_LOG(INFO) << __func__ - << ": Read the cancel frame, closing connection"; + LOG(INFO) << __func__ << ": Read the cancel frame, closing connection"; DoCancel( share_target_id, [](StatusCodes status_codes) {}, /*is_initiator_of_cancellation=*/false); @@ -2949,15 +2925,15 @@ void NearbySharingServiceImpl::OnFrameRead( break; default: - NL_LOG(ERROR) << __func__ << ": Discarding unknown frame of type"; + LOG(ERROR) << __func__ << ": Discarding unknown frame of type"; break; } ShareSession* session = GetShareSession(share_target_id); if (!session || !session->frames_reader()) { - NL_LOG(WARNING) << __func__ - << ": Stopped reading further frames, due to no connection " - "established."; + LOG(WARNING) << __func__ + << ": Stopped reading further frames, due to no connection " + "established."; return; } @@ -2985,17 +2961,17 @@ std::optional NearbySharingServiceImpl::CreateShareTarget( const std::optional& certificate, bool is_incoming) { if (!advertisement.device_name() && !certificate.has_value()) { - NL_VLOG(1) << __func__ - << ": Failed to retrieve public certificate for contact " - "only advertisement."; + VLOG(1) << __func__ + << ": Failed to retrieve public certificate for contact " + "only advertisement."; return std::nullopt; } std::optional device_name = GetDeviceName(advertisement, certificate); if (!device_name.has_value()) { - NL_VLOG(1) << __func__ - << ": Failed to retrieve device name for advertisement."; + VLOG(1) << __func__ + << ": Failed to retrieve device name for advertisement."; return std::nullopt; } @@ -3035,9 +3011,8 @@ void NearbySharingServiceImpl::IncomingPayloadTransferUpdate( IncomingShareSession* session = GetIncomingShareSession(share_target_id); if (!session) { // ShareTarget already disconnected. - NL_LOG(WARNING) - << "Received payload update after share target disconnected: " - << share_target_id; + LOG(WARNING) << "Received payload update after share target disconnected: " + << share_target_id; return; } std::pair result = @@ -3099,18 +3074,17 @@ void NearbySharingServiceImpl::OutgoingPayloadTransferUpdate( OutgoingShareSession* session = GetOutgoingShareSession(share_target_id); if (!session) { // ShareTarget already disconnected. - NL_LOG(WARNING) - << "Received payload update after share target disconnected: " - << share_target_id; + LOG(WARNING) << "Received payload update after share target disconnected: " + << share_target_id; return; } // kInProgress status is logged extensively elsewhere so avoid the spam. if (metadata.status() != TransferMetadata::Status::kInProgress) { - NL_VLOG(1) << __func__ << ": Nearby Share service: " - << "Payload transfer update for share target with ID " - << share_target_id << ": " - << TransferMetadata::StatusToString(metadata.status()); + VLOG(1) << __func__ << ": Nearby Share service: " + << "Payload transfer update for share target with ID " + << share_target_id << ": " + << TransferMetadata::StatusToString(metadata.status()); } // When kComplete is received from PayloadTracker, we need to wait for @@ -3150,14 +3124,14 @@ void NearbySharingServiceImpl::OutgoingPayloadTransferUpdate( void NearbySharingServiceImpl::RemoveIncomingPayloads( const IncomingShareSession& session) { - NL_LOG(INFO) << __func__ << ": Cleaning up payloads due to transfer failure"; + LOG(INFO) << __func__ << ": Cleaning up payloads due to transfer failure"; nearby_connections_manager_->ClearIncomingPayloads(); std::vector files_for_deletion; auto file_paths_to_delete = nearby_connections_manager_->GetAndClearUnknownFilePathsToDelete(); for (auto it = file_paths_to_delete.begin(); it != file_paths_to_delete.end(); ++it) { - NL_VLOG(1) << __func__ << ": Has unknown file path to delete."; + VLOG(1) << __func__ << ": Has unknown file path to delete."; files_for_deletion.push_back(*it); } std::vector payload_file_path = @@ -3170,7 +3144,7 @@ void NearbySharingServiceImpl::RemoveIncomingPayloads( IncomingShareSession& NearbySharingServiceImpl::CreateIncomingShareSession( const ShareTarget& share_target, absl::string_view endpoint_id, std::optional certificate) { - NL_DCHECK(share_target.is_incoming); + DCHECK(share_target.is_incoming); auto [it, inserted] = incoming_share_session_map_.try_emplace( share_target.id, context_->GetClock(), *service_thread_, nearby_connections_manager_.get(), analytics_recorder_, @@ -3178,8 +3152,8 @@ IncomingShareSession& NearbySharingServiceImpl::CreateIncomingShareSession( absl::bind_front(&NearbySharingServiceImpl::OnIncomingTransferUpdate, this)); if (!inserted) { - NL_LOG(ERROR) << __func__ << ": Incoming share target id already exists " - << share_target.id; + LOG(ERROR) << __func__ << ": Incoming share target id already exists " + << share_target.id; } if (certificate.has_value()) { it->second.set_certificate(std::move(*certificate)); @@ -3451,8 +3425,8 @@ NearbySharingServiceImpl::GetBluetoothMacAddressForShareTarget( const std::optional& certificate = session.certificate(); if (!certificate) { - NL_LOG(ERROR) << __func__ << ": No decrypted public certificate found for " - << "share target id: " << session.share_target().id; + LOG(ERROR) << __func__ << ": No decrypted public certificate found for " + << "share target id: " << session.share_target().id; return std::nullopt; } @@ -3460,13 +3434,13 @@ NearbySharingServiceImpl::GetBluetoothMacAddressForShareTarget( } void NearbySharingServiceImpl::ClearOutgoingShareSessionMap() { - NL_VLOG(1) << __func__ << ": Clearing outgoing share target map."; + VLOG(1) << __func__ << ": Clearing outgoing share target map."; while (!outgoing_share_target_map_.empty()) { RemoveOutgoingShareTargetAndReportLost( /*endpoint_id=*/outgoing_share_target_map_.begin()->first); } - NL_DCHECK(outgoing_share_target_map_.empty()); - NL_DCHECK(outgoing_share_session_map_.empty()); + DCHECK(outgoing_share_target_map_.empty()); + DCHECK(outgoing_share_session_map_.empty()); } void NearbySharingServiceImpl::UnregisterShareTarget(int64_t share_target_id) { @@ -3506,21 +3480,20 @@ void NearbySharingServiceImpl::UnregisterShareTarget(int64_t share_target_id) { TriggerDiscoveryCacheExpiryTimers(); } - NL_VLOG(1) << __func__ << ": Unregister share target: " << share_target_id; + VLOG(1) << __func__ << ": Unregister share target: " << share_target_id; } } void NearbySharingServiceImpl::OnStartAdvertisingResult(bool used_device_name, Status status) { if (status == Status::kSuccess) { - NL_VLOG(1) << __func__ - << ": StartAdvertising over Nearby Connections was successful."; + VLOG(1) << __func__ + << ": StartAdvertising over Nearby Connections was successful."; SetInHighVisibility(used_device_name); } else { - NL_LOG(ERROR) << __func__ - << ": StartAdvertising over Nearby Connections failed: " - << NearbyConnectionsManager::ConnectionsStatusToString( - status); + LOG(ERROR) << __func__ + << ": StartAdvertising over Nearby Connections failed: " + << NearbyConnectionsManager::ConnectionsStatusToString(status); SetInHighVisibility(false); for (auto& observer : observers_.GetObservers()) { observer->OnStartAdvertisingFailure(); @@ -3530,13 +3503,12 @@ void NearbySharingServiceImpl::OnStartAdvertisingResult(bool used_device_name, void NearbySharingServiceImpl::OnStopAdvertisingResult(Status status) { if (status == Status::kSuccess) { - NL_VLOG(1) << __func__ - << ": StopAdvertising over Nearby Connections was successful."; + VLOG(1) << __func__ + << ": StopAdvertising over Nearby Connections was successful."; } else { - NL_LOG(ERROR) << __func__ - << ": StopAdvertising over Nearby Connections failed: " - << NearbyConnectionsManager::ConnectionsStatusToString( - status); + LOG(ERROR) << __func__ + << ": StopAdvertising over Nearby Connections failed: " + << NearbyConnectionsManager::ConnectionsStatusToString(status); } // The |advertising_power_level_| is set in |StopAdvertising| instead of @@ -3552,17 +3524,16 @@ void NearbySharingServiceImpl::OnStopAdvertisingResult(Status status) { void NearbySharingServiceImpl::OnStartDiscoveryResult(Status status) { bool success = status == Status::kSuccess; if (success) { - NL_VLOG(1) << __func__ - << ": StartDiscovery over Nearby Connections was successful."; + VLOG(1) << __func__ + << ": StartDiscovery over Nearby Connections was successful."; // Periodically download certificates if there are discovered, contact-based // advertisements that cannot decrypt any currently stored certificates. ScheduleCertificateDownloadDuringDiscovery(/*attempt_count=*/0); } else { - NL_LOG(ERROR) << __func__ - << ": StartDiscovery over Nearby Connections failed: " - << NearbyConnectionsManager::ConnectionsStatusToString( - status); + LOG(ERROR) << __func__ + << ": StartDiscovery over Nearby Connections failed: " + << NearbyConnectionsManager::ConnectionsStatusToString(status); } for (auto& observer : observers_.GetObservers()) { observer->OnStartDiscoveryResult(success); @@ -3592,8 +3563,9 @@ void NearbySharingServiceImpl::OnNetworkChanged( void NearbySharingServiceImpl::OnLanConnectedChanged(bool connected) { RunOnNearbySharingServiceThread( "lan_connection_changed", [this, connected]() { - NL_VLOG(1) << __func__ << ": LAN Connection state changed. (Connected: " - << connected << ")"; + VLOG(1) << __func__ + << ": LAN Connection state changed. (Connected: " << connected + << ")"; NearbySharingService::Observer::AdapterState state = connected ? NearbySharingService::Observer::AdapterState::ENABLED : NearbySharingService::Observer::AdapterState::DISABLED; @@ -3604,7 +3576,7 @@ void NearbySharingServiceImpl::OnLanConnectedChanged(bool connected) { } void NearbySharingServiceImpl::ResetAllSettings(bool logout) { - NL_LOG(INFO) << __func__ << ": Reset all settings!"; + LOG(INFO) << __func__ << ": Reset all settings!"; // Stop all services. StopAdvertising(); @@ -3636,7 +3608,7 @@ void NearbySharingServiceImpl::ResetAllSettings(bool logout) { settings_->AddSettingsObserver(this); certificate_manager_->ClearPublicCertificates([](bool result) { - NL_LOG(INFO) << "Clear public certificates. result: " << result; + LOG(INFO) << "Clear public certificates. result: " << result; }); } else { // should clear scheduled task to make it works immediately @@ -3758,8 +3730,8 @@ NearbySharingServiceImpl::GetSenderUseCase() { void NearbySharingServiceImpl::UpdateFilePathsInProgress( bool update_file_paths) { update_file_paths_in_progress_ = update_file_paths; - NL_LOG(INFO) << __func__ - << ": Update file paths in progress: " << update_file_paths; + LOG(INFO) << __func__ + << ": Update file paths in progress: " << update_file_paths; } } // namespace nearby::sharing