Internal logging update

PiperOrigin-RevId: 669420403
This commit is contained in:
Guogang Li
2024-08-30 13:08:35 -07:00
committed by Copybara-Service
parent e65a8a568c
commit d5b5d92f87
69 changed files with 617 additions and 724 deletions
+1 -1
View File
@@ -6,7 +6,7 @@
"location" : "https://github.com/bourdakos1/abseil-cpp-SwiftPM.git",
"state" : {
"branch" : "cxx17-test",
"revision" : "df22baef6992ac19219337c2a59a4c759fc92c0f"
"revision" : "f2c56293ba0c7dc4fed62c38dfea5c5c2d632166"
}
},
{
-1
View File
@@ -535,7 +535,6 @@ let package = Package(
"internal/platform/bluetooth_connection_info_test.cc",
"internal/platform/mutex_test.cc",
"internal/platform/atomic_reference_test.cc",
"internal/platform/logging_test.cc",
"internal/platform/multi_thread_executor_test.cc",
"internal/platform/ble_connection_info_test.cc",
"internal/platform/ble_test.cc",
+1
View File
@@ -93,6 +93,7 @@ cc_library(
"//internal/platform:base",
"//internal/platform:types",
"//proto:connections_enums_cc_proto",
"@com_google_absl//absl/log",
"@com_google_absl//absl/strings:str_format",
"@com_google_absl//absl/strings:string_view",
"@com_google_absl//absl/types:span",
+1 -1
View File
@@ -23,7 +23,7 @@ namespace nearby::windows {
Core *InitCore(connections::ServiceControllerRouter *router) {
#if defined(LOG_SEVERITY_VERBOSE)
NEARBY_LOG_SET_SEVERITY(VERBOSE);
absl::SetGlobalVLogLevel(1);
#endif // LOG_SEVERITY_VERBOSE;
return new nearby::connections::Core(router);
}
@@ -43,6 +43,7 @@ cc_library(
"@com_google_absl//absl/strings",
"@com_google_absl//absl/strings:str_format",
"@com_google_absl//absl/time",
"@com_google_protobuf//:protobuf_lite",
],
)
@@ -27,7 +27,9 @@
#include "absl/container/btree_map.h"
#include "absl/strings/string_view.h"
#include "absl/time/time.h"
#include "connections/implementation/analytics/connection_attempt_metadata_params.h"
#include "connections/payload_type.h"
#include "connections/strategy.h"
#include "internal/analytics/event_logger.h"
#include "internal/platform/count_down_latch.h"
#include "internal/platform/error_code_params.h"
@@ -37,6 +39,7 @@
#include "internal/platform/single_thread_executor.h"
#include "internal/proto/analytics/connections_log.pb.h"
#include "proto/connections_enums.pb.h"
#include "google/protobuf/repeated_ptr_field.h"
namespace nearby {
namespace analytics {
@@ -492,9 +495,9 @@ void AnalyticsRecorder::OnConnectionClosed(const std::string &endpoint_id,
}
if (current_strategy_session_ == nullptr) {
NEARBY_LOGS(VERBOSE)
<< "AnalyticsRecorder CanRecordAnalytics Unexpected call " << __func__
<< " since current_strategy_session_ is required.";
NEARBY_VLOG(1) << "AnalyticsRecorder CanRecordAnalytics Unexpected call "
<< __func__
<< " since current_strategy_session_ is required.";
return;
}
@@ -708,9 +711,8 @@ void AnalyticsRecorder::OnErrorCode(const ErrorCodeParams &params) {
connections_log.set_version(kVersion);
connections_log.set_allocated_error_code(error_code);
NEARBY_LOGS(VERBOSE)
<< "AnalyticsRecorder LogErrorCode connections_log="
<< connections_log.DebugString();
NEARBY_VLOG(1) << "AnalyticsRecorder LogErrorCode connections_log="
<< connections_log.DebugString(); // NOLINT
event_logger_->Log(connections_log);
});
@@ -772,16 +774,15 @@ AnalyticsRecorder::BuildConnectionAttemptMetadataParams(
bool AnalyticsRecorder::CanRecordAnalyticsLocked(
absl::string_view method_name) {
NEARBY_LOGS(VERBOSE) << "AnalyticsRecorder LogEvent " << method_name
<< " is calling.";
NEARBY_VLOG(1) << "AnalyticsRecorder LogEvent " << method_name
<< " is calling.";
if (event_logger_ == nullptr) {
return false;
}
if (session_was_logged_) {
NEARBY_LOGS(VERBOSE)
<< "AnalyticsRecorder CanRecordAnalytics Unexpected call "
<< method_name << " after session has already been logged.";
NEARBY_VLOG(1) << "AnalyticsRecorder CanRecordAnalytics Unexpected call "
<< method_name << " after session has already been logged.";
return false;
}
@@ -797,9 +798,8 @@ void AnalyticsRecorder::LogClientSessionLocked() {
connections_log.set_allocated_client_session(client_session.release());
connections_log.set_version(kVersion);
NEARBY_LOGS(VERBOSE)
<< "AnalyticsRecorder LogClientSession connections_log="
<< connections_log.DebugString();
NEARBY_VLOG(1) << "AnalyticsRecorder LogClientSession connections_log="
<< connections_log.DebugString(); // NOLINT
event_logger_->Log(connections_log);
});
@@ -812,8 +812,8 @@ void AnalyticsRecorder::LogEvent(EventType event_type) {
connections_log.set_event_type(event_type);
connections_log.set_version(kVersion);
NEARBY_LOGS(VERBOSE) << "AnalyticsRecorder LogEvent connections_log="
<< connections_log.DebugString();
NEARBY_VLOG(1) << "AnalyticsRecorder LogEvent connections_log="
<< connections_log.DebugString(); // NOLINT
event_logger_->Log(connections_log);
});
@@ -270,7 +270,7 @@ void BaseEndpointChannel::Close() {
// In case channel is paused, resume it first thing.
MutexLock lock(&is_paused_mutex_);
if (is_closed_) {
NEARBY_LOGS(VERBOSE) << "EndpointChannel already closed";
NEARBY_VLOG(1) << "EndpointChannel already closed";
return;
}
is_closed_ = true;
@@ -124,7 +124,7 @@ BasePcpHandler::BasePcpHandler(Mediums* mediums,
bwu_manager_(bwu_manager) {}
BasePcpHandler::~BasePcpHandler() {
NEARBY_LOGS(VERBOSE) << __func__;
NEARBY_VLOG(1) << __func__;
Shutdown();
}
@@ -630,7 +630,7 @@ void BasePcpHandler::OnEncryptionSuccessRunnableV3(
return;
}
NEARBY_LOGS(VERBOSE)
NEARBY_VLOG(1)
<< __func__
<< ": beginning authentication to the remote device as an initiator";
ConnectionsAuthenticationTransport connections_authentication_transport =
@@ -53,11 +53,10 @@ BluetoothBwuHandler::CreateUpgradedEndpointChannel(
const std::string& service_name = bluetooth_credentials.service_name();
const std::string& mac_address = bluetooth_credentials.mac_address();
NEARBY_LOGS(VERBOSE) << "BluetoothBwuHandler is attempting to connect to "
"available Bluetooth device ("
<< service_name << ", " << mac_address
<< ") for endpoint " << endpoint_id << " and service ID "
<< service_id;
NEARBY_VLOG(1) << "BluetoothBwuHandler is attempting to connect to "
"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()) {
@@ -78,7 +77,7 @@ BluetoothBwuHandler::CreateUpgradedEndpointChannel(
return nullptr;
}
NEARBY_LOGS(VERBOSE)
NEARBY_VLOG(1)
<< "BluetoothBwuHandler successfully connected to Bluetooth device ("
<< service_id << ", " << mac_address << ") while upgrading endpoint "
<< endpoint_id;
@@ -125,7 +124,7 @@ ByteArray BluetoothBwuHandler::HandleInitializeUpgradedMediumForEndpoint(
return {};
}
NEARBY_LOGS(VERBOSE)
NEARBY_VLOG(1)
<< "BluetoothBwuHandler successfully started listening for incoming "
"Bluetooth connections on service_id="
<< upgrade_service_id << " while upgrading endpoint " << endpoint_id;
+95 -96
View File
@@ -22,13 +22,16 @@
#include "absl/functional/bind_front.h"
#include "absl/time/time.h"
#include "connections/implementation/analytics/connection_attempt_metadata_params.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/endpoint_channel_manager.h"
#include "connections/implementation/flags/nearby_connections_feature_flags.h"
#include "connections/implementation/offline_frames.h"
#include "connections/implementation/service_id_constants.h"
#include "internal/platform/implementation/system_clock.h"
#ifdef NO_WEBRTC
#include "connections/implementation/webrtc_bwu_handler_stub.h"
#else
@@ -521,99 +524,95 @@ void BwuManager::OnIncomingConnection(
NEARBY_LOGS(INFO) << "BwuManager process incoming connection";
std::shared_ptr<BwuHandler::IncomingSocketConnection> connection(
mutable_connection.release());
RunOnBwuManagerThread(
"bwu-on-incoming-connection", [this, client, connection]() {
absl::Time connection_attempt_start_time =
SystemClock::ElapsedRealtime();
EndpointChannel* channel = connection->channel.get();
if (channel == nullptr) {
NEARBY_LOGS(ERROR)
<< "BwuManager failed to create new EndpointChannel for incoming "
"socket.";
connection->socket->Close();
AttemptToRecordBandwidthUpgradeErrorForUnknownEndpoint(
location::nearby::proto::connections::MEDIUM_ERROR,
location::nearby::proto::connections::SOCKET_CREATION);
return;
}
RunOnBwuManagerThread("bwu-on-incoming-connection", [this, client,
connection]() {
absl::Time connection_attempt_start_time = SystemClock::ElapsedRealtime();
EndpointChannel* channel = connection->channel.get();
if (channel == nullptr) {
NEARBY_LOGS(ERROR)
<< "BwuManager failed to create new EndpointChannel for incoming "
"socket.";
connection->socket->Close();
AttemptToRecordBandwidthUpgradeErrorForUnknownEndpoint(
location::nearby::proto::connections::MEDIUM_ERROR,
location::nearby::proto::connections::SOCKET_CREATION);
return;
}
NEARBY_LOGS(VERBOSE)
<< "BwuManager successfully created new EndpointChannel for "
"incoming socket";
NEARBY_VLOG(1) << "BwuManager successfully created new EndpointChannel for "
"incoming socket";
ClientIntroduction introduction;
if (!ReadClientIntroductionFrame(channel, introduction)) {
// This was never a fully EstablishedConnection, no need to provide a
// closure reason.
channel->Close();
NEARBY_LOGS(ERROR)
<< "BwuManager failed to read "
"BWU_NEGOTIATION.CLIENT_INTRODUCTION OfflineFrame from "
"newly-created EndpointChannel "
<< channel->GetName()
<< ", so the EndpointChannel was discarded.";
return;
}
ClientIntroduction introduction;
if (!ReadClientIntroductionFrame(channel, introduction)) {
// This was never a fully EstablishedConnection, no need to provide a
// closure reason.
channel->Close();
NEARBY_LOGS(ERROR)
<< "BwuManager failed to read "
"BWU_NEGOTIATION.CLIENT_INTRODUCTION OfflineFrame from "
"newly-created EndpointChannel "
<< channel->GetName() << ", so the EndpointChannel was discarded.";
return;
}
NEARBY_LOGS(VERBOSE) << "BwuManager successfully received "
"BWU_NEGOTIATION.CLIENT_INTRODUCTION "
"OfflineFrame on EndpointChannel "
<< channel->GetName();
NEARBY_VLOG(1) << "BwuManager successfully received "
"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.
NEARBY_LOGS(ERROR) << "BwuManager failed to write"
"BWU_NEGOTIATION.CLIENT_INTRODUCTION_ACK "
"OfflineFrame on EndpointChannel "
<< channel->GetName();
channel->Close();
return;
}
if (!WriteClientIntroductionAckFrame(channel)) {
// This was never a fully EstablishedConnection, no need to provide a
// closure reason.
NEARBY_LOGS(ERROR) << "BwuManager failed to write"
"BWU_NEGOTIATION.CLIENT_INTRODUCTION_ACK "
"OfflineFrame on EndpointChannel "
<< channel->GetName();
channel->Close();
return;
}
NEARBY_LOGS(VERBOSE) << "BwuManager successfully wrote "
"BWU_NEGOTIATION.CLIENT_INTRODUCTION_ACK "
"OfflineFrame on EndpointChannel "
<< channel->GetName();
NEARBY_VLOG(1) << "BwuManager successfully wrote "
"BWU_NEGOTIATION.CLIENT_INTRODUCTION_ACK "
"OfflineFrame on EndpointChannel "
<< channel->GetName();
const std::string& endpoint_id = introduction.endpoint_id();
ClientProxy* mapped_client;
const auto item = in_progress_upgrades_.find(endpoint_id);
if (item == in_progress_upgrades_.end()) return;
mapped_client = item->second;
CancelRetryUpgradeAlarm(endpoint_id);
if (mapped_client == nullptr) {
// This was never a fully EstablishedConnection, no need to provide a
// closure reason.
channel->Close();
return;
}
const std::string& endpoint_id = introduction.endpoint_id();
ClientProxy* mapped_client;
const auto item = in_progress_upgrades_.find(endpoint_id);
if (item == in_progress_upgrades_.end()) return;
mapped_client = item->second;
CancelRetryUpgradeAlarm(endpoint_id);
if (mapped_client == nullptr) {
// This was never a fully EstablishedConnection, no need to provide a
// closure reason.
channel->Close();
return;
}
CHECK(client == mapped_client);
CHECK(client == mapped_client);
// The ConnectionAttempt has now succeeded, so record it as such.
std::unique_ptr<ConnectionAttemptMetadataParams>
connections_attempt_metadata_params;
if (channel != nullptr) {
connections_attempt_metadata_params =
client->GetAnalyticsRecorder()
.BuildConnectionAttemptMetadataParams(
channel->GetTechnology(), channel->GetBand(),
channel->GetFrequency(), channel->GetTryCount());
}
client->GetAnalyticsRecorder().OnIncomingConnectionAttempt(
location::nearby::proto::connections::UPGRADE, channel->GetMedium(),
location::nearby::proto::connections::RESULT_SUCCESS,
SystemClock::ElapsedRealtime() - connection_attempt_start_time,
client->GetConnectionToken(endpoint_id),
connections_attempt_metadata_params.get());
// The ConnectionAttempt has now succeeded, so record it as such.
std::unique_ptr<ConnectionAttemptMetadataParams>
connections_attempt_metadata_params;
if (channel != nullptr) {
connections_attempt_metadata_params =
client->GetAnalyticsRecorder().BuildConnectionAttemptMetadataParams(
channel->GetTechnology(), channel->GetBand(),
channel->GetFrequency(), channel->GetTryCount());
}
client->GetAnalyticsRecorder().OnIncomingConnectionAttempt(
location::nearby::proto::connections::UPGRADE, channel->GetMedium(),
location::nearby::proto::connections::RESULT_SUCCESS,
SystemClock::ElapsedRealtime() - connection_attempt_start_time,
client->GetConnectionToken(endpoint_id),
connections_attempt_metadata_params.get());
// Use the introductory client information sent over to run the upgrade
// protocol.
RunUpgradeProtocol(mapped_client, endpoint_id,
std::move(connection->channel),
!introduction.supports_disabling_encryption());
});
// Use the introductory client information sent over to run the upgrade
// protocol.
RunUpgradeProtocol(mapped_client, endpoint_id,
std::move(connection->channel),
!introduction.supports_disabling_encryption());
});
}
void BwuManager::RunOnBwuManagerThread(const std::string& name,
@@ -671,10 +670,10 @@ void BwuManager::RunUpgradeProtocol(
location::nearby::proto::connections::LAST_WRITE_TO_PRIOR_CHANNEL);
return;
}
NEARBY_LOGS(VERBOSE) << "BwuManager successfully wrote "
"BWU_NEGOTIATION.LAST_WRITE_TO_PRIOR_CHANNEL "
"OfflineFrame while upgrading endpoint "
<< endpoint_id;
NEARBY_VLOG(1) << "BwuManager successfully wrote "
"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
@@ -1103,10 +1102,10 @@ void BwuManager::ProcessLastWriteToPriorChannelEvent(
location::nearby::proto::connections::SAFE_TO_CLOSE_PRIOR_CHANNEL);
return;
}
NEARBY_LOGS(VERBOSE) << "BwuManager successfully wrote "
"BWU_NEGOTIATION.SAFE_TO_CLOSE_PRIOR_CHANNEL "
"OfflineFrame while trying to upgrade endpoint "
<< endpoint_id;
NEARBY_VLOG(1) << "BwuManager successfully wrote "
"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
@@ -1164,7 +1163,7 @@ void BwuManager::ProcessSafeToClosePriorChannelEvent(
previous_endpoint_channel->Read();
previous_endpoint_channel->Close(DisconnectionReason::UPGRADED);
NEARBY_LOGS(VERBOSE)
NEARBY_VLOG(1)
<< "BwuManager cleanly shut down prior "
<< previous_endpoint_channel->GetType()
<< " EndpointChannel to conclude upgrade protocol for endpoint "
@@ -1273,9 +1272,9 @@ void BwuManager::TryNextBestUpgradeMediums(
auto channel = channel_manager_->GetChannelForEndpoint(endpoint_id);
Medium current_medium =
channel ? channel->GetMedium() : Medium::UNKNOWN_MEDIUM;
NEARBY_LOGS(VERBOSE) << "current_medium: "
<< location::nearby::proto::connections::Medium_Name(
current_medium);
NEARBY_VLOG(1) << "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())) {
+10 -11
View File
@@ -1026,11 +1026,10 @@ void ClientProxy::OnPayloadProgress(const std::string& endpoint_id,
item->second.payload_progress_cb(endpoint_id, info);
if (info.status == PayloadProgressInfo::Status::kInProgress) {
NEARBY_LOGS(VERBOSE)
<< "ClientProxy [reporting onPayloadProgress]: client="
<< GetClientId() << "; endpoint_id=" << endpoint_id
<< "; payload_id=" << info.payload_id
<< ", payload_status=" << ToString(info.status);
NEARBY_VLOG(1) << "ClientProxy [reporting onPayloadProgress]: client="
<< GetClientId() << "; endpoint_id=" << endpoint_id
<< "; payload_id=" << info.payload_id
<< ", payload_status=" << ToString(info.status);
} else {
NEARBY_LOGS(INFO)
<< "ClientProxy [reporting onPayloadProgress]: client="
@@ -1133,16 +1132,16 @@ void ClientProxy::ScheduleClearCachedEndpointIdAlarm() {
CancelClearCachedEndpointIdAlarm();
if (cached_endpoint_id_.empty()) {
NEARBY_LOGS(VERBOSE) << "ClientProxy [There is no cached local high power "
"advertising endpoint Id]: client="
<< GetClientId();
NEARBY_VLOG(1) << "ClientProxy [There is no cached local high power "
"advertising endpoint Id]: client="
<< GetClientId();
return;
}
if (IsFeatureUseStableEndpointIdEnabled() && HasOngoingConnection()) {
NEARBY_LOGS(VERBOSE) << "ClientProxy [Handle clearing cached endpoint ID "
"during disconnection]: client="
<< GetClientId();
NEARBY_VLOG(1) << "ClientProxy [Handle clearing cached endpoint ID "
"during disconnection]: client="
<< GetClientId();
return;
}
+16 -20
View File
@@ -207,8 +207,8 @@ ExceptionOr<OfflineFrame> EndpointManager::TryDecryptFrame(
while (true) {
ExceptionOr<ByteArray> decrypted = endpoint_channel->TryDecrypt(data);
if (decrypted.ok()) {
NEARBY_LOGS(VERBOSE) << "Message decrypted after "
<< SystemClock::ElapsedRealtime() - start_time;
NEARBY_VLOG(1) << "Message decrypted after "
<< SystemClock::ElapsedRealtime() - start_time;
return parser::FromBytes(decrypted.result());
}
if (decrypted.exception() == Exception::kExecution) {
@@ -500,15 +500,14 @@ EndpointManager::LockedFrameProcessor EndpointManager::GetFrameProcessor(
}
void EndpointManager::RemoveEndpointState(const std::string& endpoint_id) {
NEARBY_LOGS(VERBOSE) << "EnsureWorkersTerminated for endpoint "
<< endpoint_id;
NEARBY_VLOG(1) << "EnsureWorkersTerminated for endpoint " << endpoint_id;
auto item = endpoints_.find(endpoint_id);
if (item != endpoints_.end()) {
NEARBY_LOGS(INFO) << "EndpointState found for endpoint " << endpoint_id;
// If another instance of data and keep-alive handlers is running, it will
// terminate soon. Removing EndpointState waits for workers to complete.
endpoints_.erase(item);
NEARBY_LOGS(VERBOSE) << "Workers terminated for endpoint " << endpoint_id;
NEARBY_VLOG(1) << "Workers terminated for endpoint " << endpoint_id;
} else {
NEARBY_LOGS(INFO) << "EndpointState not found for endpoint " << endpoint_id;
}
@@ -592,8 +591,8 @@ void EndpointManager::RegisterEndpoint(
// (**) Wifi Hotspots can fail to notice a connection has been lost,
// and they will happily keep writing to /dev/null. This is why we
// listen for the pong.
NEARBY_LOGS(VERBOSE) << "EndpointManager enabling KeepAlive for endpoint "
<< endpoint_id;
NEARBY_VLOG(1) << "EndpointManager enabling KeepAlive for endpoint "
<< endpoint_id;
endpoint_state.StartEndpointKeepAliveManager(
[this, client, endpoint_id, keep_alive_interval, keep_alive_timeout](
Mutex* keep_alive_waiter_mutex,
@@ -708,14 +707,14 @@ void EndpointManager::DiscardEndpoint(ClientProxy* client,
{
MutexLock lock(&mutex_);
if (is_shutdown_) {
NEARBY_LOGS(VERBOSE)
NEARBY_VLOG(1)
<< "DiscardEndpoint called during destruction, returning early.";
return;
}
}
RemoveEndpoint(client, endpoint_id,
/* notify */client->IsConnectedToEndpoint(endpoint_id),
/* notify */ client->IsConnectedToEndpoint(endpoint_id),
reason);
});
}
@@ -760,7 +759,7 @@ void EndpointManager::RemoveEndpoint(ClientProxy* client,
? ConnectionsLog::EstablishedConnection::SAFE_DISCONNECTION
: ConnectionsLog::EstablishedConnection::UNSAFE_DISCONNECTION;
NEARBY_LOGS(INFO) << "[safe-to-disconnect] safe_disconnect_result:"
<< (safe_disconnect_result? "true" : "false");
<< (safe_disconnect_result ? "true" : "false");
}
}
if (safe_disconnect_result ==
@@ -796,8 +795,8 @@ bool EndpointManager::ApplySafeToDisconnect(const std::string& endpoint_id,
bool is_safe_disconnection = false;
bool send_disconnection_frame = true;
absl::Duration timeout_millis = FeatureFlags::GetInstance()
.GetFlags()
.safe_to_disconnect_ack_delay_millis;
.GetFlags()
.safe_to_disconnect_ack_delay_millis;
bool is_wait_for_ack = true;
switch (reason) {
case DisconnectionReason::UPGRADED:
@@ -814,10 +813,9 @@ bool EndpointManager::ApplySafeToDisconnect(const std::string& endpoint_id,
case DisconnectionReason::REMOTE_DISCONNECTION:
is_safe_disconnection = true;
send_disconnection_frame = false;
timeout_millis =
FeatureFlags::GetInstance()
.GetFlags()
.safe_to_disconnect_remote_disc_delay_millis;
timeout_millis = FeatureFlags::GetInstance()
.GetFlags()
.safe_to_disconnect_remote_disc_delay_millis;
is_wait_for_ack = false;
break;
default:
@@ -913,8 +911,7 @@ CountDownLatch EndpointManager::NotifyFrameProcessorsOnEndpointDisconnect(
}
std::vector<std::string> EndpointManager::SendPayloadAck(
std::int64_t payload_id,
const std::vector<std::string>& endpoint_ids) {
std::int64_t payload_id, const std::vector<std::string>& endpoint_ids) {
ByteArray bytes = parser::ForPayloadAckPayloadTransfer(payload_id);
PacketMetaData packet_meta_data;
@@ -926,7 +923,6 @@ std::int64_t payload_id,
packet_meta_data);
}
std::vector<std::string> EndpointManager::SendTransferFrameBytes(
const std::vector<std::string>& endpoint_ids, const ByteArray& bytes,
std::int64_t payload_id, std::int64_t offset,
@@ -971,7 +967,7 @@ EndpointManager::EndpointState::~EndpointState() {
// object (in move constructor) which prevents unregistering the channel
// prematurely.
if (channel_manager_) {
NEARBY_LOGS(VERBOSE) << "EndpointState destructor " << endpoint_id_;
NEARBY_VLOG(1) << "EndpointState destructor " << endpoint_id_;
channel_manager_->UnregisterChannelForEndpoint(
endpoint_id_, DisconnectionReason::SHUTDOWN,
ConnectionsLog::EstablishedConnection::SAFE_DISCONNECTION);
+2 -1
View File
@@ -22,6 +22,7 @@
#include "absl/strings/escaping.h"
#include "connections/implementation/mediums/ble_v2/ble_advertisement.h"
#include "connections/implementation/mediums/utils.h"
#include "internal/platform/byte_array.h"
#include "internal/platform/logging.h"
#include "internal/platform/mutex_lock.h"
#include "internal/platform/prng.h"
@@ -91,7 +92,7 @@ bool Ble::StartAdvertising(const std::string& service_id,
<< advertisement_bytes.size() << ")"
<< ", service id=" << service_id
<< ", fast advertisement service uuid="
<< 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();
+8 -10
View File
@@ -87,11 +87,10 @@ TEST_P(BleTest, CanStartAcceptingConnectionsAndConnect) {
BlePeripheral& peripheral, const std::string& service_id,
const ByteArray& advertisement_bytes,
bool fast_advertisement) {
NEARBY_LOG_OBSOLETE(INFO,
"Discovered peripheral=%p [impl=%p], fast "
"advertisement=%d.",
&peripheral, &peripheral.GetImpl(),
fast_advertisement);
NEARBY_LOGS(INFO)
<< "Discovered peripheral=" << peripheral.GetName()
<< ", impl=" << &peripheral.GetImpl()
<< ", fast advertisement=" << fast_advertisement;
atomic_discovered_peripheral.store(peripheral);
found_latch.CountDown();
},
@@ -139,11 +138,10 @@ TEST_P(BleTest, CanCancelConnect) {
BlePeripheral& peripheral, const std::string& service_id,
const ByteArray& advertisement_bytes,
bool fast_advertisement) {
NEARBY_LOG_OBSOLETE(INFO,
"Discovered peripheral=%p [impl=%p], fast "
"advertisement = %d.",
&peripheral, &peripheral.GetImpl(),
fast_advertisement);
NEARBY_LOGS(INFO)
<< "Discovered peripheral=" << peripheral.GetName()
<< ", impl=" << &peripheral.GetImpl()
<< ", fast advertisement=" << fast_advertisement;
atomic_discovered_peripheral.store(peripheral);
found_latch.CountDown();
},
+5 -6
View File
@@ -234,9 +234,9 @@ bool BleV2::StopAdvertising(const std::string& service_id) {
} else if (incoming_sockets_.empty()) {
// Otherwise, if we aren't restarting the BLE advertisement, then shutdown
// the gatt server if it's not in use.
NEARBY_LOGS(VERBOSE) << "Aggressively stopping any pre-existing "
"advertisement GATT servers "
"because no incoming BLE sockets are connected.";
NEARBY_VLOG(1) << "Aggressively stopping any pre-existing "
"advertisement GATT servers "
"because no incoming BLE sockets are connected.";
StopAdvertisementGattServerLocked();
}
@@ -820,8 +820,7 @@ void BleV2::ProcessFetchGattAdvertisementsRequest(
if (characteristic_byte.has_value()) {
advertisement_read_result.AddAdvertisement(
slot, ByteArray(characteristic_byte.value()));
NEARBY_LOGS(VERBOSE) << "Successfully read advertisement at slot="
<< slot;
NEARBY_VLOG(1) << "Successfully read advertisement at slot=" << slot;
} else {
NEARBY_LOGS(WARNING) << "Can't read advertisement for slot=" << slot;
read_success = false;
@@ -1011,7 +1010,7 @@ bool BleV2::StartGattAdvertisingLocked(
// remote device is indefinitely connected to this device's GATT server is
// when it has a BLE socket connection.
if (incoming_sockets_.empty()) {
NEARBY_LOGS(VERBOSE)
NEARBY_VLOG(1)
<< "Aggressively stopping any pre-existing advertisement GATT "
"servers because no incoming BLE sockets are connected";
StopAdvertisementGattServerLocked();
@@ -606,11 +606,11 @@ void DiscoveredPeripheralTracker::HandleAdvertisementHeader(
// Check if the advertisement header contains a service ID we're tracking.
if (!IsInterestingAdvertisementHeader(advertisement_header)) {
NEARBY_LOGS(VERBOSE) << "Ignoring BLE advertisement header="
<< absl::BytesToHexString(
ByteArray(advertisement_header).data())
<< " because it does not contain any service IDs "
"we're interested in.";
NEARBY_VLOG(1) << "Ignoring BLE advertisement header="
<< absl::BytesToHexString(
ByteArray(advertisement_header).data())
<< " because it does not contain any service IDs "
"we're interested in.";
return;
}
@@ -633,14 +633,14 @@ void DiscoveredPeripheralTracker::HandleAdvertisementHeader(
if (NearbyFlags::GetInstance().GetBoolFlag(
config_package_nearby::nearby_connections_feature::
kEnableGattQueryInThread)) {
NEARBY_LOGS(VERBOSE) << ": Handle GATT advertisement "
<< absl::BytesToHexString(
ByteArray(advertisement_header).data())
<< " in thread";
NEARBY_VLOG(1) << ": Handle GATT advertisement "
<< absl::BytesToHexString(
ByteArray(advertisement_header).data())
<< " in thread";
if (!fetching_advertisements_.insert(advertisement_header).second) {
NEARBY_LOGS(VERBOSE) << ": Ignore the advertisement header due to it "
"is already in fetching.";
NEARBY_VLOG(1) << ": Ignore the advertisement header due to it "
"is already in fetching.";
return;
}
@@ -829,10 +829,10 @@ void DiscoveredPeripheralTracker::FetchRawAdvertisementsInThread(
/*service_uuid=*/{});
UpdateCommonStateForFoundBleAdvertisement(advertisement_header);
fetching_advertisements_.erase(advertisement_header);
NEARBY_LOGS(VERBOSE) << ": Completed to handle GATT advertisement "
<< absl::BytesToHexString(
ByteArray(advertisement_header).data())
<< " in thread";
NEARBY_VLOG(1) << ": Completed to handle GATT advertisement "
<< absl::BytesToHexString(
ByteArray(advertisement_header).data())
<< " in thread";
}
}
@@ -109,9 +109,10 @@ TEST_P(BleV2Test, CanConnect) {
const ByteArray& advertisement_bytes,
bool fast_advertisement) {
discovered_peripheral = peripheral;
NEARBY_LOG_OBSOLETE(
INFO, "Discovered peripheral=%p, fast advertisement=%d",
&peripheral, fast_advertisement);
NEARBY_LOGS(INFO)
<< "Discovered peripheral="
<< peripheral.GetAddress().value_or("")
<< ", fast advertisement=" << fast_advertisement;
discovered_latch.CountDown();
},
});
@@ -167,9 +168,10 @@ TEST_P(BleV2Test, CanCancelConnect) {
const ByteArray& advertisement_bytes,
bool fast_advertisement) {
discovered_peripheral = peripheral;
NEARBY_LOG_OBSOLETE(
INFO, "Discovered peripheral=%p, fast advertisement=%d",
&peripheral, fast_advertisement);
NEARBY_LOGS(INFO)
<< "Discovered peripheral="
<< peripheral.GetAddress().value_or("")
<< ", fast advertisement=" << fast_advertisement;
discovered_latch.CountDown();
},
});
@@ -268,8 +268,8 @@ TEST_P(BluetoothClassicTest, CanConnect) {
.device_discovered_cb =
[&latch, &discovered_device](BluetoothDevice& device) {
discovered_device = device;
NEARBY_LOG_OBSOLETE(INFO, "Discovered device=%p [impl=%p]",
&device, &device.GetImpl());
NEARBY_LOGS(INFO) << "Discovered device=" << device.GetName()
<< ", impl=" << &device.GetImpl();
latch.CountDown();
},
}));
@@ -317,8 +317,8 @@ TEST_P(BluetoothClassicTest, CanCancelBeforeConnect) {
{
.device_discovered_cb =
[&latch, &discovered_device](BluetoothDevice& device) {
NEARBY_LOG_OBSOLETE(INFO, "Discovered device=%p [impl=%p]",
&device, &device.GetImpl());
NEARBY_LOGS(INFO) << "Discovered device=" << device.GetName()
<< ", impl=" << &device.GetImpl();
discovered_device = device;
latch.CountDown();
},
@@ -384,8 +384,8 @@ TEST_P(BluetoothClassicTest, CanCancelDuringConnect) {
.device_discovered_cb =
[&latch, &discovered_device](BluetoothDevice& device) {
discovered_device = device;
NEARBY_LOG_OBSOLETE(INFO, "Discovered device=%p [impl=%p]",
&device, &device.GetImpl());
NEARBY_LOGS(INFO) << "Discovered device=" << device.GetName()
<< ", impl=" << &device.GetImpl();
latch.CountDown();
},
}));
@@ -449,8 +449,8 @@ TEST_P(BluetoothClassicTest, CanCancelDuringConnect_MultipleEndpoints) {
.device_discovered_cb =
[&latch, &discovered_device](BluetoothDevice& device) {
discovered_device = device;
NEARBY_LOG_OBSOLETE(INFO, "Discovered device=%p [impl=%p]",
&device, &device.GetImpl());
NEARBY_LOGS(INFO) << "Discovered device=" << device.GetName()
<< ", impl=" << &device.GetImpl();
latch.CountDown();
},
}));
@@ -592,22 +592,22 @@ TEST_F(BluetoothClassicTest, CanDiscoverDeviceChanges) {
.device_discovered_cb =
[&discovered_latch, &discovered_device](BluetoothDevice& device) {
discovered_device = device;
NEARBY_LOG_OBSOLETE(INFO, "Discovered device=%p [impl=%p]",
&device, &device.GetImpl());
NEARBY_LOGS(INFO) << "Discovered device=" << device.GetName()
<< ", impl=" << &device.GetImpl();
discovered_latch.CountDown();
},
.device_name_changed_cb =
[&rename_latch, &discovered_device](BluetoothDevice& device) {
discovered_device = device;
NEARBY_LOG_OBSOLETE(INFO, "Rename device=%p [impl=%p]", &device,
&device.GetImpl());
NEARBY_LOGS(INFO) << "Rename device=" << device.GetName()
<< ", impl=" << &device.GetImpl();
rename_latch.CountDown();
},
.device_lost_cb =
[&lost_latch, &discovered_device](BluetoothDevice& device) {
discovered_device = device;
NEARBY_LOG_OBSOLETE(INFO, "Lost device=%p [impl=%p]", &device,
&device.GetImpl());
NEARBY_LOGS(INFO) << "Lost device=" << device.GetName()
<< ", impl=" << &device.GetImpl();
lost_latch.CountDown();
},
}));
@@ -638,8 +638,8 @@ TEST_F(BluetoothClassicTest, CanStartAcceptingConnections) {
.device_discovered_cb =
[&latch, &discovered_device](BluetoothDevice& device) {
discovered_device = device;
NEARBY_LOG_OBSOLETE(INFO, "Discovered device=%p [impl=%p]",
&device, &device.GetImpl());
NEARBY_LOGS(INFO) << "Discovered device=" << device.GetName()
<< ",impl=" << &device.GetImpl();
latch.CountDown();
},
}));
@@ -83,7 +83,7 @@ MultiplexSocket::MultiplexSocket(std::shared_ptr<MediumSocket> physical_socket)
multiplex_output_stream_{&physical_socket_ptr_->GetOutputStream(),
enabled_},
physical_reader_(&physical_socket_ptr_->GetInputStream()),
medium_(physical_socket_ptr_->GetMedium()){}
medium_(physical_socket_ptr_->GetMedium()) {}
absl::flat_hash_map<std::pair<std::string, Medium>,
MultiplexIncomingConnectionCb>&
@@ -207,8 +207,7 @@ MediumSocket* MultiplexSocket::CreateFirstVirtualSocket(
<< ", 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_);
salted_service_id_hash_key, output_stream, medium_, &virtual_sockets_);
virtual_socket->AddOnSocketClosedListener(
std::make_unique<absl::AnyInvocable<void()>>(
@@ -236,8 +235,7 @@ MediumSocket* MultiplexSocket::CreateVirtualSocket(
<< salted_service_id_hash_key;
MediumSocket* virtual_socket = physical_socket_ptr_->CreateVirtualSocket(
salted_service_id_hash_key, output_stream,
medium_, &virtual_sockets_);
salted_service_id_hash_key, output_stream, medium_, &virtual_sockets_);
virtual_socket->AddOnSocketClosedListener(
std::make_unique<absl::AnyInvocable<void()>>(
@@ -266,8 +264,8 @@ int MultiplexSocket::GetVirtualSocketCount() {
}
void MultiplexSocket::ListVirtualSocket() {
NEARBY_LOGS(INFO) << __func__ << " virtual_sockets_.size()="
<< virtual_sockets_.size();
NEARBY_LOGS(INFO) << __func__
<< " virtual_sockets_.size()=" << virtual_sockets_.size();
for (auto& [service_id_hash_key, virtual_socket] : virtual_sockets_) {
NEARBY_LOGS(INFO) << __func__
<< " service_id_hash_key=" << service_id_hash_key
@@ -356,7 +354,7 @@ void MultiplexSocket::StartReaderThread() {
fail = true;
} else {
auto length = read_int.result();
NEARBY_LOGS(VERBOSE) << __func__ << " length:" << length;
NEARBY_VLOG(1) << __func__ << " length:" << length;
if (length < 0 || length > FeatureFlags::GetInstance()
.GetFlags()
@@ -412,8 +410,7 @@ void MultiplexSocket::StartReaderThread() {
frame.control_frame());
break;
case MultiplexFrame::DATA_FRAME:
NEARBY_LOGS(VERBOSE)
<< "service_id_hash_salt: " << service_id_hash_salt;
NEARBY_VLOG(1) << "service_id_hash_salt: " << service_id_hash_salt;
HandleDataFrame(salted_service_id_hash, service_id_hash_salt,
frame.data_frame());
break;
@@ -508,8 +505,7 @@ void MultiplexSocket::HandleConnectionRequest(
NEARBY_LOGS(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_);
<< " on medium " << Medium_Name(medium_);
NEARBY_LOGS(INFO) << "The size of incomingConnectionCallbacks : "
<< GetIncomingConnectionCallbacks().size();
@@ -524,8 +520,7 @@ void MultiplexSocket::HandleConnectionRequest(
<< listening_service_id
<< ", hash salt : " << service_id_hash_salt
<< ", hash key : " << salted_service_id_hash_key
<< " on medium "
<< Medium_Name(medium_);
<< " on medium " << Medium_Name(medium_);
if (!multiplex_output_stream_.WriteConnectionResponseFrame(
salted_service_id_hash, service_id_hash_salt,
@@ -534,7 +529,7 @@ void MultiplexSocket::HandleConnectionRequest(
return;
}
NEARBY_LOGS(VERBOSE)
NEARBY_VLOG(1)
<< "EstablishVirtualSocket after local device accept the connection "
"with serviceId="
<< listening_service_id << ", serviceIdHashSalt=" << service_id_hash_salt;
@@ -613,7 +608,7 @@ void MultiplexSocket::HandleDataFrame(const ByteArray& salted_service_id_hash,
}
if (virtual_socket != nullptr) {
NEARBY_LOGS(VERBOSE)
NEARBY_VLOG(1)
<< "Received a DATA frame to feed virtual socket for salted service ID "
"Hash Key "
<< salted_service_id_hash_key;
@@ -659,8 +654,7 @@ void MultiplexSocket::OnVirtualSocketClosed(const std::string& service_id) {
shutdown = true;
}
} else {
NEARBY_LOGS(INFO) << "Virtual socket(" << service_id
<< ") not found";
NEARBY_LOGS(INFO) << "Virtual socket(" << service_id << ") not found";
}
}
latch.CountDown();
@@ -683,9 +677,9 @@ MediumSocket* MultiplexSocket::ReMapAndGetVirtualSocket(
const std::string& service_id_hash_salt) {
std::string salted_service_id_hash_key =
GenerateServiceIdHashKey(salted_service_id_hash);
NEARBY_LOGS(VERBOSE) << "ReMapAndGetVirtualSocket with serviceIdHashSalt="
<< service_id_hash_salt << ", saltedServiceIdHashKey="
<< salted_service_id_hash_key;
NEARBY_VLOG(1) << "ReMapAndGetVirtualSocket with serviceIdHashSalt="
<< service_id_hash_salt
<< ", saltedServiceIdHashKey=" << salted_service_id_hash_key;
{
MutexLock lock(&virtual_socket_mutex_);
for (auto& [hash_key, virtual_socket] : virtual_sockets_) {
@@ -764,9 +758,12 @@ void MultiplexSocket::ShutdownAll() {
latch.CountDown();
});
if (!latch.Await(FeatureFlags::GetInstance()
if (!latch
.Await(FeatureFlags::GetInstance()
.GetFlags()
.mediums_frame_write_timeout_millis).result() + 200) {
.mediums_frame_write_timeout_millis)
.result() +
200) {
NEARBY_LOGS(ERROR) << "Timeout to close virtual socket";
}
@@ -777,8 +774,6 @@ void MultiplexSocket::ShutdownAll() {
NEARBY_LOGS(INFO) << __func__ << " end";
}
} // namespace multiplex
} // namespace mediums
} // namespace connections
@@ -101,7 +101,7 @@ P2pClusterPcpHandler::P2pClusterPcpHandler(
injected_bluetooth_device_store_(injected_bluetooth_device_store) {}
P2pClusterPcpHandler::~P2pClusterPcpHandler() {
NEARBY_LOGS(VERBOSE) << __func__;
NEARBY_VLOG(1) << __func__;
Shutdown();
}
@@ -1873,9 +1873,9 @@ void P2pClusterPcpHandler::StartBluetoothDiscoveryWithPause(
BasePcpHandler::ConnectImplResult P2pClusterPcpHandler::BluetoothConnectImpl(
ClientProxy* client, BluetoothEndpoint* endpoint) {
NEARBY_LOGS(VERBOSE) << "Client " << client->GetClientId()
<< " is attempting to connect to endpoint(id="
<< endpoint->endpoint_id << ") over Bluetooth Classic.";
NEARBY_VLOG(1) << "Client " << client->GetClientId()
<< " is attempting to connect to endpoint(id="
<< endpoint->endpoint_id << ") over Bluetooth Classic.";
BluetoothDevice& device = endpoint->bluetooth_device;
BluetoothSocket bluetooth_socket = bluetooth_medium_.Connect(
@@ -1894,9 +1894,9 @@ BasePcpHandler::ConnectImplResult P2pClusterPcpHandler::BluetoothConnectImpl(
auto channel = std::make_unique<BluetoothEndpointChannel>(
endpoint->service_id, /*channel_name=*/endpoint->endpoint_id,
bluetooth_socket);
NEARBY_LOGS(VERBOSE) << "Client" << client->GetClientId()
<< " created Bluetooth endpoint channel to endpoint(id="
<< endpoint->endpoint_id << ").";
NEARBY_VLOG(1) << "Client" << client->GetClientId()
<< " created Bluetooth endpoint channel to endpoint(id="
<< endpoint->endpoint_id << ").";
client->SetBluetoothMacAddress(endpoint->endpoint_id, device.GetMacAddress());
return BasePcpHandler::ConnectImplResult{
.medium = Medium::BLUETOOTH,
@@ -2096,9 +2096,9 @@ Medium P2pClusterPcpHandler::StartBleScanning(
BasePcpHandler::ConnectImplResult P2pClusterPcpHandler::BleConnectImpl(
ClientProxy* client, BleEndpoint* endpoint) {
NEARBY_LOGS(VERBOSE) << "Client " << client->GetClientId()
<< " is attempting to connect to endpoint(id="
<< endpoint->endpoint_id << ") over BLE.";
NEARBY_VLOG(1) << "Client " << client->GetClientId()
<< " is attempting to connect to endpoint(id="
<< endpoint->endpoint_id << ") over BLE.";
BlePeripheral& peripheral = endpoint->ble_peripheral;
@@ -2317,9 +2317,9 @@ Medium P2pClusterPcpHandler::StartBleV2Scanning(
BasePcpHandler::ConnectImplResult P2pClusterPcpHandler::BleV2ConnectImpl(
ClientProxy* client, BleV2Endpoint* endpoint) {
NEARBY_LOGS(VERBOSE) << "Client " << client->GetClientId()
<< " is attempting to connect to endpoint(id="
<< endpoint->endpoint_id << ") over BLE.";
NEARBY_VLOG(1) << "Client " << client->GetClientId()
<< " is attempting to connect to endpoint(id="
<< endpoint->endpoint_id << ") over BLE.";
BleV2Peripheral& peripheral = endpoint->ble_peripheral;
+30 -30
View File
@@ -31,10 +31,12 @@
#include "connections/implementation/analytics/throughput_recorder.h"
#include "connections/implementation/client_proxy.h"
#include "connections/implementation/endpoint_channel_manager.h"
#include "connections/implementation/endpoint_manager.h"
#include "connections/implementation/flags/nearby_connections_feature_flags.h"
#include "connections/implementation/internal_payload_factory.h"
#include "connections/implementation/proto/offline_wire_formats.pb.h"
#include "connections/listeners.h"
#include "connections/payload.h"
#include "connections/payload_type.h"
#include "internal/flags/nearby_flags.h"
#include "internal/platform/byte_array.h"
@@ -119,9 +121,9 @@ bool PayloadManager::SendPayloadLoop(
location::nearby::proto::connections::PayloadStatus::LOCAL_ERROR);
return false;
}
NEARBY_LOGS(VERBOSE) << "PayloadManager successfully skipped "
<< real_offset.GetResult() << " bytes on payload_id "
<< pending_payload.GetInternalPayload()->GetId();
NEARBY_VLOG(1) << "PayloadManager successfully skipped "
<< real_offset.GetResult() << " bytes on payload_id "
<< pending_payload.GetInternalPayload()->GetId();
next_chunk_offset = real_offset.GetResult();
}
for (const auto& endpoint_id : available_endpoint_ids) {
@@ -187,9 +189,9 @@ bool PayloadManager::SendPayloadLoop(
payload_chunk.offset(), payload_chunk.body().size());
}
}
NEARBY_LOGS(VERBOSE) << "PayloadManager done sending chunk at offset "
<< next_chunk_offset << " of payload_id="
<< pending_payload.GetInternalPayload()->GetId();
NEARBY_VLOG(1) << "PayloadManager done sending chunk at offset "
<< next_chunk_offset << " of payload_id="
<< pending_payload.GetInternalPayload()->GetId();
next_chunk_offset += next_chunk_size;
if (!next_chunk_size) {
@@ -314,8 +316,7 @@ PayloadManager::PayloadManager(EndpointManager& endpoint_manager)
}
void PayloadManager::CancelAllPayloads() {
NEARBY_LOG_OBSOLETE(INFO, "PayloadManager: canceling payloads; self=%p",
this);
NEARBY_LOGS(INFO) << "PayloadManager: canceling payloads; self=" << this;
{
MutexLock lock(&mutex_);
int pending_outgoing_payloads = 0;
@@ -331,9 +332,9 @@ void PayloadManager::CancelAllPayloads() {
}
}
if (shutdown_barrier_) {
NEARBY_LOG_OBSOLETE(
INFO, "PayloadManager: waiting for pending outgoing payloads; self=%p",
this);
NEARBY_LOGS(INFO) << "PayloadManager: waiting for pending outgoing "
"payloads; self="
<< this;
shutdown_barrier_->Await();
}
}
@@ -345,12 +346,12 @@ void PayloadManager::DisconnectFromEndpointManager() {
}
PayloadManager::~PayloadManager() {
NEARBY_LOG_OBSOLETE(INFO, "PayloadManager: going down; self=%p", this);
NEARBY_LOGS(INFO) << "PayloadManager: going down; self=" << this;
ThroughputRecorderContainer::GetInstance().Shutdown();
DisconnectFromEndpointManager();
CancelAllPayloads();
NEARBY_LOG_OBSOLETE(
INFO, "PayloadManager: turn down payload executors; self=%p", this);
NEARBY_LOGS(INFO) << "PayloadManager: turn down payload executors; self="
<< this;
bytes_payload_executor_.Shutdown();
stream_payload_executor_.Shutdown();
file_payload_executor_.Shutdown();
@@ -361,20 +362,20 @@ PayloadManager::~PayloadManager() {
RunOnStatusUpdateThread(
"~payload-manager",
[this, &stop_latch]() RUN_ON_PAYLOAD_STATUS_UPDATE_THREAD() {
NEARBY_LOG_OBSOLETE(
INFO, "PayloadManager: stop tracking payloads; self=%p", this);
NEARBY_LOGS(INFO) << "PayloadManager: stop tracking payloads; self="
<< this;
MutexLock lock(&mutex_);
pending_payloads_.StopTrackingAllPayloads();
stop_latch.CountDown();
});
stop_latch.Await();
NEARBY_LOG_OBSOLETE(
INFO, "PayloadManager: turn down notification executor; self=%p", this);
NEARBY_LOGS(INFO) << "PayloadManager: turn down notification executor; self="
<< this;
// Stop all the ongoing Runnables (as gracefully as possible).
payload_status_update_executor_.Shutdown();
NEARBY_LOG_OBSOLETE(INFO, "PayloadManager: down; self=%p", this);
NEARBY_LOGS(INFO) << "PayloadManager: down; self=" << this;
}
bool PayloadManager::NotifyShutdown() {
@@ -1218,10 +1219,10 @@ void PayloadManager::ProcessDataPacket(
*payload_transfer_frame.mutable_payload_header();
PayloadTransferFrame::PayloadChunk& payload_chunk =
*payload_transfer_frame.mutable_payload_chunk();
NEARBY_LOGS(VERBOSE) << "PayloadManager got data OfflineFrame for payload_id="
<< payload_header.id()
<< " from endpoint_id=" << from_endpoint_id
<< " at offset " << payload_chunk.offset();
NEARBY_VLOG(1) << "PayloadManager got data OfflineFrame for payload_id="
<< payload_header.id()
<< " from endpoint_id=" << from_endpoint_id << " at offset "
<< payload_chunk.offset();
// We explicitly deny payloads with ID 0.
if (payload_header.id() == 0) {
NEARBY_LOGS(WARNING) << "Denying payload with ID 0 for endpoint_id="
@@ -1381,7 +1382,7 @@ void PayloadManager::ProcessControlPacket(
pending_payload->SetEndpointStatusFromControlMessage(from_endpoint_id,
control_message);
}
NEARBY_LOGS(VERBOSE)
NEARBY_VLOG(1)
<< "Marked "
<< (pending_payload->IsIncoming() ? "incoming" : "outgoing")
<< " payload_id=" << pending_payload->GetInternalPayload()->GetId()
@@ -1501,9 +1502,8 @@ PayloadManager::EndpointInfo::ControlMessageEventToEndpointInfoStatus(
void PayloadManager::EndpointInfo::SetStatusFromControlMessage(
const PayloadTransferFrame::ControlMessage& control_message) {
status.Set(ControlMessageEventToEndpointInfoStatus(control_message.event()));
NEARBY_LOGS(VERBOSE) << "Marked endpoint " << id << " with status "
<< ToString(status.Get())
<< " based on OOB ControlMessage";
NEARBY_VLOG(1) << "Marked endpoint " << id << " with status "
<< ToString(status.Get()) << " based on OOB ControlMessage";
}
void PayloadManager::EndpointInfo::MarkReceivedAckFromEndpoint() {
@@ -1664,12 +1664,12 @@ void PayloadManager::PendingPayloads::Remove(
int refcount = it->second->DecRefCount();
if (refcount == 0) {
// Nobody is using the payload, we can remove it.
NEARBY_LOGS(VERBOSE) << "Erase payload " << it->second->ToString();
NEARBY_VLOG(1) << "Erase payload " << it->second->ToString();
pending_payloads_.erase(it);
} else {
// Someone is still using the payload. Move it to the garbage bin. The
// payload will be removed when they release it.
NEARBY_LOGS(VERBOSE) << "Bin payload " << it->second->ToString();
NEARBY_VLOG(1) << "Bin payload " << it->second->ToString();
payload_garbage_bin_.push_back(
std::move(pending_payloads_.extract(it).mapped()));
}
@@ -1711,7 +1711,7 @@ void PayloadManager::PendingPayloads::ForEachPayload(
void PayloadManager::PendingPayloads::Release(PendingPayload* payload) {
// Called when `PendingPayloadHandle` is destroyed.
MutexLock lock(&mutex_);
NEARBY_LOGS(VERBOSE) << __func__ << " " << payload->ToString();
NEARBY_VLOG(1) << __func__ << " " << payload->ToString();
auto it = pending_payloads_.find(payload->GetId());
if (it != pending_payloads_.end() && it->second.get() == payload) {
// The payload is still tracked.
@@ -14,15 +14,22 @@
#include "connections/implementation/wifi_direct_bwu_handler.h"
#include <cstdint>
#include <locale>
#include <memory>
#include <string>
#include <utility>
#include "absl/functional/bind_front.h"
#include "connections/implementation/base_bwu_handler.h"
#include "connections/implementation/client_proxy.h"
#include "connections/implementation/endpoint_channel.h"
#include "connections/implementation/mediums/mediums.h"
#include "connections/implementation/offline_frames.h"
#include "connections/implementation/wifi_direct_endpoint_channel.h"
#include "internal/platform/byte_array.h"
#include "internal/platform/logging.h"
#include "internal/platform/wifi_credential.h"
#include "internal/platform/wifi_direct.h"
namespace nearby {
@@ -128,7 +135,7 @@ WifiDirectBwuHandler::CreateUpgradedEndpointChannel(
return nullptr;
}
NEARBY_LOGS(VERBOSE)
NEARBY_VLOG(1)
<< "WifiDirectBwuHandler successfully connected to WifiDirect service ("
<< port << ") while upgrading endpoint " << endpoint_id;
@@ -14,16 +14,24 @@
#include "connections/implementation/wifi_hotspot_bwu_handler.h"
#include <cstdint>
#include <locale>
#include <memory>
#include <string>
#include <utility>
#include "absl/functional/bind_front.h"
#include "connections/implementation/base_bwu_handler.h"
#include "connections/implementation/client_proxy.h"
#include "connections/implementation/endpoint_channel.h"
#include "connections/implementation/mediums/mediums.h"
#include "connections/implementation/mediums/utils.h"
#include "connections/implementation/offline_frames.h"
#include "connections/implementation/wifi_hotspot_endpoint_channel.h"
#include "connections/strategy.h"
#include "internal/platform/byte_array.h"
#include "internal/platform/logging.h"
#include "internal/platform/wifi_credential.h"
#include "internal/platform/wifi_hotspot.h"
namespace nearby {
@@ -135,7 +143,7 @@ WifiHotspotBwuHandler::CreateUpgradedEndpointChannel(
return nullptr;
}
NEARBY_LOGS(VERBOSE)
NEARBY_VLOG(1)
<< "WifiHotspotBwuHandler successfully connected to WifiHotspot service ("
<< gateway << ":" << port << ") while upgrading endpoint " << endpoint_id;
@@ -53,9 +53,9 @@ WifiLanBwuHandler::CreateUpgradedEndpointChannel(
const std::string& ip_address = upgrade_path_info_socket.ip_address();
std::int32_t port = upgrade_path_info_socket.wifi_port();
NEARBY_LOGS(VERBOSE) << "WifiLanBwuHandler is attempting to connect to "
<< "available WifiLan service (" << ip_address << ":"
<< port << ") for endpoint " << endpoint_id;
NEARBY_VLOG(1) << "WifiLanBwuHandler is attempting to connect to "
<< "available WifiLan service (" << ip_address << ":" << port
<< ") for endpoint " << endpoint_id;
WifiLanSocket socket = wifi_lan_medium_.Connect(
service_id, ip_address, port, client->GetCancellationFlag(endpoint_id));
@@ -67,7 +67,7 @@ WifiLanBwuHandler::CreateUpgradedEndpointChannel(
return nullptr;
}
NEARBY_LOGS(VERBOSE)
NEARBY_VLOG(1)
<< "WifiLanBwuHandler successfully connected to WifiLan service ("
<< ip_address << ":" << port << ") while upgrading endpoint "
<< endpoint_id;
+2 -2
View File
@@ -155,7 +155,7 @@ absl::StatusOr<HttpResponse> NearbyHttpClient::InternalGetResponse(
request_stream << std::endl;
request_stream << "body size: " << request.GetBody().GetRawData().size()
<< std::endl;
NEARBY_LOGS(VERBOSE) << request_stream.str();
NEARBY_VLOG(1) << request_stream.str();
}
absl::StatusOr<api::WebResponse> web_response =
@@ -176,7 +176,7 @@ absl::StatusOr<HttpResponse> NearbyHttpClient::InternalGetResponse(
}
response_stream << std::endl;
response_stream << "body size: " << web_response->body.size() << std::endl;
NEARBY_LOGS(VERBOSE) << response_stream.str();
NEARBY_VLOG(1) << response_stream.str();
}
HttpResponse response;
-1
View File
@@ -499,7 +499,6 @@ cc_test(
"crypto_test.cc",
"direct_executor_test.cc",
"future_test.cc",
"logging_test.cc",
"multi_thread_executor_test.cc",
"mutex_test.cc",
"scheduled_executor_test.cc",
+20 -12
View File
@@ -14,6 +14,13 @@
#include "internal/platform/ble.h"
#include <memory>
#include <string>
#include <utility>
#include "internal/platform/bluetooth_adapter.h"
#include "internal/platform/cancellation_flag.h"
#include "internal/platform/implementation/ble.h"
#include "internal/platform/logging.h"
#include "internal/platform/mutex_lock.h"
@@ -62,9 +69,9 @@ bool BleMedium::StartScanning(
if (peripherals_.empty()) return;
auto context = peripherals_.find(&peripheral);
if (context == peripherals_.end()) return;
NEARBY_LOG_OBSOLETE(INFO, "Removing peripheral=%p, impl=%p",
&(context->second->peripheral),
&peripheral);
NEARBY_LOGS(INFO) << "Removing peripheral="
<< context->second->peripheral.GetName()
<< ", impl=" << &peripheral;
discovered_peripheral_callback_.peripheral_lost_cb(
context->second->peripheral, service_id);
},
@@ -76,7 +83,7 @@ bool BleMedium::StopScanning(const std::string& service_id) {
MutexLock lock(&mutex_);
discovered_peripheral_callback_ = {};
peripherals_.clear();
NEARBY_LOG_OBSOLETE(INFO, "Ble Scanning disabled: impl=%p", &GetImpl());
NEARBY_LOGS(INFO) << "Ble Scanning disabled: impl=" << &GetImpl();
}
return impl_->StopScanning(service_id);
}
@@ -95,12 +102,12 @@ bool BleMedium::StartAcceptingConnections(const std::string& service_id,
&socket, std::make_unique<AcceptedConnectionInfo>());
auto& context = *pair.first->second;
if (!pair.second) {
NEARBY_LOG_OBSOLETE(INFO, "Accepting (again) socket=%p, impl=%p",
&context.socket, &socket);
NEARBY_LOGS(INFO) << "Accepting (again) socket=" << &context.socket
<< ", impl=" << &socket;
} else {
context.socket = BleSocket(&socket);
NEARBY_LOG_OBSOLETE(INFO, "Accepting socket=%p, impl=%p",
&context.socket, &socket);
NEARBY_LOGS(INFO)
<< "Accepting socket=" << &context.socket << ", impl=" << &socket;
}
if (accepted_connection_callback_) {
accepted_connection_callback_(context.socket, service_id);
@@ -113,8 +120,8 @@ bool BleMedium::StopAcceptingConnections(const std::string& service_id) {
MutexLock lock(&mutex_);
accepted_connection_callback_ = nullptr;
sockets_.clear();
NEARBY_LOG_OBSOLETE(INFO, "Ble accepted connection disabled: impl=%p",
&GetImpl());
NEARBY_LOGS(INFO) << "Ble accepted connection disabled: impl="
<< &GetImpl();
}
return impl_->StopAcceptingConnections(service_id);
}
@@ -124,8 +131,9 @@ BleSocket BleMedium::Connect(BlePeripheral& peripheral,
CancellationFlag* cancellation_flag) {
{
MutexLock lock(&mutex_);
NEARBY_LOG_OBSOLETE(INFO, "BleMedium::Connect: peripheral=%p [impl=%p]",
&peripheral, &peripheral.GetImpl());
NEARBY_LOGS(INFO) << "BleMedium::Connect: peripheral="
<< peripheral.GetName()
<< ",impl=" << &peripheral.GetImpl();
}
return BleSocket(
impl_->Connect(peripheral.GetImpl(), service_id, cancellation_flag));
+16 -16
View File
@@ -15,10 +15,14 @@
#include "internal/platform/ble.h"
#include <memory>
#include <string>
#include "gmock/gmock.h"
#include "protobuf-matchers/protocol-buffer-matchers.h"
#include "gtest/gtest.h"
#include "internal/platform/bluetooth_adapter.h"
#include "internal/platform/byte_array.h"
#include "internal/platform/cancellation_flag.h"
#include "internal/platform/count_down_latch.h"
#include "internal/platform/logging.h"
#include "internal/platform/medium_environment.h"
@@ -74,11 +78,10 @@ TEST_P(BleMediumTest, CanStartAcceptingConnectionsAndConnect) {
BlePeripheral& peripheral, const std::string& service_id,
const ByteArray& advertisement_bytes,
bool fast_advertisement) {
NEARBY_LOG_OBSOLETE(
INFO,
"Peripheral discovered: %s, %p, fast advertisement: %d",
peripheral.GetName().c_str(), &peripheral,
fast_advertisement);
NEARBY_LOGS(INFO)
<< "Discovered peripheral=" << peripheral.GetName()
<< ", impl=" << &peripheral.GetImpl()
<< ", fast advertisement=" << fast_advertisement;
discovered_peripheral = &peripheral;
found_latch.CountDown();
},
@@ -87,9 +90,8 @@ TEST_P(BleMediumTest, CanStartAcceptingConnectionsAndConnect) {
fast_advertisement_service_uuid);
ble_b.StartAcceptingConnections(
service_id, [&](BleSocket socket, const std::string& service_id) {
NEARBY_LOG_OBSOLETE(INFO,
"Connection accepted: socket=%p, service_id=%s",
&socket, service_id.c_str());
NEARBY_LOGS(INFO) << "Connection accepted: socket=" << &socket
<< ", service_id=" << service_id;
accepted_latch.CountDown();
});
EXPECT_TRUE(found_latch.Await(kWaitDuration).result());
@@ -134,11 +136,10 @@ TEST_P(BleMediumTest, CanCancelConnect) {
BlePeripheral& peripheral, const std::string& service_id,
const ByteArray& advertisement_bytes,
bool fast_advertisement) {
NEARBY_LOG_OBSOLETE(
INFO,
"Peripheral discovered: %s, %p, fast advertisement: %d",
peripheral.GetName().c_str(), &peripheral,
fast_advertisement);
NEARBY_LOGS(INFO)
<< "Discovered peripheral=" << peripheral.GetName()
<< ", impl=" << &peripheral.GetImpl()
<< ", fast advertisement=" << fast_advertisement;
discovered_peripheral = &peripheral;
found_latch.CountDown();
},
@@ -147,9 +148,8 @@ TEST_P(BleMediumTest, CanCancelConnect) {
fast_advertisement_service_uuid);
ble_b.StartAcceptingConnections(
service_id, [&](BleSocket socket, const std::string& service_id) {
NEARBY_LOG_OBSOLETE(INFO,
"Connection accepted: socket=%p, service_id=%s",
&socket, service_id.c_str());
NEARBY_LOGS(INFO) << "Connection accepted: socket=" << &socket
<< ", service_id=" << service_id;
accepted_latch.CountDown();
});
EXPECT_TRUE(found_latch.Await(kWaitDuration).result());
+4 -3
View File
@@ -22,6 +22,7 @@
#include "internal/platform/implementation/ble_v2.h"
#include "internal/platform/logging.h"
#include "internal/platform/mutex_lock.h"
#include "internal/platform/uuid.h"
namespace nearby {
@@ -91,7 +92,7 @@ bool BleV2Medium::StartScanning(const Uuid& service_uuid,
// prevent the stale data in cache.
peripherals_.clear();
scanning_enabled_ = true;
NEARBY_LOG_OBSOLETE(INFO, "Ble Scanning enabled; impl=%p", GetImpl());
NEARBY_LOGS(INFO) << "Ble Scanning enabled; impl=" << GetImpl();
}
return success;
}
@@ -106,7 +107,7 @@ bool BleV2Medium::StopScanning() {
scanning_enabled_ = false;
peripherals_.clear();
scan_callback_ = {};
NEARBY_LOG_OBSOLETE(INFO, "Ble Scanning disabled: impl=%p", GetImpl());
NEARBY_LOGS(INFO) << "Ble Scanning disabled: impl=" << GetImpl();
return impl_->StopScanning();
}
@@ -114,7 +115,7 @@ std::unique_ptr<api::ble_v2::BleMedium::ScanningSession>
BleV2Medium::StartScanning(const Uuid& service_uuid,
api::ble_v2::TxPowerLevel tx_power_level,
api::ble_v2::BleMedium::ScanningCallback callback) {
NEARBY_LOG_OBSOLETE(INFO, "platform mutex: %p", &mutex_);
NEARBY_LOGS(INFO) << "platform mutex: " << &mutex_;
return impl_->StartScanning(
service_uuid, tx_power_level,
api::ble_v2::BleMedium::ScanningCallback{
+1 -2
View File
@@ -50,8 +50,7 @@ void BlockingQueueStream::Write(const ByteArray& bytes) {
is_writing_ = true;
blocking_queue_.Put(bytes);
is_writing_ = false;
NEARBY_LOGS(VERBOSE) << "BlockingQueueStream wrote " << bytes.size()
<< " bytes";
NEARBY_VLOG(1) << "BlockingQueueStream wrote " << bytes.size() << " bytes";
}
Exception BlockingQueueStream::Close() {
+44 -41
View File
@@ -19,6 +19,7 @@
#include <utility>
#include "absl/container/flat_hash_map.h"
#include "absl/strings/string_view.h"
#include "internal/platform/bluetooth_adapter.h"
#include "internal/platform/cancellation_flag.h"
#include "internal/platform/implementation/bluetooth_classic.h"
@@ -79,11 +80,11 @@ BluetoothClassicMedium::~BluetoothClassicMedium() {
BluetoothSocket BluetoothClassicMedium::ConnectToService(
BluetoothDevice& remote_device, const std::string& service_uuid,
CancellationFlag* cancellation_flag) {
NEARBY_LOG_OBSOLETE(
INFO,
"BluetoothClassicMedium::ConnectToService: service_uuid=%p, "
"device=%p, [impl=%p]",
service_uuid.c_str(), &remote_device, &remote_device.GetImpl());
NEARBY_LOGS(INFO) << "BluetoothClassicMedium::ConnectToService: "
"service_uuid="
<< service_uuid
<< ", device=" << remote_device.GetMacAddress()
<< ", [impl=" << &remote_device.GetImpl() << "]";
return BluetoothSocket(impl_->ConnectToService(
remote_device.GetImpl(), service_uuid, cancellation_flag));
}
@@ -92,48 +93,50 @@ bool BluetoothClassicMedium::StartDiscovery(DiscoveryCallback callback) {
NEARBY_LOGS(INFO) << "BluetoothClassicMedium::StartDiscovery";
MutexLock lock(&mutex_);
if (discovery_enabled_) {
NEARBY_LOG_OBSOLETE(INFO, "BT Discovery already enabled; impl=%p",
&GetImpl());
NEARBY_LOGS(INFO) << "BT Discovery already enabled; impl=" << &GetImpl();
return false;
}
bool success = impl_->StartDiscovery({
.device_discovered_cb =
[this](api::BluetoothDevice& device) {
NEARBY_LOGS(VERBOSE)
<< "BT .device_discovered_cb for " << device.GetName();
NEARBY_VLOG(1) << "BT .device_discovered_cb for "
<< device.GetName();
MutexLock lock(&mutex_);
auto pair = devices_.emplace(
&device, std::make_unique<DeviceDiscoveryInfo>());
auto& context = *pair.first->second;
if (!pair.second) {
NEARBY_LOG_OBSOLETE(INFO, "Adding (again) device=%p, impl=%p",
&context.device, &device);
NEARBY_LOGS(INFO)
<< "Adding (again) device=" << context.device.GetMacAddress()
<< ",impl=" << &device;
return;
}
context.device = BluetoothDevice(&device);
NEARBY_LOG_OBSOLETE(INFO, "Adding device=%p, impl=%p",
&context.device, &device);
NEARBY_LOGS(INFO)
<< "Adding device=" << context.device.GetMacAddress()
<< ",impl=" << &device;
if (!discovery_enabled_) return;
discovery_callback_.device_discovered_cb(context.device);
},
.device_name_changed_cb =
[this](api::BluetoothDevice& device) {
NEARBY_LOGS(VERBOSE)
<< "BT .device_name_changed_cb for " << device.GetName();
NEARBY_VLOG(1) << "BT .device_name_changed_cb for "
<< device.GetName();
MutexLock lock(&mutex_);
// If the device is not already in devices_, we should not be able
// to change its name.
if (devices_.find(&device) == devices_.end()) return;
auto& context = *devices_[&device];
NEARBY_LOG_OBSOLETE(INFO, "Renaming device=%p, impl=%p",
&context.device, &device);
NEARBY_LOGS(INFO)
<< "Renaming device=" << context.device.GetMacAddress()
<< ",impl=" << &device;
if (!discovery_enabled_) return;
discovery_callback_.device_name_changed_cb(context.device);
},
.device_lost_cb =
[this](api::BluetoothDevice& device) {
NEARBY_LOGS(VERBOSE) << "BT .device_lost_cb for " <<
device.GetName();
NEARBY_VLOG(1) << "BT .device_lost_cb for "
<< device.GetMacAddress();
MutexLock lock(&mutex_);
auto item = devices_.extract(&device);
if (!item) {
@@ -142,8 +145,9 @@ bool BluetoothClassicMedium::StartDiscovery(DiscoveryCallback callback) {
return;
}
auto& context = *item.mapped();
NEARBY_LOG_OBSOLETE(INFO, "Removing device=%p, impl=%p",
&context.device, &device);
NEARBY_LOGS(INFO)
<< "Removing device=" << context.device.GetMacAddress()
<< ",impl=" << &device;
if (!discovery_enabled_) return;
discovery_callback_.device_lost_cb(context.device);
},
@@ -153,24 +157,24 @@ bool BluetoothClassicMedium::StartDiscovery(DiscoveryCallback callback) {
devices_.clear();
discovery_enabled_ = true;
}
NEARBY_LOG_OBSOLETE(INFO, "BT StartDiscovery result:%d; impl=%p", success,
&GetImpl());
NEARBY_LOGS(INFO) << "BT StartDiscovery result:" << success
<< ", impl=" << &GetImpl();
return success;
}
bool BluetoothClassicMedium::StopDiscovery() {
NEARBY_LOG_OBSOLETE(INFO, "BT StopDiscovery; impl=%p", &GetImpl());
NEARBY_LOGS(INFO) << "BT StopDiscovery; impl=" << &GetImpl();
MutexLock lock(&mutex_);
if (!discovery_enabled_) return true;
discovery_enabled_ = false;
discovery_callback_ = {};
devices_.clear();
NEARBY_LOG_OBSOLETE(INFO, "BT Discovery disabled: impl=%p", &GetImpl());
NEARBY_LOGS(INFO) << "BT Discovery disabled: impl=" << &GetImpl();
return impl_->StopDiscovery();
}
void BluetoothClassicMedium::AddObserver(Observer* observer) {
NEARBY_LOG_OBSOLETE(INFO, "BT AddObserver; impl=%p", &GetImpl());
NEARBY_LOGS(INFO) << "BT AddObserver; impl=" << &GetImpl();
MutexLock lock(&mutex_);
if (observer_list_.empty()) {
impl_->AddObserver(this);
@@ -179,7 +183,7 @@ void BluetoothClassicMedium::AddObserver(Observer* observer) {
NEARBY_LOGS(INFO) << "BT AddObserver done";
}
void BluetoothClassicMedium::RemoveObserver(Observer* observer) {
NEARBY_LOG_OBSOLETE(INFO, "BT RemoveObserver; impl=%p", &GetImpl());
NEARBY_LOGS(INFO) << "BT RemoveObserver; impl=" << &GetImpl();
MutexLock lock(&mutex_);
observer_list_.RemoveObserver(observer);
if (observer_list_.empty()) {
@@ -190,16 +194,16 @@ void BluetoothClassicMedium::RemoveObserver(Observer* observer) {
// api::BluetoothClassicMedium::Observer methods
void BluetoothClassicMedium::DeviceAdded(api::BluetoothDevice& device) {
NEARBY_LOGS(VERBOSE) << "BT DeviceAdded; name=" << device.GetName()
<< ", address=" << device.GetMacAddress();
NEARBY_VLOG(1) << "BT DeviceAdded; name=" << device.GetName()
<< ", address=" << device.GetMacAddress();
BluetoothDevice bt_device(&device);
for (auto* observer : observer_list_.GetObservers()) {
observer->DeviceAdded(bt_device);
}
}
void BluetoothClassicMedium::DeviceRemoved(api::BluetoothDevice& device) {
NEARBY_LOGS(VERBOSE) << "BT DeviceRemoved; name=" << device.GetName()
<< ", address=" << device.GetMacAddress();
NEARBY_VLOG(1) << "BT DeviceRemoved; name=" << device.GetName()
<< ", address=" << device.GetMacAddress();
BluetoothDevice bt_device(&device);
for (auto* observer : observer_list_.GetObservers()) {
observer->DeviceRemoved(bt_device);
@@ -207,9 +211,9 @@ void BluetoothClassicMedium::DeviceRemoved(api::BluetoothDevice& device) {
}
void BluetoothClassicMedium::DeviceAddressChanged(
api::BluetoothDevice& device, absl::string_view old_address) {
NEARBY_LOGS(VERBOSE) << "BT DeviceAddressChanged; name=" << device.GetName()
<< ", address=" << device.GetMacAddress()
<< ", old_address=" << old_address;
NEARBY_VLOG(1) << "BT DeviceAddressChanged; name=" << device.GetName()
<< ", address=" << device.GetMacAddress()
<< ", old_address=" << old_address;
BluetoothDevice bt_device(&device);
for (auto* observer : observer_list_.GetObservers()) {
observer->DeviceAddressChanged(bt_device, old_address);
@@ -217,9 +221,9 @@ void BluetoothClassicMedium::DeviceAddressChanged(
}
void BluetoothClassicMedium::DevicePairedChanged(api::BluetoothDevice& device,
bool new_paired_status) {
NEARBY_LOGS(VERBOSE) << "BT DevicePairedChanged; name=" << device.GetName()
<< ", address=" << device.GetMacAddress()
<< ", status=" << new_paired_status;
NEARBY_VLOG(1) << "BT DevicePairedChanged; name=" << device.GetName()
<< ", address=" << device.GetMacAddress()
<< ", status=" << new_paired_status;
BluetoothDevice bt_device(&device);
for (auto* observer : observer_list_.GetObservers()) {
observer->DevicePairedChanged(bt_device, new_paired_status);
@@ -227,10 +231,9 @@ void BluetoothClassicMedium::DevicePairedChanged(api::BluetoothDevice& device,
}
void BluetoothClassicMedium::DeviceConnectedStateChanged(
api::BluetoothDevice& device, bool connected) {
NEARBY_LOGS(VERBOSE) << "BT DeviceConnectedStateChanged: name="
<< device.GetName()
<< ", address=" << device.GetMacAddress()
<< ", connected=" << connected;
NEARBY_VLOG(1) << "BT DeviceConnectedStateChanged: name=" << device.GetName()
<< ", address=" << device.GetMacAddress()
<< ", connected=" << connected;
BluetoothDevice bt_device(&device);
for (auto* observer : observer_list_.GetObservers()) {
observer->DeviceConnectedStateChanged(bt_device, connected);
+14 -15
View File
@@ -21,6 +21,7 @@
#include "absl/functional/any_invocable.h"
#include "absl/log/check.h"
#include "absl/strings/escaping.h"
#include "absl/synchronization/mutex.h"
#include "internal/platform/byte_array.h"
#include "internal/platform/cancellation_flag.h"
@@ -142,10 +143,11 @@ bool BleMedium::StartAdvertising(
const std::string& service_id, const ByteArray& advertisement_bytes,
const std::string& fast_advertisement_service_uuid) {
NEARBY_LOGS(INFO) << "G3 Ble StartAdvertising: service_id=" << service_id
<< ", advertisement bytes=" << advertisement_bytes.data()
<< ", advertisement bytes="
<< absl::BytesToHexString(std::string(advertisement_bytes))
<< "(" << advertisement_bytes.size() << "),"
<< " fast advertisement service uuid="
<< fast_advertisement_service_uuid;
<< ", fast advertisement service uuid="
<< absl::BytesToHexString(fast_advertisement_service_uuid);
auto& env = MediumEnvironment::Instance();
auto& peripheral = adapter_->GetPeripheral();
peripheral.SetAdvertisementBytes(service_id, advertisement_bytes);
@@ -261,11 +263,10 @@ bool BleMedium::StopAcceptingConnections(const std::string& service_id) {
std::unique_ptr<api::BleSocket> BleMedium::Connect(
api::BlePeripheral& remote_peripheral, const std::string& service_id,
CancellationFlag* cancellation_flag) {
NEARBY_LOG_OBSOLETE(
INFO,
"G3 Ble Connect [self]: medium=%p, adapter=%p, peripheral=%p, "
"service_id=%s",
this, &GetAdapter(), &GetAdapter().GetPeripheral(), service_id.c_str());
NEARBY_LOGS(INFO) << "G3 Ble Connect [self]: medium=" << this
<< ", adapter=" << &GetAdapter()
<< ", peripheral=" << &GetAdapter().GetPeripheral()
<< ", service_id=" << service_id;
// First, find an instance of remote medium, that exposed this peripheral.
auto& adapter = static_cast<BlePeripheral&>(remote_peripheral).GetAdapter();
auto* medium = static_cast<BleMedium*>(adapter.GetBleMedium());
@@ -273,11 +274,10 @@ std::unique_ptr<api::BleSocket> BleMedium::Connect(
if (!medium) return {}; // Can't find medium. Bail out.
BleServerSocket* remote_server_socket = nullptr;
NEARBY_LOG_OBSOLETE(
INFO,
"G3 Ble Connect [peer]: medium=%p, adapter=%p, peripheral=%p, "
"service_id=%s",
medium, &adapter, &remote_peripheral, service_id.c_str());
NEARBY_LOGS(INFO) << "G3 Ble Connect [peer]: medium=" << medium
<< ", adapter=" << &adapter
<< ", peripheral=" << &remote_peripheral
<< ", service_id=" << service_id;
// Then, find our server socket context in this medium.
{
absl::MutexLock medium_lock(&medium->mutex_);
@@ -312,8 +312,7 @@ std::unique_ptr<api::BleSocket> BleMedium::Connect(
return {};
}
NEARBY_LOG_OBSOLETE(INFO, "G3 Ble Connect: connected: socket=%p",
socket.get());
NEARBY_LOGS(INFO) << "G3 Ble Connect: connected: socket=" << socket.get();
return socket;
}
@@ -148,9 +148,9 @@ bool BleGattClient::DiscoverServiceAndCharacteristics(
absl::StrAppend(out, std::string(uuid));
});
NEARBY_LOGS(VERBOSE) << __func__ << ": Discover service_uuid="
<< std::string(service_uuid)
<< " with characteristic_uuids=" << flat_characteristics;
NEARBY_VLOG(1) << __func__
<< ": Discover service_uuid=" << std::string(service_uuid)
<< " with characteristic_uuids=" << flat_characteristics;
try {
if (ble_device_ == nullptr) {
@@ -208,8 +208,7 @@ bool BleGattClient::DiscoverServiceAndCharacteristics(
winrt::guid uuid = service.Uuid();
std::string uuid_string = winrt::to_string(winrt::to_hstring(uuid));
NEARBY_LOGS(VERBOSE) << __func__
<< ": Found service UUID=" << uuid_string;
NEARBY_VLOG(1) << __func__ << ": Found service UUID=" << uuid_string;
if (!is_nearby_uuid_equal_to_winrt_guid(service_uuid, uuid)) {
NEARBY_LOGS(WARNING)
<< __func__
@@ -239,8 +238,8 @@ bool BleGattClient::DiscoverServiceAndCharacteristics(
gatt_characteristic.Uuid())));
});
NEARBY_LOGS(VERBOSE) << __func__ << ": Found GATT characteristics="
<< flat_characteristics;
NEARBY_VLOG(1) << __func__
<< ": Found GATT characteristics=" << flat_characteristics;
bool found_all = true;
@@ -270,7 +269,7 @@ bool BleGattClient::DiscoverServiceAndCharacteristics(
}
// found all characteristics.
NEARBY_LOGS(VERBOSE) << __func__ << ": Found all characteristics.";
NEARBY_VLOG(1) << __func__ << ": Found all characteristics.";
return true;
}
@@ -294,9 +293,9 @@ absl::optional<api::ble_v2::GattCharacteristic>
BleGattClient::GetCharacteristic(const Uuid& service_uuid,
const Uuid& characteristic_uuid) {
absl::MutexLock lock(&mutex_);
NEARBY_LOGS(VERBOSE) << __func__ << ": Stared to get characteristic UUID="
<< std::string(characteristic_uuid)
<< " in service UUID=" << std::string(service_uuid);
NEARBY_VLOG(1) << __func__ << ": Stared to get characteristic UUID="
<< std::string(characteristic_uuid)
<< " in service UUID=" << std::string(service_uuid);
try {
std::optional<GattCharacteristic> gatt_characteristic =
GetNativeCharacteristic(service_uuid, characteristic_uuid);
@@ -341,8 +340,8 @@ BleGattClient::GetCharacteristic(const Uuid& service_uuid,
native_characteristic_map_[result].native_characteristic =
gatt_characteristic;
NEARBY_LOGS(VERBOSE) << __func__ << ": Return Characteristic. uuid="
<< std::string(characteristic_uuid);
NEARBY_VLOG(1) << __func__ << ": Return Characteristic. uuid="
<< std::string(characteristic_uuid);
return result;
} catch (std::exception exception) {
@@ -361,8 +360,8 @@ BleGattClient::GetCharacteristic(const Uuid& service_uuid,
absl::optional<std::string> BleGattClient::ReadCharacteristic(
const api::ble_v2::GattCharacteristic& characteristic) {
absl::MutexLock lock(&mutex_);
NEARBY_LOGS(VERBOSE) << __func__ << ": Read characteristic="
<< std::string(characteristic.uuid);
NEARBY_VLOG(1) << __func__ << ": Read characteristic="
<< std::string(characteristic.uuid);
try {
std::optional<GattCharacteristic> gatt_characteristic =
GetNativeCharacteristic(characteristic.service_uuid,
@@ -397,8 +396,8 @@ absl::optional<std::string> BleGattClient::ReadCharacteristic(
data.push_back(static_cast<char>(data_reader.ReadByte()));
}
NEARBY_LOGS(VERBOSE) << __func__
<< ": Got characteristic value length=" << data.size();
NEARBY_VLOG(1) << __func__
<< ": Got characteristic value length=" << data.size();
return data;
} catch (std::exception exception) {
@@ -418,8 +417,8 @@ bool BleGattClient::WriteCharacteristic(
const api::ble_v2::GattCharacteristic& characteristic,
absl::string_view value, api::ble_v2::GattClient::WriteType write_type) {
absl::MutexLock lock(&mutex_);
NEARBY_LOGS(VERBOSE) << __func__ << ": write characteristic: "
<< std::string(characteristic.uuid);
NEARBY_VLOG(1) << __func__ << ": write characteristic: "
<< std::string(characteristic.uuid);
try {
std::optional<GattCharacteristic> gatt_characteristic =
native_characteristic_map_[characteristic].native_characteristic;
@@ -449,10 +448,9 @@ bool BleGattClient::WriteCharacteristic(
<< GattCommunicationStatusToString(status);
return false;
} else {
NEARBY_LOGS(VERBOSE) << __func__
<< ": Write data to GATT characteristic: "
<< std::string(characteristic.uuid)
<< ", bytes count: " << value.size();
NEARBY_VLOG(1) << __func__ << ": Write data to GATT characteristic: "
<< std::string(characteristic.uuid)
<< ", bytes count: " << value.size();
return true;
}
} catch (std::exception exception) {
@@ -473,8 +471,7 @@ bool BleGattClient::SetCharacteristicSubscription(
absl::AnyInvocable<void(absl::string_view value)>
on_characteristic_changed_cb) {
absl::MutexLock lock(&mutex_);
NEARBY_LOGS(VERBOSE) << __func__
<< ": Started to set Characteristic Subscription.";
NEARBY_VLOG(1) << __func__ << ": Started to set Characteristic Subscription.";
GattClientCharacteristicConfigurationDescriptorValue gcccd_value =
GattClientCharacteristicConfigurationDescriptorValue::None;
if ((characteristic.property & Property::kNotify) != Property::kNone) {
@@ -552,7 +549,7 @@ bool BleGattClient::SetCharacteristicSubscription(
void BleGattClient::Disconnect() {
absl::MutexLock lock(&mutex_);
try {
NEARBY_LOGS(VERBOSE) << __func__ << ": Disconnect is called.";
NEARBY_VLOG(1) << __func__ << ": Disconnect is called.";
if (ble_device_ != nullptr) {
ble_device_.Close();
ble_device_ = nullptr;
@@ -571,10 +568,9 @@ void BleGattClient::Disconnect() {
std::optional<GattCharacteristic> BleGattClient::GetNativeCharacteristic(
const Uuid& service_uuid, const Uuid& characteristic_uuid) {
NEARBY_LOGS(VERBOSE) << __func__
<< ": Stared to get native characteristic UUID="
<< std::string(characteristic_uuid)
<< " in service UUID=" << std::string(service_uuid);
NEARBY_VLOG(1) << __func__ << ": Stared to get native characteristic UUID="
<< std::string(characteristic_uuid)
<< " in service UUID=" << std::string(service_uuid);
try {
if (ble_device_ == nullptr) {
@@ -604,9 +600,9 @@ std::optional<GattCharacteristic> BleGattClient::GetNativeCharacteristic(
gatt_characteristics_result.Characteristics()) {
if (is_nearby_uuid_equal_to_winrt_guid(characteristic_uuid,
characteristic.Uuid())) {
NEARBY_LOGS(VERBOSE)
<< __func__ << ": Return native Characteristic. uuid="
<< std::string(characteristic_uuid);
NEARBY_VLOG(1) << __func__
<< ": Return native Characteristic. uuid="
<< std::string(characteristic_uuid);
return characteristic;
}
@@ -632,9 +628,8 @@ std::optional<GattCharacteristic> BleGattClient::GetNativeCharacteristic(
bool BleGattClient::WriteCharacteristicConfigurationDescriptor(
GattCharacteristic& characteristic,
GattClientCharacteristicConfigurationDescriptorValue value) {
NEARBY_LOGS(VERBOSE)
<< __func__
<< ": Stared to write characteristic configuration descriptor";
NEARBY_VLOG(1) << __func__
<< ": Stared to write characteristic configuration descriptor";
try {
GattCommunicationStatus status =
@@ -642,9 +637,9 @@ bool BleGattClient::WriteCharacteristicConfigurationDescriptor(
.WriteClientCharacteristicConfigurationDescriptorAsync(value)
.get();
if (status == GattCommunicationStatus::Success) {
NEARBY_LOGS(VERBOSE) << __func__
<< ": Successfully write client characteristic "
"configuration descriptor";
NEARBY_VLOG(1) << __func__
<< ": Successfully write client characteristic "
"configuration descriptor";
return true;
}
NEARBY_LOGS(ERROR) << __func__
@@ -670,7 +665,7 @@ bool BleGattClient::WriteCharacteristicConfigurationDescriptor(
void BleGattClient::OnCharacteristicValueChanged(
const api::ble_v2::GattCharacteristic& characteristic,
GattValueChangedEventArgs args) {
NEARBY_LOGS(VERBOSE) << __func__ << ": Gatt Characteristic value changed.";
NEARBY_VLOG(1) << __func__ << ": Gatt Characteristic value changed.";
IBuffer buffer = args.CharacteristicValue();
int size = buffer.Length();
DataReader data_reader = DataReader::FromBuffer(buffer);
@@ -679,8 +674,8 @@ void BleGattClient::OnCharacteristicValueChanged(
for (int i = 0; i < size; ++i) {
data.push_back(static_cast<char>(data_reader.ReadByte()));
}
NEARBY_LOGS(VERBOSE) << __func__
<< ": Got characteristic value length= " << data.size();
NEARBY_VLOG(1) << __func__
<< ": Got characteristic value length= " << data.size();
absl::AnyInvocable<void(absl::string_view value)>
on_characteristic_changed_cb;
@@ -167,8 +167,7 @@ bool BleGattServer::UpdateCharacteristic(
for (auto& it : gatt_characteristic_datas_) {
if (it.gatt_characteristic.uuid == characteristic.uuid) {
NEARBY_LOGS(VERBOSE) << __func__
<< ": Found the characteristic to update.";
NEARBY_VLOG(1) << __func__ << ": Found the characteristic to update.";
it.data = value;
// If it is in running, notify the value changed.
@@ -201,8 +200,8 @@ absl::Status BleGattServer::NotifyCharacteristicChanged(
const ByteArray& new_value) {
absl::MutexLock lock(&mutex_);
// Currently, the method is not hooked up at platform layer.
NEARBY_LOGS(VERBOSE) << __func__ << ": Notify characteristic="
<< std::string(characteristic.uuid) << " changed.";
NEARBY_VLOG(1) << __func__ << ": Notify characteristic="
<< std::string(characteristic.uuid) << " changed.";
return absl::OkStatus();
}
@@ -210,7 +209,7 @@ void BleGattServer::Stop() {
absl::AnyInvocable<void()> close_notifier = nullptr;
{
absl::MutexLock lock(&mutex_);
NEARBY_LOGS(VERBOSE) << __func__ << ": Start to stop GATT server.";
NEARBY_VLOG(1) << __func__ << ": Start to stop GATT server.";
if (gatt_service_provider_ != nullptr) {
try {
if (is_advertising_) {
@@ -242,8 +241,8 @@ void BleGattServer::Stop() {
bool BleGattServer::InitializeGattServer() {
try {
// Create and advertise GATT service.
NEARBY_LOGS(VERBOSE) << __func__ << ": Create GATT service service_uuid="
<< std::string(service_uuid_);
NEARBY_VLOG(1) << __func__ << ": Create GATT service service_uuid="
<< std::string(service_uuid_);
if (adapter_ == nullptr) {
NEARBY_LOGS(ERROR) << __func__ << ": Bluetooth adapter is absent.";
@@ -320,12 +319,10 @@ bool BleGattServer::InitializeGattServer() {
is_notify_supported = true;
}
NEARBY_LOGS(VERBOSE) << __func__
<< ": GATT characteristic properties: read="
<< is_read_supported
<< ",write=" << is_write_supported
<< ",indicate=" << is_indicate_supported
<< ",notify=" << is_notify_supported;
NEARBY_VLOG(1) << __func__ << ": GATT characteristic properties: read="
<< is_read_supported << ",write=" << is_write_supported
<< ",indicate=" << is_indicate_supported
<< ",notify=" << is_notify_supported;
gatt_characteristic_parameters.CharacteristicProperties(properties);
gatt_characteristic_parameters.WriteProtectionLevel(
@@ -334,10 +331,10 @@ bool BleGattServer::InitializeGattServer() {
winrt::guid characteristic_uuid = nearby_uuid_to_winrt_guid(
characteristic_data.gatt_characteristic.uuid);
NEARBY_LOGS(VERBOSE) << __func__
<< ": Create characteristic characteristic_uuid="
<< winrt::to_string(
winrt::to_hstring(characteristic_uuid));
NEARBY_VLOG(1) << __func__
<< ": Create characteristic characteristic_uuid="
<< winrt::to_string(
winrt::to_hstring(characteristic_uuid));
GattLocalCharacteristicResult result =
gatt_service_provider_.Service()
@@ -356,9 +353,9 @@ bool BleGattServer::InitializeGattServer() {
::winrt::guid local_characteristic_guid =
characteristic_data.local_characteristic.Uuid();
NEARBY_LOGS(VERBOSE) << __func__ << ": Local GATT characteristic. uuid: "
<< winrt::to_string(
winrt::to_hstring(local_characteristic_guid));
NEARBY_VLOG(1) << __func__ << ": Local GATT characteristic. uuid: "
<< winrt::to_string(
winrt::to_hstring(local_characteristic_guid));
// Setup gatt local characteristic events.
if (is_read_supported) {
@@ -408,9 +405,9 @@ bool BleGattServer::StartAdvertisement(const ByteArray& service_data,
absl::MutexLock lock(&mutex_);
try {
NEARBY_LOGS(VERBOSE) << __func__ << ": service_data="
<< absl::BytesToHexString(service_data.AsStringView())
<< ", is_connectable=" << is_connectable;
NEARBY_VLOG(1) << __func__ << ": service_data="
<< absl::BytesToHexString(service_data.AsStringView())
<< ", is_connectable=" << is_connectable;
if (is_advertising_) {
NEARBY_LOGS(ERROR) << ": GATT server is already in advertising.";
@@ -567,7 +564,7 @@ void BleGattServer::SetCloseNotifier(absl::AnyInvocable<void()> notifier) {
request.RespondWithValue(buffer);
deferral.Complete();
NEARBY_LOGS(VERBOSE) << __func__ << ": Sent data to remote device.";
NEARBY_VLOG(1) << __func__ << ": Sent data to remote device.";
return {};
} catch (std::exception exception) {
NEARBY_LOGS(ERROR) << __func__ << ": Exception: " << exception.what();
@@ -600,11 +600,11 @@ void BleMedium::AdvertisementReceivedHandler(
ByteArray advertisement_data(data);
NEARBY_LOGS(VERBOSE) << "Nearby BLE Medium Advertisement discovered. "
"0x16 Service data: advertisement bytes= 0x"
<< absl::BytesToHexString(
advertisement_data.AsStringView())
<< "(" << advertisement_data.size() << ")";
NEARBY_VLOG(1) << "Nearby BLE Medium Advertisement discovered. "
"0x16 Service data: advertisement bytes= 0x"
<< absl::BytesToHexString(
advertisement_data.AsStringView())
<< "(" << advertisement_data.size() << ")";
std::string peripheral_name =
uint64_to_mac_address_string(args.BluetoothAddress());
@@ -1085,13 +1085,12 @@ void BleV2Medium::AdvertisementReceivedHandler(
ByteArray advertisement_data(data);
NEARBY_LOGS(VERBOSE) << "Nearby BLE Medium "
<< service_uuid_.Get16BitAsString()
<< " Advertisement discovered. "
"0x16 Service data: advertisement bytes= 0x"
<< absl::BytesToHexString(
advertisement_data.AsStringView())
<< "(" << advertisement_data.size() << ")";
NEARBY_VLOG(1) << "Nearby BLE Medium " << service_uuid_.Get16BitAsString()
<< " Advertisement discovered. "
"0x16 Service data: advertisement bytes= 0x"
<< absl::BytesToHexString(
advertisement_data.AsStringView())
<< "(" << advertisement_data.size() << ")";
std::string bluetooth_address =
uint64_to_mac_address_string(args.BluetoothAddress());
@@ -40,26 +40,26 @@ api::ble_v2::BlePeripheral* BleV2Socket::GetRemotePeripheral() {
bool BleV2Socket::Connect(api::ble_v2::BlePeripheral* ble_peripheral) {
// TODO(b/271031645): implement BLE socket using weave
NEARBY_LOGS(VERBOSE) << __func__ << ": Connect to BLE peripheral="
<< ble_peripheral->GetAddress();
NEARBY_VLOG(1) << __func__ << ": Connect to BLE peripheral="
<< ble_peripheral->GetAddress();
return false;
}
ExceptionOr<ByteArray> BleV2Socket::BleInputStream::Read(std::int64_t size) {
// TODO(b/271031645): implement BLE socket using weave
NEARBY_LOGS(VERBOSE) << __func__ << ": Read data size=" << size;
NEARBY_VLOG(1) << __func__ << ": Read data size=" << size;
return ExceptionOr<ByteArray>(Exception::kIo);
}
Exception BleV2Socket::BleInputStream::Close() {
// TODO(b/271031645): implement BLE socket using weave
NEARBY_LOGS(VERBOSE) << __func__ << ": Close BLE input stream.";
NEARBY_VLOG(1) << __func__ << ": Close BLE input stream.";
return {Exception::kSuccess};
}
Exception BleV2Socket::BleOutputStream::Write(const ByteArray& data) {
// TODO(b/271031645): implement BLE socket using weave
NEARBY_LOGS(VERBOSE) << __func__ << ": Write data size=" << data.size();
NEARBY_VLOG(1) << __func__ << ": Write data size=" << data.size();
return {Exception::kIo};
}
@@ -40,6 +40,7 @@
#include "absl/strings/str_format.h"
#include "third_party/json/src/json.hpp"
#include "internal/platform/feature_flags.h"
#include "internal/platform/implementation/platform.h"
#include "internal/platform/implementation/windows/generated/winrt/Windows.Foundation.h"
#include "internal/platform/implementation/windows/utils.h"
#include "internal/platform/logging.h"
@@ -347,8 +348,8 @@ void BluetoothAdapter::RestoreRadioNameIfNecessary() {
return;
}
NEARBY_LOGS(VERBOSE) << __func__
<< ": loaded settings: " << local_settings.dump();
NEARBY_VLOG(1) << __func__
<< ": loaded settings: " << local_settings.dump();
LocalSettings settings = local_settings.get<LocalSettings>();
@@ -391,8 +392,8 @@ void BluetoothAdapter::StoreRadioNames(absl::string_view original_radio_name,
json encoded_local_settings;
to_json(encoded_local_settings, local_settings);
NEARBY_LOGS(VERBOSE) << __func__ << ": saved settings: "
<< encoded_local_settings.dump();
NEARBY_VLOG(1) << __func__
<< ": saved settings: " << encoded_local_settings.dump();
ByteArray data(encoded_local_settings.dump());
@@ -345,8 +345,8 @@ std::unique_ptr<api::BluetoothSocket> BluetoothClassicMedium::ConnectToService(
std::unique_ptr<api::BluetoothPairing> BluetoothClassicMedium::CreatePairing(
api::BluetoothDevice& remote_device) {
NEARBY_LOGS(VERBOSE) << __func__ << ": Start to createPairing with device: "
<< remote_device.GetMacAddress();
NEARBY_VLOG(1) << __func__ << ": Start to createPairing with device: "
<< remote_device.GetMacAddress();
try {
winrt::Windows::Devices::Bluetooth::BluetoothDevice bluetooth_device =
winrt::Windows::Devices::Bluetooth::BluetoothDevice::
@@ -360,8 +360,8 @@ std::unique_ptr<api::BluetoothPairing> BluetoothClassicMedium::CreatePairing(
return std::make_unique<BluetoothPairing>(bluetooth_device,
custom_pairing);
}
NEARBY_LOGS(VERBOSE) << __func__
<< ": Failed to get DeviceInformationCustomPairing.";
NEARBY_VLOG(1) << __func__
<< ": Failed to get DeviceInformationCustomPairing.";
} catch (std::exception exception) {
NEARBY_LOGS(ERROR) << __func__ << " : Failed to create pairing. exception: "
<< exception.what();
@@ -54,8 +54,7 @@ BluetoothPairing::BluetoothPairing(
BluetoothDevice bluetooth_device,
DeviceInformationCustomPairing custom_pairing)
: bluetooth_device_(bluetooth_device), custom_pairing_(custom_pairing) {
NEARBY_LOGS(VERBOSE) << __func__
<< ": BluetoothPairing is created for device.";
NEARBY_VLOG(1) << __func__ << ": BluetoothPairing is created for device.";
}
BluetoothPairing::~BluetoothPairing() {
@@ -64,19 +63,17 @@ BluetoothPairing::~BluetoothPairing() {
std::exchange(pairing_requested_token_, {}));
}
CancelPairing();
NEARBY_LOGS(VERBOSE) << __func__
<< ": BluetoothPairing is destroyed for device.";
NEARBY_VLOG(1) << __func__ << ": BluetoothPairing is destroyed for device.";
}
bool BluetoothPairing::InitiatePairing(
api::BluetoothPairingCallback pairing_cb) {
NEARBY_LOGS(VERBOSE) << __func__ << ": Start to initiate pairing process.";
NEARBY_VLOG(1) << __func__ << ": Start to initiate pairing process.";
try {
pairing_requested_token_ = custom_pairing_.PairingRequested(
{this, &BluetoothPairing::OnPairingRequested});
if (!pairing_requested_token_) {
NEARBY_LOGS(VERBOSE) << __func__
<< " Failed to registered pairing callback.";
NEARBY_VLOG(1) << __func__ << " Failed to registered pairing callback.";
return false;
}
pairing_callback_ = std::move(pairing_cb);
@@ -107,14 +104,14 @@ bool BluetoothPairing::InitiatePairing(
bool BluetoothPairing::FinishPairing(
std::optional<absl::string_view> pin_code) {
NEARBY_LOGS(VERBOSE) << __func__ << "Start to finish pairing.";
NEARBY_VLOG(1) << __func__ << "Start to finish pairing.";
try {
if (!pairing_requested_) {
NEARBY_LOGS(VERBOSE) << __func__ << "No pairing requested.";
NEARBY_VLOG(1) << __func__ << "No pairing requested.";
return false;
}
if (!pairing_deferral_) {
NEARBY_LOGS(VERBOSE) << __func__ << "No ongoing pairing process.";
NEARBY_VLOG(1) << __func__ << "No ongoing pairing process.";
return false;
}
if (expecting_pin_code_) {
@@ -129,7 +126,7 @@ bool BluetoothPairing::FinishPairing(
pairing_requested_.Accept();
}
pairing_deferral_.Complete();
NEARBY_LOGS(VERBOSE) << "Successfully finished pairing.";
NEARBY_VLOG(1) << "Successfully finished pairing.";
return true;
} catch (std::exception exception) {
NEARBY_LOGS(ERROR) << __func__ << ": Failed to finish pairing. exception: "
@@ -146,11 +143,10 @@ bool BluetoothPairing::FinishPairing(
}
bool BluetoothPairing::CancelPairing() {
NEARBY_LOGS(VERBOSE) << __func__
<< " Start to cancel ongoing pairing process.";
NEARBY_VLOG(1) << __func__ << " Start to cancel ongoing pairing process.";
try {
if (!pairing_deferral_) {
NEARBY_LOGS(VERBOSE) << __func__ << "No ongoing pairing process.";
NEARBY_VLOG(1) << __func__ << "No ongoing pairing process.";
return true;
}
// There is no way to explicitly cancel an in-progress pairing on Windows as
@@ -161,7 +157,7 @@ bool BluetoothPairing::CancelPairing() {
// deferral is completed, will know that cancellation was the actual result.
was_cancelled_ = true;
pairing_deferral_.Close();
NEARBY_LOGS(VERBOSE) << __func__ << "Canceled ongoing pairing process.";
NEARBY_VLOG(1) << __func__ << "Canceled ongoing pairing process.";
return true;
} catch (std::exception exception) {
NEARBY_LOGS(ERROR) << __func__ << ": Failed to cancel ongoing pairing "
@@ -178,20 +174,19 @@ bool BluetoothPairing::CancelPairing() {
}
bool BluetoothPairing::Unpair() {
NEARBY_LOGS(VERBOSE) << __func__ << ": Start to unpair with remote device.";
NEARBY_VLOG(1) << __func__ << ": Start to unpair with remote device.";
try {
if (!IsPaired()) {
NEARBY_LOGS(VERBOSE) << __func__ << " : Remote device Was not paired.";
NEARBY_VLOG(1) << __func__ << " : Remote device Was not paired.";
return true;
}
DeviceUnpairingResult unpairing_result =
bluetooth_device_.DeviceInformation().Pairing().UnpairAsync().get();
if (unpairing_result.Status() == DeviceUnpairingResultStatus::Unpaired) {
NEARBY_LOGS(VERBOSE) << __func__ << ": Unpaired with remote device.";
NEARBY_VLOG(1) << __func__ << ": Unpaired with remote device.";
return true;
}
NEARBY_LOGS(VERBOSE) << __func__
<< ": Failed to unpaired with remote device.";
NEARBY_VLOG(1) << __func__ << ": Failed to unpaired with remote device.";
} catch (std::exception exception) {
NEARBY_LOGS(ERROR) << __func__
<< ": Failed to unpaired with device. exception: "
@@ -229,7 +224,7 @@ bool BluetoothPairing::IsPaired() {
void BluetoothPairing::OnPairingRequested(
DeviceInformationCustomPairing custom_pairing,
DevicePairingRequestedEventArgs pairing_requested) {
NEARBY_LOGS(VERBOSE) << __func__ << "Requested to pair.";
NEARBY_VLOG(1) << __func__ << "Requested to pair.";
try {
DevicePairingKinds pairing_kind = pairing_requested.PairingKind();
pairing_requested_ = pairing_requested;
@@ -32,8 +32,8 @@ Executor::Executor(int32_t max_concurrency)
void Executor::Execute(Runnable&& runnable) {
if (shut_down_) {
NEARBY_LOGS(VERBOSE) << "Warning: " << __func__
<< ": Attempt to execute on a shut down pool.";
NEARBY_VLOG(1) << "Warning: " << __func__
<< ": Attempt to execute on a shut down pool.";
return;
}
@@ -25,7 +25,7 @@
namespace nearby {
namespace windows {
api::LogMessage::Severity min_log_severity_ = api::LogMessage::Severity::kInfo;
api::LogMessage::Severity g_min_log_severity = api::LogMessage::Severity::kInfo;
inline absl::LogSeverity ConvertSeverity(api::LogMessage::Severity severity) {
switch (severity) {
@@ -65,11 +65,11 @@ std::ostream& LogMessage::Stream() { return log_streamer_.stream(); }
namespace api {
void LogMessage::SetMinLogSeverity(Severity severity) {
windows::min_log_severity_ = severity;
windows::g_min_log_severity = severity;
}
bool LogMessage::ShouldCreateLogMessage(Severity severity) {
return severity >= windows::min_log_severity_;
return severity >= windows::g_min_log_severity;
}
} // namespace api
} // namespace nearby
@@ -36,7 +36,6 @@ class LogMessage : public api::LogMessage {
private:
google::LogMessage log_streamer_;
static api::LogMessage::Severity min_log_severity_;
};
} // namespace windows
@@ -25,6 +25,7 @@
#include "nlohmann/json.hpp"
#include "nlohmann/json_fwd.hpp"
#include "internal/base/files.h"
#include "internal/platform/implementation/platform.h"
#include "internal/platform/implementation/windows/preferences_repository.h"
#include "internal/platform/logging.h"
@@ -83,13 +83,12 @@ ThreadPool::ThreadPool(PTP_POOL thread_pool,
: thread_pool_(thread_pool),
thread_pool_environ_(thread_pool_environ),
max_pool_size_(max_pool_size) {
NEARBY_LOGS(VERBOSE) << __func__ << ": Thread pool(" << this
<< ") is created with size:" << max_pool_size_;
NEARBY_VLOG(1) << __func__ << ": Thread pool(" << this
<< ") is created with size:" << max_pool_size_;
}
ThreadPool::~ThreadPool() {
NEARBY_LOGS(VERBOSE) << __func__ << ": Thread pool(" << this
<< ") is released.";
NEARBY_VLOG(1) << __func__ << ": Thread pool(" << this << ") is released.";
if (thread_pool_ == nullptr) {
return;
@@ -112,8 +111,8 @@ bool ThreadPool::Run(Runnable task) {
PTP_WORK work;
tasks_.push(std::move(task));
NEARBY_LOGS(VERBOSE) << __func__ << ": Scheduled to run task("
<< &tasks_.back() << ").";
NEARBY_VLOG(1) << __func__ << ": Scheduled to run task(" << &tasks_.back()
<< ").";
work = CreateThreadpoolWork(WorkCallback, this, &thread_pool_environ_);
if (work == nullptr) {
@@ -146,19 +145,19 @@ void ThreadPool::ShutDown() {
if (running_tasks_count_ == 0) {
CloseThreadpool(thread_pool_);
thread_pool_ = nullptr;
NEARBY_LOGS(VERBOSE) << __func__ << ": Thread pool(" << this
<< ") is shut down.";
NEARBY_VLOG(1) << __func__ << ": Thread pool(" << this
<< ") is shut down.";
return;
}
if (shutdown_latch_ != nullptr) {
NEARBY_LOGS(VERBOSE) << __func__ << ": Thread pool(" << this
<< ") is already in shutting down.";
NEARBY_VLOG(1) << __func__ << ": Thread pool(" << this
<< ") is already in shutting down.";
return;
}
NEARBY_LOGS(VERBOSE) << __func__ << ": Thread pool(" << this
<< ") is shutting down.";
NEARBY_VLOG(1) << __func__ << ": Thread pool(" << this
<< ") is shutting down.";
shutdown_latch_ = std::make_unique<CountDownLatch>(1);
}
@@ -170,8 +169,7 @@ void ThreadPool::ShutDown() {
absl::MutexLock lock(&mutex_);
CloseThreadpool(thread_pool_);
thread_pool_ = nullptr;
NEARBY_LOGS(VERBOSE) << __func__ << ": Thread pool(" << this
<< ") is shut down.";
NEARBY_VLOG(1) << __func__ << ": Thread pool(" << this << ") is shut down.";
}
}
@@ -185,8 +183,7 @@ void ThreadPool::RunNextTask() {
return;
}
if (!tasks_.empty()) {
NEARBY_LOGS(VERBOSE) << __func__ << ": Run task(" << &tasks_.front()
<< ").";
NEARBY_VLOG(1) << __func__ << ": Run task(" << &tasks_.front() << ").";
task = std::move(tasks_.front());
tasks_.pop();
@@ -15,18 +15,20 @@
#include "internal/platform/implementation/windows/utils.h"
#include <windows.h>
#include <winsock2.h>
// Standard C/C++ headers
#include <codecvt>
#include <cstddef>
#include <cstdint>
#include <exception>
#include <locale>
#include <stdexcept>
#include <string>
#include <vector>
// Third party headers
#include "absl/strings/ascii.h"
#include "absl/strings/str_cat.h"
#include "absl/strings/str_format.h"
// Nearby connections headers
@@ -182,8 +184,8 @@ Uuid winrt_guid_to_nearby_uuid(const ::winrt::guid& guid) {
int64_t data3 = guid.Data3;
int64_t msb = ((data1 >> 24) & 0xff) << 56 | ((data1 >> 16) & 0xff) << 48 |
((data1 >> 8) & 0xff) << 40 | ((data1)&0xff) << 32 |
((data2 >> 8) & 0xff) << 24 | ((data2)&0xff) << 16 |
((data1 >> 8) & 0xff) << 40 | ((data1) & 0xff) << 32 |
((data2 >> 8) & 0xff) << 24 | ((data2) & 0xff) << 16 |
((data3 >> 8) & 0xff) << 8 | (data3 & 0xff);
int64_t lsb =
@@ -215,7 +217,7 @@ winrt::guid nearby_uuid_to_winrt_guid(Uuid uuid) {
}
bool is_nearby_uuid_equal_to_winrt_guid(const Uuid& uuid,
const ::winrt::guid& guid) {
const ::winrt::guid& guid) {
return uuid == winrt_guid_to_nearby_uuid(guid);
}
@@ -242,7 +244,7 @@ bool InspectableReader::ReadBoolean(IInspectable inspectable) {
return property_value.GetBoolean();
}
uint16 InspectableReader::ReadUint16(IInspectable inspectable) {
uint16_t InspectableReader::ReadUint16(IInspectable inspectable) {
if (inspectable == nullptr) {
return 0;
}
@@ -260,7 +262,7 @@ uint16 InspectableReader::ReadUint16(IInspectable inspectable) {
return property_value.GetUInt16();
}
uint32 InspectableReader::ReadUint32(IInspectable inspectable) {
uint32_t InspectableReader::ReadUint32(IInspectable inspectable) {
if (inspectable == nullptr) {
return 0;
}
@@ -316,7 +318,7 @@ std::vector<std::string> InspectableReader::ReadStringArray(
winrt::com_array<winrt::hstring> strings;
property_value.GetStringArray(strings);
for (winrt::hstring str : strings) {
for (const winrt::hstring& str : strings) {
result.push_back(winrt::to_string(str));
}
return result;
@@ -60,8 +60,7 @@ const std::string WebRtcMedium::GetDefaultCountryCode() {
}
std::wstring wideGeo(systemGeoName);
std::string systemGeoNameString(wideGeo.begin(), wideGeo.end());
NEARBY_LOGS(VERBOSE) << "GetUserDefaultGeoName() returns: "
<< systemGeoNameString;
NEARBY_VLOG(1) << "GetUserDefaultGeoName() returns: " << systemGeoNameString;
return systemGeoNameString;
}
@@ -281,7 +281,6 @@ void WifiHotspotServerSocket::SocketErrorNotice(absl::string_view reason) {
bool WifiHotspotServerSocket::SetupServerSocketWinSock() {
WSADATA wsa_data;
WSAEVENT socket_event;
int flag = 1;
int result = WSAStartup(MAKEWORD(2, 2), &wsa_data);
@@ -347,7 +346,7 @@ bool WifiHotspotServerSocket::SetupServerSocketWinSock() {
return false;
}
NEARBY_LOGS(INFO) << "Hotspot Server Socket " << listen_socket_
<< " started to listen with socket event: " << socket_event;
<< " started to listen.";
submittable_executor_.Execute([this]() {
DWORD index;
@@ -116,11 +116,11 @@ DEVINST SearchForDeviceInstance(wchar_t* pEntireDeviceList);
void CloseRegKeyHandle(HKEY softwareKey); // NOLINT
void OpenRegKeyHandle(DEVINST devInst, HKEY& softwareKey);
DWORD GetRegKeyWCHARValue(DEVINST deviceInstance, LPCWSTR keyName, // NOLINT
wchar_t* valOut, PDWORD pValLen, // NOLINT
PDWORD pDataType); // NOLINT
wchar_t* valOut, PDWORD pValLen, // NOLINT
PDWORD pDataType); // NOLINT
DWORD GetFullDllLoadPathFromPieRegistry(DEVINST pieDeviceInstance,
PWCHAR* ppDllPathValue); // NOLINT
HADAPTER WifiGetAdapterList(HINSTANCE murocApiDllHandle, // NOLINT
HADAPTER WifiGetAdapterList(HINSTANCE murocApiDllHandle, // NOLINT
PINTEL_ADAPTER_LIST_V120* ppAllAdapters);
void RegisterIntelCallback(HINSTANCE murocApiDllHandle,
MurocDefs::PINTEL_CALLBACK pIntelEventCbHandle);
@@ -185,7 +185,7 @@ int WifiIntel::GetGOChannel() {
nullptr;
int channel = -1;
DWORD dwError = ERROR_SUCCESS; // NOLINT
DWORD dwError = ERROR_SUCCESS; // NOLINT
MUROC_RET murocApiRetVal = IWLAN_E_FAILURE; // NOLINT
INTEL_WIFI_HEADER intelWifiHeader;
MurocDefs::INTEL_GO_OPERATION_CHANNEL_SETTING intelGOChan;
@@ -194,8 +194,7 @@ int WifiIntel::GetGOChannel() {
WifiPanQueryPreferredChannelSettingFunc =
(WIFIPANQUERYPREFERREDCHANNELSETTING)GetProcAddress( // NOLINT
muroc_api_dll_handle_,
"WifiPanQueryPreferredChannelSetting");
muroc_api_dll_handle_, "WifiPanQueryPreferredChannelSetting");
if (WifiPanQueryPreferredChannelSettingFunc == nullptr) {
dwError = GetLastError(); // NOLINT
@@ -204,7 +203,7 @@ int WifiIntel::GetGOChannel() {
<< dwError;
return channel;
}
NEARBY_LOGS(VERBOSE)
NEARBY_VLOG(1)
<< "Load WifiPanQueryPreferredChannelSetting API completed successfully";
intelWifiHeader.dwSize =
@@ -236,9 +235,8 @@ int WifiIntel::GetGOChannel() {
bool WifiIntel::SetScanFilter(int channel) {
#ifndef NO_INTEL_PIE
WIFILEGACYGOSETSCANFILTER WifiLegacyGoSetScanFilterFunc =
nullptr;
DWORD dwError = ERROR_SUCCESS; // NOLINT
WIFILEGACYGOSETSCANFILTER WifiLegacyGoSetScanFilterFunc = nullptr;
DWORD dwError = ERROR_SUCCESS; // NOLINT
MUROC_RET murocApiRetVal = IWLAN_E_FAILURE; // NOLINT
INTEL_WIFI_HEADER intelWifiHeader;
MurocDefs::WIFI_LEGACY_GO_SCAN_FILTER scanFilter;
@@ -249,21 +247,18 @@ bool WifiIntel::SetScanFilter(int channel) {
NEARBY_LOGS(INFO) << "Set scan channel:" << channel;
WifiLegacyGoSetScanFilterFunc =
(WIFILEGACYGOSETSCANFILTER)GetProcAddress( // NOLINT
muroc_api_dll_handle_,
"WifiLegacyGoSetScanFilter");
muroc_api_dll_handle_, "WifiLegacyGoSetScanFilter");
if (WifiLegacyGoSetScanFilterFunc == nullptr) {
dwError = GetLastError(); // NOLINT
NEARBY_LOGS(INFO)
<< "GetProcAddress WifiLegacyGoSetScanFilterFunc error: "
<< dwError;
NEARBY_LOGS(INFO) << "GetProcAddress WifiLegacyGoSetScanFilterFunc error: "
<< dwError;
return false;
}
NEARBY_LOGS(VERBOSE)
NEARBY_VLOG(1)
<< "Load WifiLegacyGoSetScanFilterFunc API completed successfully";
intelWifiHeader.dwSize =
sizeof(MurocDefs::WIFI_LEGACY_GO_SCAN_FILTER);
intelWifiHeader.dwSize = sizeof(MurocDefs::WIFI_LEGACY_GO_SCAN_FILTER);
memset(&scanFilter, 0, sizeof(scanFilter));
scanFilter.channel = (UINT8)channel;
murocApiRetVal = WifiLegacyGoSetScanFilterFunc(
@@ -288,9 +283,8 @@ bool WifiIntel::SetScanFilter(int channel) {
bool WifiIntel::ResetScanFilter() {
#ifndef NO_INTEL_PIE
WIFIPANRESETLEGACYGOSCANFILTER WifiPanReSetLegacyGoScanFilterFunc =
nullptr;
DWORD dwError = ERROR_SUCCESS; // NOLINT
WIFIPANRESETLEGACYGOSCANFILTER WifiPanReSetLegacyGoScanFilterFunc = nullptr;
DWORD dwError = ERROR_SUCCESS; // NOLINT
MUROC_RET murocApiRetVal = IWLAN_E_FAILURE; // NOLINT
INTEL_WIFI_HEADER intelWifiHeader;
@@ -298,8 +292,7 @@ bool WifiIntel::ResetScanFilter() {
WifiPanReSetLegacyGoScanFilterFunc =
(WIFIPANRESETLEGACYGOSCANFILTER)GetProcAddress( // NOLINT
muroc_api_dll_handle_,
"WifiPanReSetLegacyGoScanFilter");
muroc_api_dll_handle_, "WifiPanReSetLegacyGoScanFilter");
if (WifiPanReSetLegacyGoScanFilterFunc == nullptr) {
dwError = GetLastError(); // NOLINT
@@ -308,11 +301,11 @@ bool WifiIntel::ResetScanFilter() {
<< dwError;
return false;
}
NEARBY_LOGS(VERBOSE)
NEARBY_VLOG(1)
<< "Load WifiPanReSetLegacyGoScanFilterFunc API completed successfully";
intelWifiHeader.dwSize = 0;
murocApiRetVal = WifiPanReSetLegacyGoScanFilterFunc(
wifi_adapter_handle_, &intelWifiHeader);
murocApiRetVal = WifiPanReSetLegacyGoScanFilterFunc(wifi_adapter_handle_,
&intelWifiHeader);
if (murocApiRetVal == IWLAN_E_SUCCESS) { // NOLINT
NEARBY_LOGS(INFO) << "Calling WifiPanReSetLegacyGoScanFilter API succeeded";
@@ -385,8 +378,7 @@ bool IsHwIdMatching(DEVINST devInst, const wchar_t* expecedHwId) {
// Compare to given HW ID
wchar_t* pdest = wcsstr(currentDeviceHwId, expecedHwId); // NOLINT
if (nullptr != pdest) {
std::wcout << "wifi_intel.cc"
<< ":" << __LINE__
std::wcout << "wifi_intel.cc" << ":" << __LINE__
<< "] Intel WIFI hwId is found: " << expecedHwId << std::endl;
isHwIdFound = true;
}
@@ -442,10 +434,10 @@ void OpenRegKeyHandle(DEVINST devInst, HKEY& softwareKey) {
if (devInst != NULL) {
// opens a registry key for device-specific configuration information.
configRet = CM_Open_DevNode_Key(devInst, KEY_READ, 0, // NOLINT
RegDisposition_OpenExisting,
&softwareKey, CM_REGISTRY_SOFTWARE);
RegDisposition_OpenExisting, &softwareKey,
CM_REGISTRY_SOFTWARE);
NEARBY_LOGS(VERBOSE) << absl::StrFormat("softwareKey %p ", softwareKey);
NEARBY_VLOG(1) << absl::StrFormat("softwareKey %p ", softwareKey);
if (configRet != CR_SUCCESS) {
NEARBY_LOGS(INFO)
@@ -493,11 +485,11 @@ DWORD GetFullDllLoadPathFromPieRegistry(DEVINST pieDeviceInstance,
<< "Unexpected error! GetRegKeyWCHARValue return Value of " << status;
return status;
} else {
NEARBY_LOGS(VERBOSE) << "Queried key length successfully!";
NEARBY_VLOG(1) << "Queried key length successfully!";
}
dllFullPathLen = (dllPathBufferLen + sizeof(PIE_API_DLL));
NEARBY_LOGS(VERBOSE) << "dll Full Path Length = " << dllFullPathLen;
NEARBY_VLOG(1) << "dll Full Path Length = " << dllFullPathLen;
pLoadPathString = new wchar_t[dllFullPathLen];
SecureZeroMemory(pLoadPathString, dllFullPathLen); // NOLINT
@@ -513,15 +505,14 @@ DWORD GetFullDllLoadPathFromPieRegistry(DEVINST pieDeviceInstance,
return status;
} else {
pathString = pLoadPathString;
NEARBY_LOGS(VERBOSE) << "Queried key successfully!";
NEARBY_VLOG(1) << "Queried key successfully!";
}
std::wstring fullString = pathString + PIE_API_DLL;
wcscpy_s(pLoadPathString, dllFullPathLen, fullString.c_str()); // NOLINT
std::wcout << "wifi_intel.cc"
<< ":" << __LINE__
std::wcout << "wifi_intel.cc" << ":" << __LINE__
<< "] PIE Dll Path and Name = " << pLoadPathString << std::endl;
if (ppDllPathValue != nullptr) {
@@ -551,8 +542,8 @@ HINSTANCE WifiIntel::PIEDllLoader() {
// load the library and get the handle
murocApiDllHandle = LoadLibraryW(pDllPathValue); // NOLINT
NEARBY_LOGS(VERBOSE) << absl::StrFormat("Muroc Api Dll Handle is 0x%p ",
murocApiDllHandle);
NEARBY_VLOG(1) << absl::StrFormat("Muroc Api Dll Handle is 0x%p ",
murocApiDllHandle);
} else {
NEARBY_LOGS(INFO) << "GetFullDllLoadPathFromPieRegistry fails eith error: "
<< ret;
@@ -581,8 +572,8 @@ HADAPTER WifiGetAdapterList(HINSTANCE murocApiDllHandle,
return INVALID_HADAPTER;
}
NEARBY_LOGS(VERBOSE) << "GetProcAddress for WifiGetAdapterListFunction API "
"completed successfully";
NEARBY_VLOG(1) << "GetProcAddress for WifiGetAdapterListFunction API "
"completed successfully";
INTEL_WIFI_HEADER intelHeader = {INTEL_STRUCT_VERSION_V156, // NOLINT
sizeof(MurocDefs::INTEL_ADAPTER_LIST_V120)};
MUROC_RET murocApiRetVal = IWLAN_E_FAILURE;
@@ -619,7 +610,7 @@ void RegisterIntelCallback(
return;
}
NEARBY_LOGS(VERBOSE) << "Load RegisterIntelCallback API successfully";
NEARBY_VLOG(1) << "Load RegisterIntelCallback API successfully";
MUROC_RET murocApiRetVal = IWLAN_E_FAILURE;
murocApiRetVal = registerIntelCBFunc(pIntelEventCbHandle);
@@ -649,13 +640,13 @@ void DeregisterIntelCallback(HINSTANCE murocApiDllHandle,
}
{
NEARBY_LOGS(VERBOSE) << "Load DeregisterIntelCallback API successfully";
NEARBY_VLOG(1) << "Load DeregisterIntelCallback API successfully";
MUROC_RET murocApiRetVal = IWLAN_E_FAILURE;
murocApiRetVal = deregisterIntelCBFunc(fnCallback);
if (murocApiRetVal == IWLAN_E_SUCCESS) {
NEARBY_LOGS(VERBOSE) << "Calling DeregisterIntelCallback API succeeded.";
NEARBY_VLOG(1) << "Calling DeregisterIntelCallback API succeeded.";
} else {
NEARBY_LOGS(INFO)
<< "Calling DeregisterIntelCallback API fails with error:"
@@ -683,13 +674,13 @@ void FreeMemoryList(HINSTANCE murocApiDllHandle, void* ptr) {
}
if ((freeMemoryListFunction != nullptr)) {
NEARBY_LOGS(VERBOSE) << "Load FreeListMemory API successfully";
NEARBY_VLOG(1) << "Load FreeListMemory API successfully";
MUROC_RET murocApiRetVal = IWLAN_E_FAILURE;
murocApiRetVal = freeMemoryListFunction(ptr);
if (murocApiRetVal == IWLAN_E_SUCCESS) {
NEARBY_LOGS(VERBOSE) << "Calling FreeListMemory API succeeded.";
NEARBY_VLOG(1) << "Calling FreeListMemory API succeeded.";
} else {
NEARBY_LOGS(INFO) << "Calling FreeListMemory API failed with error: "
<< murocApiRetVal;
+13 -80
View File
@@ -1,4 +1,4 @@
// Copyright 2020 Google LLC
// Copyright 2024 Google LLC
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
@@ -15,91 +15,24 @@
#ifndef PLATFORM_BASE_LOGGING_H_
#define PLATFORM_BASE_LOGGING_H_
// base/logging.h is only included to allow logging clients to include CHECK's.
// In Chrome this is base/check.h. See crbug/1212611.
#ifdef NEARBY_CHROMIUM
#if defined(NEARBY_CHROMIUM)
// Chromium does not use absl log. Forward to Chromium native log macros.
#include "base/check.h"
// base/logging.h is available externally as "glog". However, this repo contains
// template files that can't be built by Swift Package Manager. To build with
// SPM we only need CHECK and DCHECK defined.
#elif defined(NEARBY_SWIFTPM)
#include <sstream>
#define CHECK(condition) static_cast<void>(0), condition ? (void) 0 : abort()
#define DCHECK(condition) static_cast<void>(0), (void) 0
#define CHECK_GT(a, b) static_cast<void>(0), a > b ? (void) 0 : abort()
#define DCHECK_GT(a, b) static_cast<void>(0), a > b ? (void) 0 : abort()
#define CHECK_LE(a, b) static_cast<void>(0), a <= b ? (void) 0 : abort()
#define DCHECK_LE(a, b) static_cast<void>(0), a <= b ? (void) 0 : abort()
#define CHECK_NE(a, b) static_cast<void>(0), a != b ? (void) 0 : abort()
#define DCHECK_NE(a, b) static_cast<void>(0), a != b ? (void) 0 : abort()
#define CHECK_EQ(a, b) static_cast<void>(0), a == b ? (void) 0 : abort()
#define DCHECK_EQ(a, b) static_cast<void>(0), a == b ? (void) 0 : abort()
#define CHECK_GE(a, b) static_cast<void>(0), a >= b ? (void) 0 : abort()
#define DCHECK_GE(a, b) static_cast<void>(0), a >= b ? (void) 0 : abort()
#else
#include "base/check_op.h"
#include "glog/logging.h"
#else // defined(NEARBY_CHROMIUM)
// IWYU pragma: begin_exports
#include "absl/log/check.h" // nogncheck
#include "absl/log/log.h" // nogncheck
#include "absl/log/log.h" // nogncheck
// IWYU pragma: end_exports
#endif
#include "internal/platform/implementation/log_message.h"
#include "internal/platform/implementation/platform.h"
namespace nearby {
// This class is used to explicitly ignore values in the conditional
// logging macros. This avoids compiler warnings like "value computed
// is not used" and "statement has no effect".
class LogMessageVoidify {
public:
LogMessageVoidify() = default;
// This has to be an operator with a precedence lower than << but
// higher than ?:
void operator&(std::ostream&) {}
};
} // namespace nearby
// Severity enum conversion
#define NEARBY_SEVERITY_VERBOSE nearby::api::LogMessage::Severity::kVerbose
#define NEARBY_SEVERITY_INFO nearby::api::LogMessage::Severity::kInfo
#define NEARBY_SEVERITY_WARNING nearby::api::LogMessage::Severity::kWarning
#define NEARBY_SEVERITY_ERROR nearby::api::LogMessage::Severity::kError
#define NEARBY_SEVERITY_FATAL nearby::api::LogMessage::Severity::kFatal
#if defined(_WIN32)
// wingdi.h defines ERROR to be 0. When we call LOG(ERROR), it gets substituted
// with 0, and it expands to NEARBY_SEVERITY_0. To allow us to keep using this
// syntax, we define this macro to do the same thing as NEARBY_SEVERITY_ERROR.
#define NEARBY_SEVERITY_0 nearby::api::LogMessage::Severity::kError
#endif // defined(_WIN32)
#define NEARBY_SEVERITY(severity) NEARBY_SEVERITY_##severity
// Log enabling
#define NEARBY_LOG_IS_ON(severity) \
nearby::api::LogMessage::ShouldCreateLogMessage(NEARBY_SEVERITY(severity))
#define NEARBY_LOG_SET_SEVERITY(severity) \
nearby::api::LogMessage::SetMinLogSeverity(NEARBY_SEVERITY(severity))
// Log message creation
#define NEARBY_LOG_MESSAGE(severity) \
nearby::api::ImplementationPlatform::CreateLogMessage( \
__FILE__, __LINE__, NEARBY_SEVERITY(severity))
#endif // defined(NEARBY_CHROMIUM)
// Public APIs
// The stream statement must come last or otherwise it won't compile.
#define NEARBY_LOGS(severity) \
!(NEARBY_LOG_IS_ON(severity)) \
? (void)0 \
: nearby::LogMessageVoidify() & NEARBY_LOG_MESSAGE(severity)->Stream()
// The stream statement must come last, or it won't compile.
#define NEARBY_VLOG(level) VLOG(level)
#define NEARBY_LOGS(severity) LOG(severity)
// DO NOT USE. Switch to NEARBY_LOGS() instead.
#define NEARBY_LOG_OBSOLETE(severity, ...) \
NEARBY_LOG_IS_ON(severity) \
? NEARBY_LOG_MESSAGE(severity)->Print(__VA_ARGS__) : (void)0
#ifdef NEARBY_SWIFTPM
#define LOG(severity) NEARBY_LOGS(severity)
#endif
#define NEARBY_DLOG(severity) DLOG(severity)
#define NEARBY_DVLOG(severity) DVLOG(severity)
#endif // PLATFORM_BASE_LOGGING_H_
-53
View File
@@ -1,53 +0,0 @@
// Copyright 2020 Google LLC
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// https://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
#include "internal/platform/logging.h"
#include "gmock/gmock.h"
#include "protobuf-matchers/protocol-buffer-matchers.h"
#include "gtest/gtest.h"
namespace {
TEST(LoggingTest, CanLog) {
NEARBY_LOG_SET_SEVERITY(INFO);
int num = 42;
NEARBY_LOGS(INFO) << "The answer to everything: " << num++;
EXPECT_EQ(num, 43);
}
TEST(LoggingTest, CanLog_LoggingDisabled) {
NEARBY_LOG_SET_SEVERITY(ERROR);
int num = 42;
NEARBY_LOGS(INFO) << "The answer to everything: " << num++;
// num++ should not be evaluated
EXPECT_EQ(num, 42);
}
TEST(LoggingTest, CanStream) {
NEARBY_LOG_SET_SEVERITY(INFO);
int num = 42;
NEARBY_LOGS(INFO) << "The answer to everything: " << num++;
EXPECT_EQ(num, 43);
}
TEST(LoggingTest, CanStream_LoggingDisabled) {
NEARBY_LOG_SET_SEVERITY(ERROR);
int num = 42;
NEARBY_LOGS(INFO) << "The answer to everything: " << num++;
// num++ should not be evaluated
EXPECT_EQ(num, 42);
}
} // namespace
+6 -4
View File
@@ -24,6 +24,7 @@
#include "absl/container/flat_hash_set.h"
#include "absl/status/status.h"
#include "absl/strings/escaping.h"
#include "absl/strings/str_format.h"
#include "absl/strings/string_view.h"
#include "absl/time/time.h"
@@ -180,7 +181,7 @@ void MediumEnvironment::OnBluetoothDeviceStateChanged(
// Store device name, and report it as discovered.
info.devices.emplace(&device, name);
if (enable_notifications_) {
NEARBY_LOGS(VERBOSE) << "Notify about new discovered device";
NEARBY_VLOG(1) << "Notify about new discovered device";
info.callback.device_discovered_cb(device);
for (auto& observer : observers_.GetObservers()) {
observer->DeviceAdded(device);
@@ -204,7 +205,7 @@ void MediumEnvironment::OnBluetoothDeviceStateChanged(
} else {
// Device is in discovery mode, so we are reporting it anyway.
if (enable_notifications_) {
NEARBY_LOGS(VERBOSE) << "Notify about existing discovered device";
NEARBY_VLOG(1) << "Notify about existing discovered device";
info.callback.device_discovered_cb(device);
for (auto& observer : observers_.GetObservers()) {
observer->DeviceAdded(device);
@@ -216,7 +217,7 @@ void MediumEnvironment::OnBluetoothDeviceStateChanged(
// Known device is turned off.
// Erase it from the map, and report as lost.
if (enable_notifications_) {
NEARBY_LOGS(VERBOSE) << "Notify about removed device";
NEARBY_VLOG(1) << "Notify about removed device";
info.callback.device_lost_cb(device);
for (auto& observer : observers_.GetObservers()) {
observer->DeviceRemoved(device);
@@ -530,7 +531,8 @@ void MediumEnvironment::UpdateBleMediumForScanning(
<< "; medium=" << &medium
<< "; service_id=" << service_id
<< "; fast_advertisement_service_uuid="
<< fast_advertisement_service_uuid
<< absl::BytesToHexString(
fast_advertisement_service_uuid)
<< "; enabled=" << enabled;
for (auto& medium_info : ble_mediums_) {
auto& local_medium = medium_info.first;
+1 -1
View File
@@ -139,7 +139,7 @@ void BaseSocket::WritePacket(absl::StatusOr<Packet> packet) {
NEARBY_LOGS(WARNING) << "Packet status:" << packet.status();
return;
}
CHECK(packet->SetPacketCounter(packet_counter_generator_.Next()).ok());
CHECK_OK(packet->SetPacketCounter(packet_counter_generator_.Next()));
NEARBY_LOGS(INFO) << "transmitting packet";
connection_.Transmit(packet->GetBytes());
}
+4
View File
@@ -20,7 +20,11 @@
#include <utility>
#include "absl/base/thread_annotations.h"
#include "internal/platform/byte_array.h"
#include "internal/platform/future.h"
#include "internal/platform/logging.h"
#include "internal/platform/mutex.h"
#include "internal/platform/runnable.h"
#include "internal/platform/single_thread_executor.h"
#include "internal/weave/connection.h"
#include "internal/weave/control_packet_write_request.h"
@@ -18,6 +18,7 @@
#include <utility>
#include "absl/status/status.h"
#include "absl/status/statusor.h"
#include "internal/weave/packet.h"
namespace nearby {
+1
View File
@@ -22,6 +22,7 @@
#include <vector>
#include "absl/status/status.h"
#include "absl/status/statusor.h"
#include "absl/strings/str_format.h"
#include "absl/strings/string_view.h"
#include "internal/platform/byte_array.h"
+2
View File
@@ -15,11 +15,13 @@
#ifndef THIRD_PARTY_NEARBY_INTERNAL_WEAVE_PACKET_H_
#define THIRD_PARTY_NEARBY_INTERNAL_WEAVE_PACKET_H_
#include <cstdint>
#include <string>
#include <utility>
#include "absl/status/status.h"
#include "absl/status/statusor.h"
#include "absl/strings/string_view.h"
#include "internal/platform/byte_array.h"
namespace nearby {
+1
View File
@@ -31,6 +31,7 @@ cc_library(
"//internal/weave",
"@com_google_absl//absl/random",
"@com_google_absl//absl/status",
"@com_google_absl//absl/strings",
],
)
+5
View File
@@ -14,12 +14,17 @@
#include "internal/weave/sockets/client_socket.h"
#include <cstdint>
#include <memory>
#include <string>
#include <utility>
#include "absl/status/status.h"
#include "absl/strings/str_cat.h"
#include "internal/platform/logging.h"
#include "internal/weave/base_socket.h"
#include "internal/weave/connection.h"
#include "internal/weave/packet.h"
#include "internal/weave/socket_callback.h"
#include "internal/weave/sockets/initial_data_provider.h"
+2
View File
@@ -17,8 +17,10 @@
#include <memory>
#include "internal/platform/single_thread_executor.h"
#include "internal/weave/base_socket.h"
#include "internal/weave/connection.h"
#include "internal/weave/packet.h"
#include "internal/weave/socket_callback.h"
#include "internal/weave/sockets/initial_data_provider.h"
@@ -15,9 +15,12 @@
#ifndef THIRD_PARTY_NEARBY_INTERNAL_WEAVE_SOCKETS_INITIAL_DATA_PROVIDER_H_
#define THIRD_PARTY_NEARBY_INTERNAL_WEAVE_SOCKETS_INITIAL_DATA_PROVIDER_H_
#include <cmath>
#include <cstdint>
#include <string>
#include "absl/random/random.h"
#include "absl/strings/str_cat.h"
namespace nearby {
namespace weave {
+4
View File
@@ -20,8 +20,12 @@
#include <utility>
#include "absl/status/status.h"
#include "absl/strings/string_view.h"
#include "internal/platform/logging.h"
#include "internal/weave/base_socket.h"
#include "internal/weave/connection.h"
#include "internal/weave/packet.h"
#include "internal/weave/socket_callback.h"
namespace nearby {
namespace weave {
+1 -2
View File
@@ -15,10 +15,9 @@
#ifndef THIRD_PARTY_NEARBY_INTERNAL_WEAVE_SOCKETS_SERVER_SOCKET_H_
#define THIRD_PARTY_NEARBY_INTERNAL_WEAVE_SOCKETS_SERVER_SOCKET_H_
#include <memory>
#include "internal/weave/base_socket.h"
#include "internal/weave/connection.h"
#include "internal/weave/packet.h"
#include "internal/weave/socket_callback.h"
namespace nearby {
+5 -3
View File
@@ -15,10 +15,12 @@
#include "presence/implementation/action_factory.h"
#include <algorithm>
#include <cstdint>
#include <vector>
#include "absl/types/optional.h"
#include "internal/platform/logging.h"
#include "presence/data_element.h"
#include "presence/implementation/base_broadcast_request.h"
namespace nearby {
namespace presence {
@@ -64,8 +66,8 @@ int GetMask(const DataElement& element) {
return GetActionMask(ActionBit(element.GetValue()[0]));
}
}
NEARBY_LOG_OBSOLETE(
WARNING, "Data Element 0x%x not supported in base advertisement", type);
NEARBY_LOGS(WARNING) << "Data Element " << type
<< " not supported in base advertisement";
return kEmptyMask;
}
@@ -146,9 +146,9 @@ absl::StatusOr<DataElement> ParseDataElement(const absl::string_view input,
"Data element (%s) is %d bytes long. Expected at least %d",
absl::BytesToHexString(input), input.size(), index));
}
NEARBY_LOGS(VERBOSE) << "Type: " << static_cast<int>(data_type)
<< " length: " << static_cast<int>(length) << " DE: "
<< absl::BytesToHexString(input.substr(start, length));
NEARBY_VLOG(1) << "Type: " << static_cast<int>(data_type)
<< " length: " << static_cast<int>(length) << " DE: "
<< absl::BytesToHexString(input.substr(start, length));
return DataElement(data_type, input.substr(start, length));
}
} // namespace
@@ -244,7 +244,7 @@ absl::StatusOr<Advertisement> AdvertisementDecoderImpl::DecodeAdvertisement(
return absl::OutOfRangeError("Empty advertisement");
}
uint8_t version = advertisement[0];
NEARBY_LOGS(VERBOSE) << "Version: " << version;
NEARBY_VLOG(1) << "Version: " << version;
if (version != kAdvertisementVersion) {
return absl::UnimplementedError(absl::StrFormat(
"Advertisement version (%d) is not supported", version));
@@ -151,8 +151,8 @@ AdvertisementFactory::CreateBaseNpAdvertisement(
if (!result.ok()) {
return result;
}
NEARBY_LOGS(VERBOSE) << "Unencrypted advertisement payload "
<< absl::BytesToHexString(unencrypted);
NEARBY_VLOG(1) << "Unencrypted advertisement payload "
<< absl::BytesToHexString(unencrypted);
absl::StatusOr<std::string> encrypted =
EncryptDataElements(*credential, request.salt, unencrypted);
if (!encrypted.ok()) {
+5 -5
View File
@@ -171,7 +171,7 @@ absl::optional<LocalCredential> BroadcastManager::SelectCredential( // NOLINT
}
std::string salt = SelectSalt(*credential, broadcast_request.salt);
if (salt != broadcast_request.salt) {
NEARBY_LOGS(VERBOSE) << "Changed salt";
NEARBY_VLOG(1) << "Changed salt";
broadcast_request.salt = salt;
}
return *credential;
@@ -193,7 +193,7 @@ absl::optional<LocalCredential> BroadcastManager::Advertise( // NOLINT
NEARBY_LOGS(WARNING) << "Can't create advertisement, reason: "
<< advertisement.status();
NotifyStartCallbackStatus(id, advertisement.status());
return absl::optional<LocalCredential>(); //NOLINT
return absl::optional<LocalCredential>(); // NOLINT
}
std::unique_ptr<AdvertisingSession> session =
mediums_->GetBle().StartAdvertising(
@@ -205,7 +205,7 @@ absl::optional<LocalCredential> BroadcastManager::Advertise( // NOLINT
if (!session) {
NotifyStartCallbackStatus(id,
absl::InternalError("Can't start advertising"));
return absl::optional<LocalCredential>(); //NOLINT
return absl::optional<LocalCredential>(); // NOLINT
}
it->second.SetAdvertisingSession(std::move(session));
return credential;
@@ -233,8 +233,8 @@ void BroadcastManager::StopBroadcast(BroadcastSessionId id) {
"stop-broadcast", [this, id]() ABSL_EXCLUSIVE_LOCKS_REQUIRED(executor_) {
auto it = sessions_.find(id);
if (it == sessions_.end()) {
NEARBY_LOGS(VERBOSE)
<< absl::StrFormat("BroadcastSession(0x%x) not found", id);
NEARBY_VLOG(1) << absl::StrFormat("BroadcastSession(0x%x) not found",
id);
return;
}
it->second.StopAdvertising();
+1 -1
View File
@@ -80,7 +80,7 @@ void PresenceClientImpl::StopBroadcast(BroadcastSessionId session_id) {
if (borrowed) {
(*borrowed)->StopBroadcast(session_id);
} else {
NEARBY_LOGS(VERBOSE) << "Session already finished, id: " << session_id;
NEARBY_VLOG(1) << "Session already finished, id: " << session_id;
}
}
+2 -3
View File
@@ -288,7 +288,7 @@ void NearbyConnectionsServiceImpl::AcceptConnection(
return;
}
NEARBY_LOGS(VERBOSE) << "payload callback id=" << payload.GetId();
NEARBY_VLOG(1) << "payload callback id=" << payload.GetId();
switch (payload.GetType()) {
case NcPayloadType::kBytes:
@@ -309,8 +309,7 @@ void NearbyConnectionsServiceImpl::AcceptConnection(
transfer_update.payload_id = info.payload_id;
transfer_update.status = static_cast<PayloadStatus>(info.status);
transfer_update.total_bytes = info.total_bytes;
NEARBY_LOGS(VERBOSE)
<< "payload transfer update id=" << info.payload_id;
NEARBY_VLOG(1) << "payload transfer update id=" << info.payload_id;
auto payload_listener = payload_listeners_.find(endpoint_id);
if (payload_listener != payload_listeners_.end()) {
payload_listener->second.payload_progress_cb(endpoint_id,