Log API calls to Nearby Connections

PiperOrigin-RevId: 678791269
This commit is contained in:
Guogang Li
2024-09-25 11:56:27 -07:00
committed by Copybara-Service
parent 2455d0cc66
commit dc35037fee
@@ -14,14 +14,26 @@
#include "connections/implementation/offline_service_controller.h"
#include <cstdint>
#include <string>
#include <utility>
#include <vector>
#include "absl/strings/str_join.h"
#include "absl/strings/string_view.h"
#include "connections/advertising_options.h"
#include "connections/connection_options.h"
#include "connections/discovery_options.h"
#include "connections/implementation/client_proxy.h"
#include "connections/listeners.h"
#include "connections/out_of_band_connection_metadata.h"
#include "connections/params.h"
#include "connections/payload.h"
#include "connections/status.h"
#include "connections/v3/connection_listening_options.h"
#include "connections/v3/listeners.h"
#include "internal/interop/device.h"
#include "internal/platform/logging.h"
namespace nearby {
namespace connections {
@@ -42,7 +54,8 @@ Status OfflineServiceController::StartAdvertising(
const ConnectionRequestInfo& info) {
if (stop_) return {Status::kOutOfOrderApiCall};
NEARBY_LOGS(INFO) << "Client " << client->GetClientId()
<< " requested advertising to start.";
<< " requested to start advertising for service_id "
<< service_id;
return pcp_manager_.StartAdvertising(client, service_id, advertising_options,
info);
}
@@ -50,7 +63,8 @@ Status OfflineServiceController::StartAdvertising(
void OfflineServiceController::StopAdvertising(ClientProxy* client) {
if (stop_) return;
NEARBY_LOGS(INFO) << "Client " << client->GetClientId()
<< " requested advertising to stop.";
<< " requested to stop advertising for service_id "
<< client->GetAdvertisingServiceId();
pcp_manager_.StopAdvertising(client);
}
@@ -59,7 +73,8 @@ Status OfflineServiceController::StartDiscovery(
const DiscoveryOptions& discovery_options, DiscoveryListener listener) {
if (stop_) return {Status::kOutOfOrderApiCall};
NEARBY_LOGS(INFO) << "Client " << client->GetClientId()
<< " requested discovery to start.";
<< " requested to start discovery for service_id "
<< service_id;
return pcp_manager_.StartDiscovery(client, service_id, discovery_options,
std::move(listener));
}
@@ -67,7 +82,8 @@ Status OfflineServiceController::StartDiscovery(
void OfflineServiceController::StopDiscovery(ClientProxy* client) {
if (stop_) return;
NEARBY_LOGS(INFO) << "Client " << client->GetClientId()
<< " requested discovery to stop.";
<< " requested to stop discovery for service_id "
<< client->GetDiscoveryServiceId();
pcp_manager_.StopDiscovery(client);
}
@@ -76,12 +92,18 @@ OfflineServiceController::StartListeningForIncomingConnections(
ClientProxy* client, absl::string_view service_id,
v3::ConnectionListener listener,
const v3::ConnectionListeningOptions& options) {
NEARBY_LOGS(INFO) << "Client " << client->GetClientId()
<< " requested to start listening for service_id "
<< service_id;
return pcp_manager_.StartListeningForIncomingConnections(
client, service_id, std::move(listener), options);
}
void OfflineServiceController::StopListeningForIncomingConnections(
ClientProxy* client) {
NEARBY_LOGS(INFO) << "Client " << client->GetClientId()
<< " requested to stop listening for service_id "
<< client->GetListeningForIncomingConnectionsServiceId();
pcp_manager_.StopListeningForIncomingConnections(client);
}
@@ -89,6 +111,13 @@ void OfflineServiceController::InjectEndpoint(
ClientProxy* client, const std::string& service_id,
const OutOfBandConnectionMetadata& metadata) {
if (stop_) return;
NEARBY_LOGS(INFO) << "Client " << client->GetClientId()
<< " requested to inject endpoint {endpoint_id:"
<< metadata.endpoint_id << ", endpoint_info:"
<< metadata.endpoint_info.AsStringView()
<< ",remote_bluetooth_mac_address:"
<< metadata.remote_bluetooth_mac_address.AsStringView()
<< "} for service_id " << service_id;
pcp_manager_.InjectEndpoint(client, service_id, metadata);
}
@@ -98,7 +127,7 @@ Status OfflineServiceController::RequestConnection(
const ConnectionOptions& connection_options) {
if (stop_) return {Status::kOutOfOrderApiCall};
NEARBY_LOGS(INFO) << "Client " << client->GetClientId()
<< " requested a connection to endpoint_id=" << endpoint_id;
<< " requested a connection to endpoint_id " << endpoint_id;
return pcp_manager_.RequestConnection(client, endpoint_id, info,
connection_options);
}
@@ -109,7 +138,7 @@ Status OfflineServiceController::RequestConnectionV3(
const ConnectionOptions& connection_options) {
if (stop_) return {Status::kOutOfOrderApiCall};
NEARBY_LOGS(INFO) << "Client " << client->GetClientId()
<< " requested a connection to endpoint_id="
<< " requested a connection to endpoint_id "
<< remote_device.GetEndpointId();
return pcp_manager_.RequestConnectionV3(client, remote_device, info,
connection_options);
@@ -120,7 +149,7 @@ Status OfflineServiceController::AcceptConnection(
PayloadListener listener) {
if (stop_) return {Status::kOutOfOrderApiCall};
NEARBY_LOGS(INFO) << "Client " << client->GetClientId()
<< " accepted the connection with endpoint_id="
<< " accepted the connection from endpoint_id "
<< endpoint_id;
return pcp_manager_.AcceptConnection(client, endpoint_id,
std::move(listener));
@@ -130,7 +159,7 @@ Status OfflineServiceController::RejectConnection(
ClientProxy* client, const std::string& endpoint_id) {
if (stop_) return {Status::kOutOfOrderApiCall};
NEARBY_LOGS(INFO) << "Client " << client->GetClientId()
<< " rejected the connection with endpoint_id="
<< " rejected the connection from endpoint_id "
<< endpoint_id;
return pcp_manager_.RejectConnection(client, endpoint_id);
}
@@ -139,7 +168,7 @@ void OfflineServiceController::InitiateBandwidthUpgrade(
ClientProxy* client, const std::string& endpoint_id) {
if (stop_) return;
NEARBY_LOGS(INFO) << "Client " << client->GetClientId()
<< " initiated a manual bandwidth upgrade with endpoint_id="
<< " initiated a manual bandwidth upgrade with endpoint_id "
<< endpoint_id;
bwu_manager_.InitiateBwuForEndpoint(client, endpoint_id);
}
@@ -149,8 +178,8 @@ void OfflineServiceController::SendPayload(
Payload payload) {
if (stop_) return;
NEARBY_LOGS(INFO) << "Client " << client->GetClientId()
<< " is sending payload_id=" << payload.GetId()
<< " to endpoint_ids={" << absl::StrJoin(endpoint_ids, ",")
<< " is sending payload " << payload.GetId()
<< " to endpoint_ids {" << absl::StrJoin(endpoint_ids, ",")
<< "}";
payload_manager_.SendPayload(client, endpoint_ids, std::move(payload));
}
@@ -159,7 +188,7 @@ Status OfflineServiceController::CancelPayload(ClientProxy* client,
std::int64_t payload_id) {
if (stop_) return {Status::kOutOfOrderApiCall};
NEARBY_LOGS(INFO) << "Client " << client->GetClientId()
<< " cancelled payload_id=" << payload_id;
<< " cancelled payload " << payload_id;
return payload_manager_.CancelPayload(client, payload_id);
}
@@ -167,7 +196,7 @@ void OfflineServiceController::DisconnectFromEndpoint(
ClientProxy* client, const std::string& endpoint_id) {
if (stop_) return;
NEARBY_LOGS(INFO) << "Client " << client->GetClientId()
<< " requested a disconnection from endpoint_id="
<< " requested a disconnection from endpoint_id "
<< endpoint_id;
endpoint_manager_.UnregisterEndpoint(client, endpoint_id);
}
@@ -176,6 +205,10 @@ Status OfflineServiceController::UpdateAdvertisingOptions(
ClientProxy* client, absl::string_view service_id,
const AdvertisingOptions& advertising_options) {
if (stop_) return {Status::kOutOfOrderApiCall};
NEARBY_LOGS(INFO)
<< "Client " << client->GetClientId()
<< " requested to update advertising options for service_id "
<< service_id;
return pcp_manager_.UpdateAdvertisingOptions(client, service_id,
advertising_options);
}
@@ -184,6 +217,9 @@ Status OfflineServiceController::UpdateDiscoveryOptions(
ClientProxy* client, absl::string_view service_id,
const DiscoveryOptions& discovery_options) {
if (stop_) return {Status::kOutOfOrderApiCall};
NEARBY_LOGS(INFO) << "Client " << client->GetClientId()
<< " requested to update discovery options for service_id "
<< service_id;
return pcp_manager_.UpdateDiscoveryOptions(client, service_id,
discovery_options);
}
@@ -192,11 +228,12 @@ void OfflineServiceController::SetCustomSavePath(ClientProxy* client,
const std::string& path) {
if (stop_) return;
NEARBY_LOGS(INFO) << "Client " << client->GetClientId()
<< " requested to set custom save path: " << path;
<< " requested to set custom save path to " << path;
payload_manager_.SetCustomSavePath(client, path);
}
void OfflineServiceController::ShutdownBwuManagerExecutors() {
NEARBY_LOGS(INFO) << "Shutting down BwuManager executors.";
bwu_manager_.ShutdownExecutors();
}