mirror of
https://github.com/kidfromjupiter/nearby.git
synced 2026-09-14 14:46:12 -04:00
Replace NEARBY_LOGS with LOG for all coding under google3/third_party/nearby/
PiperOrigin-RevId: 786733783
This commit is contained in:
+2
-2
@@ -278,12 +278,12 @@ NC_INSTANCE NcCreateService() {
|
||||
void NcCloseService(NC_INSTANCE instance) {
|
||||
NcContext* nc_context = GetContext(instance);
|
||||
if (nc_context == nullptr) {
|
||||
NEARBY_LOGS(WARNING) << "Trying to close not existent service " << instance;
|
||||
LOG(WARNING) << "Trying to close not existent service " << instance;
|
||||
return;
|
||||
}
|
||||
|
||||
nc_context->core->StopAllEndpoints([](::nearby::connections::Status status) {
|
||||
NEARBY_LOGS(INFO) << "Stopping all endpoints with status "
|
||||
LOG(INFO) << "Stopping all endpoints with status "
|
||||
<< status.ToString();
|
||||
});
|
||||
|
||||
|
||||
+4
-4
@@ -74,7 +74,7 @@ Core::~Core() {
|
||||
CountDownLatch latch(1);
|
||||
router_->StopAllEndpoints(&client_, [&latch](Status) { latch.CountDown(); });
|
||||
if (!latch.Await(kWaitForDisconnect).result()) {
|
||||
NEARBY_LOGS(FATAL) << "Unable to shutdown";
|
||||
LOG(FATAL) << "Unable to shutdown";
|
||||
}
|
||||
}
|
||||
|
||||
@@ -133,7 +133,7 @@ void Core::RequestConnection(absl::string_view endpoint_id,
|
||||
connection_options.keep_alive_timeout_millis == 0 ||
|
||||
connection_options.keep_alive_interval_millis >=
|
||||
connection_options.keep_alive_timeout_millis) {
|
||||
NEARBY_LOGS(WARNING)
|
||||
LOG(WARNING)
|
||||
<< "Client request connection with keep-alive frame as interval="
|
||||
<< connection_options.keep_alive_interval_millis
|
||||
<< ", timeout=" << connection_options.keep_alive_timeout_millis
|
||||
@@ -393,7 +393,7 @@ void Core::RequestConnectionV3(const NearbyDevice& local_device,
|
||||
connection_options.keep_alive_timeout_millis == 0 ||
|
||||
connection_options.keep_alive_interval_millis >=
|
||||
connection_options.keep_alive_timeout_millis) {
|
||||
NEARBY_LOGS(WARNING)
|
||||
LOG(WARNING)
|
||||
<< "Client request connection with keep-alive frame as interval="
|
||||
<< connection_options.keep_alive_interval_millis
|
||||
<< ", timeout=" << connection_options.keep_alive_timeout_millis
|
||||
@@ -426,7 +426,7 @@ void Core::RequestConnectionV3(const NearbyDevice& remote_device,
|
||||
connection_options.keep_alive_timeout_millis == 0 ||
|
||||
connection_options.keep_alive_interval_millis >=
|
||||
connection_options.keep_alive_timeout_millis) {
|
||||
NEARBY_LOGS(WARNING)
|
||||
LOG(WARNING)
|
||||
<< "Client request connection with keep-alive frame as interval="
|
||||
<< connection_options.keep_alive_interval_millis
|
||||
<< ", timeout=" << connection_options.keep_alive_timeout_millis
|
||||
|
||||
+10
-10
@@ -240,7 +240,7 @@ TEST(CoreV3Test, TestCallbackWrapWorksStartAdvertisingV3FourArgs) {
|
||||
EXPECT_CALL(mock_controller, StartAdvertising)
|
||||
.WillOnce([&](ClientProxy*, absl::string_view, const AdvertisingOptions&,
|
||||
const ConnectionRequestInfo& info, const ResultCallback&) {
|
||||
NEARBY_LOGS(INFO) << "StartAdvertising called";
|
||||
LOG(INFO) << "StartAdvertising called";
|
||||
ASSERT_FALSE(info.endpoint_info.Empty());
|
||||
// call all callbacks to make sure it all gets called correctly.
|
||||
info.listener.initiated_cb("FAKE", {});
|
||||
@@ -251,7 +251,7 @@ TEST(CoreV3Test, TestCallbackWrapWorksStartAdvertisingV3FourArgs) {
|
||||
});
|
||||
EXPECT_CALL(mock_controller, StopAllEndpoints)
|
||||
.WillOnce([&](ClientProxy* client, ResultCallback callback) {
|
||||
NEARBY_LOGS(INFO) << "StopAllEndpoints called";
|
||||
LOG(INFO) << "StopAllEndpoints called";
|
||||
callback({Status::kSuccess});
|
||||
});
|
||||
Core core{&mock_controller};
|
||||
@@ -297,7 +297,7 @@ TEST(CoreV3Test, TestStartAdvertisingV3NonConnectionsDeviceProvider) {
|
||||
EXPECT_CALL(mock_controller, StartAdvertising)
|
||||
.WillOnce([&](ClientProxy*, absl::string_view, const AdvertisingOptions&,
|
||||
const ConnectionRequestInfo& info, ResultCallback) {
|
||||
NEARBY_LOGS(INFO) << "StartAdvertising called";
|
||||
LOG(INFO) << "StartAdvertising called";
|
||||
ASSERT_TRUE(info.endpoint_info.Empty());
|
||||
// call all callbacks to make sure it all gets called correctly.
|
||||
info.listener.initiated_cb("FAKE", {});
|
||||
@@ -308,7 +308,7 @@ TEST(CoreV3Test, TestStartAdvertisingV3NonConnectionsDeviceProvider) {
|
||||
});
|
||||
EXPECT_CALL(mock_controller, StopAllEndpoints)
|
||||
.WillOnce([&](ClientProxy* client, ResultCallback callback) {
|
||||
NEARBY_LOGS(INFO) << "StopAllEndpoints called";
|
||||
LOG(INFO) << "StopAllEndpoints called";
|
||||
callback({Status::kSuccess});
|
||||
});
|
||||
Core core{&mock_controller};
|
||||
@@ -356,7 +356,7 @@ TEST(CoreV3Test, TestStartAdvertisingV3NonConnectionsDevice) {
|
||||
EXPECT_CALL(mock_controller, StartAdvertising)
|
||||
.WillOnce([&](ClientProxy*, absl::string_view, const AdvertisingOptions&,
|
||||
const ConnectionRequestInfo& info, const ResultCallback&) {
|
||||
NEARBY_LOGS(INFO) << "StartAdvertising called";
|
||||
LOG(INFO) << "StartAdvertising called";
|
||||
ASSERT_TRUE(info.endpoint_info.Empty());
|
||||
// call all callbacks to make sure it all gets called correctly.
|
||||
info.listener.initiated_cb("FAKE", {});
|
||||
@@ -367,7 +367,7 @@ TEST(CoreV3Test, TestStartAdvertisingV3NonConnectionsDevice) {
|
||||
});
|
||||
EXPECT_CALL(mock_controller, StopAllEndpoints)
|
||||
.WillOnce([&](ClientProxy* client, ResultCallback callback) {
|
||||
NEARBY_LOGS(INFO) << "StopAllEndpoints called";
|
||||
LOG(INFO) << "StopAllEndpoints called";
|
||||
callback({Status::kSuccess});
|
||||
});
|
||||
Core core{&mock_controller};
|
||||
@@ -414,7 +414,7 @@ TEST(CoreV3Test, TestCallbackWrapWorksStartAdvertisingV3FiveArgs) {
|
||||
EXPECT_CALL(mock_controller, StartAdvertising)
|
||||
.WillOnce([&](ClientProxy*, absl::string_view, const AdvertisingOptions&,
|
||||
const ConnectionRequestInfo& info, const ResultCallback&) {
|
||||
NEARBY_LOGS(INFO) << "StartAdvertising called";
|
||||
LOG(INFO) << "StartAdvertising called";
|
||||
ASSERT_FALSE(info.endpoint_info.Empty());
|
||||
// call all callbacks to make sure it all gets called correctly.
|
||||
info.listener.initiated_cb("FAKE", {});
|
||||
@@ -425,7 +425,7 @@ TEST(CoreV3Test, TestCallbackWrapWorksStartAdvertisingV3FiveArgs) {
|
||||
});
|
||||
EXPECT_CALL(mock_controller, StopAllEndpoints)
|
||||
.WillOnce([&](ClientProxy* client, ResultCallback callback) {
|
||||
NEARBY_LOGS(INFO) << "StopAllEndpoints called";
|
||||
LOG(INFO) << "StopAllEndpoints called";
|
||||
callback({Status::kSuccess});
|
||||
});
|
||||
Core core{&mock_controller};
|
||||
@@ -473,14 +473,14 @@ TEST(CoreV3Test, TestCallbackWrapWorksStartDiscoveryV3) {
|
||||
.WillOnce([&](ClientProxy*, absl::string_view, const DiscoveryOptions&,
|
||||
DiscoveryListener listener, const ResultCallback&) {
|
||||
// call all callbacks to make sure it all gets called correctly.
|
||||
NEARBY_LOGS(INFO) << "StartDiscovery called";
|
||||
LOG(INFO) << "StartDiscovery called";
|
||||
listener.endpoint_distance_changed_cb("FAKE", {});
|
||||
listener.endpoint_found_cb("FAKE", ByteArray(), "");
|
||||
listener.endpoint_lost_cb("FAKE");
|
||||
});
|
||||
EXPECT_CALL(mock_controller, StopAllEndpoints)
|
||||
.WillOnce([&](ClientProxy* client, ResultCallback callback) {
|
||||
NEARBY_LOGS(INFO) << "StopAllEndpoints called";
|
||||
LOG(INFO) << "StopAllEndpoints called";
|
||||
callback({Status::kSuccess});
|
||||
});
|
||||
v3::DiscoveryOptions options;
|
||||
|
||||
@@ -66,7 +66,7 @@ NC_PAYLOAD_ID GeneratePayloadId() { return nearby::Prng().NextInt64(); }
|
||||
void ResultCB(std::optional<Dart_Port> port, NC_STATUS status) {
|
||||
(void)status; // Avoid unused parameter warning
|
||||
if (!port.has_value()) {
|
||||
NEARBY_LOGS(ERROR) << "ResultCB called with invalid port.";
|
||||
LOG(ERROR) << "ResultCB called with invalid port.";
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -75,7 +75,7 @@ void ResultCB(std::optional<Dart_Port> port, NC_STATUS status) {
|
||||
dart_object_result_callback.value.as_int64 = static_cast<int64_t>(status);
|
||||
const bool result = Dart_PostCObject_DL(*port, &dart_object_result_callback);
|
||||
if (!result) {
|
||||
NEARBY_LOGS(WARNING) << "Posting message to port failed.";
|
||||
LOG(WARNING) << "Posting message to port failed.";
|
||||
}
|
||||
}
|
||||
|
||||
@@ -93,7 +93,7 @@ void ListenerInitiatedCB(
|
||||
NC_INSTANCE instance, int endpoint_id,
|
||||
const NC_CONNECTION_RESPONSE_INFO *connection_response_info,
|
||||
void *context) {
|
||||
NEARBY_LOGS(INFO) << "Advertising initiated: id="
|
||||
LOG(INFO) << "Advertising initiated: id="
|
||||
<< GetEndpointIdString(endpoint_id);
|
||||
|
||||
Dart_CObject dart_object_endpoint_id = {
|
||||
@@ -122,12 +122,12 @@ void ListenerInitiatedCB(
|
||||
kClientState->GetConnectionListenerDart()->initiated_dart_port,
|
||||
&dart_object_initiated);
|
||||
if (!result) {
|
||||
NEARBY_LOGS(INFO) << "Posting message to port failed.";
|
||||
LOG(INFO) << "Posting message to port failed.";
|
||||
}
|
||||
}
|
||||
|
||||
void ListenerAcceptedCB(NC_INSTANCE instance, int endpoint_id, void *context) {
|
||||
NEARBY_LOGS(INFO) << "Advertising accepted: id="
|
||||
LOG(INFO) << "Advertising accepted: id="
|
||||
<< GetEndpointIdString(endpoint_id);
|
||||
Dart_CObject dart_object_accepted;
|
||||
dart_object_accepted.type = Dart_CObject_kInt32;
|
||||
@@ -136,13 +136,13 @@ void ListenerAcceptedCB(NC_INSTANCE instance, int endpoint_id, void *context) {
|
||||
kClientState->GetConnectionListenerDart()->accepted_dart_port,
|
||||
&dart_object_accepted);
|
||||
if (!result) {
|
||||
NEARBY_LOGS(INFO) << "Posting message to port failed.";
|
||||
LOG(INFO) << "Posting message to port failed.";
|
||||
}
|
||||
}
|
||||
|
||||
void ListenerRejectedCB(NC_INSTANCE instance, int endpoint_id, NC_STATUS status,
|
||||
void *context) {
|
||||
NEARBY_LOGS(INFO) << "Advertising rejected: id="
|
||||
LOG(INFO) << "Advertising rejected: id="
|
||||
<< GetEndpointIdString(endpoint_id);
|
||||
Dart_CObject dart_object_rejected;
|
||||
dart_object_rejected.type = Dart_CObject_kInt32;
|
||||
@@ -151,13 +151,13 @@ void ListenerRejectedCB(NC_INSTANCE instance, int endpoint_id, NC_STATUS status,
|
||||
kClientState->GetConnectionListenerDart()->rejected_dart_port,
|
||||
&dart_object_rejected);
|
||||
if (!result) {
|
||||
NEARBY_LOGS(INFO) << "Posting message to port failed.";
|
||||
LOG(INFO) << "Posting message to port failed.";
|
||||
}
|
||||
}
|
||||
|
||||
void ListenerDisconnectedCB(NC_INSTANCE instance, int endpoint_id,
|
||||
void *context) {
|
||||
NEARBY_LOGS(INFO) << "Advertising disconnected: id="
|
||||
LOG(INFO) << "Advertising disconnected: id="
|
||||
<< GetEndpointIdString(endpoint_id);
|
||||
Dart_CObject dart_object_disconnected;
|
||||
dart_object_disconnected.type = Dart_CObject_kInt32;
|
||||
@@ -166,13 +166,13 @@ void ListenerDisconnectedCB(NC_INSTANCE instance, int endpoint_id,
|
||||
kClientState->GetConnectionListenerDart()->disconnected_dart_port,
|
||||
&dart_object_disconnected);
|
||||
if (!result) {
|
||||
NEARBY_LOGS(INFO) << "Posting message to port failed.";
|
||||
LOG(INFO) << "Posting message to port failed.";
|
||||
}
|
||||
}
|
||||
|
||||
void ListenerBandwidthChangedCB(NC_INSTANCE instance, int endpoint_id,
|
||||
NC_MEDIUM medium, void *context) {
|
||||
NEARBY_LOGS(INFO) << "Advertising bandwidth changed: id="
|
||||
LOG(INFO) << "Advertising bandwidth changed: id="
|
||||
<< GetEndpointIdString(endpoint_id);
|
||||
Dart_CObject dart_object_bandwidth_changed;
|
||||
|
||||
@@ -182,21 +182,21 @@ void ListenerBandwidthChangedCB(NC_INSTANCE instance, int endpoint_id,
|
||||
kClientState->GetConnectionListenerDart()->bandwidth_changed_dart_port,
|
||||
&dart_object_bandwidth_changed);
|
||||
if (!result) {
|
||||
NEARBY_LOGS(INFO) << "Posting message to port failed.";
|
||||
LOG(INFO) << "Posting message to port failed.";
|
||||
}
|
||||
}
|
||||
|
||||
void ListenerEndpointFoundCB(NC_INSTANCE instance, int endpoint_id,
|
||||
const NC_DATA *endpoint_info,
|
||||
const NC_DATA *service_id, void *context) {
|
||||
NEARBY_LOGS(INFO) << "Device discovered: id="
|
||||
LOG(INFO) << "Device discovered: id="
|
||||
<< GetEndpointIdString(endpoint_id);
|
||||
NEARBY_LOGS(INFO) << "Device discovered: service_id="
|
||||
LOG(INFO) << "Device discovered: service_id="
|
||||
<< std::string(service_id->data, service_id->size);
|
||||
|
||||
std::string endpoint_info_str = absl::BytesToHexString(
|
||||
absl::string_view(endpoint_info->data, endpoint_info->size));
|
||||
NEARBY_LOGS(INFO) << "Device discovered: info=" << endpoint_info_str;
|
||||
LOG(INFO) << "Device discovered: info=" << endpoint_info_str;
|
||||
|
||||
Dart_CObject dart_object_endpoint_id = {
|
||||
.type = Dart_CObject_Type::Dart_CObject_kInt32,
|
||||
@@ -221,13 +221,13 @@ void ListenerEndpointFoundCB(NC_INSTANCE instance, int endpoint_id,
|
||||
kClientState->GetDiscoveryListenerDart()->found_dart_port,
|
||||
&dart_object_found);
|
||||
if (!result) {
|
||||
NEARBY_LOGS(INFO) << "Posting message to port failed.";
|
||||
LOG(INFO) << "Posting message to port failed.";
|
||||
}
|
||||
}
|
||||
|
||||
void ListenerEndpointLostCB(NC_INSTANCE instance, int endpoint_id,
|
||||
void *context) {
|
||||
NEARBY_LOGS(INFO) << "Device lost: id=" << GetEndpointIdString(endpoint_id);
|
||||
LOG(INFO) << "Device lost: id=" << GetEndpointIdString(endpoint_id);
|
||||
Dart_CObject dart_object_lost;
|
||||
dart_object_lost.type = Dart_CObject_kInt32;
|
||||
dart_object_lost.value.as_int32 = endpoint_id;
|
||||
@@ -235,7 +235,7 @@ void ListenerEndpointLostCB(NC_INSTANCE instance, int endpoint_id,
|
||||
kClientState->GetDiscoveryListenerDart()->lost_dart_port,
|
||||
&dart_object_lost);
|
||||
if (!result) {
|
||||
NEARBY_LOGS(INFO) << "Posting message to port failed.";
|
||||
LOG(INFO) << "Posting message to port failed.";
|
||||
}
|
||||
}
|
||||
|
||||
@@ -243,7 +243,7 @@ void ListenerEndpointDistanceChangedCB(NC_INSTANCE instance, int endpoint_id,
|
||||
NC_DISTANCE_INFO distance_info,
|
||||
void *context) {
|
||||
(void)distance_info; // Avoid unused parameter warning
|
||||
NEARBY_LOGS(INFO) << "Device distance changed: id="
|
||||
LOG(INFO) << "Device distance changed: id="
|
||||
<< GetEndpointIdString(endpoint_id);
|
||||
Dart_CObject dart_object_distance_changed;
|
||||
dart_object_distance_changed.type = Dart_CObject_kInt32;
|
||||
@@ -252,13 +252,13 @@ void ListenerEndpointDistanceChangedCB(NC_INSTANCE instance, int endpoint_id,
|
||||
kClientState->GetDiscoveryListenerDart()->distance_changed_dart_port,
|
||||
&dart_object_distance_changed);
|
||||
if (!result) {
|
||||
NEARBY_LOGS(INFO) << "Posting message to port failed.";
|
||||
LOG(INFO) << "Posting message to port failed.";
|
||||
}
|
||||
}
|
||||
|
||||
void ListenerPayloadCB(NC_INSTANCE instance, int endpoint_id,
|
||||
const NC_PAYLOAD *payload, void *context) {
|
||||
NEARBY_LOGS(INFO) << "Payload callback called. id: "
|
||||
LOG(INFO) << "Payload callback called. id: "
|
||||
<< GetEndpointIdString(endpoint_id)
|
||||
<< ", payload_id: " << payload->id
|
||||
<< ", type: " << payload->type;
|
||||
@@ -277,7 +277,7 @@ void ListenerPayloadCB(NC_INSTANCE instance, int endpoint_id,
|
||||
size_t bytes_size = payload->content.bytes.content.size;
|
||||
|
||||
if (bytes_size == 0) {
|
||||
NEARBY_LOGS(INFO) << "Failed to get the payload as bytes.";
|
||||
LOG(INFO) << "Failed to get the payload as bytes.";
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -302,7 +302,7 @@ void ListenerPayloadCB(NC_INSTANCE instance, int endpoint_id,
|
||||
if (!Dart_PostCObject_DL(
|
||||
kClientState->GetPayloadListenerDart()->initial_byte_info_port,
|
||||
&dart_object_payload)) {
|
||||
NEARBY_LOGS(INFO) << "Posting message to port failed.";
|
||||
LOG(INFO) << "Posting message to port failed.";
|
||||
}
|
||||
return;
|
||||
}
|
||||
@@ -319,7 +319,7 @@ void ListenerPayloadCB(NC_INSTANCE instance, int endpoint_id,
|
||||
if (!Dart_PostCObject_DL(
|
||||
kClientState->GetPayloadListenerDart()->initial_stream_info_port,
|
||||
&dart_object_payload)) {
|
||||
NEARBY_LOGS(INFO) << "Posting message to port failed.";
|
||||
LOG(INFO) << "Posting message to port failed.";
|
||||
}
|
||||
return;
|
||||
}
|
||||
@@ -347,12 +347,12 @@ void ListenerPayloadCB(NC_INSTANCE instance, int endpoint_id,
|
||||
if (!Dart_PostCObject_DL(
|
||||
kClientState->GetPayloadListenerDart()->initial_file_info_port,
|
||||
&dart_object_payload)) {
|
||||
NEARBY_LOGS(INFO) << "Posting message to port failed.";
|
||||
LOG(INFO) << "Posting message to port failed.";
|
||||
}
|
||||
return;
|
||||
}
|
||||
default:
|
||||
NEARBY_LOGS(INFO) << "Invalid payload type.";
|
||||
LOG(INFO) << "Invalid payload type.";
|
||||
return;
|
||||
}
|
||||
}
|
||||
@@ -360,7 +360,7 @@ void ListenerPayloadCB(NC_INSTANCE instance, int endpoint_id,
|
||||
void ListenerPayloadProgressCB(
|
||||
NC_INSTANCE instance, int endpoint_id,
|
||||
const NC_PAYLOAD_PROGRESS_INFO *payload_progress_info, void *context) {
|
||||
NEARBY_LOGS(INFO) << "Payload progress callback called. id: "
|
||||
LOG(INFO) << "Payload progress callback called. id: "
|
||||
<< GetEndpointIdString(endpoint_id)
|
||||
<< ", payload_id: " << payload_progress_info->id
|
||||
<< ", bytes transferred: "
|
||||
@@ -403,7 +403,7 @@ void ListenerPayloadProgressCB(
|
||||
if (!Dart_PostCObject_DL(
|
||||
kClientState->GetPayloadListenerDart()->payload_progress_dart_port,
|
||||
&dart_object_payload_progress)) {
|
||||
NEARBY_LOGS(INFO) << "Posting message to port failed.";
|
||||
LOG(INFO) << "Posting message to port failed.";
|
||||
}
|
||||
}
|
||||
|
||||
@@ -414,7 +414,7 @@ void PostResult(Dart_Port &result_cb, NC_STATUS value) {
|
||||
const bool result =
|
||||
Dart_PostCObject_DL(result_cb, &dart_object_result_callback);
|
||||
if (!result) {
|
||||
NEARBY_LOGS(INFO) << "Returning error to port failed.";
|
||||
LOG(INFO) << "Returning error to port failed.";
|
||||
}
|
||||
}
|
||||
|
||||
@@ -449,7 +449,7 @@ void EnableBleV2Dart(NC_INSTANCE instance, int64_t enable,
|
||||
status);
|
||||
},
|
||||
nullptr);
|
||||
NEARBY_LOGS(INFO) << "EnableBleV2Dart callback is called with enable="
|
||||
LOG(INFO) << "EnableBleV2Dart callback is called with enable="
|
||||
<< enable;
|
||||
}
|
||||
|
||||
@@ -756,11 +756,11 @@ void SendPayloadDart(NC_INSTANCE instance, int endpoint_id,
|
||||
result_cb);
|
||||
std::vector<int> endpoint_ids = {endpoint_id};
|
||||
|
||||
NEARBY_LOGS(INFO) << "Payload type: " << payload_dart.type;
|
||||
LOG(INFO) << "Payload type: " << payload_dart.type;
|
||||
switch (payload_dart.type) {
|
||||
case PAYLOAD_TYPE_UNKNOWN:
|
||||
case PAYLOAD_TYPE_STREAM:
|
||||
NEARBY_LOGS(INFO) << "Payload type not supported yet";
|
||||
LOG(INFO) << "Payload type not supported yet";
|
||||
PostResult(result_cb, NC_STATUS_PAYLOADUNKNOWN);
|
||||
break;
|
||||
case PAYLOAD_TYPE_BYTE: {
|
||||
@@ -783,7 +783,7 @@ void SendPayloadDart(NC_INSTANCE instance, int endpoint_id,
|
||||
break;
|
||||
}
|
||||
case PAYLOAD_TYPE_FILE:
|
||||
NEARBY_LOGS(INFO) << "File name: "
|
||||
LOG(INFO) << "File name: "
|
||||
<< std::string(payload_dart.data.data,
|
||||
payload_dart.data.size)
|
||||
<< ", size " << payload_dart.size;
|
||||
|
||||
@@ -164,7 +164,7 @@ OperationResultCategory ConvertToOperationResultCategory(
|
||||
|
||||
AnalyticsRecorder::AnalyticsRecorder(EventLogger *event_logger)
|
||||
: event_logger_(event_logger) {
|
||||
NEARBY_LOGS(INFO) << "Start AnalyticsRecorder ctor event_logger_="
|
||||
LOG(INFO) << "Start AnalyticsRecorder ctor event_logger_="
|
||||
<< event_logger_;
|
||||
LogStartSession();
|
||||
}
|
||||
@@ -173,7 +173,7 @@ AnalyticsRecorder::AnalyticsRecorder(EventLogger *event_logger,
|
||||
bool no_record_time_millis)
|
||||
: event_logger_(event_logger),
|
||||
no_record_time_millis_(no_record_time_millis) {
|
||||
NEARBY_LOGS(INFO) << "Start AnalyticsRecorder ctor event_logger_="
|
||||
LOG(INFO) << "Start AnalyticsRecorder ctor event_logger_="
|
||||
<< event_logger_;
|
||||
LogStartSession();
|
||||
}
|
||||
@@ -205,7 +205,7 @@ void AnalyticsRecorder::OnStartAdvertising(
|
||||
return;
|
||||
}
|
||||
if (!strategy.IsValid()) {
|
||||
NEARBY_LOGS(INFO) << "AnalyticsRecorder OnStartAdvertising with unknown "
|
||||
LOG(INFO) << "AnalyticsRecorder OnStartAdvertising with unknown "
|
||||
"strategy, bail out.";
|
||||
return;
|
||||
}
|
||||
@@ -267,7 +267,7 @@ void AnalyticsRecorder::OnStartDiscovery(
|
||||
return;
|
||||
}
|
||||
if (!strategy.IsValid()) {
|
||||
NEARBY_LOGS(INFO) << "AnalyticsRecorder OnStartDiscovery unknown "
|
||||
LOG(INFO) << "AnalyticsRecorder OnStartDiscovery unknown "
|
||||
"strategy enter, bail out.";
|
||||
return;
|
||||
}
|
||||
@@ -346,7 +346,7 @@ void AnalyticsRecorder::OnEndpointFound(Medium medium) {
|
||||
return;
|
||||
}
|
||||
if (current_discovery_phase_ == nullptr) {
|
||||
NEARBY_LOGS(INFO) << "Unable to record discovered endpoint due to null "
|
||||
LOG(INFO) << "Unable to record discovered endpoint due to null "
|
||||
"current_discovery_phase_";
|
||||
return;
|
||||
}
|
||||
@@ -453,7 +453,7 @@ void AnalyticsRecorder::OnIncomingConnectionAttempt(
|
||||
return;
|
||||
}
|
||||
if (current_strategy_session_ == nullptr) {
|
||||
NEARBY_LOGS(INFO) << "Unable to record incoming connection attempt due to "
|
||||
LOG(INFO) << "Unable to record incoming connection attempt due to "
|
||||
"null current_strategy_session_";
|
||||
return;
|
||||
}
|
||||
@@ -532,7 +532,7 @@ void AnalyticsRecorder::OnOutgoingConnectionAttempt(
|
||||
return;
|
||||
}
|
||||
if (current_strategy_session_ == nullptr) {
|
||||
NEARBY_LOGS(INFO) << "Unable to record outgoing connection attempt due to "
|
||||
LOG(INFO) << "Unable to record outgoing connection attempt due to "
|
||||
"null current_strategy_session_";
|
||||
return;
|
||||
}
|
||||
@@ -648,7 +648,7 @@ void AnalyticsRecorder::OnConnectionClosed(const std::string &endpoint_id,
|
||||
DisconnectionReason reason,
|
||||
SafeDisconnectionResult result) {
|
||||
MutexLock lock(&mutex_);
|
||||
NEARBY_LOGS(INFO) << __func__
|
||||
LOG(INFO) << __func__
|
||||
<< ": OnConnectionClosed is called with endpoint_id:"
|
||||
<< endpoint_id << ", medium:" << Medium_Name(medium)
|
||||
<< ", reason:" << DisconnectionReason_Name(reason)
|
||||
@@ -659,7 +659,7 @@ void AnalyticsRecorder::OnConnectionClosed(const std::string &endpoint_id,
|
||||
}
|
||||
|
||||
if (current_strategy_session_ == nullptr) {
|
||||
NEARBY_VLOG(1) << "AnalyticsRecorder CanRecordAnalytics Unexpected call "
|
||||
VLOG(1) << "AnalyticsRecorder CanRecordAnalytics Unexpected call "
|
||||
<< __func__
|
||||
<< " since current_strategy_session_ is required.";
|
||||
return;
|
||||
@@ -886,7 +886,7 @@ void AnalyticsRecorder::OnErrorCode(const ErrorCodeParams ¶ms) {
|
||||
connections_log.set_version(kVersion);
|
||||
connections_log.set_allocated_error_code(error_code.release());
|
||||
|
||||
NEARBY_VLOG(1) << "AnalyticsRecorder LogErrorCode connections_log="
|
||||
VLOG(1) << "AnalyticsRecorder LogErrorCode connections_log="
|
||||
<< connections_log.DebugString(); // NOLINT
|
||||
|
||||
event_logger_->Log(connections_log);
|
||||
@@ -895,7 +895,7 @@ void AnalyticsRecorder::OnErrorCode(const ErrorCodeParams ¶ms) {
|
||||
void AnalyticsRecorder::LogStartSession() {
|
||||
MutexLock lock(&mutex_);
|
||||
if (start_client_session_was_logged_) {
|
||||
NEARBY_LOGS(WARNING)
|
||||
LOG(WARNING)
|
||||
<< "AnalyticsRecorder CanRecordAnalytics Unexpected call "
|
||||
<< kOnStartClientSession
|
||||
<< " after start client session has already been logged.";
|
||||
@@ -1011,14 +1011,14 @@ OperationResultCode AnalyticsRecorder::GetChannelIoErrorResultCodeFromMedium(
|
||||
|
||||
bool AnalyticsRecorder::CanRecordAnalyticsLocked(
|
||||
absl::string_view method_name) {
|
||||
NEARBY_VLOG(1) << "AnalyticsRecorder LogEvent " << method_name
|
||||
VLOG(1) << "AnalyticsRecorder LogEvent " << method_name
|
||||
<< " is calling.";
|
||||
if (event_logger_ == nullptr) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (session_was_logged_) {
|
||||
NEARBY_VLOG(1) << "AnalyticsRecorder CanRecordAnalytics Unexpected call "
|
||||
VLOG(1) << "AnalyticsRecorder CanRecordAnalytics Unexpected call "
|
||||
<< method_name << " after session has already been logged.";
|
||||
return false;
|
||||
}
|
||||
@@ -1035,7 +1035,7 @@ void AnalyticsRecorder::LogClientSessionLocked() {
|
||||
connections_log.set_allocated_client_session(client_session_.release());
|
||||
connections_log.set_version(kVersion);
|
||||
|
||||
NEARBY_VLOG(1) << "AnalyticsRecorder LogClientSession connections_log="
|
||||
VLOG(1) << "AnalyticsRecorder LogClientSession connections_log="
|
||||
<< connections_log.DebugString(); // NOLINT
|
||||
|
||||
event_logger_->Log(connections_log);
|
||||
@@ -1047,7 +1047,7 @@ void AnalyticsRecorder::LogEvent(EventType event_type) {
|
||||
connections_log.set_event_type(event_type);
|
||||
connections_log.set_version(kVersion);
|
||||
|
||||
NEARBY_VLOG(1) << "AnalyticsRecorder LogEvent connections_log="
|
||||
VLOG(1) << "AnalyticsRecorder LogEvent connections_log="
|
||||
<< connections_log.DebugString(); // NOLINT
|
||||
|
||||
event_logger_->Log(connections_log);
|
||||
@@ -1091,7 +1091,7 @@ void AnalyticsRecorder::UpdateStrategySessionLocked(
|
||||
void AnalyticsRecorder::RecordAdvertisingPhaseDurationAndReasonLocked(
|
||||
bool on_stop) const {
|
||||
if (current_advertising_phase_ == nullptr) {
|
||||
NEARBY_LOGS(INFO) << "Unable to record advertising phase duration due to "
|
||||
LOG(INFO) << "Unable to record advertising phase duration due to "
|
||||
"null current_advertising_phase_";
|
||||
return;
|
||||
}
|
||||
@@ -1122,7 +1122,7 @@ void AnalyticsRecorder::FinishAdvertisingPhaseLocked() {
|
||||
*current_strategy_session_->add_advertising_phase() =
|
||||
*std::move(current_advertising_phase_);
|
||||
} else {
|
||||
NEARBY_LOGS(INFO) << "Unable to record advertising phase due to null "
|
||||
LOG(INFO) << "Unable to record advertising phase due to null "
|
||||
"current_strategy_session_";
|
||||
}
|
||||
}
|
||||
@@ -1132,7 +1132,7 @@ void AnalyticsRecorder::FinishAdvertisingPhaseLocked() {
|
||||
void AnalyticsRecorder::RecordDiscoveryPhaseDurationAndReasonLocked(
|
||||
bool on_stop) const {
|
||||
if (current_discovery_phase_ == nullptr) {
|
||||
NEARBY_LOGS(INFO) << "Unable to record discovery phase duration due to "
|
||||
LOG(INFO) << "Unable to record discovery phase duration due to "
|
||||
"null current_discovery_phase_";
|
||||
return;
|
||||
}
|
||||
@@ -1164,7 +1164,7 @@ void AnalyticsRecorder::FinishDiscoveryPhaseLocked() {
|
||||
*current_strategy_session_->add_discovery_phase() =
|
||||
*std::move(current_discovery_phase_);
|
||||
} else {
|
||||
NEARBY_LOGS(INFO) << "Unable to record discovery phase due to null "
|
||||
LOG(INFO) << "Unable to record discovery phase due to null "
|
||||
"current_strategy_session_";
|
||||
}
|
||||
}
|
||||
@@ -1174,7 +1174,7 @@ void AnalyticsRecorder::FinishDiscoveryPhaseLocked() {
|
||||
bool AnalyticsRecorder::UpdateAdvertiserConnectionRequestLocked(
|
||||
ConnectionsLog::ConnectionRequest *request) {
|
||||
if (current_advertising_phase_ == nullptr) {
|
||||
NEARBY_LOGS(INFO)
|
||||
LOG(INFO)
|
||||
<< "Unable to record advertiser connection request due to null "
|
||||
"current_advertising_phase_";
|
||||
return false;
|
||||
@@ -1194,7 +1194,7 @@ bool AnalyticsRecorder::UpdateAdvertiserConnectionRequestLocked(
|
||||
bool AnalyticsRecorder::UpdateDiscovererConnectionRequestLocked(
|
||||
ConnectionsLog::ConnectionRequest *request) {
|
||||
if (current_discovery_phase_ == nullptr) {
|
||||
NEARBY_LOGS(INFO) << "Unable to record discoverer connection request due "
|
||||
LOG(INFO) << "Unable to record discoverer connection request due "
|
||||
"to null current_discovery_phase_.";
|
||||
return false;
|
||||
}
|
||||
@@ -1323,7 +1323,7 @@ void AnalyticsRecorder::FinishUpgradeAttemptLocked(
|
||||
BandwidthUpgradeErrorStage error_stage,
|
||||
OperationResultCode operation_result_code, bool erase_item) {
|
||||
if (current_strategy_session_ == nullptr) {
|
||||
NEARBY_LOGS(INFO) << "Unable to record upgrade attempt due to null "
|
||||
LOG(INFO) << "Unable to record upgrade attempt due to null "
|
||||
"current_strategy_session_";
|
||||
return;
|
||||
}
|
||||
@@ -1455,7 +1455,7 @@ ConnectionsLog::Payload AnalyticsRecorder::PendingPayload::GetProtoPayload(
|
||||
void AnalyticsRecorder::LogicalConnection::PhysicalConnectionEstablished(
|
||||
Medium medium, const std::string &connection_token) {
|
||||
if (current_medium_ != UNKNOWN_MEDIUM) {
|
||||
NEARBY_LOGS(WARNING)
|
||||
LOG(WARNING)
|
||||
<< "Unexpected call to PhysicalConnectionEstablished while "
|
||||
"AnalyticsRecorder still has an active current medium.";
|
||||
}
|
||||
@@ -1483,12 +1483,12 @@ void AnalyticsRecorder::LogicalConnection::PhysicalConnectionEstablished(
|
||||
void AnalyticsRecorder::LogicalConnection::PhysicalConnectionClosed(
|
||||
Medium medium, DisconnectionReason reason, SafeDisconnectionResult result) {
|
||||
if (current_medium_ == UNKNOWN_MEDIUM) {
|
||||
NEARBY_LOGS(WARNING)
|
||||
LOG(WARNING)
|
||||
<< "Unexpected call to PhysicalConnectionClosed() for medium "
|
||||
<< Medium_Name(medium)
|
||||
<< " while AnalyticsRecorder has no active current medium";
|
||||
} else if (current_medium_ != medium) {
|
||||
NEARBY_LOGS(WARNING)
|
||||
LOG(WARNING)
|
||||
<< "Unexpected call to PhysicalConnectionClosed() for medium "
|
||||
<< Medium_Name(medium) << "while AnalyticsRecorder has active medium "
|
||||
<< Medium_Name(current_medium_);
|
||||
@@ -1496,7 +1496,7 @@ void AnalyticsRecorder::LogicalConnection::PhysicalConnectionClosed(
|
||||
|
||||
auto it = physical_connections_.find(medium);
|
||||
if (it == physical_connections_.end()) {
|
||||
NEARBY_LOGS(WARNING)
|
||||
LOG(WARNING)
|
||||
<< "Unexpected call to physicalConnectionClosed() for medium "
|
||||
<< Medium_Name(medium)
|
||||
<< " with no corresponding EstablishedConnection that was previously"
|
||||
@@ -1506,7 +1506,7 @@ void AnalyticsRecorder::LogicalConnection::PhysicalConnectionClosed(
|
||||
ConnectionsLog::EstablishedConnection *established_connection =
|
||||
it->second.get();
|
||||
if (established_connection->has_disconnection_reason()) {
|
||||
NEARBY_LOGS(WARNING)
|
||||
LOG(WARNING)
|
||||
<< "Unexpected call to physicalConnectionClosed() for medium "
|
||||
<< Medium_Name(medium) << " which already has disconnection reason "
|
||||
<< DisconnectionReason_Name(
|
||||
@@ -1539,7 +1539,7 @@ std::vector<ConnectionsLog::EstablishedConnection>
|
||||
AnalyticsRecorder::LogicalConnection::GetEstablisedConnections() {
|
||||
std::vector<ConnectionsLog::EstablishedConnection> established_connections;
|
||||
if (current_medium_ != UNKNOWN_MEDIUM) {
|
||||
NEARBY_LOGS(WARNING)
|
||||
LOG(WARNING)
|
||||
<< "AnalyticsRecorder expected no more active physical connections "
|
||||
"before logging this endpoint connection.";
|
||||
return established_connections;
|
||||
@@ -1552,7 +1552,7 @@ AnalyticsRecorder::LogicalConnection::GetEstablisedConnections() {
|
||||
for (auto &established_connection : established_connections) {
|
||||
if (absl::Milliseconds(established_connection.duration_millis()) >=
|
||||
kConnectionTokenMaxLife) {
|
||||
NEARBY_LOGS(INFO) << "connection token exceed TTL, drop token.";
|
||||
LOG(INFO) << "connection token exceed TTL, drop token.";
|
||||
established_connection.set_connection_token("");
|
||||
}
|
||||
}
|
||||
@@ -1581,7 +1581,7 @@ void AnalyticsRecorder::LogicalConnection::IncomingPayloadDone(
|
||||
std::int64_t payload_id, PayloadStatus status,
|
||||
OperationResultCode operation_result_code) {
|
||||
if (current_medium_ == UNKNOWN_MEDIUM) {
|
||||
NEARBY_LOGS(WARNING) << "Unexpected call to incomingPayloadDone() while "
|
||||
LOG(WARNING) << "Unexpected call to incomingPayloadDone() while "
|
||||
"AnalyticsRecorder has no active current medium.";
|
||||
return;
|
||||
}
|
||||
@@ -1620,7 +1620,7 @@ void AnalyticsRecorder::LogicalConnection::OutgoingPayloadDone(
|
||||
std::int64_t payload_id, PayloadStatus status,
|
||||
OperationResultCode operation_result_code) {
|
||||
if (current_medium_ == UNKNOWN_MEDIUM) {
|
||||
NEARBY_LOGS(WARNING) << "Unexpected call to outgoingPayloadDone() while "
|
||||
LOG(WARNING) << "Unexpected call to outgoingPayloadDone() while "
|
||||
"AnalyticsRecorder has no active current medium.";
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -56,11 +56,11 @@ void ThroughputRecorder::Start(PayloadType payload_type,
|
||||
(payload_direction == PayloadDirection::INCOMING_PAYLOAD) ? "; Receive"
|
||||
: "; Send";
|
||||
|
||||
NEARBY_LOGS(INFO) << "Start TP profiling for payload_id:" << payload_id_
|
||||
LOG(INFO) << "Start TP profiling for payload_id:" << payload_id_
|
||||
<< direction;
|
||||
|
||||
if (payload_type == PayloadType::kUnknown) {
|
||||
NEARBY_LOGS(INFO)
|
||||
LOG(INFO)
|
||||
<< "Ignore ThroughputRecorder::start for Unknown Payload type";
|
||||
return;
|
||||
}
|
||||
@@ -74,9 +74,9 @@ void ThroughputRecorder::Start(PayloadType payload_type,
|
||||
|
||||
bool ThroughputRecorder::Stop() {
|
||||
MutexLock lock(&mutex_);
|
||||
NEARBY_LOGS(INFO) << "Stop TP profiling for payload_id:" << payload_id_;
|
||||
LOG(INFO) << "Stop TP profiling for payload_id:" << payload_id_;
|
||||
if (payload_type_ == PayloadType::kUnknown) {
|
||||
NEARBY_LOGS(INFO) << "Ignore ThroughputRecorder::stop as it never start";
|
||||
LOG(INFO) << "Ignore ThroughputRecorder::stop as it never start";
|
||||
return false;
|
||||
}
|
||||
{
|
||||
@@ -130,7 +130,7 @@ bool ThroughputRecorder::Stop() {
|
||||
? "Decryption"
|
||||
: "Encryption",
|
||||
encryption_time_, socket_io_time_);
|
||||
NEARBY_LOGS(INFO) << dump_content;
|
||||
LOG(INFO) << dump_content;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -188,7 +188,7 @@ bool ThroughputRecorder::Throughput::dump() {
|
||||
(payload_direction_ == PayloadDirection::INCOMING_PAYLOAD) ? "Decryption"
|
||||
: "Encryption",
|
||||
encryption_time_, socket_io_time_, other);
|
||||
NEARBY_LOGS(INFO) << dump_content;
|
||||
LOG(INFO) << dump_content;
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -220,7 +220,7 @@ void ThroughputRecorder::OnFrameSent(Medium medium,
|
||||
PacketMetaData& packetMetaData) {
|
||||
MutexLock lock(&mutex_);
|
||||
if (payload_type_ == PayloadType::kUnknown) {
|
||||
NEARBY_LOGS(INFO) << "PayloadType is invalid, return";
|
||||
LOG(INFO) << "PayloadType is invalid, return";
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -238,7 +238,7 @@ void ThroughputRecorder::OnFrameReceived(Medium medium,
|
||||
PacketMetaData& packetMetaData) {
|
||||
MutexLock lock(&mutex_);
|
||||
if (payload_type_ == PayloadType::kUnknown) {
|
||||
NEARBY_LOGS(INFO) << "PayloadType is invalid, return";
|
||||
LOG(INFO) << "PayloadType is invalid, return";
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -276,10 +276,10 @@ std::string ThroughputRecorder::ToString(PayloadType type) {
|
||||
|
||||
void ThroughputRecorderContainer::Shutdown() {
|
||||
MutexLock lock(&mutex_);
|
||||
NEARBY_LOGS(INFO) << __func__
|
||||
LOG(INFO) << __func__
|
||||
<< ". Num of Instance:" << throughput_recorders_.size();
|
||||
for (auto& throughput_recorder : throughput_recorders_) {
|
||||
NEARBY_LOGS(INFO) << "Stop instance: " << throughput_recorder.second;
|
||||
LOG(INFO) << "Stop instance: " << throughput_recorder.second;
|
||||
throughput_recorder.second->Stop();
|
||||
delete throughput_recorder.second;
|
||||
}
|
||||
@@ -296,7 +296,7 @@ ThroughputRecorder* ThroughputRecorderContainer::GetTPRecorder(
|
||||
std::string direction =
|
||||
(payload_direction == PayloadDirection::INCOMING_PAYLOAD) ? "; Receive"
|
||||
: "; Send";
|
||||
NEARBY_LOGS(INFO) << "Add ThroughputRecorder instance : " << instance
|
||||
LOG(INFO) << "Add ThroughputRecorder instance : " << instance
|
||||
<< " for payload_id:" << payload_id << direction;
|
||||
throughput_recorders_.emplace(
|
||||
std::pair<int64_t, PayloadDirection>(payload_id, payload_direction),
|
||||
@@ -316,7 +316,7 @@ void ThroughputRecorderContainer::StopTPRecorder(
|
||||
auto it = throughput_recorders_.find(
|
||||
std::pair<int64_t, PayloadDirection>(payload_id, payload_direction));
|
||||
if (it != throughput_recorders_.end()) {
|
||||
NEARBY_LOGS(INFO) << "Found and stop/delete ThroughputRecorder instance : "
|
||||
LOG(INFO) << "Found and stop/delete ThroughputRecorder instance : "
|
||||
<< &(it->second) << " for payload_id:" << payload_id
|
||||
<< direction;
|
||||
it->second->Stop();
|
||||
@@ -325,7 +325,7 @@ void ThroughputRecorderContainer::StopTPRecorder(
|
||||
std::pair<int64_t, PayloadDirection>(payload_id, payload_direction));
|
||||
return;
|
||||
}
|
||||
NEARBY_LOGS(INFO) << "No ThroughputRecorder found for :" << payload_id;
|
||||
LOG(INFO) << "No ThroughputRecorder found for :" << payload_id;
|
||||
}
|
||||
|
||||
int ThroughputRecorderContainer::GetSize() {
|
||||
|
||||
@@ -151,7 +151,7 @@ TEST_P(ThroughputRecorderTest, OnFrameSentStopAndDump) {
|
||||
packet_meta_data);
|
||||
|
||||
if (GetParam() == true) {
|
||||
NEARBY_LOGS(INFO) << "MarkAsSuccess";
|
||||
LOG(INFO) << "MarkAsSuccess";
|
||||
TPRecorder->MarkAsSuccess();
|
||||
}
|
||||
EXPECT_TRUE(TPRecorder->Stop());
|
||||
|
||||
@@ -54,7 +54,7 @@ void BaseBwuHandler::RevertInitiatorState() {
|
||||
void BaseBwuHandler::RevertInitiatorState(const std::string& upgrade_service_id,
|
||||
const std::string& endpoint_id) {
|
||||
if (!IsInitiatorUpgradeServiceId(upgrade_service_id)) {
|
||||
NEARBY_LOGS(ERROR)
|
||||
LOG(ERROR)
|
||||
<< "BaseBwuHandler::RevertInitiatorState: input service ID "
|
||||
<< upgrade_service_id << " is not an BWU initiator ID; ignoring.";
|
||||
return;
|
||||
@@ -82,7 +82,7 @@ void BaseBwuHandler::RevertResponderState(const std::string& service_id) {
|
||||
void BaseBwuHandler::NotifyOnIncomingConnection(
|
||||
ClientProxy* client, std::unique_ptr<IncomingSocketConnection> connection) {
|
||||
if (!incoming_connection_callback_) {
|
||||
NEARBY_LOGS(WARNING)
|
||||
LOG(WARNING)
|
||||
<< "Ignoring incoming connection, no callback registered";
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -136,7 +136,7 @@ ExceptionOr<ByteArray> BaseEndpointChannel::Read(
|
||||
}
|
||||
|
||||
if (read_int.result() < 0 || read_int.result() > max_allowed_read_bytes_) {
|
||||
NEARBY_LOGS(WARNING) << __func__ << ": Read an invalid number of bytes: "
|
||||
LOG(WARNING) << __func__ << ": Read an invalid number of bytes: "
|
||||
<< read_int.result();
|
||||
return ExceptionOr<ByteArray>(Exception::kIo);
|
||||
}
|
||||
@@ -173,24 +173,24 @@ ExceptionOr<ByteArray> BaseEndpointChannel::Read(
|
||||
if (parsed.ok()) {
|
||||
if (parser::GetFrameType(parsed.result()) ==
|
||||
location::nearby::connections::V1Frame::KEEP_ALIVE) {
|
||||
NEARBY_LOGS(INFO)
|
||||
LOG(INFO)
|
||||
<< __func__
|
||||
<< ": Read unencrypted KEEP_ALIVE on encrypted channel.";
|
||||
result = ByteArray(input);
|
||||
} else {
|
||||
NEARBY_LOGS(WARNING)
|
||||
LOG(WARNING)
|
||||
<< __func__ << ": Read unexpected unencrypted frame of type "
|
||||
<< parser::GetFrameType(parsed.result());
|
||||
}
|
||||
} else {
|
||||
message_exception.value = parsed.exception();
|
||||
NEARBY_LOGS(WARNING)
|
||||
LOG(WARNING)
|
||||
<< __func__ << ": Unable to parse data as unencrypted message.";
|
||||
}
|
||||
}
|
||||
packet_meta_data.StopEncryption();
|
||||
if (result.Empty()) {
|
||||
NEARBY_LOGS(WARNING) << __func__ << ": Unable to parse read result.";
|
||||
LOG(WARNING) << __func__ << ": Unable to parse read result.";
|
||||
return ExceptionOr<ByteArray>(message_exception);
|
||||
}
|
||||
}
|
||||
@@ -234,7 +234,7 @@ Exception BaseEndpointChannel::Write(const ByteArray& data,
|
||||
crypto_context_->EncodeMessageToPeer(std::string(data));
|
||||
packet_meta_data.StopEncryption();
|
||||
if (!encrypted) {
|
||||
NEARBY_LOGS(WARNING) << __func__ << ": Failed to encrypt data.";
|
||||
LOG(WARNING) << __func__ << ": Failed to encrypt data.";
|
||||
return {Exception::kIo};
|
||||
}
|
||||
encrypted_data = ByteArray(std::move(*encrypted));
|
||||
@@ -244,7 +244,7 @@ Exception BaseEndpointChannel::Write(const ByteArray& data,
|
||||
|
||||
size_t data_size = data_to_write->size();
|
||||
if (data_size < 0 || data_size > max_allowed_read_bytes_) {
|
||||
NEARBY_LOGS(WARNING) << __func__ << ": Write an invalid number of bytes: "
|
||||
LOG(WARNING) << __func__ << ": Write an invalid number of bytes: "
|
||||
<< data_size;
|
||||
return {Exception::kIo};
|
||||
}
|
||||
@@ -253,19 +253,19 @@ Exception BaseEndpointChannel::Write(const ByteArray& data,
|
||||
Exception write_exception =
|
||||
WriteInt(writer_, static_cast<std::int32_t>(data_size));
|
||||
if (write_exception.Raised()) {
|
||||
NEARBY_LOGS(WARNING) << __func__ << ": Failed to write header: "
|
||||
LOG(WARNING) << __func__ << ": Failed to write header: "
|
||||
<< write_exception.value;
|
||||
return write_exception;
|
||||
}
|
||||
write_exception = writer_->Write(*data_to_write);
|
||||
if (write_exception.Raised()) {
|
||||
NEARBY_LOGS(WARNING) << __func__ << ": Failed to write data: "
|
||||
LOG(WARNING) << __func__ << ": Failed to write data: "
|
||||
<< write_exception.value;
|
||||
return write_exception;
|
||||
}
|
||||
Exception flush_exception = writer_->Flush();
|
||||
if (flush_exception.Raised()) {
|
||||
NEARBY_LOGS(WARNING) << __func__ << ": Failed to flush writer: "
|
||||
LOG(WARNING) << __func__ << ": Failed to flush writer: "
|
||||
<< flush_exception.value;
|
||||
return flush_exception;
|
||||
}
|
||||
@@ -285,7 +285,7 @@ void BaseEndpointChannel::Close() {
|
||||
// In case channel is paused, resume it first thing.
|
||||
MutexLock lock(&is_paused_mutex_);
|
||||
if (is_closed_) {
|
||||
NEARBY_VLOG(1) << "EndpointChannel already closed";
|
||||
VLOG(1) << "EndpointChannel already closed";
|
||||
return;
|
||||
}
|
||||
is_closed_ = true;
|
||||
@@ -303,7 +303,7 @@ void BaseEndpointChannel::CloseIo() {
|
||||
// IO and Read() will proceed normally (with Exception::kIo).
|
||||
Exception exception = reader_->Close();
|
||||
if (!exception.Ok()) {
|
||||
NEARBY_LOGS(WARNING) << __func__
|
||||
LOG(WARNING) << __func__
|
||||
<< ": Exception closing reader: " << exception.value;
|
||||
}
|
||||
}
|
||||
@@ -313,7 +313,7 @@ void BaseEndpointChannel::CloseIo() {
|
||||
// IO and Write() will proceed normally (with Exception::kIo).
|
||||
Exception exception = writer_->Close();
|
||||
if (!exception.Ok()) {
|
||||
NEARBY_LOGS(WARNING) << __func__
|
||||
LOG(WARNING) << __func__
|
||||
<< ": Exception closing writer: " << exception.value;
|
||||
}
|
||||
}
|
||||
@@ -339,7 +339,7 @@ void BaseEndpointChannel::Close(
|
||||
void BaseEndpointChannel::Close(
|
||||
location::nearby::proto::connections::DisconnectionReason reason,
|
||||
SafeDisconnectionResult result) {
|
||||
NEARBY_LOGS(INFO) << __func__
|
||||
LOG(INFO) << __func__
|
||||
<< ": Closing endpoint channel, reason: " << reason;
|
||||
Close();
|
||||
|
||||
@@ -477,7 +477,7 @@ void BaseEndpointChannel::BlockUntilUnpaused() {
|
||||
while (is_paused_) {
|
||||
Exception wait_succeeded = is_paused_cond_.Wait();
|
||||
if (!wait_succeeded.Ok()) {
|
||||
NEARBY_LOGS(WARNING) << __func__ << ": Failure waiting to unpause: "
|
||||
LOG(WARNING) << __func__ << ": Failure waiting to unpause: "
|
||||
<< wait_succeeded.value;
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -66,11 +66,11 @@ std::function<void()> MakeDataPump(
|
||||
std::string label, InputStream* input, OutputStream* output,
|
||||
std::function<void(const ByteArray&)> monitor = nullptr) {
|
||||
return [label, input, output, monitor]() {
|
||||
NEARBY_LOGS(INFO) << "streaming data through '" << label << "'";
|
||||
LOG(INFO) << "streaming data through '" << label << "'";
|
||||
while (true) {
|
||||
auto read_response = input->Read(kChunkSize);
|
||||
if (!read_response.ok()) {
|
||||
NEARBY_LOGS(INFO) << "Peer reader closed on '" << label << "'";
|
||||
LOG(INFO) << "Peer reader closed on '" << label << "'";
|
||||
output->Close();
|
||||
break;
|
||||
}
|
||||
@@ -79,12 +79,12 @@ std::function<void()> MakeDataPump(
|
||||
}
|
||||
auto write_response = output->Write(read_response.result());
|
||||
if (write_response.Raised()) {
|
||||
NEARBY_LOGS(INFO) << "Peer writer closed on '" << label << "'";
|
||||
LOG(INFO) << "Peer writer closed on '" << label << "'";
|
||||
input->Close();
|
||||
break;
|
||||
}
|
||||
}
|
||||
NEARBY_LOGS(INFO) << "streaming terminated on '" << label << "'";
|
||||
LOG(INFO) << "streaming terminated on '" << label << "'";
|
||||
};
|
||||
}
|
||||
|
||||
@@ -97,7 +97,7 @@ std::function<void(const ByteArray&)> MakeDataMonitor(const std::string& label,
|
||||
absl::MutexLock lock(mutex);
|
||||
*capture += s;
|
||||
}
|
||||
NEARBY_LOGS(INFO) << "source='" << label << "'"
|
||||
LOG(INFO) << "source='" << label << "'"
|
||||
<< "; message='" << s << "'";
|
||||
};
|
||||
}
|
||||
@@ -122,7 +122,7 @@ DoDhKeyExchange(BaseEndpointChannel* channel_a,
|
||||
std::unique_ptr<securegcm::UKey2Handshake> ukey2,
|
||||
const std::string& auth_token,
|
||||
const ByteArray& raw_auth_token) {
|
||||
NEARBY_LOGS(INFO) << "client-A side key negotiation done";
|
||||
LOG(INFO) << "client-A side key negotiation done";
|
||||
EXPECT_TRUE(ukey2->VerifyHandshake());
|
||||
auto context = ukey2->ToConnectionContext();
|
||||
EXPECT_NE(context, nullptr);
|
||||
@@ -132,7 +132,7 @@ DoDhKeyExchange(BaseEndpointChannel* channel_a,
|
||||
.on_failure_cb =
|
||||
[&latch](const std::string& endpoint_id,
|
||||
EndpointChannel* channel) {
|
||||
NEARBY_LOGS(INFO) << "client-A side key negotiation failed";
|
||||
LOG(INFO) << "client-A side key negotiation failed";
|
||||
latch.CountDown();
|
||||
},
|
||||
});
|
||||
@@ -145,7 +145,7 @@ DoDhKeyExchange(BaseEndpointChannel* channel_a,
|
||||
std::unique_ptr<securegcm::UKey2Handshake> ukey2,
|
||||
const std::string& auth_token,
|
||||
const ByteArray& raw_auth_token) {
|
||||
NEARBY_LOGS(INFO) << "client-B side key negotiation done";
|
||||
LOG(INFO) << "client-B side key negotiation done";
|
||||
EXPECT_TRUE(ukey2->VerifyHandshake());
|
||||
auto context = ukey2->ToConnectionContext();
|
||||
EXPECT_NE(context, nullptr);
|
||||
@@ -155,7 +155,7 @@ DoDhKeyExchange(BaseEndpointChannel* channel_a,
|
||||
.on_failure_cb =
|
||||
[&latch](const std::string& endpoint_id,
|
||||
EndpointChannel* channel) {
|
||||
NEARBY_LOGS(INFO) << "client-B side key negotiation failed";
|
||||
LOG(INFO) << "client-B side key negotiation failed";
|
||||
latch.CountDown();
|
||||
},
|
||||
});
|
||||
|
||||
@@ -124,17 +124,17 @@ BasePcpHandler::BasePcpHandler(Mediums* mediums,
|
||||
bwu_manager_(bwu_manager) {}
|
||||
|
||||
BasePcpHandler::~BasePcpHandler() {
|
||||
NEARBY_VLOG(1) << __func__;
|
||||
VLOG(1) << __func__;
|
||||
Shutdown();
|
||||
}
|
||||
|
||||
void BasePcpHandler::Shutdown() {
|
||||
if (closed_.Set(true)) return;
|
||||
NEARBY_LOGS(INFO) << "Initiating shutdown of BasePcpHandler("
|
||||
LOG(INFO) << "Initiating shutdown of BasePcpHandler("
|
||||
<< strategy_.GetName() << ")";
|
||||
DisconnectFromEndpointManager();
|
||||
// Stop all the ongoing Runnables (as gracefully as possible).
|
||||
NEARBY_LOGS(INFO) << "BasePcpHandler(" << strategy_.GetName()
|
||||
LOG(INFO) << "BasePcpHandler(" << strategy_.GetName()
|
||||
<< ") is bringing down executors.";
|
||||
|
||||
encryption_runner_.Shutdown();
|
||||
@@ -144,13 +144,13 @@ void BasePcpHandler::Shutdown() {
|
||||
|
||||
serial_executor_.Shutdown();
|
||||
alarm_executor_.Shutdown();
|
||||
NEARBY_LOGS(INFO) << "BasePcpHandler(" << strategy_.GetName()
|
||||
LOG(INFO) << "BasePcpHandler(" << strategy_.GetName()
|
||||
<< ") has shut down.";
|
||||
}
|
||||
|
||||
void BasePcpHandler::DisconnectFromEndpointManager() {
|
||||
if (stop_.Set(true)) return;
|
||||
NEARBY_LOGS(INFO) << "BasePcpHandler(" << strategy_.GetName()
|
||||
LOG(INFO) << "BasePcpHandler(" << strategy_.GetName()
|
||||
<< ") unregister from EPM.";
|
||||
// Unregister ourselves from EPM message dispatcher.
|
||||
endpoint_manager_->UnregisterFrameProcessor(V1Frame::CONNECTION_RESPONSE,
|
||||
@@ -227,7 +227,7 @@ Status BasePcpHandler::StartAdvertising(
|
||||
AdvertisingOptions compatible_advertising_options =
|
||||
advertising_options.CompatibleOptions();
|
||||
StripOutUnavailableMediums(compatible_advertising_options);
|
||||
NEARBY_LOGS(INFO) << "StartAdvertising with supported mediums: "
|
||||
LOG(INFO) << "StartAdvertising with supported mediums: "
|
||||
<< GetStringValueOfSupportedMediums(
|
||||
compatible_advertising_options);
|
||||
|
||||
@@ -296,7 +296,7 @@ Status BasePcpHandler::StartAdvertising(
|
||||
}
|
||||
|
||||
void BasePcpHandler::StopAdvertising(ClientProxy* client) {
|
||||
NEARBY_LOGS(INFO) << "StopAdvertising local_endpoint_id="
|
||||
LOG(INFO) << "StopAdvertising local_endpoint_id="
|
||||
<< client->GetLocalEndpointId();
|
||||
CountDownLatch latch(1);
|
||||
RunOnPcpHandlerThread("stop-advertising",
|
||||
@@ -395,18 +395,18 @@ BooleanMediumSelector BasePcpHandler::ComputeIntersectionOfSupportedMediums(
|
||||
// TODO(b/268243340): Add Supported Medium field to ConnectionResponseFrame
|
||||
if (pending_connection_info.is_incoming) {
|
||||
for (auto medium : their_mediums) {
|
||||
NEARBY_LOGS(INFO) << "Their supported medium name: "
|
||||
LOG(INFO) << "Their supported medium name: "
|
||||
<< location::nearby::proto::connections::Medium_Name(
|
||||
medium);
|
||||
}
|
||||
} else {
|
||||
NEARBY_LOGS(INFO)
|
||||
LOG(INFO)
|
||||
<< "Current ConnectionResponseFrame from host has no Supported Mediums "
|
||||
"field, so use calculated default medium instead.";
|
||||
}
|
||||
|
||||
for (Medium my_medium : GetConnectionMediumsByPriority()) {
|
||||
NEARBY_LOGS(INFO) << "Our supported medium name: "
|
||||
LOG(INFO) << "Our supported medium name: "
|
||||
<< location::nearby::proto::connections::Medium_Name(
|
||||
my_medium);
|
||||
if (std::find(their_mediums.begin(), their_mediums.end(), my_medium) !=
|
||||
@@ -449,7 +449,7 @@ Status BasePcpHandler::StartDiscovery(ClientProxy* client,
|
||||
Future<Status> response;
|
||||
DiscoveryOptions stripped_discovery_options = discovery_options;
|
||||
StripOutUnavailableMediums(stripped_discovery_options);
|
||||
NEARBY_LOGS(INFO) << "StartDiscovery with supported mediums:"
|
||||
LOG(INFO) << "StartDiscovery with supported mediums:"
|
||||
<< GetStringValueOfSupportedMediums(
|
||||
stripped_discovery_options);
|
||||
RunOnPcpHandlerThread(
|
||||
@@ -513,7 +513,7 @@ void BasePcpHandler::WaitForLatch(const std::string& method_name,
|
||||
Exception await_exception = latch->Await();
|
||||
if (!await_exception.Ok()) {
|
||||
if (await_exception.Raised(Exception::kTimeout)) {
|
||||
NEARBY_LOGS(INFO) << "Blocked in " << method_name;
|
||||
LOG(INFO) << "Blocked in " << method_name;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -522,17 +522,17 @@ Status BasePcpHandler::WaitForResult(const std::string& method_name,
|
||||
std::int64_t client_id,
|
||||
Future<Status>* future) {
|
||||
if (!future) {
|
||||
NEARBY_LOGS(INFO) << "No future to wait for; return with error";
|
||||
LOG(INFO) << "No future to wait for; return with error";
|
||||
return {Status::kError};
|
||||
}
|
||||
NEARBY_LOGS(INFO) << "Waiting for future to complete: " << method_name;
|
||||
LOG(INFO) << "Waiting for future to complete: " << method_name;
|
||||
ExceptionOr<Status> result = future->Get();
|
||||
if (!result.ok()) {
|
||||
NEARBY_LOGS(INFO) << "Future:[" << method_name
|
||||
LOG(INFO) << "Future:[" << method_name
|
||||
<< "] completed with exception:" << result.exception();
|
||||
return {Status::kError};
|
||||
}
|
||||
NEARBY_LOGS(INFO) << "Future:[" << method_name
|
||||
LOG(INFO) << "Future:[" << method_name
|
||||
<< "] completed with status:" << result.result().value;
|
||||
return result.result();
|
||||
}
|
||||
@@ -540,7 +540,7 @@ Status BasePcpHandler::WaitForResult(const std::string& method_name,
|
||||
void BasePcpHandler::RunOnPcpHandlerThread(const std::string& name,
|
||||
Runnable runnable) {
|
||||
if (closed_.Get()) {
|
||||
NEARBY_LOGS(WARNING) << "Skip to run PCP Handler task " << name
|
||||
LOG(WARNING) << "Skip to run PCP Handler task " << name
|
||||
<< " due to PCP Handler is closed";
|
||||
return;
|
||||
}
|
||||
@@ -569,7 +569,7 @@ EncryptionRunner::ResultListener BasePcpHandler::GetResultListener() {
|
||||
RunOnPcpHandlerThread(
|
||||
"encryption-failure",
|
||||
[this, endpoint_id, channel]() RUN_ON_PCP_HANDLER_THREAD() {
|
||||
NEARBY_LOGS(ERROR)
|
||||
LOG(ERROR)
|
||||
<< "Encryption failed for endpoint_id=" << endpoint_id
|
||||
<< " on medium="
|
||||
<< location::nearby::proto::connections::Medium_Name(
|
||||
@@ -606,7 +606,7 @@ EncryptionRunner::ResultListener BasePcpHandler::GetResultListenerV3(
|
||||
RunOnPcpHandlerThread(
|
||||
"encryption-failure",
|
||||
[this, endpoint_id, channel]() RUN_ON_PCP_HANDLER_THREAD() {
|
||||
NEARBY_LOGS(ERROR)
|
||||
LOG(ERROR)
|
||||
<< "Encryption failed for endpoint_id=" << endpoint_id
|
||||
<< " on medium="
|
||||
<< location::nearby::proto::connections::Medium_Name(
|
||||
@@ -627,7 +627,7 @@ void BasePcpHandler::OnEncryptionSuccessRunnableV3(
|
||||
// TODO(b/316421187): Add test coverage
|
||||
auto it = pending_connections_.find(remote_device.GetEndpointId());
|
||||
if (it == pending_connections_.end()) {
|
||||
NEARBY_LOGS(ERROR)
|
||||
LOG(ERROR)
|
||||
<< __func__
|
||||
<< ": Connection not found on UKEY negotination complete; endpoint_id="
|
||||
<< remote_device.GetEndpointId();
|
||||
@@ -659,12 +659,12 @@ void BasePcpHandler::OnEncryptionSuccessRunnableV3(
|
||||
// TODO(b/305004353): Authenticate the connection in the responder role for
|
||||
// outgoing connections.
|
||||
if (!pending_connection_info.is_incoming) {
|
||||
NEARBY_LOGS(ERROR) << __func__
|
||||
LOG(ERROR) << __func__
|
||||
<< ": only outgoing connections are supported";
|
||||
return;
|
||||
}
|
||||
|
||||
NEARBY_VLOG(1)
|
||||
VLOG(1)
|
||||
<< __func__
|
||||
<< ": beginning authentication to the remote device as an initiator";
|
||||
ConnectionsAuthenticationTransport connections_authentication_transport =
|
||||
@@ -674,7 +674,7 @@ void BasePcpHandler::OnEncryptionSuccessRunnableV3(
|
||||
/*remote_device=*/remote_device,
|
||||
/*shared_secret=*/auth_token,
|
||||
/*authentication_transport=*/connections_authentication_transport);
|
||||
NEARBY_LOGS(INFO) << __func__ << ": authentication result = "
|
||||
LOG(INFO) << __func__ << ": authentication result = "
|
||||
<< AuthenticationStatusToString(
|
||||
pending_connection_info.authentication_status);
|
||||
|
||||
@@ -693,7 +693,7 @@ void BasePcpHandler::OnEncryptionSuccessRunnable(
|
||||
// TODO(b/316421187): Add test coverage
|
||||
auto it = pending_connections_.find(endpoint_id);
|
||||
if (it == pending_connections_.end()) {
|
||||
NEARBY_LOGS(INFO)
|
||||
LOG(INFO)
|
||||
<< "Connection not found on UKEY negotination complete; endpoint_id="
|
||||
<< endpoint_id;
|
||||
return;
|
||||
@@ -727,7 +727,7 @@ void BasePcpHandler::RegisterDeviceAfterEncryptionSuccess(
|
||||
pending_connection_info.SetCryptoContext(std::move(ukey2));
|
||||
pending_connection_info.connection_token =
|
||||
GetHashedConnectionToken(raw_auth_token);
|
||||
NEARBY_LOGS(INFO)
|
||||
LOG(INFO)
|
||||
<< "Register encrypted connection; wait for response; endpoint_id="
|
||||
<< endpoint_id;
|
||||
|
||||
@@ -758,7 +758,7 @@ void BasePcpHandler::RegisterDeviceAfterEncryptionSuccess(
|
||||
pending_connection_info.connection_token);
|
||||
|
||||
if (auto future_status = pending_connection_info.result.lock()) {
|
||||
NEARBY_LOGS(INFO) << "Connection established; Finalising future OK.";
|
||||
LOG(INFO) << "Connection established; Finalising future OK.";
|
||||
future_status->Set({Status::kSuccess});
|
||||
pending_connection_info.result.reset();
|
||||
}
|
||||
@@ -768,7 +768,7 @@ void BasePcpHandler::OnEncryptionFailureRunnable(
|
||||
const std::string& endpoint_id, EndpointChannel* endpoint_channel) {
|
||||
auto it = pending_connections_.find(endpoint_id);
|
||||
if (it == pending_connections_.end()) {
|
||||
NEARBY_LOGS(INFO)
|
||||
LOG(INFO)
|
||||
<< "Connection not found on UKEY negotination complete; endpoint_id="
|
||||
<< endpoint_id;
|
||||
return;
|
||||
@@ -783,7 +783,7 @@ void BasePcpHandler::OnEncryptionFailureRunnable(
|
||||
// the map had already updated with the winning EndpointChannel, we closed
|
||||
// it too by accident.
|
||||
if (*endpoint_channel != *pending_connection_info.channel) {
|
||||
NEARBY_LOGS(INFO) << "Not destroying channel [mismatch]: passed="
|
||||
LOG(INFO) << "Not destroying channel [mismatch]: passed="
|
||||
<< endpoint_channel->GetName() << "; expected="
|
||||
<< pending_connection_info.channel->GetName();
|
||||
return;
|
||||
@@ -823,7 +823,7 @@ ConnectionInfo BasePcpHandler::FillConnectionInfo(
|
||||
medium_role_info.set_support_wifi_hotspot_client(true);
|
||||
connection_info.medium_role.emplace(medium_role_info);
|
||||
}
|
||||
NEARBY_LOGS(INFO) << "Query for WIFI information: is_supports_5_ghz="
|
||||
LOG(INFO) << "Query for WIFI information: is_supports_5_ghz="
|
||||
<< connection_info.supports_5_ghz
|
||||
<< "; bssid=" << connection_info.bssid
|
||||
<< "; ap_frequency=" << connection_info.ap_frequency
|
||||
@@ -861,7 +861,7 @@ Status BasePcpHandler::RequestConnection(
|
||||
|
||||
DiscoveredEndpoint* endpoint = GetDiscoveredEndpoint(endpoint_id);
|
||||
if (endpoint == nullptr) {
|
||||
NEARBY_LOGS(INFO)
|
||||
LOG(INFO)
|
||||
<< "Discovered endpoint not found: endpoint_id=" << endpoint_id;
|
||||
result->Set({Status::kEndpointUnknown});
|
||||
return;
|
||||
@@ -873,13 +873,13 @@ Status BasePcpHandler::RequestConnection(
|
||||
if (AppendRemoteBluetoothMacAddressEndpoint(
|
||||
endpoint_id, remote_bluetooth_mac_address,
|
||||
client->GetDiscoveryOptions()))
|
||||
NEARBY_LOGS(INFO)
|
||||
LOG(INFO)
|
||||
<< "Appended remote Bluetooth MAC Address endpoint ["
|
||||
<< remote_bluetooth_mac_address << "]";
|
||||
}
|
||||
|
||||
if (AppendWebRTCEndpoint(endpoint_id, client->GetDiscoveryOptions()))
|
||||
NEARBY_LOGS(INFO) << "Appended Web RTC endpoint.";
|
||||
LOG(INFO) << "Appended Web RTC endpoint.";
|
||||
|
||||
auto discovered_endpoints = GetDiscoveredEndpoints(endpoint_id);
|
||||
std::unique_ptr<EndpointChannel> channel;
|
||||
@@ -899,7 +899,7 @@ Status BasePcpHandler::RequestConnection(
|
||||
Medium channel_medium =
|
||||
channel ? channel->GetMedium() : Medium::UNKNOWN_MEDIUM;
|
||||
if (channel == nullptr) {
|
||||
NEARBY_LOGS(INFO)
|
||||
LOG(INFO)
|
||||
<< "Endpoint channel not available: endpoint_id=" << endpoint_id;
|
||||
ProcessPreConnectionInitiationFailure(
|
||||
client, channel_medium, endpoint_id, channel.get(),
|
||||
@@ -908,7 +908,7 @@ Status BasePcpHandler::RequestConnection(
|
||||
return;
|
||||
}
|
||||
|
||||
NEARBY_LOGS(INFO)
|
||||
LOG(INFO)
|
||||
<< "In requestConnection(), wrote ConnectionRequestFrame "
|
||||
"to endpoint_id="
|
||||
<< endpoint_id;
|
||||
@@ -924,7 +924,7 @@ Status BasePcpHandler::RequestConnection(
|
||||
local_device->GetType(), local_device->ToProtoBytes(),
|
||||
connection_info, channel.get());
|
||||
if (!write_exception.Ok()) {
|
||||
NEARBY_LOGS(INFO) << "Failed to send connection request: endpoint_id="
|
||||
LOG(INFO) << "Failed to send connection request: endpoint_id="
|
||||
<< endpoint_id;
|
||||
ProcessPreConnectionInitiationFailure(
|
||||
client, channel_medium, endpoint_id, channel.get(),
|
||||
@@ -935,7 +935,7 @@ Status BasePcpHandler::RequestConnection(
|
||||
return;
|
||||
}
|
||||
|
||||
NEARBY_LOGS(INFO) << "Adding connection to pending set: endpoint_id="
|
||||
LOG(INFO) << "Adding connection to pending set: endpoint_id="
|
||||
<< endpoint_id;
|
||||
|
||||
// We've successfully connected to the device, and are now about to jump
|
||||
@@ -964,19 +964,19 @@ Status BasePcpHandler::RequestConnection(
|
||||
.emplace(endpoint_id, std::move(pending_connection_info))
|
||||
.first->second.channel.get();
|
||||
|
||||
NEARBY_LOGS(INFO) << "Initiating secure connection: endpoint_id="
|
||||
LOG(INFO) << "Initiating secure connection: endpoint_id="
|
||||
<< endpoint_id;
|
||||
// Next, we'll set up encryption. When it's done, our future will return
|
||||
// and RequestConnection() will finish.
|
||||
encryption_runner_.StartClient(client, endpoint_id, endpoint_channel,
|
||||
GetResultListener());
|
||||
});
|
||||
NEARBY_LOGS(INFO) << "Waiting for connection to complete: endpoint_id="
|
||||
LOG(INFO) << "Waiting for connection to complete: endpoint_id="
|
||||
<< endpoint_id;
|
||||
auto status =
|
||||
WaitForResult(absl::StrCat("RequestConnection(", endpoint_id, ")"),
|
||||
client->GetClientId(), result.get());
|
||||
NEARBY_LOGS(INFO) << "Wait is complete: endpoint_id=" << endpoint_id
|
||||
LOG(INFO) << "Wait is complete: endpoint_id=" << endpoint_id
|
||||
<< "; status=" << status.value;
|
||||
return status;
|
||||
}
|
||||
@@ -1003,7 +1003,7 @@ Status BasePcpHandler::RequestConnectionV3(
|
||||
|
||||
DiscoveredEndpoint* endpoint = GetDiscoveredEndpoint(endpoint_id);
|
||||
if (endpoint == nullptr) {
|
||||
NEARBY_LOGS(INFO)
|
||||
LOG(INFO)
|
||||
<< "Discovered endpoint not found: endpoint_id=" << endpoint_id;
|
||||
result->Set({Status::kEndpointUnknown});
|
||||
return;
|
||||
@@ -1015,13 +1015,13 @@ Status BasePcpHandler::RequestConnectionV3(
|
||||
if (AppendRemoteBluetoothMacAddressEndpoint(
|
||||
endpoint_id, remote_bluetooth_mac_address,
|
||||
client->GetDiscoveryOptions()))
|
||||
NEARBY_LOGS(INFO)
|
||||
LOG(INFO)
|
||||
<< "Appended remote Bluetooth MAC Address endpoint ["
|
||||
<< remote_bluetooth_mac_address << "]";
|
||||
}
|
||||
|
||||
if (AppendWebRTCEndpoint(endpoint_id, client->GetDiscoveryOptions()))
|
||||
NEARBY_LOGS(INFO) << "Appended Web RTC endpoint.";
|
||||
LOG(INFO) << "Appended Web RTC endpoint.";
|
||||
|
||||
auto discovered_endpoints = GetDiscoveredEndpoints(endpoint_id);
|
||||
std::unique_ptr<EndpointChannel> channel;
|
||||
@@ -1031,7 +1031,7 @@ Status BasePcpHandler::RequestConnectionV3(
|
||||
if (!MediumSupportedByClientOptions(connect_endpoint->medium,
|
||||
connection_options))
|
||||
continue;
|
||||
NEARBY_LOGS(INFO)
|
||||
LOG(INFO)
|
||||
<< "Try to connect with endpoint(id=" << endpoint_id
|
||||
<< ") by Medium: "
|
||||
<< location::nearby::proto::connections::Medium_Name(
|
||||
@@ -1046,7 +1046,7 @@ Status BasePcpHandler::RequestConnectionV3(
|
||||
Medium channel_medium =
|
||||
channel ? channel->GetMedium() : Medium::UNKNOWN_MEDIUM;
|
||||
if (channel == nullptr) {
|
||||
NEARBY_LOGS(INFO)
|
||||
LOG(INFO)
|
||||
<< "Endpoint channel not available: endpoint_id=" << endpoint_id;
|
||||
ProcessPreConnectionInitiationFailure(
|
||||
client, channel_medium, endpoint_id, channel.get(),
|
||||
@@ -1055,7 +1055,7 @@ Status BasePcpHandler::RequestConnectionV3(
|
||||
return;
|
||||
}
|
||||
|
||||
NEARBY_LOGS(INFO)
|
||||
LOG(INFO)
|
||||
<< "In requestConnectionV3(), wrote ConnectionRequestFrame "
|
||||
"to endpoint_id="
|
||||
<< endpoint_id;
|
||||
@@ -1072,7 +1072,7 @@ Status BasePcpHandler::RequestConnectionV3(
|
||||
connection_info, channel.get());
|
||||
|
||||
if (!write_exception.Ok()) {
|
||||
NEARBY_LOGS(INFO) << "Failed to send connection request: endpoint_id="
|
||||
LOG(INFO) << "Failed to send connection request: endpoint_id="
|
||||
<< endpoint_id;
|
||||
ProcessPreConnectionInitiationFailure(
|
||||
client, channel_medium, endpoint_id, channel.get(),
|
||||
@@ -1083,7 +1083,7 @@ Status BasePcpHandler::RequestConnectionV3(
|
||||
return;
|
||||
}
|
||||
|
||||
NEARBY_LOGS(INFO) << "Adding connection to pending set: endpoint_id="
|
||||
LOG(INFO) << "Adding connection to pending set: endpoint_id="
|
||||
<< endpoint_id;
|
||||
|
||||
// We've successfully connected to the device, and are now about to jump
|
||||
@@ -1112,7 +1112,7 @@ Status BasePcpHandler::RequestConnectionV3(
|
||||
.emplace(endpoint_id, std::move(pending_connection_info))
|
||||
.first->second.channel.get();
|
||||
|
||||
NEARBY_LOGS(INFO) << "Initiating secure connection: endpoint_id="
|
||||
LOG(INFO) << "Initiating secure connection: endpoint_id="
|
||||
<< endpoint_id;
|
||||
// Next, we'll set up encryption and authenticate the remote device.
|
||||
// When it's done, our future will return and RequestConnectionV3()
|
||||
@@ -1122,12 +1122,12 @@ Status BasePcpHandler::RequestConnectionV3(
|
||||
GetResultListenerV3(*(client->GetLocalDeviceProvider()),
|
||||
remote_device, *endpoint_channel));
|
||||
});
|
||||
NEARBY_LOGS(INFO) << "Waiting for connection to complete: endpoint_id="
|
||||
LOG(INFO) << "Waiting for connection to complete: endpoint_id="
|
||||
<< endpoint_id;
|
||||
auto status =
|
||||
WaitForResult(absl::StrCat("RequestConnectionV3(", endpoint_id, ")"),
|
||||
client->GetClientId(), result.get());
|
||||
NEARBY_LOGS(INFO) << "Wait is complete: endpoint_id=" << endpoint_id
|
||||
LOG(INFO) << "Wait is complete: endpoint_id=" << endpoint_id
|
||||
<< "; status=" << status.value;
|
||||
return status;
|
||||
}
|
||||
@@ -1416,7 +1416,7 @@ void BasePcpHandler::ProcessPreConnectionInitiationFailure(
|
||||
}
|
||||
|
||||
if (result != nullptr) {
|
||||
NEARBY_LOGS(INFO) << "Connection failed; aborting future";
|
||||
LOG(INFO) << "Connection failed; aborting future";
|
||||
result->Set(status);
|
||||
}
|
||||
|
||||
@@ -1446,9 +1446,9 @@ Status BasePcpHandler::AcceptConnection(ClientProxy* client,
|
||||
"accept-connection", [this, client, endpoint_id,
|
||||
payload_listener = std::move(payload_listener),
|
||||
&response]() RUN_ON_PCP_HANDLER_THREAD() mutable {
|
||||
NEARBY_LOGS(INFO) << "AcceptConnection: endpoint_id=" << endpoint_id;
|
||||
LOG(INFO) << "AcceptConnection: endpoint_id=" << endpoint_id;
|
||||
if (!pending_connections_.count(endpoint_id)) {
|
||||
NEARBY_LOGS(INFO)
|
||||
LOG(INFO)
|
||||
<< "AcceptConnection: no pending connection for endpoint_id="
|
||||
<< endpoint_id;
|
||||
|
||||
@@ -1465,7 +1465,7 @@ Status BasePcpHandler::AcceptConnection(ClientProxy* client,
|
||||
std::shared_ptr<EndpointChannel> channel =
|
||||
channel_manager_->GetChannelForEndpoint(endpoint_id);
|
||||
if (channel == nullptr) {
|
||||
NEARBY_LOGS(ERROR) << "Channel destroyed before Accept; bring down "
|
||||
LOG(ERROR) << "Channel destroyed before Accept; bring down "
|
||||
"connection: endpoint_id="
|
||||
<< endpoint_id;
|
||||
ProcessPreConnectionResultFailure(
|
||||
@@ -1480,7 +1480,7 @@ Status BasePcpHandler::AcceptConnection(ClientProxy* client,
|
||||
Status::kSuccess, client->GetLocalOsInfo(),
|
||||
client->GetLocalMultiplexSocketBitmask()));
|
||||
if (!write_exception.Ok()) {
|
||||
NEARBY_LOGS(INFO)
|
||||
LOG(INFO)
|
||||
<< "AcceptConnection: failed to send response: endpoint_id="
|
||||
<< endpoint_id;
|
||||
ProcessPreConnectionResultFailure(
|
||||
@@ -1490,7 +1490,7 @@ Status BasePcpHandler::AcceptConnection(ClientProxy* client,
|
||||
return;
|
||||
}
|
||||
|
||||
NEARBY_LOGS(INFO) << "AcceptConnection: accepting locally: endpoint_id="
|
||||
LOG(INFO) << "AcceptConnection: accepting locally: endpoint_id="
|
||||
<< endpoint_id;
|
||||
connection_info.LocalEndpointAcceptedConnection(
|
||||
endpoint_id, std::move(payload_listener));
|
||||
@@ -1509,9 +1509,9 @@ Status BasePcpHandler::RejectConnection(ClientProxy* client,
|
||||
RunOnPcpHandlerThread(
|
||||
"reject-connection",
|
||||
[this, client, endpoint_id, &response]() RUN_ON_PCP_HANDLER_THREAD() {
|
||||
NEARBY_LOGS(INFO) << "RejectConnection: id=" << endpoint_id;
|
||||
LOG(INFO) << "RejectConnection: id=" << endpoint_id;
|
||||
if (!pending_connections_.count(endpoint_id)) {
|
||||
NEARBY_LOGS(INFO)
|
||||
LOG(INFO)
|
||||
<< "RejectConnection: no pending connection for endpoint_id="
|
||||
<< endpoint_id;
|
||||
response.Set({Status::kEndpointUnknown});
|
||||
@@ -1527,7 +1527,7 @@ Status BasePcpHandler::RejectConnection(ClientProxy* client,
|
||||
std::shared_ptr<EndpointChannel> channel =
|
||||
channel_manager_->GetChannelForEndpoint(endpoint_id);
|
||||
if (channel == nullptr) {
|
||||
NEARBY_LOGS(ERROR)
|
||||
LOG(ERROR)
|
||||
<< "Channel destroyed before Reject; bring down connection: "
|
||||
"endpoint_id="
|
||||
<< endpoint_id;
|
||||
@@ -1543,7 +1543,7 @@ Status BasePcpHandler::RejectConnection(ClientProxy* client,
|
||||
Status::kConnectionRejected, client->GetLocalOsInfo(),
|
||||
client->GetLocalMultiplexSocketBitmask()));
|
||||
if (!write_exception.Ok()) {
|
||||
NEARBY_LOGS(INFO)
|
||||
LOG(INFO)
|
||||
<< "RejectConnection: failed to send response: endpoint_id="
|
||||
<< endpoint_id;
|
||||
ProcessPreConnectionResultFailure(
|
||||
@@ -1553,7 +1553,7 @@ Status BasePcpHandler::RejectConnection(ClientProxy* client,
|
||||
return;
|
||||
}
|
||||
|
||||
NEARBY_LOGS(INFO) << "RejectConnection: rejecting locally: endpoint_id="
|
||||
LOG(INFO) << "RejectConnection: rejecting locally: endpoint_id="
|
||||
<< endpoint_id;
|
||||
connection_info.LocalEndpointRejectedConnection(endpoint_id);
|
||||
EvaluateConnectionResult(client, endpoint_id,
|
||||
@@ -1573,11 +1573,11 @@ void BasePcpHandler::OnIncomingFrame(
|
||||
RunOnPcpHandlerThread(
|
||||
"incoming-frame",
|
||||
[this, client, endpoint_id, frame, &latch]() RUN_ON_PCP_HANDLER_THREAD() {
|
||||
NEARBY_LOGS(INFO) << "OnConnectionResponse: endpoint_id="
|
||||
LOG(INFO) << "OnConnectionResponse: endpoint_id="
|
||||
<< endpoint_id;
|
||||
|
||||
if (client->HasRemoteEndpointResponded(endpoint_id)) {
|
||||
NEARBY_LOGS(INFO)
|
||||
LOG(INFO)
|
||||
<< "OnConnectionResponse: already handled; endpoint_id="
|
||||
<< endpoint_id;
|
||||
return;
|
||||
@@ -1597,12 +1597,12 @@ void BasePcpHandler::OnIncomingFrame(
|
||||
accepted = connection_response.status() == Status::kSuccess;
|
||||
}
|
||||
if (accepted) {
|
||||
NEARBY_LOGS(INFO)
|
||||
LOG(INFO)
|
||||
<< "OnConnectionResponse: remote accepted; endpoint_id="
|
||||
<< endpoint_id;
|
||||
client->RemoteEndpointAcceptedConnection(endpoint_id);
|
||||
} else {
|
||||
NEARBY_LOGS(INFO)
|
||||
LOG(INFO)
|
||||
<< "OnConnectionResponse: remote rejected; endpoint_id="
|
||||
<< endpoint_id << "; status=" << connection_response.status();
|
||||
client->RemoteEndpointRejectedConnection(endpoint_id);
|
||||
@@ -1618,7 +1618,7 @@ void BasePcpHandler::OnIncomingFrame(
|
||||
}
|
||||
|
||||
if (connection_response.has_safe_to_disconnect_version()) {
|
||||
NEARBY_LOGS(INFO)
|
||||
LOG(INFO)
|
||||
<< "[safe-to-disconnect]: endpoint_id=" << endpoint_id
|
||||
<< "; Version = "
|
||||
<< connection_response.safe_to_disconnect_version();
|
||||
@@ -1670,7 +1670,7 @@ void BasePcpHandler::OnEndpointFound(
|
||||
ClientProxy* client, std::shared_ptr<DiscoveredEndpoint> endpoint) {
|
||||
// Check if we've seen this endpoint ID before.
|
||||
std::string& endpoint_id = endpoint->endpoint_id;
|
||||
NEARBY_LOGS(INFO) << "OnEndpointFound: id=" << endpoint_id << ", medium="
|
||||
LOG(INFO) << "OnEndpointFound: id=" << endpoint_id << ", medium="
|
||||
<< location::nearby::proto::connections::Medium_Name(
|
||||
endpoint->medium)
|
||||
<< " [enter]";
|
||||
@@ -1684,7 +1684,7 @@ void BasePcpHandler::OnEndpointFound(
|
||||
// Because the DCT endpoint info is mocked on BLE, we need to specially
|
||||
// handle it to avoid device refresh between different mediums.
|
||||
if (discovered_endpoint->medium == endpoint->medium) {
|
||||
NEARBY_LOGS(INFO) << "Ignore the dup endpoint info on medium "
|
||||
LOG(INFO) << "Ignore the dup endpoint info on medium "
|
||||
<< location::nearby::proto::connections::Medium_Name(
|
||||
endpoint->medium);
|
||||
return;
|
||||
@@ -1694,7 +1694,7 @@ void BasePcpHandler::OnEndpointFound(
|
||||
// Endpoint info should be same for an endpoint ID. If it is changed,
|
||||
// we should reset discovered endpoints of the endpoint ID, and use the
|
||||
// new endpoint info and medium as discovered endpoint.
|
||||
NEARBY_LOGS(INFO) << "Endpoint info of endpoint " << endpoint_id
|
||||
LOG(INFO) << "Endpoint info of endpoint " << endpoint_id
|
||||
<< " changed on medium "
|
||||
<< location::nearby::proto::connections::Medium_Name(
|
||||
endpoint->medium);
|
||||
@@ -1714,7 +1714,7 @@ void BasePcpHandler::OnEndpointFound(
|
||||
return;
|
||||
}
|
||||
if (discovered_endpoint->medium == endpoint->medium) {
|
||||
NEARBY_LOGS(INFO) << "Ignore the dup endpoint info on medium "
|
||||
LOG(INFO) << "Ignore the dup endpoint info on medium "
|
||||
<< location::nearby::proto::connections::Medium_Name(
|
||||
endpoint->medium);
|
||||
return;
|
||||
@@ -1726,7 +1726,7 @@ void BasePcpHandler::OnEndpointFound(
|
||||
discovered_endpoints_.emplace(endpoint_id, std::move(endpoint))
|
||||
->second.get();
|
||||
|
||||
NEARBY_LOGS(INFO) << "Adding new medium for endpoint: endpoint_id="
|
||||
LOG(INFO) << "Adding new medium for endpoint: endpoint_id="
|
||||
<< endpoint_id << "; medium="
|
||||
<< location::nearby::proto::connections::Medium_Name(
|
||||
owned_endpoint->medium);
|
||||
@@ -1744,7 +1744,7 @@ void BasePcpHandler::OnEndpointFound(
|
||||
void BasePcpHandler::OnEndpointLost(
|
||||
ClientProxy* client, const BasePcpHandler::DiscoveredEndpoint& endpoint) {
|
||||
// Look up the DiscoveredEndpoint we have in our cache.
|
||||
NEARBY_LOGS(INFO) << "OnEndpointLost: id=" << endpoint.endpoint_id
|
||||
LOG(INFO) << "OnEndpointLost: id=" << endpoint.endpoint_id
|
||||
<< " on medium="
|
||||
<< location::nearby::proto::connections::Medium_Name(
|
||||
endpoint.medium);
|
||||
@@ -1752,7 +1752,7 @@ void BasePcpHandler::OnEndpointLost(
|
||||
auto range = discovered_endpoints_.equal_range(endpoint.endpoint_id);
|
||||
bool is_range_empty = range.first == range.second;
|
||||
if (is_range_empty) {
|
||||
NEARBY_LOGS(INFO) << "No previous endpoint (nothing to lose): endpoint_id="
|
||||
LOG(INFO) << "No previous endpoint (nothing to lose): endpoint_id="
|
||||
<< endpoint.endpoint_id;
|
||||
return;
|
||||
}
|
||||
@@ -1768,13 +1768,13 @@ void BasePcpHandler::OnEndpointLost(
|
||||
// that the remote device changed their info. We reported onFound for the
|
||||
// new info and are just now figuring out that we lost the old info.
|
||||
if (discovered_endpoint->endpoint_info != endpoint.endpoint_info) {
|
||||
NEARBY_LOGS(INFO) << "Previous endpoint name mismatch; passed="
|
||||
LOG(INFO) << "Previous endpoint name mismatch; passed="
|
||||
<< absl::BytesToHexString(endpoint.endpoint_info.data())
|
||||
<< "; expected="
|
||||
<< absl::BytesToHexString(
|
||||
discovered_endpoint->endpoint_info.data());
|
||||
}
|
||||
NEARBY_LOGS(INFO) << "Erase Endpoint " << endpoint.endpoint_id
|
||||
LOG(INFO) << "Erase Endpoint " << endpoint.endpoint_id
|
||||
<< " on Medium "
|
||||
<< location::nearby::proto::connections::Medium_Name(
|
||||
discovered_endpoint->medium);
|
||||
@@ -1789,7 +1789,7 @@ void BasePcpHandler::OnEndpointLost(
|
||||
void BasePcpHandler::OnInstantLost(ClientProxy* client,
|
||||
const std::string& endpoint_id,
|
||||
const ByteArray& endpoint_info) {
|
||||
NEARBY_LOGS(INFO) << "OnInstantLost: id=" << endpoint_id;
|
||||
LOG(INFO) << "OnInstantLost: id=" << endpoint_id;
|
||||
std::vector<BasePcpHandler::DiscoveredEndpoint*> discovered_endpoints =
|
||||
GetDiscoveredEndpoints(endpoint_id);
|
||||
if (discovered_endpoints.empty()) {
|
||||
@@ -1802,7 +1802,7 @@ void BasePcpHandler::OnInstantLost(ClientProxy* client,
|
||||
}
|
||||
}
|
||||
|
||||
NEARBY_LOGS(INFO) << "Reported lost endpoint " << endpoint_id
|
||||
LOG(INFO) << "Reported lost endpoint " << endpoint_id
|
||||
<< " on all mediums.";
|
||||
}
|
||||
|
||||
@@ -1895,7 +1895,7 @@ bool BasePcpHandler::IsPreferred(
|
||||
for (const auto& medium : mediums) {
|
||||
absl::StrAppend(&medium_string, medium, "; ");
|
||||
}
|
||||
NEARBY_LOGS(ERROR) << "Failed to find either " << new_endpoint.medium
|
||||
LOG(ERROR) << "Failed to find either " << new_endpoint.medium
|
||||
<< " or " << old_endpoint.medium
|
||||
<< " in the list of locally supported mediums despite "
|
||||
"expecting to find both, when deciding which medium "
|
||||
@@ -1915,7 +1915,7 @@ Exception BasePcpHandler::OnIncomingConnection(
|
||||
// incoming connection where we attempted to check that state.
|
||||
if (!client->IsAdvertising() &&
|
||||
!client->IsListeningForIncomingConnections()) {
|
||||
NEARBY_LOGS(WARNING) << "Ignoring incoming connection on medium "
|
||||
LOG(WARNING) << "Ignoring incoming connection on medium "
|
||||
<< location::nearby::proto::connections::Medium_Name(
|
||||
channel->GetMedium())
|
||||
<< " because client=" << client->GetClientId()
|
||||
@@ -1929,7 +1929,7 @@ Exception BasePcpHandler::OnIncomingConnection(
|
||||
|
||||
if (!wrapped_frame.ok()) {
|
||||
if (wrapped_frame.exception()) {
|
||||
NEARBY_LOGS(ERROR)
|
||||
LOG(ERROR)
|
||||
<< "Failed to parse incoming connection request; client="
|
||||
<< client->GetClientId()
|
||||
<< "; device=" << absl::BytesToHexString(remote_endpoint_info.data())
|
||||
@@ -1947,14 +1947,14 @@ Exception BasePcpHandler::OnIncomingConnection(
|
||||
OfflineFrame& frame = wrapped_frame.result();
|
||||
const ConnectionRequestFrame& connection_request =
|
||||
frame.v1().connection_request();
|
||||
NEARBY_LOGS(INFO) << "In onIncomingConnection("
|
||||
LOG(INFO) << "In onIncomingConnection("
|
||||
<< location::nearby::proto::connections::Medium_Name(
|
||||
channel->GetMedium())
|
||||
<< ") for client=" << client->GetClientId()
|
||||
<< ", read ConnectionRequestFrame from endpoint(id="
|
||||
<< connection_request.endpoint_id() << ")";
|
||||
if (client->IsConnectedToEndpoint(connection_request.endpoint_id())) {
|
||||
NEARBY_LOGS(ERROR) << "Incoming connection on medium "
|
||||
LOG(ERROR) << "Incoming connection on medium "
|
||||
<< location::nearby::proto::connections::Medium_Name(
|
||||
channel->GetMedium())
|
||||
<< " was denied because we're "
|
||||
@@ -1974,7 +1974,7 @@ Exception BasePcpHandler::OnIncomingConnection(
|
||||
// listen to them.
|
||||
if (client->ShouldEnforceTopologyConstraints() &&
|
||||
!CanReceiveIncomingConnection(client)) {
|
||||
NEARBY_LOGS(ERROR) << "Incoming connections are currently disallowed.";
|
||||
LOG(ERROR) << "Incoming connections are currently disallowed.";
|
||||
return {Exception::kIo};
|
||||
}
|
||||
|
||||
@@ -1988,7 +1988,7 @@ Exception BasePcpHandler::OnIncomingConnection(
|
||||
// Legacy clients will be treated as Connections devices.
|
||||
: NearbyDevice::Type::kConnectionsDevice;
|
||||
if (listening_device_type != incoming_type) {
|
||||
NEARBY_LOGS(WARNING) << "Device requesting a connection is the wrong type."
|
||||
LOG(WARNING) << "Device requesting a connection is the wrong type."
|
||||
<< "Expected type: " << listening_device_type
|
||||
<< ", got type: " << incoming_type;
|
||||
return {Exception::kIo};
|
||||
@@ -2019,7 +2019,7 @@ Exception BasePcpHandler::OnIncomingConnection(
|
||||
connection_options.keep_alive_timeout_millis == 0 ||
|
||||
connection_options.keep_alive_interval_millis >=
|
||||
connection_options.keep_alive_timeout_millis) {
|
||||
NEARBY_LOGS(WARNING)
|
||||
LOG(WARNING)
|
||||
<< "Incoming connection has wrong keep-alive frame interval="
|
||||
<< connection_options.keep_alive_interval_millis
|
||||
<< ", timeout=" << connection_options.keep_alive_timeout_millis
|
||||
@@ -2040,7 +2040,7 @@ Exception BasePcpHandler::OnIncomingConnection(
|
||||
connection_info.medium_role.emplace(medium_metadata.medium_role());
|
||||
}
|
||||
if (medium_metadata.has_medium_role()) {
|
||||
NEARBY_LOGS(INFO)
|
||||
LOG(INFO)
|
||||
<< connection_request.endpoint_id()
|
||||
<< "'s WIFI information: is_supports_5_ghz="
|
||||
<< connection_info.supports_5_ghz << "; bssid=" << connection_info.bssid
|
||||
@@ -2064,7 +2064,7 @@ Exception BasePcpHandler::OnIncomingConnection(
|
||||
<< "; support_awdl_subscriber="
|
||||
<< medium_metadata.medium_role().support_awdl_subscriber();
|
||||
} else {
|
||||
NEARBY_LOGS(INFO) << connection_request.endpoint_id()
|
||||
LOG(INFO) << connection_request.endpoint_id()
|
||||
<< "'s WIFI information: is_supports_5_ghz="
|
||||
<< connection_info.supports_5_ghz
|
||||
<< "; bssid=" << connection_info.bssid
|
||||
@@ -2113,7 +2113,7 @@ bool BasePcpHandler::BreakTie(ClientProxy* client,
|
||||
if (it != pending_connections_.end()) {
|
||||
BasePcpHandler::PendingConnectionInfo& pending_connection_info = it->second;
|
||||
|
||||
NEARBY_LOGS(INFO)
|
||||
LOG(INFO)
|
||||
<< "In onIncomingConnection("
|
||||
<< location::nearby::proto::connections::Medium_Name(
|
||||
endpoint_channel->GetMedium())
|
||||
@@ -2129,7 +2129,7 @@ bool BasePcpHandler::BreakTie(ClientProxy* client,
|
||||
// Our connection won! Clean up their connection.
|
||||
endpoint_channel->Close();
|
||||
|
||||
NEARBY_LOGS(INFO) << "In onIncomingConnection("
|
||||
LOG(INFO) << "In onIncomingConnection("
|
||||
<< location::nearby::proto::connections::Medium_Name(
|
||||
endpoint_channel->GetMedium())
|
||||
<< ") for client=" << client->GetClientId()
|
||||
@@ -2140,7 +2140,7 @@ bool BasePcpHandler::BreakTie(ClientProxy* client,
|
||||
// Aw, we lost. Clean up our connection, and then we'll let their
|
||||
// connection continue on.
|
||||
ProcessTieBreakLoss(client, endpoint_id, &pending_connection_info);
|
||||
NEARBY_LOGS(INFO)
|
||||
LOG(INFO)
|
||||
<< "In onIncomingConnection("
|
||||
<< location::nearby::proto::connections::Medium_Name(
|
||||
endpoint_channel->GetMedium())
|
||||
@@ -2153,7 +2153,7 @@ bool BasePcpHandler::BreakTie(ClientProxy* client,
|
||||
endpoint_channel->Close();
|
||||
ProcessTieBreakLoss(client, endpoint_id, &pending_connection_info);
|
||||
|
||||
NEARBY_LOGS(INFO)
|
||||
LOG(INFO)
|
||||
<< "In onIncomingConnection("
|
||||
<< location::nearby::proto::connections::Medium_Name(
|
||||
endpoint_channel->GetMedium())
|
||||
@@ -2173,7 +2173,7 @@ Status BasePcpHandler::VerifyConnectionRequest(const std::string& endpoint_id,
|
||||
// If we already have a pending connection, then we shouldn't allow any
|
||||
// more outgoing connections to this endpoint.
|
||||
if (pending_connections_.count(endpoint_id)) {
|
||||
NEARBY_LOGS(INFO)
|
||||
LOG(INFO)
|
||||
<< "In requestConnection(), connection requested with "
|
||||
"endpoint(id="
|
||||
<< endpoint_id
|
||||
@@ -2185,7 +2185,7 @@ Status BasePcpHandler::VerifyConnectionRequest(const std::string& endpoint_id,
|
||||
// listen to them.
|
||||
if (client->ShouldEnforceTopologyConstraints() &&
|
||||
!CanSendOutgoingConnection(client)) {
|
||||
NEARBY_LOGS(INFO) << "In requestConnection(), client="
|
||||
LOG(INFO) << "In requestConnection(), client="
|
||||
<< client->GetClientId()
|
||||
<< " attempted a connection with endpoint(id="
|
||||
<< endpoint_id
|
||||
@@ -2227,7 +2227,7 @@ bool BasePcpHandler::AppendRemoteBluetoothMacAddressEndpoint(
|
||||
for (auto item = it.first; item != it.second; item++) {
|
||||
if (item->second->medium ==
|
||||
location::nearby::proto::connections::Medium::BLUETOOTH) {
|
||||
NEARBY_LOGS(INFO)
|
||||
LOG(INFO)
|
||||
<< "Cannot append remote Bluetooth MAC Address endpoint, because "
|
||||
"the endpoint has already been found over Bluetooth ["
|
||||
<< remote_bluetooth_mac_address << "]";
|
||||
@@ -2238,7 +2238,7 @@ bool BasePcpHandler::AppendRemoteBluetoothMacAddressEndpoint(
|
||||
auto remote_bluetooth_device =
|
||||
GetRemoteBluetoothDevice(remote_bluetooth_mac_address);
|
||||
if (!remote_bluetooth_device.IsValid()) {
|
||||
NEARBY_LOGS(INFO)
|
||||
LOG(INFO)
|
||||
<< "Cannot append remote Bluetooth MAC Address endpoint, because a "
|
||||
"valid Bluetooth device could not be derived ["
|
||||
<< remote_bluetooth_mac_address << "]";
|
||||
@@ -2297,11 +2297,11 @@ void BasePcpHandler::EvaluateConnectionResult(ClientProxy* client,
|
||||
bool is_connection_accepted = client->IsConnectionAccepted(endpoint_id);
|
||||
if (!is_connection_accepted && !client->IsConnectionRejected(endpoint_id)) {
|
||||
if (!client->HasLocalEndpointResponded(endpoint_id)) {
|
||||
NEARBY_LOGS(INFO)
|
||||
LOG(INFO)
|
||||
<< "ConnectionResult: local client did not respond; endpoint_id="
|
||||
<< endpoint_id;
|
||||
} else if (!client->HasRemoteEndpointResponded(endpoint_id)) {
|
||||
NEARBY_LOGS(INFO)
|
||||
LOG(INFO)
|
||||
<< "ConnectionResult: remote client did not respond; endpoint_id="
|
||||
<< endpoint_id;
|
||||
}
|
||||
@@ -2312,7 +2312,7 @@ void BasePcpHandler::EvaluateConnectionResult(ClientProxy* client,
|
||||
// no longer pending.
|
||||
auto it = pending_connections_.find(endpoint_id);
|
||||
if (it == pending_connections_.end()) {
|
||||
NEARBY_LOGS(INFO) << "No pending connection to evaluate; endpoint_id="
|
||||
LOG(INFO) << "No pending connection to evaluate; endpoint_id="
|
||||
<< endpoint_id;
|
||||
return;
|
||||
}
|
||||
@@ -2323,7 +2323,7 @@ void BasePcpHandler::EvaluateConnectionResult(ClientProxy* client,
|
||||
std::shared_ptr<EndpointChannel> endpint_channel =
|
||||
channel_manager_->GetChannelForEndpoint(endpoint_id);
|
||||
if (endpint_channel == nullptr) {
|
||||
NEARBY_LOGS(WARNING) << "No endpint channel for endpoint_id="
|
||||
LOG(WARNING) << "No endpint channel for endpoint_id="
|
||||
<< endpoint_id;
|
||||
return;
|
||||
}
|
||||
@@ -2332,7 +2332,7 @@ void BasePcpHandler::EvaluateConnectionResult(ClientProxy* client,
|
||||
|
||||
Status response_code;
|
||||
if (is_connection_accepted) {
|
||||
NEARBY_LOGS(INFO) << "Pending connection accepted; endpoint_id="
|
||||
LOG(INFO) << "Pending connection accepted; endpoint_id="
|
||||
<< endpoint_id;
|
||||
response_code = {Status::kSuccess};
|
||||
|
||||
@@ -2358,12 +2358,12 @@ void BasePcpHandler::EvaluateConnectionResult(ClientProxy* client,
|
||||
if (client->IsMultiplexSocketSupported(endpoint_id,
|
||||
channel->GetMedium())) {
|
||||
if (!channel->EnableMultiplexSocket()) {
|
||||
NEARBY_LOGS(INFO)
|
||||
LOG(INFO)
|
||||
<< "MultiplexSocket is not implemented for Medium: "
|
||||
<< location::nearby::proto::connections::Medium_Name(
|
||||
channel->GetMedium());
|
||||
} else {
|
||||
NEARBY_LOGS(INFO)
|
||||
LOG(INFO)
|
||||
<< "MultiplexSocket is supported for Medium: "
|
||||
<< location::nearby::proto::connections::Medium_Name(
|
||||
channel->GetMedium())
|
||||
@@ -2371,10 +2371,10 @@ void BasePcpHandler::EvaluateConnectionResult(ClientProxy* client,
|
||||
}
|
||||
}
|
||||
} else {
|
||||
NEARBY_LOGS(INFO) << "channel is null";
|
||||
LOG(INFO) << "channel is null";
|
||||
}
|
||||
} else {
|
||||
NEARBY_LOGS(INFO) << "Pending connection rejected; endpoint_id="
|
||||
LOG(INFO) << "Pending connection rejected; endpoint_id="
|
||||
<< endpoint_id;
|
||||
response_code = {Status::kConnectionRejected};
|
||||
}
|
||||
@@ -2418,7 +2418,7 @@ void BasePcpHandler::EvaluateConnectionResult(ClientProxy* client,
|
||||
}
|
||||
client->OnBandwidthChanged(endpoint_id, medium);
|
||||
|
||||
NEARBY_LOGS(INFO) << "Connection accepted on Medium:"
|
||||
LOG(INFO) << "Connection accepted on Medium:"
|
||||
<< location::nearby::proto::connections::Medium_Name(
|
||||
medium);
|
||||
|
||||
@@ -2517,7 +2517,7 @@ void BasePcpHandler::LogConnectionAttemptSuccess(
|
||||
connections_attempt_metadata_params->operation_result_code =
|
||||
OperationResultCode::DETAIL_SUCCESS;
|
||||
} else {
|
||||
NEARBY_LOGS(ERROR) << "PendingConnectionInfo channel is null for "
|
||||
LOG(ERROR) << "PendingConnectionInfo channel is null for "
|
||||
"LogConnectionAttemptSuccess. Bail out.";
|
||||
return;
|
||||
}
|
||||
@@ -2562,7 +2562,7 @@ void BasePcpHandler::PendingConnectionInfo::SetCryptoContext(
|
||||
BasePcpHandler::PendingConnectionInfo::~PendingConnectionInfo() {
|
||||
auto future_status = result.lock();
|
||||
if (future_status && !future_status->IsSet()) {
|
||||
NEARBY_LOGS(INFO) << "Future was not set; destroying info";
|
||||
LOG(INFO) << "Future was not set; destroying info";
|
||||
future_status->Set({Status::kError});
|
||||
}
|
||||
|
||||
|
||||
@@ -681,7 +681,7 @@ class BasePcpHandlerTest
|
||||
EXPECT_EQ(pcp_handler->RequestConnection(client, endpoint_id, info,
|
||||
connection_options),
|
||||
expected_result);
|
||||
NEARBY_LOGS(INFO) << "Stopping Encryption Runner";
|
||||
LOG(INFO) << "Stopping Encryption Runner";
|
||||
}
|
||||
|
||||
void RequestConnectionV3(
|
||||
@@ -800,14 +800,14 @@ class BasePcpHandlerTest
|
||||
MockPcpHandler::DiscoveredEndpoint* endpoint) {
|
||||
if (endpoint->medium ==
|
||||
location::nearby::proto::connections::WIFI_LAN) {
|
||||
NEARBY_LOGS(INFO) << "Connect with Medium WIFI_LAN failed.";
|
||||
LOG(INFO) << "Connect with Medium WIFI_LAN failed.";
|
||||
return MockPcpHandler::ConnectImplResult{
|
||||
.medium = endpoint->medium,
|
||||
.status = {Status::kError},
|
||||
.endpoint_channel = nullptr,
|
||||
};
|
||||
} else {
|
||||
NEARBY_LOGS(INFO)
|
||||
LOG(INFO)
|
||||
<< "Connect with Medium: "
|
||||
<< location::nearby::proto::connections::Medium_Name(
|
||||
endpoint->medium);
|
||||
@@ -844,7 +844,7 @@ class BasePcpHandlerTest
|
||||
EXPECT_EQ(pcp_handler->RequestConnection(client, endpoint_id, info,
|
||||
connection_options),
|
||||
expected_result);
|
||||
NEARBY_LOGS(INFO) << "Stopping Encryption Runner";
|
||||
LOG(INFO) << "Stopping Encryption Runner";
|
||||
}
|
||||
MockConnectionListener mock_connection_listener_;
|
||||
MockDiscoveryListener mock_discovery_listener_;
|
||||
@@ -1126,7 +1126,7 @@ TEST_F(BasePcpHandlerTest, WifiMediumFailFallBackToBT) {
|
||||
EXPECT_CALL(mock_connection_listener_.rejected_cb, Call).Times(AtLeast(0));
|
||||
RequestConnectionWifiLanFail(endpoint_id, std::move(channel_a),
|
||||
channel_b.get(), &client, &pcp_handler);
|
||||
NEARBY_LOGS(INFO) << "RequestConnection complete";
|
||||
LOG(INFO) << "RequestConnection complete";
|
||||
channel_b->Close();
|
||||
bwu.Shutdown();
|
||||
pcp_handler.DisconnectFromEndpointManager();
|
||||
@@ -1152,7 +1152,7 @@ TEST_P(BasePcpHandlerTest, RequestConnectionChangesState) {
|
||||
EXPECT_CALL(mock_connection_listener_.rejected_cb, Call).Times(AtLeast(0));
|
||||
RequestConnection("1234", std::move(channel_a), channel_b.get(), &client,
|
||||
&pcp_handler, connect_medium);
|
||||
NEARBY_LOGS(INFO) << "RequestConnection complete";
|
||||
LOG(INFO) << "RequestConnection complete";
|
||||
channel_b->Close();
|
||||
bwu.Shutdown();
|
||||
pcp_handler.DisconnectFromEndpointManager();
|
||||
@@ -1197,7 +1197,7 @@ TEST_P(BasePcpHandlerTest, CanRequestConnectionPresence) {
|
||||
EXPECT_CALL(mock_connection_listener_.rejected_cb, Call).Times(AtLeast(0));
|
||||
RequestConnection("1234", std::move(channel_a), channel_b.get(), &client,
|
||||
&pcp_handler, connect_medium);
|
||||
NEARBY_LOGS(INFO) << "RequestConnection complete";
|
||||
LOG(INFO) << "RequestConnection complete";
|
||||
channel_b->Close();
|
||||
bwu.Shutdown();
|
||||
pcp_handler.DisconnectFromEndpointManager();
|
||||
@@ -1227,7 +1227,7 @@ TEST_P(BasePcpHandlerTest, CanRequestConnectionLegacy) {
|
||||
EXPECT_CALL(mock_connection_listener_.rejected_cb, Call).Times(AtLeast(0));
|
||||
RequestConnection("1234", std::move(channel_a), channel_b.get(), &client,
|
||||
&pcp_handler, connect_medium);
|
||||
NEARBY_LOGS(INFO) << "RequestConnection complete";
|
||||
LOG(INFO) << "RequestConnection complete";
|
||||
channel_b->Close();
|
||||
bwu.Shutdown();
|
||||
pcp_handler.DisconnectFromEndpointManager();
|
||||
@@ -1258,7 +1258,7 @@ TEST_P(BasePcpHandlerTest, RequestConnectionV3) {
|
||||
EXPECT_CALL(mock_connection_listener_.rejected_cb, Call).Times(AtLeast(0));
|
||||
RequestConnectionV3(mock_device_, std::move(channel_a), channel_b.get(),
|
||||
&client, &pcp_handler, connect_medium, &provider);
|
||||
NEARBY_LOGS(INFO) << "RequestConnectionV3 complete";
|
||||
LOG(INFO) << "RequestConnectionV3 complete";
|
||||
channel_b->Close();
|
||||
bwu.Shutdown();
|
||||
pcp_handler.DisconnectFromEndpointManager();
|
||||
@@ -1293,7 +1293,7 @@ TEST_P(BasePcpHandlerTest, RequestConnectionV3_AuthenticationFailure) {
|
||||
&pcp_handler, connect_medium, &provider, /*flag=*/nullptr,
|
||||
/*expected_result=*/{Status::kSuccess},
|
||||
/*expected_authentication_status=*/AuthenticationStatus::kFailure);
|
||||
NEARBY_LOGS(INFO) << "RequestConnectionV3 complete";
|
||||
LOG(INFO) << "RequestConnectionV3 complete";
|
||||
channel_b->Close();
|
||||
bwu.Shutdown();
|
||||
pcp_handler.DisconnectFromEndpointManager();
|
||||
@@ -1369,7 +1369,7 @@ TEST_P(BasePcpHandlerTest, RequestConnectionV3_ConnectImplFailure) {
|
||||
EXPECT_EQ(pcp_handler.RequestConnectionV3(&client, mock_device_, info,
|
||||
connection_options),
|
||||
expected_result);
|
||||
NEARBY_LOGS(INFO) << "RequestConnectionV3 complete";
|
||||
LOG(INFO) << "RequestConnectionV3 complete";
|
||||
channel_b->Close();
|
||||
bwu.Shutdown();
|
||||
pcp_handler.DisconnectFromEndpointManager();
|
||||
@@ -1444,7 +1444,7 @@ TEST_P(BasePcpHandlerTest, RequestConnection_ConnectImplFailure) {
|
||||
EXPECT_EQ(pcp_handler.RequestConnection(&client, std::string(kTestEndpointId),
|
||||
info, connection_options),
|
||||
expected_result);
|
||||
NEARBY_LOGS(INFO) << "RequestConnection complete";
|
||||
LOG(INFO) << "RequestConnection complete";
|
||||
channel_b->Close();
|
||||
bwu.Shutdown();
|
||||
pcp_handler.DisconnectFromEndpointManager();
|
||||
@@ -1472,7 +1472,7 @@ TEST_P(BasePcpHandlerTest, IoError_RequestConnectionV3Fails) {
|
||||
RequestConnectionV3(mock_device_, std::move(channel_a), channel_b.get(),
|
||||
&client, &pcp_handler, connect_medium, nullptr, nullptr,
|
||||
{Status::kEndpointIoError});
|
||||
NEARBY_LOGS(INFO) << "RequestConnectionV3 complete";
|
||||
LOG(INFO) << "RequestConnectionV3 complete";
|
||||
channel_b->Close();
|
||||
bwu.Shutdown();
|
||||
pcp_handler.DisconnectFromEndpointManager();
|
||||
@@ -1501,7 +1501,7 @@ TEST_P(BasePcpHandlerTest, IoError_RequestConnectionFails) {
|
||||
RequestConnection(endpoint_id, std::move(channel_a), channel_b.get(), &client,
|
||||
&pcp_handler, connect_medium, nullptr,
|
||||
{Status::kEndpointIoError});
|
||||
NEARBY_LOGS(INFO) << "RequestConnection complete";
|
||||
LOG(INFO) << "RequestConnection complete";
|
||||
channel_b->Close();
|
||||
bwu.Shutdown();
|
||||
pcp_handler.DisconnectFromEndpointManager();
|
||||
@@ -1527,11 +1527,11 @@ TEST_P(BasePcpHandlerTest, AcceptConnectionChangesState) {
|
||||
EXPECT_CALL(*channel_b, CloseImpl).Times(1);
|
||||
RequestConnection(endpoint_id, std::move(channel_a), channel_b.get(), &client,
|
||||
&pcp_handler, connect_medium);
|
||||
NEARBY_LOGS(INFO) << "Attempting to accept connection: id=" << endpoint_id;
|
||||
LOG(INFO) << "Attempting to accept connection: id=" << endpoint_id;
|
||||
EXPECT_EQ(pcp_handler.AcceptConnection(&client, endpoint_id, {}),
|
||||
Status{Status::kSuccess});
|
||||
EXPECT_CALL(mock_connection_listener_.rejected_cb, Call).Times(AtLeast(0));
|
||||
NEARBY_LOGS(INFO) << "Closing connection: id=" << endpoint_id;
|
||||
LOG(INFO) << "Closing connection: id=" << endpoint_id;
|
||||
channel_b->Close();
|
||||
bwu.Shutdown();
|
||||
pcp_handler.DisconnectFromEndpointManager();
|
||||
@@ -1555,10 +1555,10 @@ TEST_P(BasePcpHandlerTest, RejectConnectionChangesState) {
|
||||
EXPECT_CALL(mock_connection_listener_.rejected_cb, Call).Times(1);
|
||||
RequestConnection(endpoint_id, std::move(channel_pair.first), channel_b.get(),
|
||||
&client, &pcp_handler, connect_medium);
|
||||
NEARBY_LOGS(INFO) << "Attempting to reject connection: id=" << endpoint_id;
|
||||
LOG(INFO) << "Attempting to reject connection: id=" << endpoint_id;
|
||||
EXPECT_EQ(pcp_handler.RejectConnection(&client, endpoint_id),
|
||||
Status{Status::kSuccess});
|
||||
NEARBY_LOGS(INFO) << "Closing connection: id=" << endpoint_id;
|
||||
LOG(INFO) << "Closing connection: id=" << endpoint_id;
|
||||
channel_b->Close();
|
||||
bwu.Shutdown();
|
||||
pcp_handler.DisconnectFromEndpointManager();
|
||||
@@ -1585,20 +1585,20 @@ TEST_P(BasePcpHandlerTest, OnIncomingFrameChangesState) {
|
||||
EXPECT_CALL(*channel_b, CloseImpl).Times(1);
|
||||
RequestConnection(endpoint_id, std::move(channel_a), channel_b.get(), &client,
|
||||
&pcp_handler, connect_medium);
|
||||
NEARBY_LOGS(INFO) << "Attempting to accept connection: id=" << endpoint_id;
|
||||
LOG(INFO) << "Attempting to accept connection: id=" << endpoint_id;
|
||||
EXPECT_CALL(mock_connection_listener_.accepted_cb, Call).Times(1);
|
||||
EXPECT_CALL(mock_connection_listener_.disconnected_cb, Call)
|
||||
.Times(AtLeast(0));
|
||||
EXPECT_EQ(pcp_handler.AcceptConnection(&client, endpoint_id, {}),
|
||||
Status{Status::kSuccess});
|
||||
NEARBY_LOGS(INFO) << "Simulating remote accept: id=" << endpoint_id;
|
||||
LOG(INFO) << "Simulating remote accept: id=" << endpoint_id;
|
||||
OsInfo os_info;
|
||||
auto frame = parser::FromBytes(parser::ForConnectionResponse(
|
||||
Status::kSuccess, os_info, /*multiplex_socket_bitmask=*/0));
|
||||
EXPECT_CALL(mock_connection_listener_.bandwidth_changed_cb, Call).Times(1);
|
||||
pcp_handler.OnIncomingFrame(frame.result(), endpoint_id, &client,
|
||||
connect_medium, packet_meta_data);
|
||||
NEARBY_LOGS(INFO) << "Closing connection: id=" << endpoint_id;
|
||||
LOG(INFO) << "Closing connection: id=" << endpoint_id;
|
||||
channel_b->Close();
|
||||
bwu.Shutdown();
|
||||
pcp_handler.DisconnectFromEndpointManager();
|
||||
@@ -1628,11 +1628,11 @@ TEST_P(BasePcpHandlerTest, DestructorIsCalledOnProtocolEndpoint) {
|
||||
RequestConnection(endpoint_id, std::move(channel_a), channel_b.get(),
|
||||
&client, &pcp_handler, connect_medium, &destroyed_flag);
|
||||
mediums_count = mediums.size();
|
||||
NEARBY_LOGS(INFO) << "Attempting to accept connection: id=" << endpoint_id;
|
||||
LOG(INFO) << "Attempting to accept connection: id=" << endpoint_id;
|
||||
EXPECT_EQ(pcp_handler.AcceptConnection(&client, endpoint_id, {}),
|
||||
Status{Status::kSuccess});
|
||||
EXPECT_CALL(mock_connection_listener_.rejected_cb, Call).Times(AtLeast(0));
|
||||
NEARBY_LOGS(INFO) << "Closing connection: id=" << endpoint_id;
|
||||
LOG(INFO) << "Closing connection: id=" << endpoint_id;
|
||||
channel_b->Close();
|
||||
bwu.Shutdown();
|
||||
pcp_handler.DisconnectFromEndpointManager();
|
||||
@@ -1672,7 +1672,7 @@ TEST_P(BasePcpHandlerTest, MultipleMediumsProduceSingleEndpointLostEvent) {
|
||||
&client, &pcp_handler, connect_medium, &destroyed_flag);
|
||||
auto allowed_mediums = pcp_handler.GetDiscoveryMediums(&client);
|
||||
mediums_count = allowed_mediums.size();
|
||||
NEARBY_LOGS(INFO) << "Attempting to accept connection: id=" << endpoint_id;
|
||||
LOG(INFO) << "Attempting to accept connection: id=" << endpoint_id;
|
||||
EXPECT_EQ(pcp_handler.AcceptConnection(&client, endpoint_id, {}),
|
||||
Status{Status::kSuccess});
|
||||
EXPECT_CALL(mock_connection_listener_.rejected_cb, Call).Times(AtLeast(0));
|
||||
@@ -1685,7 +1685,7 @@ TEST_P(BasePcpHandlerTest, MultipleMediumsProduceSingleEndpointLostEvent) {
|
||||
}
|
||||
EXPECT_EQ(pcp_handler.GetDiscoveredEndpoint(endpoint_id), nullptr);
|
||||
EXPECT_FALSE(client.IsConnectedToEndpoint(endpoint_id));
|
||||
NEARBY_LOGS(INFO) << "Closing connection: id=" << endpoint_id;
|
||||
LOG(INFO) << "Closing connection: id=" << endpoint_id;
|
||||
channel_b->Close();
|
||||
bwu.Shutdown();
|
||||
pcp_handler.DisconnectFromEndpointManager();
|
||||
|
||||
@@ -57,7 +57,7 @@ BluetoothBwuHandler::CreateUpgradedEndpointChannel(
|
||||
upgrade_path_info.bluetooth_credentials();
|
||||
if (!bluetooth_credentials.has_service_name() ||
|
||||
!bluetooth_credentials.has_mac_address()) {
|
||||
NEARBY_LOGS(ERROR)
|
||||
LOG(ERROR)
|
||||
<< "BluetoothBwuHandler failed to parse UpgradePathInfo.";
|
||||
return {
|
||||
Error(OperationResultCode::CONNECTIVITY_BLUETOOTH_INVALID_CREDENTIAL)};
|
||||
@@ -66,14 +66,14 @@ BluetoothBwuHandler::CreateUpgradedEndpointChannel(
|
||||
const std::string& service_name = bluetooth_credentials.service_name();
|
||||
const std::string& mac_address = bluetooth_credentials.mac_address();
|
||||
|
||||
NEARBY_VLOG(1) << "BluetoothBwuHandler is attempting to connect to "
|
||||
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()) {
|
||||
NEARBY_LOGS(ERROR)
|
||||
LOG(ERROR)
|
||||
<< "BluetoothBwuHandler failed to derive a valid Bluetooth device "
|
||||
"from the MAC address ("
|
||||
<< mac_address << ") for endpoint " << endpoint_id;
|
||||
@@ -84,14 +84,14 @@ BluetoothBwuHandler::CreateUpgradedEndpointChannel(
|
||||
ErrorOr<BluetoothSocket> socket_result = bluetooth_medium_.Connect(
|
||||
device, service_id, client->GetCancellationFlag(endpoint_id));
|
||||
if (socket_result.has_error()) {
|
||||
NEARBY_LOGS(ERROR)
|
||||
LOG(ERROR)
|
||||
<< "BluetoothBwuHandler failed to connect to the Bluetooth device ("
|
||||
<< service_name << ", " << mac_address << ") for endpoint "
|
||||
<< endpoint_id << " and service ID " << service_id;
|
||||
return {Error(socket_result.error().operation_result_code().value())};
|
||||
}
|
||||
|
||||
NEARBY_VLOG(1)
|
||||
VLOG(1)
|
||||
<< "BluetoothBwuHandler successfully connected to Bluetooth device ("
|
||||
<< service_id << ", " << mac_address << ") while upgrading endpoint "
|
||||
<< endpoint_id;
|
||||
@@ -99,7 +99,7 @@ BluetoothBwuHandler::CreateUpgradedEndpointChannel(
|
||||
auto channel = std::make_unique<BluetoothEndpointChannel>(
|
||||
service_id, /*channel_name=*/service_id, socket_result.value());
|
||||
if (channel == nullptr) {
|
||||
NEARBY_LOGS(ERROR)
|
||||
LOG(ERROR)
|
||||
<< "BluetoothBwuHandler failed to create Bluetooth endpoint "
|
||||
"channel to the Bluetooth device ("
|
||||
<< service_name << ", " << mac_address << ") for endpoint "
|
||||
@@ -118,7 +118,7 @@ ByteArray BluetoothBwuHandler::HandleInitializeUpgradedMediumForEndpoint(
|
||||
const std::string& endpoint_id) {
|
||||
std::string mac_address = bluetooth_medium_.GetMacAddress();
|
||||
if (mac_address.empty()) {
|
||||
NEARBY_LOGS(ERROR) << "BluetoothBwuHandler couldn't initiate the "
|
||||
LOG(ERROR) << "BluetoothBwuHandler couldn't initiate the "
|
||||
"BLUETOOTH upgrade for service ID "
|
||||
<< upgrade_service_id << " and endpoint " << endpoint_id
|
||||
<< " because MAC address is empty.";
|
||||
@@ -131,7 +131,7 @@ ByteArray BluetoothBwuHandler::HandleInitializeUpgradedMediumForEndpoint(
|
||||
absl::bind_front(
|
||||
&BluetoothBwuHandler::OnIncomingBluetoothConnection, this,
|
||||
client))) {
|
||||
NEARBY_LOGS(ERROR) << "BluetoothBwuHandler couldn't initiate the "
|
||||
LOG(ERROR) << "BluetoothBwuHandler couldn't initiate the "
|
||||
"BLUETOOTH upgrade for endpoint "
|
||||
<< endpoint_id
|
||||
<< " because it failed to start listening for "
|
||||
@@ -139,7 +139,7 @@ ByteArray BluetoothBwuHandler::HandleInitializeUpgradedMediumForEndpoint(
|
||||
|
||||
return {};
|
||||
}
|
||||
NEARBY_VLOG(1)
|
||||
VLOG(1)
|
||||
<< "BluetoothBwuHandler successfully started listening for incoming "
|
||||
"Bluetooth connections on service_id="
|
||||
<< upgrade_service_id << " while upgrading endpoint " << endpoint_id;
|
||||
@@ -151,7 +151,7 @@ ByteArray BluetoothBwuHandler::HandleInitializeUpgradedMediumForEndpoint(
|
||||
void BluetoothBwuHandler::HandleRevertInitiatorStateForService(
|
||||
const std::string& upgrade_service_id) {
|
||||
bluetooth_medium_.StopAcceptingConnections(upgrade_service_id);
|
||||
NEARBY_LOGS(INFO)
|
||||
LOG(INFO)
|
||||
<< "BluetoothBwuHandler successfully reverted all Bluetooth state.";
|
||||
}
|
||||
|
||||
|
||||
@@ -75,7 +75,7 @@ TEST_F(BluetoothBwuTest, SoftAPBWUInit_STACreateEndpointChannel) {
|
||||
mediums_1, [&](ClientProxy* client,
|
||||
std::unique_ptr<BwuHandler::IncomingSocketConnection>
|
||||
mutable_connection) {
|
||||
NEARBY_LOGS(WARNING) << "Server socket connection accept call back";
|
||||
LOG(WARNING) << "Server socket connection accept call back";
|
||||
accept_latch.CountDown();
|
||||
EXPECT_TRUE(end_latch.Await(kWaitDuration).result());
|
||||
});
|
||||
|
||||
@@ -125,7 +125,7 @@ BwuManager::BwuManager(
|
||||
}
|
||||
|
||||
BwuManager::~BwuManager() {
|
||||
NEARBY_LOGS(INFO) << "BwuManager going down";
|
||||
LOG(INFO) << "BwuManager going down";
|
||||
Shutdown();
|
||||
}
|
||||
|
||||
@@ -176,7 +176,7 @@ void BwuManager::InitBwuHandlers() {
|
||||
}
|
||||
|
||||
void BwuManager::Shutdown() {
|
||||
NEARBY_LOGS(INFO) << "Initiating shutdown of BwuManager.";
|
||||
LOG(INFO) << "Initiating shutdown of BwuManager.";
|
||||
|
||||
endpoint_manager_->UnregisterFrameProcessor(
|
||||
V1Frame::BANDWIDTH_UPGRADE_NEGOTIATION, this);
|
||||
@@ -201,7 +201,7 @@ void BwuManager::Shutdown() {
|
||||
}
|
||||
handlers_.clear();
|
||||
|
||||
NEARBY_LOGS(INFO) << "BwuManager has shut down.";
|
||||
LOG(INFO) << "BwuManager has shut down.";
|
||||
}
|
||||
|
||||
void BwuManager::MakeSingleThreadedForTesting() {
|
||||
@@ -232,14 +232,14 @@ void BwuManager::InitiateBwuForEndpoint(ClientProxy* client,
|
||||
|
||||
RunOnBwuManagerThread("bwu-init", [this, client, endpoint_id,
|
||||
proposed_medium]() {
|
||||
NEARBY_LOGS(INFO) << "InitiateBwuForEndpoint for endpoint " << endpoint_id
|
||||
LOG(INFO) << "InitiateBwuForEndpoint for endpoint " << endpoint_id
|
||||
<< " with medium "
|
||||
<< location::nearby::proto::connections::Medium_Name(
|
||||
proposed_medium);
|
||||
|
||||
if (channel_manager_->isWifiLanConnected() &&
|
||||
(proposed_medium == Medium::WIFI_HOTSPOT)) {
|
||||
NEARBY_LOGS(INFO)
|
||||
LOG(INFO)
|
||||
<< "Some endpoint is using WIFI_LAN and proposed upgrade medium is "
|
||||
"WIFI_HOTSPOT. Don't do the BWU because STA connecting to "
|
||||
"WIFI_HOTSPOT will destroy WIFI_LAN which will lead BWU fail and "
|
||||
@@ -250,7 +250,7 @@ void BwuManager::InitiateBwuForEndpoint(ClientProxy* client,
|
||||
SetBwuMediumForEndpoint(endpoint_id, proposed_medium);
|
||||
BwuHandler* handler = GetHandlerForMedium(proposed_medium);
|
||||
if (!handler) {
|
||||
NEARBY_LOGS(ERROR)
|
||||
LOG(ERROR)
|
||||
<< "BwuManager cannot initiate bandwidth upgrade for endpoint "
|
||||
<< endpoint_id
|
||||
<< " because the current BandwidthUpgradeMedium cannot be deduced.";
|
||||
@@ -258,7 +258,7 @@ void BwuManager::InitiateBwuForEndpoint(ClientProxy* client,
|
||||
}
|
||||
|
||||
if (in_progress_upgrades_.contains(endpoint_id)) {
|
||||
NEARBY_LOGS(INFO)
|
||||
LOG(INFO)
|
||||
<< "BwuManager is ignoring bandwidth upgrade for endpoint "
|
||||
<< endpoint_id
|
||||
<< " because we're already upgrading bandwidth for that endpoint.";
|
||||
@@ -281,7 +281,7 @@ void BwuManager::InitiateBwuForEndpoint(ClientProxy* client,
|
||||
// Bluetooth is the best medium, and we attempt to upgrade from Bluetooth
|
||||
// to Bluetooth.
|
||||
if (proposed_medium == channel_medium) {
|
||||
NEARBY_LOGS(INFO) << "BwuManager ignoring the upgrade for endpoint "
|
||||
LOG(INFO) << "BwuManager ignoring the upgrade for endpoint "
|
||||
<< endpoint_id
|
||||
<< " because it is already connected over medium "
|
||||
<< location::nearby::proto::connections::Medium_Name(
|
||||
@@ -295,7 +295,7 @@ void BwuManager::InitiateBwuForEndpoint(ClientProxy* client,
|
||||
client->GetConnectionToken(endpoint_id));
|
||||
|
||||
if (channel == nullptr) {
|
||||
NEARBY_LOGS(INFO)
|
||||
LOG(INFO)
|
||||
<< "BwuManager couldn't complete the upgrade for endpoint "
|
||||
<< endpoint_id
|
||||
<< " because it couldn't find an existing EndpointChannel for it.";
|
||||
@@ -329,7 +329,7 @@ void BwuManager::InitiateBwuForEndpoint(ClientProxy* client,
|
||||
CONNECTIVITY_GENERIC_WRITING_CHANNEL_IO_ERROR);
|
||||
return;
|
||||
}
|
||||
NEARBY_LOGS(INFO)
|
||||
LOG(INFO)
|
||||
<< "BwuManager successfully wrote the "
|
||||
"BANDWIDTH_UPGRADE_NEGOTIATION.UPGRADE_PATH_REQUEST "
|
||||
"OfflineFrame while upgrading endpoint "
|
||||
@@ -347,7 +347,7 @@ void BwuManager::InitiateBwuForEndpoint(ClientProxy* client,
|
||||
// Because we grab the endpointChannel first thing, it is possible the
|
||||
// endpointChannel is stale by the time we attempt to write over it.
|
||||
if (bytes.Empty()) {
|
||||
NEARBY_LOGS(ERROR)
|
||||
LOG(ERROR)
|
||||
<< "BwuManager couldn't complete the upgrade for endpoint "
|
||||
<< endpoint_id << " to medium "
|
||||
<< location::nearby::proto::connections::Medium_Name(proposed_medium)
|
||||
@@ -368,7 +368,7 @@ void BwuManager::InitiateBwuForEndpoint(ClientProxy* client,
|
||||
return;
|
||||
}
|
||||
if (!channel->Write(bytes).Ok()) {
|
||||
NEARBY_LOGS(ERROR)
|
||||
LOG(ERROR)
|
||||
<< "BwuManager couldn't complete the upgrade for endpoint "
|
||||
<< endpoint_id << " to medium "
|
||||
<< location::nearby::proto::connections::Medium_Name(proposed_medium)
|
||||
@@ -389,7 +389,7 @@ void BwuManager::InitiateBwuForEndpoint(ClientProxy* client,
|
||||
return;
|
||||
}
|
||||
|
||||
NEARBY_LOGS(INFO)
|
||||
LOG(INFO)
|
||||
<< "BwuManager successfully wrote the "
|
||||
"BWU_NEGOTIATION.UPGRADE_PATH_AVAILABLE OfflineFrame while "
|
||||
"upgrading endpoint "
|
||||
@@ -407,7 +407,7 @@ void BwuManager::OnIncomingFrame(OfflineFrame& frame,
|
||||
if (frame_type != V1Frame::BANDWIDTH_UPGRADE_NEGOTIATION) return;
|
||||
|
||||
auto bwu_frame = frame.v1().bandwidth_upgrade_negotiation();
|
||||
NEARBY_LOGS(INFO) << "OnIncomingFrame: bwu_frame="
|
||||
LOG(INFO) << "OnIncomingFrame: bwu_frame="
|
||||
<< BandwidthUpgradeNegotiationFrame::EventType_Name(
|
||||
bwu_frame.event_type())
|
||||
<< ", endpoint_id=" << endpoint_id << ", medium="
|
||||
@@ -434,7 +434,7 @@ void BwuManager::OnEndpointDisconnect(ClientProxy* client,
|
||||
const std::string& endpoint_id,
|
||||
CountDownLatch barrier,
|
||||
DisconnectionReason reason) {
|
||||
NEARBY_LOGS(INFO)
|
||||
LOG(INFO)
|
||||
<< "BwuManager has processed endpoint disconnection for endpoint "
|
||||
<< endpoint_id << " with reason " << DisconnectionReason_Name(reason);
|
||||
RunOnBwuManagerThread("bwu-on-endpoint-disconnect", [this, client, service_id,
|
||||
@@ -475,7 +475,7 @@ void BwuManager::RevertBwuMediumForEndpoint(const std::string& service_id,
|
||||
// If |support_multiple_bwu_mediums| is disabled, we take a less fine-grained
|
||||
// approach and revert the handler for _all_ endpoints.
|
||||
if (!FeatureFlags::GetInstance().GetFlags().support_multiple_bwu_mediums) {
|
||||
NEARBY_LOGS(INFO) << "Reverting medium "
|
||||
LOG(INFO) << "Reverting medium "
|
||||
<< location::nearby::proto::connections::Medium_Name(
|
||||
medium)
|
||||
<< " for all endpoints for service " << service_id;
|
||||
@@ -487,7 +487,7 @@ void BwuManager::RevertBwuMediumForEndpoint(const std::string& service_id,
|
||||
return;
|
||||
}
|
||||
|
||||
NEARBY_LOGS(INFO) << "Reverting medium "
|
||||
LOG(INFO) << "Reverting medium "
|
||||
<< location::nearby::proto::connections::Medium_Name(medium)
|
||||
<< " for service ID " << service_id << " and endpoint "
|
||||
<< endpoint_id;
|
||||
@@ -495,7 +495,7 @@ void BwuManager::RevertBwuMediumForEndpoint(const std::string& service_id,
|
||||
|
||||
BwuHandler* handler = GetHandlerForMedium(medium);
|
||||
if (!handler) {
|
||||
NEARBY_LOGS(INFO) << "No BWU handler can be found for "
|
||||
LOG(INFO) << "No BWU handler can be found for "
|
||||
<< location::nearby::proto::connections::Medium_Name(
|
||||
medium);
|
||||
return;
|
||||
@@ -554,12 +554,12 @@ BwuHandler* BwuManager::GetHandlerForMedium(Medium medium) const {
|
||||
void BwuManager::OnBwuNegotiationFrame(ClientProxy* client,
|
||||
const BwuNegotiationFrame frame,
|
||||
const std::string& endpoint_id) {
|
||||
NEARBY_LOGS(INFO) << "OnBwuNegotiationFrame: processing incoming "
|
||||
LOG(INFO) << "OnBwuNegotiationFrame: processing incoming "
|
||||
<< BwuNegotiationFrame::EventType_Name(frame.event_type())
|
||||
<< " frame for endpoint " << endpoint_id;
|
||||
|
||||
if (!client->IsConnectedToEndpoint(endpoint_id)) {
|
||||
NEARBY_LOGS(WARNING)
|
||||
LOG(WARNING)
|
||||
<< "BwuManager skips the process BANDWIDTH_UPGRADE_NEGOTIATION before "
|
||||
"PCP connected, "
|
||||
<< frame.event_type();
|
||||
@@ -593,7 +593,7 @@ void BwuManager::OnBwuNegotiationFrame(ClientProxy* client,
|
||||
ProcessSafeToClosePriorChannelEvent(client, endpoint_id);
|
||||
break;
|
||||
default:
|
||||
NEARBY_LOGS(WARNING)
|
||||
LOG(WARNING)
|
||||
<< "BwuManager can't process unknown incoming OfflineFrame of type "
|
||||
<< BandwidthUpgradeNegotiationFrame::EventType_Name(
|
||||
frame.event_type())
|
||||
@@ -605,7 +605,7 @@ void BwuManager::OnBwuNegotiationFrame(ClientProxy* client,
|
||||
void BwuManager::OnIncomingConnection(
|
||||
ClientProxy* client,
|
||||
std::unique_ptr<BwuHandler::IncomingSocketConnection> mutable_connection) {
|
||||
NEARBY_LOGS(INFO) << "BwuManager process incoming connection";
|
||||
LOG(INFO) << "BwuManager process incoming connection";
|
||||
std::shared_ptr<BwuHandler::IncomingSocketConnection> connection(
|
||||
mutable_connection.release());
|
||||
RunOnBwuManagerThread("bwu-on-incoming-connection", [this, client,
|
||||
@@ -613,7 +613,7 @@ void BwuManager::OnIncomingConnection(
|
||||
absl::Time connection_attempt_start_time = SystemClock::ElapsedRealtime();
|
||||
EndpointChannel* channel = connection->channel.get();
|
||||
if (channel == nullptr) {
|
||||
NEARBY_LOGS(ERROR)
|
||||
LOG(ERROR)
|
||||
<< "BwuManager failed to create new EndpointChannel for incoming "
|
||||
"socket.";
|
||||
connection->socket->Close();
|
||||
@@ -624,7 +624,7 @@ void BwuManager::OnIncomingConnection(
|
||||
return;
|
||||
}
|
||||
|
||||
NEARBY_VLOG(1) << "BwuManager successfully created new EndpointChannel for "
|
||||
VLOG(1) << "BwuManager successfully created new EndpointChannel for "
|
||||
"incoming socket";
|
||||
|
||||
ClientIntroduction introduction;
|
||||
@@ -632,7 +632,7 @@ void BwuManager::OnIncomingConnection(
|
||||
// This was never a fully EstablishedConnection, no need to provide a
|
||||
// closure reason.
|
||||
channel->Close();
|
||||
NEARBY_LOGS(ERROR)
|
||||
LOG(ERROR)
|
||||
<< "BwuManager failed to read "
|
||||
"BWU_NEGOTIATION.CLIENT_INTRODUCTION OfflineFrame from "
|
||||
"newly-created EndpointChannel "
|
||||
@@ -640,7 +640,7 @@ void BwuManager::OnIncomingConnection(
|
||||
return;
|
||||
}
|
||||
|
||||
NEARBY_VLOG(1) << "BwuManager successfully received "
|
||||
VLOG(1) << "BwuManager successfully received "
|
||||
"BWU_NEGOTIATION.CLIENT_INTRODUCTION "
|
||||
"OfflineFrame on EndpointChannel "
|
||||
<< channel->GetName();
|
||||
@@ -648,7 +648,7 @@ void BwuManager::OnIncomingConnection(
|
||||
if (!WriteClientIntroductionAckFrame(channel)) {
|
||||
// This was never a fully EstablishedConnection, no need to provide a
|
||||
// closure reason.
|
||||
NEARBY_LOGS(ERROR) << "BwuManager failed to write"
|
||||
LOG(ERROR) << "BwuManager failed to write"
|
||||
"BWU_NEGOTIATION.CLIENT_INTRODUCTION_ACK "
|
||||
"OfflineFrame on EndpointChannel "
|
||||
<< channel->GetName();
|
||||
@@ -656,7 +656,7 @@ void BwuManager::OnIncomingConnection(
|
||||
return;
|
||||
}
|
||||
|
||||
NEARBY_VLOG(1) << "BwuManager successfully wrote "
|
||||
VLOG(1) << "BwuManager successfully wrote "
|
||||
"BWU_NEGOTIATION.CLIENT_INTRODUCTION_ACK "
|
||||
"OfflineFrame on EndpointChannel "
|
||||
<< channel->GetName();
|
||||
@@ -715,7 +715,7 @@ void BwuManager::RunOnBwuManagerThread(const std::string& name,
|
||||
void BwuManager::RunUpgradeProtocol(
|
||||
ClientProxy* client, const std::string& endpoint_id,
|
||||
std::unique_ptr<EndpointChannel> new_channel, bool enable_encryption) {
|
||||
NEARBY_LOGS(INFO) << "RunUpgradeProtocol new channel @" << new_channel.get()
|
||||
LOG(INFO) << "RunUpgradeProtocol new channel @" << new_channel.get()
|
||||
<< " name: " << new_channel->GetName() << ", medium: "
|
||||
<< location::nearby::proto::connections::Medium_Name(
|
||||
new_channel->GetMedium());
|
||||
@@ -730,7 +730,7 @@ void BwuManager::RunUpgradeProtocol(
|
||||
new_channel->Pause();
|
||||
auto old_channel = channel_manager_->GetChannelForEndpoint(endpoint_id);
|
||||
if (!old_channel) {
|
||||
NEARBY_LOGS(INFO)
|
||||
LOG(INFO)
|
||||
<< "BwuManager didn't find a previous EndpointChannel for "
|
||||
<< endpoint_id
|
||||
<< " when registering the new EndpointChannel, short-circuiting the "
|
||||
@@ -748,7 +748,7 @@ void BwuManager::RunUpgradeProtocol(
|
||||
// this endpoint by telling the remote device that it will not receive any
|
||||
// more writes over that EndpointChannel.
|
||||
if (!old_channel->Write(parser::ForBwuLastWrite()).Ok()) {
|
||||
NEARBY_LOGS(ERROR)
|
||||
LOG(ERROR)
|
||||
<< "BwuManager failed to write "
|
||||
"BWU_NEGOTIATION.LAST_WRITE_TO_PRIOR_CHANNEL OfflineFrame to "
|
||||
"endpoint "
|
||||
@@ -759,7 +759,7 @@ void BwuManager::RunUpgradeProtocol(
|
||||
OperationResultCode::CONNECTIVITY_GENERIC_WRITING_CHANNEL_IO_ERROR);
|
||||
return;
|
||||
}
|
||||
NEARBY_VLOG(1) << "BwuManager successfully wrote "
|
||||
VLOG(1) << "BwuManager successfully wrote "
|
||||
"BWU_NEGOTIATION.LAST_WRITE_TO_PRIOR_CHANNEL "
|
||||
"OfflineFrame while upgrading endpoint "
|
||||
<< endpoint_id;
|
||||
@@ -784,7 +784,7 @@ void BwuManager::ProcessBwuPathAvailableEvent(
|
||||
const UpgradePathInfo& upgrade_path_info) {
|
||||
Medium upgrade_medium =
|
||||
parser::UpgradePathInfoMediumToMedium(upgrade_path_info.medium());
|
||||
NEARBY_LOGS(INFO) << "ProcessBwuPathAvailableEvent for endpoint "
|
||||
LOG(INFO) << "ProcessBwuPathAvailableEvent for endpoint "
|
||||
<< endpoint_id << " medium "
|
||||
<< location::nearby::proto::connections::Medium_Name(
|
||||
upgrade_medium);
|
||||
@@ -794,7 +794,7 @@ void BwuManager::ProcessBwuPathAvailableEvent(
|
||||
((upgrade_medium == Medium::WIFI_DIRECT) &&
|
||||
(client->GetLocalOsInfo().type() ==
|
||||
location::nearby::connections::OsInfo::WINDOWS)))) {
|
||||
NEARBY_LOGS(INFO)
|
||||
LOG(INFO)
|
||||
<< "Some endpoint is using WIFI_LAN and proposed upgrade medium is "
|
||||
<< location::nearby::proto::connections::Medium_Name(upgrade_medium)
|
||||
<< ". Don't do the BWU because this will destroy WIFI_LAN which will "
|
||||
@@ -817,13 +817,13 @@ void BwuManager::ProcessBwuPathAvailableEvent(
|
||||
}
|
||||
}
|
||||
if (abort_bwu) {
|
||||
NEARBY_LOGS(INFO)
|
||||
LOG(INFO)
|
||||
<< "ProcessBandwidthUpgradePathAvailableEvent ignored by Advertiser";
|
||||
return;
|
||||
}
|
||||
|
||||
if (in_progress_upgrades_.contains(endpoint_id)) {
|
||||
NEARBY_LOGS(ERROR)
|
||||
LOG(ERROR)
|
||||
<< "BwuManager received a duplicate bandwidth upgrade for endpoint "
|
||||
<< endpoint_id
|
||||
<< ". We're out of sync with the remote device and cannot recover; "
|
||||
@@ -854,7 +854,7 @@ void BwuManager::ProcessBwuPathAvailableEvent(
|
||||
}
|
||||
// Check for the correct medium so we don't process an incorrect OfflineFrame.
|
||||
if (upgrade_medium != GetBwuMediumForEndpoint(endpoint_id)) {
|
||||
NEARBY_LOGS(INFO) << "Medium not matching";
|
||||
LOG(INFO) << "Medium not matching";
|
||||
RunUpgradeFailedProtocol(client, endpoint_id, upgrade_path_info);
|
||||
return;
|
||||
}
|
||||
@@ -917,7 +917,7 @@ void BwuManager::ProcessBwuPathAvailableEvent(
|
||||
}
|
||||
|
||||
if (channel == nullptr) {
|
||||
NEARBY_LOGS(INFO) << "Failed to get new channel.";
|
||||
LOG(INFO) << "Failed to get new channel.";
|
||||
RunUpgradeFailedProtocol(client, endpoint_id, upgrade_path_info);
|
||||
return;
|
||||
}
|
||||
@@ -934,7 +934,7 @@ BwuManager::ProcessBwuPathAvailableEventInternal(
|
||||
Medium medium =
|
||||
parser::UpgradePathInfoMediumToMedium(upgrade_path_info.medium());
|
||||
if (medium != GetBwuMediumForEndpoint(endpoint_id)) {
|
||||
NEARBY_LOGS(ERROR)
|
||||
LOG(ERROR)
|
||||
<< "ProcessBwuPathAvailableEventInternal failed for endpoint "
|
||||
<< endpoint_id << " medium "
|
||||
<< location::nearby::proto::connections::Medium_Name(medium)
|
||||
@@ -944,7 +944,7 @@ BwuManager::ProcessBwuPathAvailableEventInternal(
|
||||
|
||||
BwuHandler* handler = GetHandlerForMedium(medium);
|
||||
if (!handler) {
|
||||
NEARBY_LOGS(ERROR)
|
||||
LOG(ERROR)
|
||||
<< "ProcessBwuPathAvailableEventInternal failed for endpoint "
|
||||
<< endpoint_id << " medium "
|
||||
<< location::nearby::proto::connections::Medium_Name(medium)
|
||||
@@ -952,7 +952,7 @@ BwuManager::ProcessBwuPathAvailableEventInternal(
|
||||
return {Error(OperationResultCode::NEARBY_UPGRADE_PATH_ON_WRONG_MEDIUM)};
|
||||
}
|
||||
|
||||
NEARBY_LOGS(INFO) << "ProcessBwuPathAvailableEventInternal for "
|
||||
LOG(INFO) << "ProcessBwuPathAvailableEventInternal for "
|
||||
"endpoint "
|
||||
<< endpoint_id << " medium "
|
||||
<< location::nearby::proto::connections::Medium_Name(
|
||||
@@ -967,7 +967,7 @@ BwuManager::ProcessBwuPathAvailableEventInternal(
|
||||
std::shared_ptr<EndpointChannel> old_channel =
|
||||
channel_manager_->GetChannelForEndpoint(endpoint_id);
|
||||
if (!old_channel) {
|
||||
NEARBY_LOGS(ERROR)
|
||||
LOG(ERROR)
|
||||
<< "ProcessBwuPathAvailableEventInternal failed for endpoint "
|
||||
<< endpoint_id << " medium "
|
||||
<< location::nearby::proto::connections::Medium_Name(medium)
|
||||
@@ -989,7 +989,7 @@ BwuManager::ProcessBwuPathAvailableEventInternal(
|
||||
old_medium == Medium::BLE && medium == Medium::WIFI_HOTSPOT) {
|
||||
disable_ble_scanning = true;
|
||||
if (enable_ble_v2) {
|
||||
NEARBY_LOGS(INFO)
|
||||
LOG(INFO)
|
||||
<< "For Apple OS, if upgrade from BLE_V2 to WIFI_HOTSPOT, "
|
||||
"we need to pause "
|
||||
"BLE_V2 scanning because it can interfere with WIFI "
|
||||
@@ -1008,14 +1008,14 @@ BwuManager::ProcessBwuPathAvailableEventInternal(
|
||||
kEnableStopBleScanningOnWifiUpgrade)) {
|
||||
if (disable_ble_scanning) {
|
||||
if (enable_ble_v2) {
|
||||
NEARBY_LOGS(INFO) << "Resume BLE_V2 scanning.";
|
||||
LOG(INFO) << "Resume BLE_V2 scanning.";
|
||||
ble_v2_medium_.ResumeMediumScanning();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (result.has_error() || !result.has_value()) {
|
||||
NEARBY_LOGS(ERROR) << "BwuManager failed to create an endpoint "
|
||||
LOG(ERROR) << "BwuManager failed to create an endpoint "
|
||||
"channel to endpoint"
|
||||
<< endpoint_id << ", aborting upgrade.";
|
||||
client->GetAnalyticsRecorder().OnBandwidthUpgradeError(
|
||||
@@ -1037,7 +1037,7 @@ BwuManager::ProcessBwuPathAvailableEventInternal(
|
||||
// closure reason.
|
||||
new_channel->Close();
|
||||
|
||||
NEARBY_LOGS(ERROR)
|
||||
LOG(ERROR)
|
||||
<< "BwuManager failed to write BWU_NEGOTIATION.CLIENT_INTRODUCTION "
|
||||
"OfflineFrame to newly-created EndpointChannel "
|
||||
<< new_channel->GetName() << ", aborting upgrade.";
|
||||
@@ -1057,7 +1057,7 @@ BwuManager::ProcessBwuPathAvailableEventInternal(
|
||||
// closure reason.
|
||||
new_channel->Close();
|
||||
|
||||
NEARBY_LOGS(ERROR) << "BwuManager failed to read "
|
||||
LOG(ERROR) << "BwuManager failed to read "
|
||||
"BWU_NEGOTIATION.CLIENT_INTRODUCTION_ACK "
|
||||
"OfflineFrame to newly-created EndpointChannel "
|
||||
<< new_channel->GetName() << ", aborting upgrade.";
|
||||
@@ -1067,7 +1067,7 @@ BwuManager::ProcessBwuPathAvailableEventInternal(
|
||||
}
|
||||
}
|
||||
|
||||
NEARBY_LOGS(INFO) << "BwuManager successfully wrote "
|
||||
LOG(INFO) << "BwuManager successfully wrote "
|
||||
"BWU_NEGOTIATION.CLIENT_INTRODUCTION OfflineFrame to "
|
||||
"newly-created EndpointChannel "
|
||||
<< new_channel->GetName() << " while upgrading endpoint "
|
||||
@@ -1081,7 +1081,7 @@ BwuManager::ProcessBwuPathAvailableEventInternal(
|
||||
void BwuManager::RunUpgradeFailedProtocol(
|
||||
ClientProxy* client, const std::string& endpoint_id,
|
||||
const UpgradePathInfo& upgrade_path_info) {
|
||||
NEARBY_LOGS(INFO) << "RunUpgradeFailedProtocol for endpoint " << endpoint_id
|
||||
LOG(INFO) << "RunUpgradeFailedProtocol for endpoint " << endpoint_id
|
||||
<< " medium "
|
||||
<< location::nearby::proto::connections::Medium_Name(
|
||||
parser::UpgradePathInfoMediumToMedium(
|
||||
@@ -1092,7 +1092,7 @@ void BwuManager::RunUpgradeFailedProtocol(
|
||||
std::shared_ptr<EndpointChannel> channel =
|
||||
channel_manager_->GetChannelForEndpoint(endpoint_id);
|
||||
if (!channel) {
|
||||
NEARBY_LOGS(ERROR)
|
||||
LOG(ERROR)
|
||||
<< "BwuManager didn't find a previous EndpointChannel for "
|
||||
<< endpoint_id
|
||||
<< " when sending an upgrade failure frame, short-circuiting the "
|
||||
@@ -1108,7 +1108,7 @@ void BwuManager::RunUpgradeFailedProtocol(
|
||||
if (!channel->Write(parser::ForBwuFailure(upgrade_path_info)).Ok()) {
|
||||
channel->Close(DisconnectionReason::IO_ERROR);
|
||||
|
||||
NEARBY_LOGS(ERROR)
|
||||
LOG(ERROR)
|
||||
<< "BwuManager failed to write BWU_NEGOTIATION.UPGRADE_FAILURE "
|
||||
"OfflineFrame to endpoint "
|
||||
<< endpoint_id << ", short-circuiting the upgrade protocol.";
|
||||
@@ -1124,20 +1124,20 @@ void BwuManager::RunUpgradeFailedProtocol(
|
||||
RevertBwuMediumForEndpoint(channel->GetServiceId(), endpoint_id);
|
||||
}
|
||||
in_progress_upgrades_.erase(endpoint_id);
|
||||
NEARBY_LOGS(INFO) << "BwuManager has informed endpoint " << endpoint_id
|
||||
LOG(INFO) << "BwuManager has informed endpoint " << endpoint_id
|
||||
<< " that the bandwidth upgrade failed.";
|
||||
}
|
||||
|
||||
bool BwuManager::ReadClientIntroductionFrame(EndpointChannel* channel,
|
||||
ClientIntroduction& introduction) {
|
||||
NEARBY_LOGS(INFO) << "ReadClientIntroductionFrame with channel name: "
|
||||
LOG(INFO) << "ReadClientIntroductionFrame with channel name: "
|
||||
<< channel->GetName() << ", medium: "
|
||||
<< location::nearby::proto::connections::Medium_Name(
|
||||
channel->GetMedium());
|
||||
CancelableAlarm timeout_alarm(
|
||||
"BwuManager::ReadClientIntroductionFrame",
|
||||
[channel]() {
|
||||
NEARBY_LOGS(ERROR) << "In BwuManager, failed to read the "
|
||||
LOG(ERROR) << "In BwuManager, failed to read the "
|
||||
"ClientIntroductionFrame after "
|
||||
<< absl::FormatDuration(
|
||||
kReadClientIntroductionFrameTimeout)
|
||||
@@ -1151,7 +1151,7 @@ bool BwuManager::ReadClientIntroductionFrame(EndpointChannel* channel,
|
||||
if (!data.ok()) return false;
|
||||
auto transfer(parser::FromBytes(data.result()));
|
||||
if (!transfer.ok()) {
|
||||
NEARBY_LOGS(ERROR) << "In ReadClientIntroductionFrame, attempted to read a "
|
||||
LOG(ERROR) << "In ReadClientIntroductionFrame, attempted to read a "
|
||||
"ClientIntroductionFrame from EndpointChannel "
|
||||
<< channel->GetType()
|
||||
<< " but was unable to obtain any OfflineFrame.";
|
||||
@@ -1159,7 +1159,7 @@ bool BwuManager::ReadClientIntroductionFrame(EndpointChannel* channel,
|
||||
}
|
||||
OfflineFrame frame = transfer.result();
|
||||
if (!frame.has_v1() || !frame.v1().has_bandwidth_upgrade_negotiation()) {
|
||||
NEARBY_LOGS(ERROR)
|
||||
LOG(ERROR)
|
||||
<< "In ReadClientIntroductionFrame, expected a "
|
||||
"BANDWIDTH_UPGRADE_NEGOTIATION v1 OfflineFrame but got a "
|
||||
<< parser::GetFrameType(frame) << " frame instead.";
|
||||
@@ -1167,7 +1167,7 @@ bool BwuManager::ReadClientIntroductionFrame(EndpointChannel* channel,
|
||||
}
|
||||
if (frame.v1().bandwidth_upgrade_negotiation().event_type() !=
|
||||
BandwidthUpgradeNegotiationFrame::CLIENT_INTRODUCTION) {
|
||||
NEARBY_LOGS(ERROR)
|
||||
LOG(ERROR)
|
||||
<< "In ReadClientIntroductionFrame, expected a CLIENT_INTRODUCTION "
|
||||
"v1 OfflineFrame but got a BANDWIDTH_UPGRADE_NEGOTIATION frame "
|
||||
"with eventType "
|
||||
@@ -1182,14 +1182,14 @@ bool BwuManager::ReadClientIntroductionFrame(EndpointChannel* channel,
|
||||
}
|
||||
|
||||
bool BwuManager::ReadClientIntroductionAckFrame(EndpointChannel* channel) {
|
||||
NEARBY_LOGS(INFO) << "ReadClientIntroductionAckFrame with channel name: "
|
||||
LOG(INFO) << "ReadClientIntroductionAckFrame with channel name: "
|
||||
<< channel->GetName() << ", medium: "
|
||||
<< location::nearby::proto::connections::Medium_Name(
|
||||
channel->GetMedium());
|
||||
CancelableAlarm timeout_alarm(
|
||||
"BwuManager::ReadClientIntroductionAckFrame",
|
||||
[channel]() {
|
||||
NEARBY_LOGS(ERROR)
|
||||
LOG(ERROR)
|
||||
<< "In BwuManager, failed to read the ClientIntroductionAckFrame "
|
||||
"after "
|
||||
<< absl::FormatDuration(kReadClientIntroductionFrameTimeout)
|
||||
@@ -1213,7 +1213,7 @@ bool BwuManager::ReadClientIntroductionAckFrame(EndpointChannel* channel) {
|
||||
}
|
||||
|
||||
bool BwuManager::WriteClientIntroductionAckFrame(EndpointChannel* channel) {
|
||||
NEARBY_LOGS(INFO) << "WriteClientIntroductionAckFrame channel name: "
|
||||
LOG(INFO) << "WriteClientIntroductionAckFrame channel name: "
|
||||
<< channel->GetName() << ", medium: "
|
||||
<< location::nearby::proto::connections::Medium_Name(
|
||||
channel->GetMedium());
|
||||
@@ -1234,7 +1234,7 @@ void BwuManager::ProcessLastWriteToPriorChannelEvent(
|
||||
EndpointChannel* previous_endpoint_channel =
|
||||
previous_endpoint_channels_[endpoint_id].get();
|
||||
if (!previous_endpoint_channel) {
|
||||
NEARBY_LOGS(ERROR)
|
||||
LOG(ERROR)
|
||||
<< "BwuManager received a BWU_NEGOTIATION.LAST_WRITE_TO_PRIOR_CHANNEL "
|
||||
"OfflineFrame for unknown endpoint "
|
||||
<< endpoint_id << ", can't complete the upgrade protocol.";
|
||||
@@ -1242,7 +1242,7 @@ void BwuManager::ProcessLastWriteToPriorChannelEvent(
|
||||
return;
|
||||
}
|
||||
|
||||
NEARBY_LOGS(INFO) << "ProcessLastWriteToPriorChannelEvent: service_id="
|
||||
LOG(INFO) << "ProcessLastWriteToPriorChannelEvent: service_id="
|
||||
<< previous_endpoint_channel->GetServiceId()
|
||||
<< ", endpoint_id=" << endpoint_id << ", medium="
|
||||
<< location::nearby::proto::connections::Medium_Name(
|
||||
@@ -1254,7 +1254,7 @@ void BwuManager::ProcessLastWriteToPriorChannelEvent(
|
||||
// avoid leaks.
|
||||
previous_endpoint_channels_.erase(endpoint_id);
|
||||
|
||||
NEARBY_LOGS(ERROR) << "BwuManager failed to write "
|
||||
LOG(ERROR) << "BwuManager failed to write "
|
||||
"BWU_NEGOTIATION.SAFE_TO_CLOSE_PRIOR_CHANNEL "
|
||||
"OfflineFrame to endpoint "
|
||||
<< endpoint_id
|
||||
@@ -1265,7 +1265,7 @@ void BwuManager::ProcessLastWriteToPriorChannelEvent(
|
||||
OperationResultCode::CONNECTIVITY_GENERIC_WRITING_CHANNEL_IO_ERROR);
|
||||
return;
|
||||
}
|
||||
NEARBY_VLOG(1) << "BwuManager successfully wrote "
|
||||
VLOG(1) << "BwuManager successfully wrote "
|
||||
"BWU_NEGOTIATION.SAFE_TO_CLOSE_PRIOR_CHANNEL "
|
||||
"OfflineFrame while trying to upgrade endpoint "
|
||||
<< endpoint_id;
|
||||
@@ -1278,7 +1278,7 @@ void BwuManager::ProcessLastWriteToPriorChannelEvent(
|
||||
|
||||
void BwuManager::ProcessSafeToClosePriorChannelEvent(
|
||||
ClientProxy* client, const std::string& endpoint_id) {
|
||||
NEARBY_LOGS(INFO) << "ProcessSafeToClosePriorChannelEvent for endpoint "
|
||||
LOG(INFO) << "ProcessSafeToClosePriorChannelEvent for endpoint "
|
||||
<< endpoint_id;
|
||||
// By this point in the upgrade protocol, there's no more writes happening
|
||||
// over the prior EndpointChannel, and the remote device has given us the
|
||||
@@ -1296,13 +1296,13 @@ void BwuManager::ProcessSafeToClosePriorChannelEvent(
|
||||
auto item = previous_endpoint_channels_.extract(endpoint_id);
|
||||
auto& previous_endpoint_channel = item.mapped();
|
||||
if (previous_endpoint_channel == nullptr) {
|
||||
NEARBY_LOGS(ERROR)
|
||||
LOG(ERROR)
|
||||
<< "BwuManager received a BWU_NEGOTIATION.SAFE_TO_CLOSE_PRIOR_CHANNEL "
|
||||
"OfflineFrame for unknown endpoint "
|
||||
<< endpoint_id << ", can't complete the upgrade protocol.";
|
||||
return;
|
||||
}
|
||||
NEARBY_LOGS(INFO)
|
||||
LOG(INFO)
|
||||
<< "BwuManager successfully received a "
|
||||
<< "BWU_NEGOTIATION.SAFE_TO_CLOSE_PRIOR_CHANNEL OfflineFrame while "
|
||||
<< "trying to upgrade endpoint " << endpoint_id;
|
||||
@@ -1312,7 +1312,7 @@ void BwuManager::ProcessSafeToClosePriorChannelEvent(
|
||||
// circumstances so it is necessary to send it unencrypted. This way the
|
||||
// serial crypto context does not increment here.
|
||||
previous_endpoint_channel->DisableEncryption();
|
||||
NEARBY_LOGS(INFO) << "[safe-to-disconnect] Sending "
|
||||
LOG(INFO) << "[safe-to-disconnect] Sending "
|
||||
"DISCONNECTION frame with request 0, ack 0";
|
||||
previous_endpoint_channel->Write(
|
||||
parser::ForDisconnection(/* request_safe_to_disconnect */ false,
|
||||
@@ -1326,7 +1326,7 @@ void BwuManager::ProcessSafeToClosePriorChannelEvent(
|
||||
previous_endpoint_channel->Read();
|
||||
previous_endpoint_channel->Close(DisconnectionReason::UPGRADED);
|
||||
|
||||
NEARBY_VLOG(1)
|
||||
VLOG(1)
|
||||
<< "BwuManager cleanly shut down prior "
|
||||
<< previous_endpoint_channel->GetType()
|
||||
<< " EndpointChannel to conclude upgrade protocol for endpoint "
|
||||
@@ -1345,7 +1345,7 @@ void BwuManager::ProcessSafeToClosePriorChannelEvent(
|
||||
channel_manager_->GetChannelForEndpoint(endpoint_id);
|
||||
|
||||
if (!channel) {
|
||||
NEARBY_LOGS(ERROR) << "BwuManager attempted to resume the current "
|
||||
LOG(ERROR) << "BwuManager attempted to resume the current "
|
||||
"EndpointChannel with endpoint "
|
||||
<< endpoint_id << ", but none was found.";
|
||||
return;
|
||||
@@ -1370,7 +1370,7 @@ void BwuManager::ProcessUpgradeFailureEvent(
|
||||
ClientProxy* client, const std::string& endpoint_id,
|
||||
const UpgradePathInfo& upgrade_info, BandwidthUpgradeResult result,
|
||||
bool record_analytic, OperationResultCode operation_result_code) {
|
||||
NEARBY_LOGS(INFO) << "ProcessUpgradeFailureEvent for endpoint " << endpoint_id
|
||||
LOG(INFO) << "ProcessUpgradeFailureEvent for endpoint " << endpoint_id
|
||||
<< " from medium: "
|
||||
<< location::nearby::proto::connections::Medium_Name(
|
||||
parser::UpgradePathInfoMediumToMedium(
|
||||
@@ -1389,7 +1389,7 @@ void BwuManager::ProcessUpgradeFailureEvent(
|
||||
channel_manager_->GetConnectedEndpointsCount() > 1) {
|
||||
// We can't change the currentBwuMedium, so there are no more upgrade
|
||||
// attempts for this endpoint. Sorry.
|
||||
NEARBY_LOGS(ERROR)
|
||||
LOG(ERROR)
|
||||
<< "BwuManager failed to attempt a new bandwidth upgrade for endpoint "
|
||||
<< endpoint_id
|
||||
<< " because we have other connected endpoints and can't try a new "
|
||||
@@ -1439,7 +1439,7 @@ void BwuManager::TryNextBestUpgradeMediums(
|
||||
ClientProxy* client, const std::string& endpoint_id,
|
||||
std::vector<Medium> upgrade_mediums) {
|
||||
Medium next_medium = ChooseBestUpgradeMedium(endpoint_id, upgrade_mediums);
|
||||
NEARBY_LOGS(INFO) << "Try Next Best Medium for endpoint " << endpoint_id
|
||||
LOG(INFO) << "Try Next Best Medium for endpoint " << endpoint_id
|
||||
<< " after ChooseBestUpgradeMedium: "
|
||||
<< location::nearby::proto::connections::Medium_Name(
|
||||
next_medium);
|
||||
@@ -1450,7 +1450,7 @@ void BwuManager::TryNextBestUpgradeMediums(
|
||||
auto channel = channel_manager_->GetChannelForEndpoint(endpoint_id);
|
||||
Medium current_medium =
|
||||
channel ? channel->GetMedium() : Medium::UNKNOWN_MEDIUM;
|
||||
NEARBY_VLOG(1) << "current_medium: "
|
||||
VLOG(1) << "current_medium: "
|
||||
<< location::nearby::proto::connections::Medium_Name(
|
||||
current_medium);
|
||||
if (current_medium != Medium::WIFI_LAN &&
|
||||
@@ -1463,7 +1463,7 @@ void BwuManager::TryNextBestUpgradeMediums(
|
||||
// Attempt to set the new upgrade medium.
|
||||
if (!GetHandlerForMedium(next_medium)) {
|
||||
// As Medium without handler has been stripped out, this shouldn't be hit
|
||||
NEARBY_LOGS(INFO)
|
||||
LOG(INFO)
|
||||
<< "BwuManager failed to attempt a new bandwidth upgrade for endpoint "
|
||||
<< endpoint_id
|
||||
<< " because we couldn't set a new bandwidth upgrade medium.";
|
||||
@@ -1473,7 +1473,7 @@ void BwuManager::TryNextBestUpgradeMediums(
|
||||
|
||||
// Now that we've successfully picked a new upgrade medium to try,
|
||||
// re-initiate the bandwidth upgrade.
|
||||
NEARBY_LOGS(INFO) << "BwuManager is attempting to upgrade endpoint "
|
||||
LOG(INFO) << "BwuManager is attempting to upgrade endpoint "
|
||||
<< endpoint_id
|
||||
<< " again with a new bandwidth upgrade medium.";
|
||||
InitiateBwuForEndpoint(client, endpoint_id, next_medium);
|
||||
@@ -1539,7 +1539,7 @@ Medium BwuManager::ChooseBestUpgradeMedium(
|
||||
// Case 2: This is our first time upgrading, but there are no available
|
||||
// upgrade mediums. Fall through to returning UNKNOWN_MEDIUM at the
|
||||
// bottom.
|
||||
NEARBY_LOGS(INFO)
|
||||
LOG(INFO)
|
||||
<< "Current upgrade medium is unset, but there are no common supported "
|
||||
"upgrade mediums.";
|
||||
} else {
|
||||
@@ -1561,7 +1561,7 @@ Medium BwuManager::ChooseBestUpgradeMedium(
|
||||
location::nearby::proto::connections::Medium_Name(medium),
|
||||
"; ");
|
||||
}
|
||||
NEARBY_LOGS(INFO)
|
||||
LOG(INFO)
|
||||
<< "Current upgrade medium "
|
||||
<< location::nearby::proto::connections::Medium_Name(current_medium)
|
||||
<< " is not supported by the remote endpoint (supported mediums: "
|
||||
@@ -1593,7 +1593,7 @@ void BwuManager::RetryUpgradesAfterDelay(ClientProxy* client,
|
||||
retry_upgrade_alarms_.emplace(endpoint_id,
|
||||
std::make_pair(std::move(alarm), delay));
|
||||
retry_delays_[endpoint_id] = delay;
|
||||
NEARBY_LOGS(INFO) << "Retry bandwidth upgrade after "
|
||||
LOG(INFO) << "Retry bandwidth upgrade after "
|
||||
<< absl::FormatDuration(delay);
|
||||
}
|
||||
|
||||
@@ -1611,14 +1611,14 @@ void BwuManager::AttemptToRecordBandwidthUpgradeErrorForUnknownEndpoint(
|
||||
// make for them.
|
||||
client->GetAnalyticsRecorder().OnBandwidthUpgradeError(
|
||||
endpoint_id, result, error_stage, operation_result_code);
|
||||
NEARBY_LOGS(INFO) << "BwuManager got error "
|
||||
LOG(INFO) << "BwuManager got error "
|
||||
<< BandwidthUpgradeResult_Name(result) << " at stage "
|
||||
<< BandwidthUpgradeErrorStage_Name(error_stage)
|
||||
<< " when upgrading endpoint " << endpoint_id;
|
||||
}
|
||||
// Otherwise, we have no way of knowing which endpoint was trying to connect
|
||||
// to us :(
|
||||
NEARBY_LOGS(INFO) << "BwuManager got error "
|
||||
LOG(INFO) << "BwuManager got error "
|
||||
<< BandwidthUpgradeResult_Name(result) << " at stage "
|
||||
<< BandwidthUpgradeErrorStage_Name(error_stage)
|
||||
<< ", but we don't know which endpoint was trying to "
|
||||
@@ -1663,7 +1663,7 @@ absl::Duration BwuManager::CalculateNextRetryDelay(
|
||||
}
|
||||
|
||||
void BwuManager::CancelRetryUpgradeAlarm(const std::string& endpoint_id) {
|
||||
NEARBY_LOGS(INFO) << "CancelRetryUpgradeAlarm for endpoint " << endpoint_id;
|
||||
LOG(INFO) << "CancelRetryUpgradeAlarm for endpoint " << endpoint_id;
|
||||
auto item = retry_upgrade_alarms_.extract(endpoint_id);
|
||||
if (item.empty()) return;
|
||||
auto& pair = item.mapped();
|
||||
@@ -1671,11 +1671,11 @@ void BwuManager::CancelRetryUpgradeAlarm(const std::string& endpoint_id) {
|
||||
}
|
||||
|
||||
void BwuManager::CancelAllRetryUpgradeAlarms() {
|
||||
NEARBY_LOGS(INFO) << "CancelAllRetryUpgradeAlarms invoked";
|
||||
LOG(INFO) << "CancelAllRetryUpgradeAlarms invoked";
|
||||
for (auto& item : retry_upgrade_alarms_) {
|
||||
const std::string& endpoint_id = item.first;
|
||||
CancelableAlarm* cancellable_alarm = item.second.first.get();
|
||||
NEARBY_LOGS(INFO) << "CancelRetryUpgradeAlarm for endpoint " << endpoint_id;
|
||||
LOG(INFO) << "CancelRetryUpgradeAlarm for endpoint " << endpoint_id;
|
||||
cancellable_alarm->Cancel();
|
||||
}
|
||||
retry_upgrade_alarms_.clear();
|
||||
|
||||
@@ -89,7 +89,7 @@ bool IsFeatureUseStableEndpointIdEnabled() {
|
||||
|
||||
ClientProxy::ClientProxy(::nearby::analytics::EventLogger* event_logger)
|
||||
: client_id_(Prng().NextInt64()) {
|
||||
NEARBY_LOGS(INFO) << "ClientProxy ctor event_logger=" << event_logger;
|
||||
LOG(INFO) << "ClientProxy ctor event_logger=" << event_logger;
|
||||
is_dct_enabled_ = NearbyFlags::GetInstance().GetBoolFlag(
|
||||
config_package_nearby::nearby_connections_feature::kEnableDct);
|
||||
analytics_recorder_ =
|
||||
@@ -108,7 +108,7 @@ ClientProxy::ClientProxy(::nearby::analytics::EventLogger* event_logger)
|
||||
local_safe_to_disconnect_version_ = NearbyFlags::GetInstance().GetInt64Flag(
|
||||
config_package_nearby::nearby_connections_feature::
|
||||
kSafeToDisconnectVersion);
|
||||
NEARBY_LOGS(INFO) << "[safe-to-disconnect]: Local enabled: "
|
||||
LOG(INFO) << "[safe-to-disconnect]: Local enabled: "
|
||||
<< supports_safe_to_disconnect_
|
||||
<< "; Version: " << local_safe_to_disconnect_version_;
|
||||
// Generate a 7 bits dedup value.
|
||||
@@ -123,22 +123,22 @@ std::int64_t ClientProxy::GetClientId() const { return client_id_; }
|
||||
std::string ClientProxy::GetLocalEndpointId() {
|
||||
MutexLock lock(&mutex_);
|
||||
if (IsDctEnabled() && GetEndpointIdForDct().has_value()) {
|
||||
NEARBY_LOGS(INFO) << "DCT is using genereted endpoint id.";
|
||||
LOG(INFO) << "DCT is using genereted endpoint id.";
|
||||
return GetEndpointIdForDct().value();
|
||||
} else {
|
||||
if (!local_endpoint_id_.empty()) {
|
||||
NEARBY_LOGS(INFO) << __func__ << ": Reusing cached endpoint id: "
|
||||
LOG(INFO) << __func__ << ": Reusing cached endpoint id: "
|
||||
<< local_endpoint_id_;
|
||||
return local_endpoint_id_;
|
||||
}
|
||||
if (external_device_provider_ == nullptr) {
|
||||
local_endpoint_id_ = GenerateLocalEndpointId();
|
||||
NEARBY_LOGS(INFO) << __func__ << ": Locally generating endpoint id: "
|
||||
LOG(INFO) << __func__ << ": Locally generating endpoint id: "
|
||||
<< local_endpoint_id_;
|
||||
} else {
|
||||
local_endpoint_id_ =
|
||||
external_device_provider_->GetLocalDevice()->GetEndpointId();
|
||||
NEARBY_LOGS(INFO)
|
||||
LOG(INFO)
|
||||
<< __func__
|
||||
<< ": From external device provider, populating endpoint id: "
|
||||
<< local_endpoint_id_;
|
||||
@@ -183,7 +183,7 @@ std::string ClientProxy::GenerateLocalEndpointId() {
|
||||
if (IsFeatureUseStableEndpointIdEnabled()) {
|
||||
if (!cached_endpoint_id_.empty()) {
|
||||
if (stable_endpoint_id_mode_) {
|
||||
NEARBY_LOGS(INFO) << "ClientProxy [Local Endpoint Re-using cached "
|
||||
LOG(INFO) << "ClientProxy [Local Endpoint Re-using cached "
|
||||
"endpoint id due to in stable endpoint id mode]: "
|
||||
"client="
|
||||
<< GetClientId()
|
||||
@@ -194,7 +194,7 @@ std::string ClientProxy::GenerateLocalEndpointId() {
|
||||
} else {
|
||||
if (high_vis_mode_) {
|
||||
if (!cached_endpoint_id_.empty()) {
|
||||
NEARBY_LOGS(INFO) << "ClientProxy [Local Endpoint Re-using cached "
|
||||
LOG(INFO) << "ClientProxy [Local Endpoint Re-using cached "
|
||||
"endpoint id]: client="
|
||||
<< GetClientId()
|
||||
<< "; cached_endpoint_id_=" << cached_endpoint_id_;
|
||||
@@ -231,7 +231,7 @@ void ClientProxy::StartedAdvertising(
|
||||
operation_result_with_mediums,
|
||||
const AdvertisingOptions& advertising_options) {
|
||||
MutexLock lock(&mutex_);
|
||||
NEARBY_LOGS(INFO) << "ClientProxy [StartedAdvertising]: client="
|
||||
LOG(INFO) << "ClientProxy [StartedAdvertising]: client="
|
||||
<< GetClientId();
|
||||
|
||||
if (IsFeatureUseStableEndpointIdEnabled()) {
|
||||
@@ -245,7 +245,7 @@ void ClientProxy::StartedAdvertising(
|
||||
} else {
|
||||
if (high_vis_mode_) {
|
||||
cached_endpoint_id_ = local_endpoint_id_;
|
||||
NEARBY_LOGS(INFO)
|
||||
LOG(INFO)
|
||||
<< "ClientProxy [High Visibility Mode Adv, Cache EndpointId]: client="
|
||||
<< GetClientId() << "; cached_endpoint_id_=" << cached_endpoint_id_;
|
||||
CancelClearCachedEndpointIdAlarm();
|
||||
@@ -268,7 +268,7 @@ void ClientProxy::StartedAdvertising(
|
||||
|
||||
void ClientProxy::StoppedAdvertising() {
|
||||
MutexLock lock(&mutex_);
|
||||
NEARBY_LOGS(INFO) << "ClientProxy [StoppedAdvertising]: client="
|
||||
LOG(INFO) << "ClientProxy [StoppedAdvertising]: client="
|
||||
<< GetClientId();
|
||||
|
||||
if (IsAdvertising()) {
|
||||
@@ -436,21 +436,21 @@ void ClientProxy::OnEndpointFound(
|
||||
location::nearby::proto::connections::Medium medium) {
|
||||
MutexLock lock(&mutex_);
|
||||
|
||||
NEARBY_LOGS(INFO) << "ClientProxy [Endpoint Found]: [enter] id="
|
||||
LOG(INFO) << "ClientProxy [Endpoint Found]: [enter] id="
|
||||
<< endpoint_id << "; service=" << service_id
|
||||
<< "; info=" << absl::BytesToHexString(endpoint_info.data())
|
||||
<< "; medium="
|
||||
<< location::nearby::proto::connections::Medium_Name(
|
||||
medium);
|
||||
if (!IsDiscoveringServiceId(service_id)) {
|
||||
NEARBY_LOGS(INFO) << "ClientProxy [Endpoint Found]: Ignoring event for id="
|
||||
LOG(INFO) << "ClientProxy [Endpoint Found]: Ignoring event for id="
|
||||
<< endpoint_id
|
||||
<< " because this client is not discovering.";
|
||||
return;
|
||||
}
|
||||
|
||||
if (discovered_endpoint_ids_.count(endpoint_id)) {
|
||||
NEARBY_LOGS(WARNING)
|
||||
LOG(WARNING)
|
||||
<< "ClientProxy [Endpoint Found]: Ignoring event for id=" << endpoint_id
|
||||
<< " because this client has already reported this endpoint as found.";
|
||||
return;
|
||||
@@ -466,10 +466,10 @@ void ClientProxy::OnEndpointLost(const std::string& service_id,
|
||||
const std::string& endpoint_id) {
|
||||
MutexLock lock(&mutex_);
|
||||
|
||||
NEARBY_LOGS(INFO) << "ClientProxy [Endpoint Lost]: [enter] id=" << endpoint_id
|
||||
LOG(INFO) << "ClientProxy [Endpoint Lost]: [enter] id=" << endpoint_id
|
||||
<< "; service=" << service_id;
|
||||
if (!IsDiscoveringServiceId(service_id)) {
|
||||
NEARBY_LOGS(INFO) << "ClientProxy [Endpoint Lost]: Ignoring event for id="
|
||||
LOG(INFO) << "ClientProxy [Endpoint Lost]: Ignoring event for id="
|
||||
<< endpoint_id
|
||||
<< " because this client is not discovering.";
|
||||
return;
|
||||
@@ -477,7 +477,7 @@ void ClientProxy::OnEndpointLost(const std::string& service_id,
|
||||
|
||||
const auto it = discovered_endpoint_ids_.find(endpoint_id);
|
||||
if (it == discovered_endpoint_ids_.end()) {
|
||||
NEARBY_LOGS(WARNING)
|
||||
LOG(WARNING)
|
||||
<< "ClientProxy [Endpoint Lost]: Ignoring event for id=" << endpoint_id
|
||||
<< " because this client has not yet reported this endpoint as found";
|
||||
return;
|
||||
@@ -490,7 +490,7 @@ void ClientProxy::OnEndpointLost(const std::string& service_id,
|
||||
void ClientProxy::OnRequestConnection(
|
||||
const Strategy& strategy, const std::string& endpoint_id,
|
||||
const ConnectionOptions& connection_options) {
|
||||
NEARBY_LOGS(INFO) << "ClientProxy [RequestConnection]: id=" << endpoint_id;
|
||||
LOG(INFO) << "ClientProxy [RequestConnection]: id=" << endpoint_id;
|
||||
analytics_recorder_->OnRequestConnection(strategy, endpoint_id);
|
||||
}
|
||||
|
||||
@@ -520,7 +520,7 @@ void ClientProxy::OnConnectionInitiated(
|
||||
// (can not use c++17 features, until chromium does) we unpack manually.
|
||||
auto& pair_iter = result.first;
|
||||
bool inserted = result.second;
|
||||
NEARBY_LOGS(INFO)
|
||||
LOG(INFO)
|
||||
<< "ClientProxy [Connection Initiated]: add Connection: client="
|
||||
<< GetClientId() << "; endpoint_id=" << endpoint_id
|
||||
<< "; inserted=" << inserted;
|
||||
@@ -542,11 +542,11 @@ void ClientProxy::OnConnectionInitiated(
|
||||
}
|
||||
|
||||
void ClientProxy::OnConnectionAccepted(const std::string& endpoint_id) {
|
||||
NEARBY_LOGS(INFO) << "ClientProxy [ConnectionAccepted]: id=" << endpoint_id;
|
||||
LOG(INFO) << "ClientProxy [ConnectionAccepted]: id=" << endpoint_id;
|
||||
MutexLock lock(&mutex_);
|
||||
|
||||
if (!HasPendingConnectionToEndpoint(endpoint_id)) {
|
||||
NEARBY_LOGS(INFO) << "ClientProxy [Connection Accepted]: no pending "
|
||||
LOG(INFO) << "ClientProxy [Connection Accepted]: no pending "
|
||||
"connection; endpoint_id="
|
||||
<< endpoint_id;
|
||||
return;
|
||||
@@ -562,11 +562,11 @@ void ClientProxy::OnConnectionAccepted(const std::string& endpoint_id) {
|
||||
|
||||
void ClientProxy::OnConnectionRejected(const std::string& endpoint_id,
|
||||
const Status& status) {
|
||||
NEARBY_LOGS(INFO) << "ClientProxy [ConnectionRejected]: id=" << endpoint_id;
|
||||
LOG(INFO) << "ClientProxy [ConnectionRejected]: id=" << endpoint_id;
|
||||
MutexLock lock(&mutex_);
|
||||
|
||||
if (!HasPendingConnectionToEndpoint(endpoint_id)) {
|
||||
NEARBY_LOGS(INFO) << "ClientProxy [Connection Rejected]: no pending "
|
||||
LOG(INFO) << "ClientProxy [Connection Rejected]: no pending "
|
||||
"connection; endpoint_id="
|
||||
<< endpoint_id;
|
||||
return;
|
||||
@@ -582,7 +582,7 @@ void ClientProxy::OnConnectionRejected(const std::string& endpoint_id,
|
||||
|
||||
void ClientProxy::OnBandwidthChanged(const std::string& endpoint_id,
|
||||
Medium new_medium) {
|
||||
NEARBY_LOGS(INFO) << "ClientProxy [BandwidthChanged]: id=" << endpoint_id;
|
||||
LOG(INFO) << "ClientProxy [BandwidthChanged]: id=" << endpoint_id;
|
||||
MutexLock lock(&mutex_);
|
||||
|
||||
ConnectionPair* item = LookupConnection(endpoint_id);
|
||||
@@ -590,13 +590,13 @@ void ClientProxy::OnBandwidthChanged(const std::string& endpoint_id,
|
||||
item->first.connected_medium = new_medium;
|
||||
item->first.connection_listener.bandwidth_changed_cb(endpoint_id,
|
||||
new_medium);
|
||||
NEARBY_LOGS(INFO) << "ClientProxy [reporting onBandwidthChanged]: client="
|
||||
LOG(INFO) << "ClientProxy [reporting onBandwidthChanged]: client="
|
||||
<< GetClientId() << "; endpoint_id=" << endpoint_id;
|
||||
}
|
||||
}
|
||||
|
||||
void ClientProxy::OnDisconnected(const std::string& endpoint_id, bool notify) {
|
||||
NEARBY_LOGS(INFO) << "ClientProxy [OnDisconnected]: id=" << endpoint_id;
|
||||
LOG(INFO) << "ClientProxy [OnDisconnected]: id=" << endpoint_id;
|
||||
MutexLock lock(&mutex_);
|
||||
|
||||
const ConnectionPair* item = LookupConnection(endpoint_id);
|
||||
@@ -796,13 +796,13 @@ void ClientProxy::LocalEndpointAcceptedConnection(
|
||||
const std::string& endpoint_id, PayloadListener listener) {
|
||||
MutexLock lock(&mutex_);
|
||||
if (HasLocalEndpointResponded(endpoint_id)) {
|
||||
NEARBY_LOGS(INFO)
|
||||
LOG(INFO)
|
||||
<< "ClientProxy [Local Accepted]: local endpoint has responded; id="
|
||||
<< endpoint_id;
|
||||
return;
|
||||
}
|
||||
AppendConnectionStatus(endpoint_id, Connection::kLocalEndpointAccepted);
|
||||
NEARBY_LOGS(INFO) << "ClientProxy [Local Accepted]: id=" << endpoint_id;
|
||||
LOG(INFO) << "ClientProxy [Local Accepted]: id=" << endpoint_id;
|
||||
ConnectionPair* item = LookupConnection(endpoint_id);
|
||||
if (item != nullptr) {
|
||||
item->second = std::move(listener);
|
||||
@@ -815,7 +815,7 @@ void ClientProxy::LocalEndpointRejectedConnection(
|
||||
MutexLock lock(&mutex_);
|
||||
|
||||
if (HasLocalEndpointResponded(endpoint_id)) {
|
||||
NEARBY_LOGS(INFO)
|
||||
LOG(INFO)
|
||||
<< "ClientProxy [Local Rejected]: local endpoint has responded; id="
|
||||
<< endpoint_id;
|
||||
return;
|
||||
@@ -830,7 +830,7 @@ void ClientProxy::RemoteEndpointAcceptedConnection(
|
||||
MutexLock lock(&mutex_);
|
||||
|
||||
if (HasRemoteEndpointResponded(endpoint_id)) {
|
||||
NEARBY_LOGS(INFO)
|
||||
LOG(INFO)
|
||||
<< "ClientProxy [Remote Accepted]: remote endpoint has responded; id="
|
||||
<< endpoint_id;
|
||||
return;
|
||||
@@ -845,7 +845,7 @@ void ClientProxy::RemoteEndpointRejectedConnection(
|
||||
MutexLock lock(&mutex_);
|
||||
|
||||
if (HasRemoteEndpointResponded(endpoint_id)) {
|
||||
NEARBY_LOGS(INFO)
|
||||
LOG(INFO)
|
||||
<< "ClientProxy [Remote Rejected]: remote endpoint has responded; id="
|
||||
<< endpoint_id;
|
||||
return;
|
||||
@@ -1039,7 +1039,7 @@ void ClientProxy::OnPayload(const std::string& endpoint_id, Payload payload) {
|
||||
const std::pair<ClientProxy::Connection, PayloadListener>* item =
|
||||
LookupConnection(endpoint_id);
|
||||
if (item != nullptr) {
|
||||
NEARBY_LOGS(INFO) << "ClientProxy [reporting onPayloadReceived]: client="
|
||||
LOG(INFO) << "ClientProxy [reporting onPayloadReceived]: client="
|
||||
<< GetClientId() << "; endpoint_id=" << endpoint_id
|
||||
<< " ; payload {id:" << payload.GetId()
|
||||
<< ", type:" << payload.GetType() << "}";
|
||||
@@ -1071,12 +1071,12 @@ void ClientProxy::OnPayloadProgress(const std::string& endpoint_id,
|
||||
item->second.payload_progress_cb(endpoint_id, info);
|
||||
|
||||
if (info.status == PayloadProgressInfo::Status::kInProgress) {
|
||||
NEARBY_VLOG(1) << "ClientProxy [reporting onPayloadProgress]: client="
|
||||
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)
|
||||
LOG(INFO)
|
||||
<< "ClientProxy [reporting onPayloadProgress]: client="
|
||||
<< GetClientId() << "; endpoint_id=" << endpoint_id
|
||||
<< "; payload_id=" << info.payload_id
|
||||
@@ -1141,7 +1141,7 @@ v3::ConnectionListeningOptions ClientProxy::GetListeningOptions() const {
|
||||
|
||||
void ClientProxy::EnterHighVisibilityMode() {
|
||||
MutexLock lock(&mutex_);
|
||||
NEARBY_LOGS(INFO) << "ClientProxy [EnterHighVisibilityMode]: client="
|
||||
LOG(INFO) << "ClientProxy [EnterHighVisibilityMode]: client="
|
||||
<< GetClientId();
|
||||
|
||||
high_vis_mode_ = true;
|
||||
@@ -1149,7 +1149,7 @@ void ClientProxy::EnterHighVisibilityMode() {
|
||||
|
||||
void ClientProxy::ExitHighVisibilityMode() {
|
||||
MutexLock lock(&mutex_);
|
||||
NEARBY_LOGS(INFO) << "ClientProxy [ExitHighVisibilityMode]: client="
|
||||
LOG(INFO) << "ClientProxy [ExitHighVisibilityMode]: client="
|
||||
<< GetClientId();
|
||||
|
||||
high_vis_mode_ = false;
|
||||
@@ -1158,7 +1158,7 @@ void ClientProxy::ExitHighVisibilityMode() {
|
||||
|
||||
void ClientProxy::EnterStableEndpointIdMode() {
|
||||
MutexLock lock(&mutex_);
|
||||
NEARBY_LOGS(INFO) << "ClientProxy [EnterStableEndpointIdMode]: client="
|
||||
LOG(INFO) << "ClientProxy [EnterStableEndpointIdMode]: client="
|
||||
<< GetClientId();
|
||||
|
||||
stable_endpoint_id_mode_ = true;
|
||||
@@ -1166,7 +1166,7 @@ void ClientProxy::EnterStableEndpointIdMode() {
|
||||
|
||||
void ClientProxy::ExitStableEndpointIdMode() {
|
||||
MutexLock lock(&mutex_);
|
||||
NEARBY_LOGS(INFO) << "ClientProxy [ExitStableEndpointIdMode]: client="
|
||||
LOG(INFO) << "ClientProxy [ExitStableEndpointIdMode]: client="
|
||||
<< GetClientId();
|
||||
|
||||
stable_endpoint_id_mode_ = false;
|
||||
@@ -1177,14 +1177,14 @@ void ClientProxy::ScheduleClearCachedEndpointIdAlarm() {
|
||||
CancelClearCachedEndpointIdAlarm();
|
||||
|
||||
if (cached_endpoint_id_.empty()) {
|
||||
NEARBY_VLOG(1) << "ClientProxy [There is no cached local high power "
|
||||
VLOG(1) << "ClientProxy [There is no cached local high power "
|
||||
"advertising endpoint Id]: client="
|
||||
<< GetClientId();
|
||||
return;
|
||||
}
|
||||
|
||||
if (IsFeatureUseStableEndpointIdEnabled() && HasOngoingConnection()) {
|
||||
NEARBY_VLOG(1) << "ClientProxy [Handle clearing cached endpoint ID "
|
||||
VLOG(1) << "ClientProxy [Handle clearing cached endpoint ID "
|
||||
"during disconnection]: client="
|
||||
<< GetClientId();
|
||||
return;
|
||||
@@ -1192,7 +1192,7 @@ void ClientProxy::ScheduleClearCachedEndpointIdAlarm() {
|
||||
|
||||
// Schedule to clear cache high visibility mode advertisement endpoint id in
|
||||
// 30s.
|
||||
NEARBY_LOGS(INFO) << "ClientProxy [High Visibility Mode Adv, Schedule to "
|
||||
LOG(INFO) << "ClientProxy [High Visibility Mode Adv, Schedule to "
|
||||
"Clear Cache EndpointId]: client="
|
||||
<< GetClientId()
|
||||
<< "; cached_endpoint_id_=" << cached_endpoint_id_;
|
||||
@@ -1201,7 +1201,7 @@ void ClientProxy::ScheduleClearCachedEndpointIdAlarm() {
|
||||
"clear_high_power_endpoint_id_cache",
|
||||
[this]() {
|
||||
MutexLock lock(&mutex_);
|
||||
NEARBY_LOGS(INFO)
|
||||
LOG(INFO)
|
||||
<< "ClientProxy [Cleared cached local high power advertising "
|
||||
"endpoint Id.]: client="
|
||||
<< GetClientId()
|
||||
@@ -1249,7 +1249,7 @@ std::int32_t ClientProxy::GetLocalMultiplexSocketBitmask() const {
|
||||
kEnableMultiplexWifiLan)
|
||||
? kWifiLanMultiplexEnabled
|
||||
: 0);
|
||||
NEARBY_LOGS(INFO) << "ClientProxy [GetLocalMultiplexSocketBitmask]: "
|
||||
LOG(INFO) << "ClientProxy [GetLocalMultiplexSocketBitmask]: "
|
||||
<< multiplex_bitmask;
|
||||
return multiplex_bitmask;
|
||||
}
|
||||
@@ -1262,7 +1262,7 @@ void ClientProxy::SetRemoteMultiplexSocketBitmask(
|
||||
if (item != nullptr) {
|
||||
item->first.remote_multiplex_socket_bitmask =
|
||||
remote_multiplex_socket_bitmask;
|
||||
NEARBY_LOGS(INFO) << "ClientProxy [SetRemoteMultiplexSocketBitmask]: "
|
||||
LOG(INFO) << "ClientProxy [SetRemoteMultiplexSocketBitmask]: "
|
||||
<< remote_multiplex_socket_bitmask;
|
||||
}
|
||||
}
|
||||
@@ -1271,7 +1271,7 @@ bool ClientProxy::IsLocalMultiplexSocketSupported(Medium medium) {
|
||||
int bitmask = GetLocalMultiplexSocketBitmask();
|
||||
switch (medium) {
|
||||
case Medium::BLUETOOTH:
|
||||
NEARBY_LOGS(INFO) << "ClientProxy [IsLocalMultiplexSocketSupported]: "
|
||||
LOG(INFO) << "ClientProxy [IsLocalMultiplexSocketSupported]: "
|
||||
<< (bitmask & kBtMultiplexEnabled);
|
||||
return (bitmask & kBtMultiplexEnabled) != 0;
|
||||
case Medium::WIFI_LAN:
|
||||
@@ -1314,7 +1314,7 @@ bool ClientProxy::GetWebRtcNonCellular() { return webrtc_non_cellular_; }
|
||||
void ClientProxy::SetWebRtcNonCellular(bool webrtc_non_cellular) {
|
||||
std::string allow_webrtc_cellular_str =
|
||||
webrtc_non_cellular ? "disallow" : "allow";
|
||||
NEARBY_LOGS(INFO) << "ClientProxy: client=" << GetClientId()
|
||||
LOG(INFO) << "ClientProxy: client=" << GetClientId()
|
||||
<< allow_webrtc_cellular_str << " to use mobile data.",
|
||||
webrtc_non_cellular_ = webrtc_non_cellular;
|
||||
}
|
||||
|
||||
@@ -43,7 +43,7 @@ std::string ConnectionsAuthenticationTransport::ReadMessage() const {
|
||||
if (response.ok()) {
|
||||
return response.result().string_data();
|
||||
}
|
||||
NEARBY_LOGS(WARNING) << "ConnectionsAuthenticationTransport: read failed "
|
||||
LOG(WARNING) << "ConnectionsAuthenticationTransport: read failed "
|
||||
"with exception/result: "
|
||||
<< response.exception();
|
||||
return "";
|
||||
|
||||
@@ -73,7 +73,7 @@ bool HandleEncryptionSuccess(const std::string& endpoint_id,
|
||||
void CancelableAlarmRunnable(ClientProxy* client,
|
||||
const std::string& endpoint_id,
|
||||
EndpointChannel* endpoint_channel) {
|
||||
NEARBY_LOGS(INFO) << "Timing out encryption for client "
|
||||
LOG(INFO) << "Timing out encryption for client "
|
||||
<< client->GetClientId()
|
||||
<< " to endpoint_id=" << endpoint_id << " after "
|
||||
<< absl::FormatDuration(kTimeout);
|
||||
@@ -126,7 +126,7 @@ class ServerRunnable final {
|
||||
return;
|
||||
}
|
||||
|
||||
NEARBY_LOGS(INFO)
|
||||
LOG(INFO)
|
||||
<< "In StartServer(), read UKEY2 Message 1 from endpoint(id="
|
||||
<< endpoint_id_ << ").";
|
||||
|
||||
@@ -149,7 +149,7 @@ class ServerRunnable final {
|
||||
return;
|
||||
}
|
||||
|
||||
NEARBY_LOGS(INFO)
|
||||
LOG(INFO)
|
||||
<< "In StartServer(), wrote UKEY2 Message 2 to endpoint(id="
|
||||
<< endpoint_id_ << ").";
|
||||
|
||||
@@ -175,7 +175,7 @@ class ServerRunnable final {
|
||||
return;
|
||||
}
|
||||
|
||||
NEARBY_LOGS(INFO)
|
||||
LOG(INFO)
|
||||
<< "In StartServer(), read UKEY2 Message 3 from endpoint(id="
|
||||
<< endpoint_id_ << ").";
|
||||
|
||||
@@ -190,7 +190,7 @@ class ServerRunnable final {
|
||||
|
||||
private:
|
||||
void LogException() const {
|
||||
NEARBY_LOGS(ERROR) << "In StartServer(), UKEY2 failed with endpoint(id="
|
||||
LOG(ERROR) << "In StartServer(), UKEY2 failed with endpoint(id="
|
||||
<< endpoint_id_ << ").";
|
||||
}
|
||||
|
||||
@@ -204,7 +204,7 @@ class ServerRunnable final {
|
||||
Exception write_exception =
|
||||
channel_->Write(ByteArray(*parse_result.alert_to_send));
|
||||
if (!write_exception.Ok()) {
|
||||
NEARBY_LOGS(WARNING)
|
||||
LOG(WARNING)
|
||||
<< "In StartServer(), client " << client_->GetClientId()
|
||||
<< " failed to pass the alert error message to endpoint(id="
|
||||
<< endpoint_id_ << ").";
|
||||
@@ -263,7 +263,7 @@ class ClientRunnable final {
|
||||
return;
|
||||
}
|
||||
|
||||
NEARBY_LOGS(INFO)
|
||||
LOG(INFO)
|
||||
<< "In StartClient(), wrote UKEY2 Message 1 to endpoint(id="
|
||||
<< endpoint_id_ << ").";
|
||||
|
||||
@@ -289,7 +289,7 @@ class ClientRunnable final {
|
||||
return;
|
||||
}
|
||||
|
||||
NEARBY_LOGS(INFO)
|
||||
LOG(INFO)
|
||||
<< "In StartClient(), read UKEY2 Message 2 from endpoint(id="
|
||||
<< endpoint_id_ << ").";
|
||||
|
||||
@@ -312,7 +312,7 @@ class ClientRunnable final {
|
||||
return;
|
||||
}
|
||||
|
||||
NEARBY_LOGS(INFO)
|
||||
LOG(INFO)
|
||||
<< "In StartClient(), wrote UKEY2 Message 3 to endpoint(id="
|
||||
<< endpoint_id_ << ").";
|
||||
|
||||
@@ -327,7 +327,7 @@ class ClientRunnable final {
|
||||
|
||||
private:
|
||||
void LogException() const {
|
||||
NEARBY_LOGS(ERROR) << "In StartClient(), UKEY2 failed with endpoint(id="
|
||||
LOG(ERROR) << "In StartClient(), UKEY2 failed with endpoint(id="
|
||||
<< endpoint_id_ << ").";
|
||||
}
|
||||
|
||||
@@ -341,7 +341,7 @@ class ClientRunnable final {
|
||||
Exception write_exception =
|
||||
channel_->Write(ByteArray(*parse_result.alert_to_send));
|
||||
if (!write_exception.Ok()) {
|
||||
NEARBY_LOGS(WARNING)
|
||||
LOG(WARNING)
|
||||
<< "In StartClient(), client " << client_->GetClientId()
|
||||
<< " failed to pass the alert error message to endpoint(id="
|
||||
<< endpoint_id_ << ").";
|
||||
|
||||
@@ -71,11 +71,11 @@ std::function<void()> MakeDataPump(
|
||||
absl::string_view label, InputStream* input, OutputStream* output,
|
||||
std::function<void(const ByteArray&)> monitor = nullptr) {
|
||||
return [label, input, output, monitor]() {
|
||||
NEARBY_LOGS(INFO) << "streaming data through '" << label << "'";
|
||||
LOG(INFO) << "streaming data through '" << label << "'";
|
||||
while (true) {
|
||||
auto read_response = input->Read(kChunkSize);
|
||||
if (!read_response.ok()) {
|
||||
NEARBY_LOGS(INFO) << "Peer reader closed on '" << label << "'";
|
||||
LOG(INFO) << "Peer reader closed on '" << label << "'";
|
||||
output->Close();
|
||||
break;
|
||||
}
|
||||
@@ -84,12 +84,12 @@ std::function<void()> MakeDataPump(
|
||||
}
|
||||
auto write_response = output->Write(read_response.result());
|
||||
if (write_response.Raised()) {
|
||||
NEARBY_LOGS(INFO) << "Peer writer closed on '" << label << "'";
|
||||
LOG(INFO) << "Peer writer closed on '" << label << "'";
|
||||
input->Close();
|
||||
break;
|
||||
}
|
||||
}
|
||||
NEARBY_LOGS(INFO) << "streaming terminated on '" << label << "'";
|
||||
LOG(INFO) << "streaming terminated on '" << label << "'";
|
||||
};
|
||||
}
|
||||
|
||||
@@ -102,7 +102,7 @@ std::function<void(const ByteArray&)> MakeDataMonitor(absl::string_view label,
|
||||
absl::MutexLock lock(mutex);
|
||||
*capture += s;
|
||||
}
|
||||
NEARBY_LOGS(INFO) << "source='" << label << "'"
|
||||
LOG(INFO) << "source='" << label << "'"
|
||||
<< "; message='" << s << "'";
|
||||
};
|
||||
}
|
||||
@@ -127,7 +127,7 @@ DoDhKeyExchange(BaseEndpointChannel* channel_a,
|
||||
std::unique_ptr<securegcm::UKey2Handshake> ukey2,
|
||||
const std::string& auth_token,
|
||||
const ByteArray& raw_auth_token) {
|
||||
NEARBY_LOGS(INFO) << "client-A side key negotiation done";
|
||||
LOG(INFO) << "client-A side key negotiation done";
|
||||
EXPECT_TRUE(ukey2->VerifyHandshake());
|
||||
auto context = ukey2->ToConnectionContext();
|
||||
EXPECT_NE(context, nullptr);
|
||||
@@ -137,7 +137,7 @@ DoDhKeyExchange(BaseEndpointChannel* channel_a,
|
||||
.on_failure_cb =
|
||||
[&latch](const std::string& endpoint_id,
|
||||
EndpointChannel* channel) {
|
||||
NEARBY_LOGS(INFO) << "client-A side key negotiation failed";
|
||||
LOG(INFO) << "client-A side key negotiation failed";
|
||||
latch.CountDown();
|
||||
},
|
||||
});
|
||||
@@ -150,7 +150,7 @@ DoDhKeyExchange(BaseEndpointChannel* channel_a,
|
||||
std::unique_ptr<securegcm::UKey2Handshake> ukey2,
|
||||
const std::string& auth_token,
|
||||
const ByteArray& raw_auth_token) {
|
||||
NEARBY_LOGS(INFO) << "client-B side key negotiation done";
|
||||
LOG(INFO) << "client-B side key negotiation done";
|
||||
EXPECT_TRUE(ukey2->VerifyHandshake());
|
||||
auto context = ukey2->ToConnectionContext();
|
||||
EXPECT_NE(context, nullptr);
|
||||
@@ -160,7 +160,7 @@ DoDhKeyExchange(BaseEndpointChannel* channel_a,
|
||||
.on_failure_cb =
|
||||
[&latch](const std::string& endpoint_id,
|
||||
EndpointChannel* channel) {
|
||||
NEARBY_LOGS(INFO) << "client-B side key negotiation failed";
|
||||
LOG(INFO) << "client-B side key negotiation failed";
|
||||
latch.CountDown();
|
||||
},
|
||||
});
|
||||
|
||||
@@ -205,7 +205,7 @@ ExceptionOr<OfflineFrame> EndpointManager::TryDecryptFrame(
|
||||
while (true) {
|
||||
ExceptionOr<ByteArray> decrypted = endpoint_channel->TryDecrypt(data);
|
||||
if (decrypted.ok()) {
|
||||
NEARBY_VLOG(1) << "Message decrypted after "
|
||||
VLOG(1) << "Message decrypted after "
|
||||
<< SystemClock::ElapsedRealtime() - start_time;
|
||||
return parser::FromBytes(decrypted.result());
|
||||
}
|
||||
@@ -518,14 +518,14 @@ EndpointManager::LockedFrameProcessor EndpointManager::GetFrameProcessor(
|
||||
}
|
||||
|
||||
void EndpointManager::RemoveEndpointState(const std::string& endpoint_id) {
|
||||
NEARBY_VLOG(1) << "EnsureWorkersTerminated for endpoint " << endpoint_id;
|
||||
VLOG(1) << "EnsureWorkersTerminated for endpoint " << endpoint_id;
|
||||
auto item = endpoints_.find(endpoint_id);
|
||||
if (item != endpoints_.end()) {
|
||||
LOG(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_VLOG(1) << "Workers terminated for endpoint " << endpoint_id;
|
||||
VLOG(1) << "Workers terminated for endpoint " << endpoint_id;
|
||||
} else {
|
||||
LOG(INFO) << "EndpointState not found for endpoint " << endpoint_id;
|
||||
}
|
||||
@@ -607,7 +607,7 @@ 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_VLOG(1) << "EndpointManager enabling KeepAlive for endpoint "
|
||||
VLOG(1) << "EndpointManager enabling KeepAlive for endpoint "
|
||||
<< endpoint_id;
|
||||
endpoint_state.StartEndpointKeepAliveManager(
|
||||
[this, client, endpoint_id, keep_alive_interval,
|
||||
@@ -723,7 +723,7 @@ void EndpointManager::DiscardEndpoint(ClientProxy* client,
|
||||
{
|
||||
MutexLock lock(&mutex_);
|
||||
if (is_shutdown_) {
|
||||
NEARBY_VLOG(1)
|
||||
VLOG(1)
|
||||
<< "DiscardEndpoint called during destruction, returning early.";
|
||||
return;
|
||||
}
|
||||
@@ -977,7 +977,7 @@ EndpointManager::EndpointState::~EndpointState() {
|
||||
// object (in move constructor) which prevents unregistering the channel
|
||||
// prematurely.
|
||||
if (channel_manager_) {
|
||||
NEARBY_VLOG(1) << "EndpointState destructor " << endpoint_id_;
|
||||
VLOG(1) << "EndpointState destructor " << endpoint_id_;
|
||||
channel_manager_->UnregisterChannelForEndpoint(
|
||||
endpoint_id_, DisconnectionReason::SHUTDOWN,
|
||||
ConnectionsLog::EstablishedConnection::SAFE_DISCONNECTION);
|
||||
|
||||
@@ -330,9 +330,9 @@ TEST_F(EndpointManagerTest, SendControlMessageAndPayloadAckWorks) {
|
||||
ON_CALL(*endpoint_channel, Read(_))
|
||||
.WillByDefault([channel = endpoint_channel.get()]() {
|
||||
if (channel->IsClosed()) return ExceptionOr<ByteArray>(Exception::kIo);
|
||||
NEARBY_LOGS(INFO) << "Simulate read delay: wait";
|
||||
LOG(INFO) << "Simulate read delay: wait";
|
||||
absl::SleepFor(absl::Milliseconds(100));
|
||||
NEARBY_LOGS(INFO) << "Simulate read delay: done";
|
||||
LOG(INFO) << "Simulate read delay: done";
|
||||
if (channel->IsClosed()) return ExceptionOr<ByteArray>(Exception::kIo);
|
||||
return ExceptionOr<ByteArray>(ByteArray{});
|
||||
});
|
||||
@@ -340,7 +340,7 @@ TEST_F(EndpointManagerTest, SendControlMessageAndPayloadAckWorks) {
|
||||
.WillByDefault(
|
||||
[channel = endpoint_channel.get()](DisconnectionReason reason) {
|
||||
channel->DoClose();
|
||||
NEARBY_LOGS(INFO) << "Channel closed";
|
||||
LOG(INFO) << "Channel closed";
|
||||
});
|
||||
EXPECT_CALL(*endpoint_channel, Write(_, _))
|
||||
.WillRepeatedly(Return(Exception{Exception::kSuccess}));
|
||||
@@ -352,9 +352,9 @@ TEST_F(EndpointManagerTest, SendControlMessageAndPayloadAckWorks) {
|
||||
auto failed_ids_2 =
|
||||
em_.SendPayloadAck(header.id(), std::vector<std::string>{endpoint_id_});
|
||||
EXPECT_EQ(failed_ids_2, std::vector<std::string>{});
|
||||
NEARBY_LOGS(INFO) << "Will unregister endpoint now";
|
||||
LOG(INFO) << "Will unregister endpoint now";
|
||||
em_.UnregisterEndpoint(client_.get(), endpoint_id_);
|
||||
NEARBY_LOGS(INFO) << "Will call destructors now";
|
||||
LOG(INFO) << "Will call destructors now";
|
||||
}
|
||||
|
||||
TEST_F(EndpointManagerTest, SingleReadOnReadError) {
|
||||
|
||||
@@ -93,7 +93,7 @@ TEST_P(AwdlTest, CanConnect) {
|
||||
.service_discovered_cb =
|
||||
[&discovered_latch, &discovered_service_info](
|
||||
NsdServiceInfo service_info, const std::string& service_id) {
|
||||
NEARBY_LOGS(INFO)
|
||||
LOG(INFO)
|
||||
<< "Discovered service_info=" << &service_info;
|
||||
discovered_service_info = service_info;
|
||||
discovered_latch.CountDown();
|
||||
@@ -146,7 +146,7 @@ TEST_P(AwdlTest, CanCancelConnect) {
|
||||
.service_discovered_cb =
|
||||
[&discovered_latch, &discovered_service_info](
|
||||
NsdServiceInfo service_info, const std::string& service_id) {
|
||||
NEARBY_LOGS(INFO)
|
||||
LOG(INFO)
|
||||
<< "Discovered service_info=" << &service_info;
|
||||
discovered_service_info = service_info;
|
||||
discovered_latch.CountDown();
|
||||
|
||||
@@ -66,13 +66,13 @@ bool Ble::StartAdvertising(const std::string& service_id,
|
||||
MutexLock lock(&mutex_);
|
||||
|
||||
if (advertisement_bytes.Empty()) {
|
||||
NEARBY_LOGS(INFO)
|
||||
LOG(INFO)
|
||||
<< "Refusing to turn on BLE advertising. Empty advertisement data.";
|
||||
return false;
|
||||
}
|
||||
|
||||
if (advertisement_bytes.size() > kMaxAdvertisementLength) {
|
||||
NEARBY_LOGS(INFO)
|
||||
LOG(INFO)
|
||||
<< "Refusing to start BLE advertising because the advertisement "
|
||||
"was too long. Expected at most "
|
||||
<< kMaxAdvertisementLength << " bytes but received "
|
||||
@@ -81,23 +81,23 @@ bool Ble::StartAdvertising(const std::string& service_id,
|
||||
}
|
||||
|
||||
if (IsAdvertisingLocked(service_id)) {
|
||||
NEARBY_LOGS(INFO)
|
||||
LOG(INFO)
|
||||
<< "Failed to BLE advertise because we're already advertising.";
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!radio_.IsEnabled()) {
|
||||
NEARBY_LOGS(INFO)
|
||||
LOG(INFO)
|
||||
<< "Can't start BLE adveertising because Bluetooth was never turned on";
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!IsAvailableLocked()) {
|
||||
NEARBY_LOGS(INFO) << "Can't turn on BLE advertising. BLE is not available.";
|
||||
LOG(INFO) << "Can't turn on BLE advertising. BLE is not available.";
|
||||
return false;
|
||||
}
|
||||
|
||||
NEARBY_LOGS(INFO) << "Turning on BLE advertising (advertisement size="
|
||||
LOG(INFO) << "Turning on BLE advertising (advertisement size="
|
||||
<< advertisement_bytes.size() << ")"
|
||||
<< ", service id=" << service_id
|
||||
<< ", fast advertisement service uuid="
|
||||
@@ -113,14 +113,14 @@ bool Ble::StartAdvertising(const std::string& service_id,
|
||||
fast_advertisement ? ByteArray{} : service_id_hash, advertisement_bytes,
|
||||
GenerateDeviceToken()}};
|
||||
if (medium_advertisement_bytes.Empty()) {
|
||||
NEARBY_LOGS(INFO) << "Failed to BLE advertise because we could not "
|
||||
LOG(INFO) << "Failed to BLE advertise because we could not "
|
||||
"create a medium advertisement.";
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!medium_.StartAdvertising(service_id, medium_advertisement_bytes,
|
||||
fast_advertisement_service_uuid)) {
|
||||
NEARBY_LOGS(ERROR)
|
||||
LOG(ERROR)
|
||||
<< "Failed to turn on BLE advertising with advertisement bytes="
|
||||
<< absl::BytesToHexString(advertisement_bytes.data())
|
||||
<< ", size=" << advertisement_bytes.size()
|
||||
@@ -137,11 +137,11 @@ bool Ble::StopAdvertising(const std::string& service_id) {
|
||||
MutexLock lock(&mutex_);
|
||||
|
||||
if (!IsAdvertisingLocked(service_id)) {
|
||||
NEARBY_LOGS(INFO) << "Can't turn off BLE advertising; it is already off";
|
||||
LOG(INFO) << "Can't turn off BLE advertising; it is already off";
|
||||
return false;
|
||||
}
|
||||
|
||||
NEARBY_LOGS(INFO) << "Turned off BLE advertising with service id="
|
||||
LOG(INFO) << "Turned off BLE advertising with service id="
|
||||
<< service_id;
|
||||
bool ret = medium_.StopAdvertising(service_id);
|
||||
// Reset our bundle of advertising state to mark that we're no longer
|
||||
@@ -153,25 +153,25 @@ bool Ble::StopAdvertising(const std::string& service_id) {
|
||||
bool Ble::StartLegacyAdvertising(
|
||||
const std::string& input_service_id, const std::string& local_endpoint_id,
|
||||
const std::string& fast_advertisement_service_uuid) {
|
||||
NEARBY_LOGS(INFO) << "StartLegacyAdvertising: " << input_service_id
|
||||
LOG(INFO) << "StartLegacyAdvertising: " << input_service_id
|
||||
<< ", local_endpoint_id: " << local_endpoint_id;
|
||||
MutexLock lock(&mutex_);
|
||||
std::string service_id = input_service_id + "-Legacy";
|
||||
|
||||
if (IsAdvertisingLocked(service_id)) {
|
||||
NEARBY_LOGS(INFO)
|
||||
LOG(INFO)
|
||||
<< "Failed to BLE legacy advertise because we're already advertising.";
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!radio_.IsEnabled()) {
|
||||
NEARBY_LOGS(INFO) << "Can't start BLE legacy advertising because Bluetooth "
|
||||
LOG(INFO) << "Can't start BLE legacy advertising because Bluetooth "
|
||||
"was never turned on";
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!IsAvailableLocked()) {
|
||||
NEARBY_LOGS(INFO)
|
||||
LOG(INFO)
|
||||
<< "Can't turn on BLE legacy advertising. BLE is not available.";
|
||||
return false;
|
||||
}
|
||||
@@ -181,7 +181,7 @@ bool Ble::StartLegacyAdvertising(
|
||||
0x41, 0x41, 0x41, 0x41, 0x41, 0x41, 0x41, 0x41, 0x41, 0x41, 0x41};
|
||||
ByteArray encoded_bytes{encoded_legacy_char_array};
|
||||
|
||||
NEARBY_LOGS(INFO) << "Turning on BLE advertising (advertisement size="
|
||||
LOG(INFO) << "Turning on BLE advertising (advertisement size="
|
||||
<< encoded_bytes.size()
|
||||
<< "): " << absl::BytesToHexString(encoded_bytes.data())
|
||||
<< ", service id=" << service_id
|
||||
@@ -190,7 +190,7 @@ bool Ble::StartLegacyAdvertising(
|
||||
|
||||
if (!medium_.StartAdvertising(service_id, encoded_bytes,
|
||||
fast_advertisement_service_uuid)) {
|
||||
NEARBY_LOGS(ERROR)
|
||||
LOG(ERROR)
|
||||
<< "Failed to turn on BLE advertising with advertisement bytes="
|
||||
<< absl::BytesToHexString(encoded_bytes.data())
|
||||
<< ", size=" << encoded_bytes.size()
|
||||
@@ -204,17 +204,17 @@ bool Ble::StartLegacyAdvertising(
|
||||
}
|
||||
|
||||
bool Ble::StopLegacyAdvertising(const std::string& input_service_id) {
|
||||
NEARBY_LOGS(INFO) << "StopLegacyAdvertising:" << input_service_id;
|
||||
LOG(INFO) << "StopLegacyAdvertising:" << input_service_id;
|
||||
MutexLock lock(&mutex_);
|
||||
|
||||
std::string service_id = input_service_id + "-Legacy";
|
||||
if (!IsAdvertisingLocked(service_id)) {
|
||||
NEARBY_LOGS(INFO)
|
||||
LOG(INFO)
|
||||
<< "Can't turn off BLE legacy advertising; it is already off";
|
||||
return false;
|
||||
}
|
||||
|
||||
NEARBY_LOGS(INFO) << "Turned off BLE legacy advertising with service id="
|
||||
LOG(INFO) << "Turned off BLE legacy advertising with service id="
|
||||
<< service_id;
|
||||
bool ret = medium_.StopAdvertising(service_id);
|
||||
// Reset our bundle of advertising state to mark that we're no longer
|
||||
@@ -241,25 +241,25 @@ bool Ble::StartScanning(const std::string& service_id,
|
||||
discovered_peripheral_callback_ = std::move(callback);
|
||||
|
||||
if (service_id.empty()) {
|
||||
NEARBY_LOGS(INFO)
|
||||
LOG(INFO)
|
||||
<< "Refusing to start BLE scanning with empty service id.";
|
||||
return false;
|
||||
}
|
||||
|
||||
if (IsScanningLocked(service_id)) {
|
||||
NEARBY_LOGS(INFO) << "Refusing to start scan of BLE peripherals because "
|
||||
LOG(INFO) << "Refusing to start scan of BLE peripherals because "
|
||||
"another scanning is already in-progress.";
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!radio_.IsEnabled()) {
|
||||
NEARBY_LOGS(INFO)
|
||||
LOG(INFO)
|
||||
<< "Can't start BLE scanning because Bluetooth was never turned on";
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!IsAvailableLocked()) {
|
||||
NEARBY_LOGS(INFO)
|
||||
LOG(INFO)
|
||||
<< "Can't scan BLE peripherals because BLE isn't available.";
|
||||
return false;
|
||||
}
|
||||
@@ -274,7 +274,7 @@ bool Ble::StartScanning(const std::string& service_id,
|
||||
bool fast_advertisement) {
|
||||
// Don't bother trying to parse zero byte advertisements.
|
||||
if (medium_advertisement_bytes.size() == 0) {
|
||||
NEARBY_LOGS(INFO) << "Skipping zero byte advertisement "
|
||||
LOG(INFO) << "Skipping zero byte advertisement "
|
||||
<< "with service_id: " << service_id;
|
||||
return;
|
||||
}
|
||||
@@ -293,11 +293,11 @@ bool Ble::StartScanning(const std::string& service_id,
|
||||
peripheral, service_id);
|
||||
},
|
||||
})) {
|
||||
NEARBY_LOGS(INFO) << "Failed to start scan of BLE services.";
|
||||
LOG(INFO) << "Failed to start scan of BLE services.";
|
||||
return false;
|
||||
}
|
||||
|
||||
NEARBY_LOGS(INFO) << "Turned on BLE scanning with service id=" << service_id;
|
||||
LOG(INFO) << "Turned on BLE scanning with service id=" << service_id;
|
||||
// Mark the fact that we're currently performing a BLE discovering.
|
||||
scanning_info_.Add(service_id);
|
||||
return true;
|
||||
@@ -307,12 +307,12 @@ bool Ble::StopScanning(const std::string& service_id) {
|
||||
MutexLock lock(&mutex_);
|
||||
|
||||
if (!IsScanningLocked(service_id)) {
|
||||
NEARBY_LOGS(INFO) << "Can't turn off BLE scanning because we never "
|
||||
LOG(INFO) << "Can't turn off BLE scanning because we never "
|
||||
"started scanning.";
|
||||
return false;
|
||||
}
|
||||
|
||||
NEARBY_LOGS(INFO) << "Turned off BLE scanning with service id=" << service_id;
|
||||
LOG(INFO) << "Turned off BLE scanning with service id=" << service_id;
|
||||
bool ret = medium_.StopScanning(service_id);
|
||||
scanning_info_.Clear();
|
||||
return ret;
|
||||
@@ -333,32 +333,32 @@ bool Ble::StartAcceptingConnections(const std::string& service_id,
|
||||
MutexLock lock(&mutex_);
|
||||
|
||||
if (service_id.empty()) {
|
||||
NEARBY_LOGS(INFO)
|
||||
LOG(INFO)
|
||||
<< "Refusing to start accepting BLE connections with empty service id.";
|
||||
return false;
|
||||
}
|
||||
|
||||
if (IsAcceptingConnectionsLocked(service_id)) {
|
||||
NEARBY_LOGS(INFO)
|
||||
LOG(INFO)
|
||||
<< "Refusing to start accepting BLE connections for " << service_id
|
||||
<< " because another BLE peripheral socket is already in-progress.";
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!radio_.IsEnabled()) {
|
||||
NEARBY_LOGS(INFO) << "Can't start accepting BLE connections for "
|
||||
LOG(INFO) << "Can't start accepting BLE connections for "
|
||||
<< service_id << " because Bluetooth isn't enabled.";
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!IsAvailableLocked()) {
|
||||
NEARBY_LOGS(INFO) << "Can't start accepting BLE connections for "
|
||||
LOG(INFO) << "Can't start accepting BLE connections for "
|
||||
<< service_id << " because BLE isn't available.";
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!medium_.StartAcceptingConnections(service_id, std::move(callback))) {
|
||||
NEARBY_LOGS(INFO) << "Failed to accept connections callback for "
|
||||
LOG(INFO) << "Failed to accept connections callback for "
|
||||
<< service_id << " .";
|
||||
return false;
|
||||
}
|
||||
@@ -371,7 +371,7 @@ bool Ble::StopAcceptingConnections(const std::string& service_id) {
|
||||
MutexLock lock(&mutex_);
|
||||
|
||||
if (!IsAcceptingConnectionsLocked(service_id)) {
|
||||
NEARBY_LOGS(INFO)
|
||||
LOG(INFO)
|
||||
<< "Can't stop accepting BLE connections because it was never started.";
|
||||
return false;
|
||||
}
|
||||
@@ -397,36 +397,36 @@ ErrorOr<BleSocket> Ble::Connect(BlePeripheral& peripheral,
|
||||
const std::string& service_id,
|
||||
CancellationFlag* cancellation_flag) {
|
||||
MutexLock lock(&mutex_);
|
||||
NEARBY_LOGS(INFO) << "BLE::Connect: service=" << &peripheral;
|
||||
LOG(INFO) << "BLE::Connect: service=" << &peripheral;
|
||||
// Socket to return. To allow for NRVO to work, it has to be a single object.
|
||||
BleSocket socket;
|
||||
|
||||
if (service_id.empty()) {
|
||||
NEARBY_LOGS(INFO) << "Refusing to create BLE socket with empty service_id.";
|
||||
LOG(INFO) << "Refusing to create BLE socket with empty service_id.";
|
||||
return {Error(OperationResultCode::NEARBY_LOCAL_CLIENT_STATE_WRONG)};
|
||||
}
|
||||
|
||||
if (!radio_.IsEnabled()) {
|
||||
NEARBY_LOGS(INFO) << "Can't create client BLE socket to " << &peripheral
|
||||
LOG(INFO) << "Can't create client BLE socket to " << &peripheral
|
||||
<< " because Bluetooth isn't enabled.";
|
||||
return {Error(OperationResultCode::MISCELLEANEOUS_BLE_SYSTEM_SERVICE_NULL)};
|
||||
}
|
||||
|
||||
if (!IsAvailableLocked()) {
|
||||
NEARBY_LOGS(INFO) << "Can't create client BLE socket [service_id="
|
||||
LOG(INFO) << "Can't create client BLE socket [service_id="
|
||||
<< service_id << "]; BLE isn't available.";
|
||||
return {Error(OperationResultCode::MEDIUM_UNAVAILABLE_BLE_NOT_AVAILABLE)};
|
||||
}
|
||||
|
||||
if (cancellation_flag->Cancelled()) {
|
||||
NEARBY_LOGS(INFO) << "Can't create client BLE socket due to cancel.";
|
||||
LOG(INFO) << "Can't create client BLE socket due to cancel.";
|
||||
return {Error(OperationResultCode::
|
||||
CLIENT_CANCELLATION_CANCEL_BLE_OUTGOING_CONNECTION)};
|
||||
}
|
||||
|
||||
socket = medium_.Connect(peripheral, service_id, cancellation_flag);
|
||||
if (!socket.IsValid()) {
|
||||
NEARBY_LOGS(INFO) << "Failed to Connect via BLE [service=" << service_id
|
||||
LOG(INFO) << "Failed to Connect via BLE [service=" << service_id
|
||||
<< "]";
|
||||
}
|
||||
|
||||
@@ -439,7 +439,7 @@ ByteArray Ble::UnwrapAdvertisementBytes(
|
||||
mediums::BleAdvertisement::CreateBleAdvertisement(
|
||||
medium_advertisement_data);
|
||||
if (!medium_ble_advertisement_status_or.ok()) {
|
||||
NEARBY_LOGS(INFO) << medium_ble_advertisement_status_or.status();
|
||||
LOG(INFO) << medium_ble_advertisement_status_or.status();
|
||||
return ByteArray();
|
||||
}
|
||||
|
||||
|
||||
@@ -88,7 +88,7 @@ TEST_P(BleTest, CanStartAcceptingConnectionsAndConnect) {
|
||||
BlePeripheral& peripheral, const std::string& service_id,
|
||||
const ByteArray& advertisement_bytes,
|
||||
bool fast_advertisement) {
|
||||
NEARBY_LOGS(INFO)
|
||||
LOG(INFO)
|
||||
<< "Discovered peripheral=" << peripheral.GetName()
|
||||
<< ", impl=" << &peripheral.GetImpl()
|
||||
<< ", fast advertisement=" << fast_advertisement;
|
||||
@@ -141,7 +141,7 @@ TEST_P(BleTest, CanCancelConnect) {
|
||||
BlePeripheral& peripheral, const std::string& service_id,
|
||||
const ByteArray& advertisement_bytes,
|
||||
bool fast_advertisement) {
|
||||
NEARBY_LOGS(INFO)
|
||||
LOG(INFO)
|
||||
<< "Discovered peripheral=" << peripheral.GetName()
|
||||
<< ", impl=" << &peripheral.GetImpl()
|
||||
<< ", fast advertisement=" << fast_advertisement;
|
||||
|
||||
@@ -68,7 +68,7 @@ BleAdvertisementHeader::BleAdvertisementHeader(
|
||||
kMinAdvertisementHeaderLength + 2) {
|
||||
advertisement_header_bytes = ble_advertisement_header_bytes;
|
||||
} else {
|
||||
NEARBY_VLOG(1) << "Cannot deserialize BLEAdvertisementHeader. "
|
||||
VLOG(1) << "Cannot deserialize BLEAdvertisementHeader. "
|
||||
"Invalid advertising data.";
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -38,7 +38,7 @@ BloomFilter::BloomFilter(std::unique_ptr<BitSet> bit_set,
|
||||
}
|
||||
// If the size is not matched, fall out.
|
||||
if (bytes.size() * 8 != bit_set_->Size()) {
|
||||
NEARBY_LOGS(INFO) << "Cannot construct from bytes since the size is not "
|
||||
LOG(INFO) << "Cannot construct from bytes since the size is not "
|
||||
"matched. bytes.size(x8) = "
|
||||
<< bytes.size() << ", bit_set.size=" << bit_set_->Size();
|
||||
return;
|
||||
|
||||
@@ -63,7 +63,7 @@ InstantOnLostAdvertisement::CreateFromHashes(
|
||||
|
||||
std::string InstantOnLostAdvertisement::ToBytes() const {
|
||||
if (hashes_.empty() || hashes_.size() > kMaxHashCount) {
|
||||
NEARBY_LOGS(ERROR) << __func__
|
||||
LOG(ERROR) << __func__
|
||||
<< ": Failed to convert hashes due to hash "
|
||||
"size is not valid, size = "
|
||||
<< hashes_.size();
|
||||
@@ -79,7 +79,7 @@ std::string InstantOnLostAdvertisement::ToBytes() const {
|
||||
std::string result = absl::StrFormat("%c%c", header, count);
|
||||
for (const auto& hash : hashes_) {
|
||||
if (hash.length() != kAdvertisementHashLength) {
|
||||
NEARBY_LOGS(ERROR) << __func__
|
||||
LOG(ERROR) << __func__
|
||||
<< ": Failed to convert hashes to advertisement due "
|
||||
"to invalid hash : "
|
||||
<< absl::BytesToHexString(hash);
|
||||
|
||||
@@ -112,7 +112,7 @@ TEST_P(BleV2Test, CanConnect) {
|
||||
const ByteArray& advertisement_bytes,
|
||||
bool fast_advertisement) {
|
||||
discovered_peripheral = peripheral;
|
||||
NEARBY_LOGS(INFO)
|
||||
LOG(INFO)
|
||||
<< "Discovered peripheral, fast advertisement="
|
||||
<< fast_advertisement;
|
||||
discovered_latch.CountDown();
|
||||
@@ -172,7 +172,7 @@ TEST_P(BleV2Test, CanCancelConnect) {
|
||||
const ByteArray& advertisement_bytes,
|
||||
bool fast_advertisement) {
|
||||
discovered_peripheral = peripheral;
|
||||
NEARBY_LOGS(INFO)
|
||||
LOG(INFO)
|
||||
<< "Discovered peripheral, fast advertisement="
|
||||
<< fast_advertisement;
|
||||
discovered_latch.CountDown();
|
||||
|
||||
@@ -268,7 +268,7 @@ TEST_P(BluetoothClassicTest, CanConnect) {
|
||||
.device_discovered_cb =
|
||||
[&latch, &discovered_device](BluetoothDevice& device) {
|
||||
discovered_device = device;
|
||||
NEARBY_LOGS(INFO) << "Discovered device=" << device.GetName()
|
||||
LOG(INFO) << "Discovered device=" << device.GetName()
|
||||
<< ", impl=" << &device.GetImpl();
|
||||
latch.CountDown();
|
||||
},
|
||||
@@ -318,7 +318,7 @@ TEST_P(BluetoothClassicTest, CanCancelBeforeConnect) {
|
||||
{
|
||||
.device_discovered_cb =
|
||||
[&latch, &discovered_device](BluetoothDevice& device) {
|
||||
NEARBY_LOGS(INFO) << "Discovered device=" << device.GetName()
|
||||
LOG(INFO) << "Discovered device=" << device.GetName()
|
||||
<< ", impl=" << &device.GetImpl();
|
||||
discovered_device = device;
|
||||
latch.CountDown();
|
||||
@@ -386,7 +386,7 @@ TEST_P(BluetoothClassicTest, CanCancelDuringConnect) {
|
||||
.device_discovered_cb =
|
||||
[&latch, &discovered_device](BluetoothDevice& device) {
|
||||
discovered_device = device;
|
||||
NEARBY_LOGS(INFO) << "Discovered device=" << device.GetName()
|
||||
LOG(INFO) << "Discovered device=" << device.GetName()
|
||||
<< ", impl=" << &device.GetImpl();
|
||||
latch.CountDown();
|
||||
},
|
||||
@@ -452,7 +452,7 @@ TEST_P(BluetoothClassicTest, CanCancelDuringConnect_MultipleEndpoints) {
|
||||
.device_discovered_cb =
|
||||
[&latch, &discovered_device](BluetoothDevice& device) {
|
||||
discovered_device = device;
|
||||
NEARBY_LOGS(INFO) << "Discovered device=" << device.GetName()
|
||||
LOG(INFO) << "Discovered device=" << device.GetName()
|
||||
<< ", impl=" << &device.GetImpl();
|
||||
latch.CountDown();
|
||||
},
|
||||
@@ -598,21 +598,21 @@ TEST_F(BluetoothClassicTest, CanDiscoverDeviceChanges) {
|
||||
.device_discovered_cb =
|
||||
[&discovered_latch, &discovered_device](BluetoothDevice& device) {
|
||||
discovered_device = device;
|
||||
NEARBY_LOGS(INFO) << "Discovered device=" << device.GetName()
|
||||
LOG(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_LOGS(INFO) << "Rename device=" << device.GetName()
|
||||
LOG(INFO) << "Rename device=" << device.GetName()
|
||||
<< ", impl=" << &device.GetImpl();
|
||||
rename_latch.CountDown();
|
||||
},
|
||||
.device_lost_cb =
|
||||
[&lost_latch, &discovered_device](BluetoothDevice& device) {
|
||||
discovered_device = device;
|
||||
NEARBY_LOGS(INFO) << "Lost device=" << device.GetName()
|
||||
LOG(INFO) << "Lost device=" << device.GetName()
|
||||
<< ", impl=" << &device.GetImpl();
|
||||
lost_latch.CountDown();
|
||||
},
|
||||
@@ -644,7 +644,7 @@ TEST_F(BluetoothClassicTest, CanStartAcceptingConnections) {
|
||||
.device_discovered_cb =
|
||||
[&latch, &discovered_device](BluetoothDevice& device) {
|
||||
discovered_device = device;
|
||||
NEARBY_LOGS(INFO) << "Discovered device=" << device.GetName()
|
||||
LOG(INFO) << "Discovered device=" << device.GetName()
|
||||
<< ",impl=" << &device.GetImpl();
|
||||
latch.CountDown();
|
||||
},
|
||||
|
||||
@@ -21,20 +21,20 @@ namespace connections {
|
||||
|
||||
BluetoothRadio::BluetoothRadio() {
|
||||
if (!IsAdapterValid()) {
|
||||
NEARBY_LOGS(ERROR) << "Bluetooth adapter is not valid: BT is not supported";
|
||||
LOG(ERROR) << "Bluetooth adapter is not valid: BT is not supported";
|
||||
}
|
||||
}
|
||||
|
||||
BluetoothRadio::~BluetoothRadio() {
|
||||
// We never enabled Bluetooth, nothing to do.
|
||||
if (!ever_saved_state_.Get()) {
|
||||
NEARBY_LOGS(INFO) << "BT adapter was not used. Not touching HW.";
|
||||
LOG(INFO) << "BT adapter was not used. Not touching HW.";
|
||||
return;
|
||||
}
|
||||
|
||||
NEARBY_LOGS(INFO) << "Bring BT adapter to original state";
|
||||
LOG(INFO) << "Bring BT adapter to original state";
|
||||
if (!SetBluetoothState(originally_enabled_.Get())) {
|
||||
NEARBY_LOGS(INFO) << "Failed to restore BT adapter original state.";
|
||||
LOG(INFO) << "Failed to restore BT adapter original state.";
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -203,7 +203,7 @@ bool IsMultiplexFrame(const ByteArray& data) {
|
||||
if (!frame.ok()) {
|
||||
return false;
|
||||
} else {
|
||||
NEARBY_LOGS(INFO) << "Checked data is a multiplex frame. Is Control ? "
|
||||
LOG(INFO) << "Checked data is a multiplex frame. Is Control ? "
|
||||
<< frame.result().has_control_frame() << ", is data ? "
|
||||
<< frame.result().has_data_frame();
|
||||
return true;
|
||||
|
||||
@@ -53,25 +53,25 @@ MultiplexOutputStream::MultiplexOutputStream(OutputStream* physical_writer,
|
||||
Exception MultiplexOutputStream::WaitForResult(const std::string& method_name,
|
||||
Future<bool>* future) {
|
||||
if (!future) {
|
||||
NEARBY_LOGS(INFO) << "No future to wait for; return with error.";
|
||||
LOG(INFO) << "No future to wait for; return with error.";
|
||||
return {Exception::kFailed};
|
||||
}
|
||||
NEARBY_LOGS(INFO) << "Waiting for future to complete: " << method_name;
|
||||
LOG(INFO) << "Waiting for future to complete: " << method_name;
|
||||
ExceptionOr<bool> result =
|
||||
future->Get(FeatureFlags::GetInstance()
|
||||
.GetFlags()
|
||||
.mediums_frame_write_timeout_millis);
|
||||
if (!result.ok()) {
|
||||
NEARBY_LOGS(INFO) << "Future:[" << method_name
|
||||
LOG(INFO) << "Future:[" << method_name
|
||||
<< "] completed with exception:" << result.exception();
|
||||
return {Exception::kFailed};
|
||||
}
|
||||
if (result.result()) {
|
||||
NEARBY_LOGS(INFO) << "Future:[" << method_name
|
||||
LOG(INFO) << "Future:[" << method_name
|
||||
<< "] completed with success.";
|
||||
return {Exception::kSuccess};
|
||||
}
|
||||
NEARBY_LOGS(INFO) << "Future:[" << method_name
|
||||
LOG(INFO) << "Future:[" << method_name
|
||||
<< "] completed with failure.";
|
||||
return {Exception::kFailed};
|
||||
}
|
||||
@@ -111,7 +111,7 @@ bool MultiplexOutputStream::WriteConnectionResponseFrame(
|
||||
bool MultiplexOutputStream::Close(const std::string& service_id) {
|
||||
auto item = virtual_output_streams_.find(service_id);
|
||||
if (item == virtual_output_streams_.end()) {
|
||||
NEARBY_LOGS(INFO) << "Don't need to close VirtualOutputStream("
|
||||
LOG(INFO) << "Don't need to close VirtualOutputStream("
|
||||
<< service_id << ") because it's already gone.";
|
||||
return false;
|
||||
}
|
||||
@@ -216,7 +216,7 @@ void MultiplexOutputStream::MultiplexWriter::EnqueueToSend(
|
||||
}
|
||||
|
||||
void MultiplexOutputStream::MultiplexWriter::StartWriting() {
|
||||
NEARBY_LOGS(INFO) << "Writing loop started.";
|
||||
LOG(INFO) << "Writing loop started.";
|
||||
while (true) {
|
||||
auto enqueued_frame = data_queue_.TryTake();
|
||||
if (enqueued_frame != std::nullopt) {
|
||||
@@ -227,23 +227,23 @@ void MultiplexOutputStream::MultiplexWriter::StartWriting() {
|
||||
MutexLock lock(&writing_mutex_);
|
||||
if (data_queue_.Empty() && is_writing_ && !is_closed_) {
|
||||
is_writing_ = false;
|
||||
NEARBY_LOGS(INFO) << "Waiting for data_queue_ has data.";
|
||||
LOG(INFO) << "Waiting for data_queue_ has data.";
|
||||
Exception wait_succeeded = is_writing_cond_.Wait();
|
||||
if (!wait_succeeded.Ok()) {
|
||||
NEARBY_LOGS(WARNING)
|
||||
LOG(WARNING)
|
||||
<< "Failure waiting to wait: " << wait_succeeded.value;
|
||||
return;
|
||||
}
|
||||
}
|
||||
if (is_closed_) {
|
||||
NEARBY_LOGS(INFO) << "Notify to close_writing_thread";
|
||||
LOG(INFO) << "Notify to close_writing_thread";
|
||||
MutexLock lock(&close_writing_thread_mutex_);
|
||||
close_writing_thread_cond_.Notify();
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
NEARBY_LOGS(INFO) << "Writing loop stopped.";
|
||||
LOG(INFO) << "Writing loop stopped.";
|
||||
}
|
||||
|
||||
void MultiplexOutputStream::MultiplexWriter::Write(
|
||||
@@ -268,10 +268,10 @@ void MultiplexOutputStream::MultiplexWriter::Write(
|
||||
|
||||
void MultiplexOutputStream::MultiplexWriter::Close() {
|
||||
if (is_closed_) {
|
||||
NEARBY_LOGS(INFO) << "MultiplexWriter is already closed.";
|
||||
LOG(INFO) << "MultiplexWriter is already closed.";
|
||||
return;
|
||||
}
|
||||
NEARBY_LOGS(INFO) << "Stop writing loop and Shutdown writer thread.";
|
||||
LOG(INFO) << "Stop writing loop and Shutdown writer thread.";
|
||||
{
|
||||
MutexLock lock(&writing_mutex_);
|
||||
is_closed_ = true;
|
||||
@@ -282,11 +282,11 @@ void MultiplexOutputStream::MultiplexWriter::Close() {
|
||||
is_write_loop_running_ = false;
|
||||
is_writing_cond_.Notify();
|
||||
}
|
||||
NEARBY_LOGS(INFO) << "Wait to close_writing_thread";
|
||||
LOG(INFO) << "Wait to close_writing_thread";
|
||||
{
|
||||
MutexLock lock(&close_writing_thread_mutex_);
|
||||
close_writing_thread_cond_.Wait(absl::Milliseconds(20));
|
||||
NEARBY_LOGS(INFO) << "Shutdown writer thread.";
|
||||
LOG(INFO) << "Shutdown writer thread.";
|
||||
writer_thread_.Shutdown();
|
||||
}
|
||||
}
|
||||
@@ -306,7 +306,7 @@ MultiplexOutputStream::VirtualOutputStream::VirtualOutputStream(
|
||||
Exception MultiplexOutputStream::VirtualOutputStream::Write(
|
||||
const ByteArray& data) {
|
||||
if (is_closed_.Get()) {
|
||||
NEARBY_LOGS(WARNING)
|
||||
LOG(WARNING)
|
||||
<< "Failed to write data because the VirtualOutputStream for "
|
||||
<< service_id_ << " closed";
|
||||
return {Exception::kIo};
|
||||
@@ -326,7 +326,7 @@ Exception MultiplexOutputStream::VirtualOutputStream::Write(
|
||||
// true to let the remote handle correctly.
|
||||
if ((service_id_hash_salt_ == kFakeSalt) && !should_pass_salt) {
|
||||
should_pass_salt = true;
|
||||
NEARBY_LOGS(INFO) << "service_idHashSalt is still a fake one and "
|
||||
LOG(INFO) << "service_idHashSalt is still a fake one and "
|
||||
"not changed yet; continue to pass salt.";
|
||||
}
|
||||
}
|
||||
@@ -354,7 +354,7 @@ Exception MultiplexOutputStream::VirtualOutputStream::Flush() {
|
||||
}
|
||||
|
||||
Exception MultiplexOutputStream::VirtualOutputStream::Close() {
|
||||
NEARBY_LOGS(INFO) << "MultiplexOutputStream::VirtualOutputStream::Close";
|
||||
LOG(INFO) << "MultiplexOutputStream::VirtualOutputStream::Close";
|
||||
is_closed_.Set(true);
|
||||
return {Exception::kSuccess};
|
||||
}
|
||||
|
||||
@@ -225,14 +225,14 @@ TEST_F(MultiplexOutputStreamTest, CreateTwoVirtualStreams_SendData) {
|
||||
std::string(GenerateServiceIdHashWithSalt(std::string(kServiceId_1),
|
||||
std::string(kSalt_1)))) {
|
||||
EXPECT_EQ(frame.data_frame().data(), std::string(data_1));
|
||||
NEARBY_LOGS(INFO) << "Read first virtual stream frame first.";
|
||||
LOG(INFO) << "Read first virtual stream frame first.";
|
||||
} else {
|
||||
EXPECT_EQ(frame.header().salted_service_id_hash(),
|
||||
std::string(GenerateServiceIdHashWithSalt(std::string(kServiceId_2),
|
||||
std::string(kSalt_2))));
|
||||
EXPECT_EQ(frame.data_frame().data(), std::string(data_2));
|
||||
first_frame_is_data_1 = false;
|
||||
NEARBY_LOGS(INFO) << "Read second virtual stream frame first.";
|
||||
LOG(INFO) << "Read second virtual stream frame first.";
|
||||
}
|
||||
|
||||
frame_data = ReadFrame();
|
||||
|
||||
@@ -107,7 +107,7 @@ MultiplexSocket* MultiplexSocket::CreateIncomingSocket(
|
||||
std::shared_ptr<MediumSocket> physical_socket,
|
||||
const std::string& service_id, std::int32_t first_frame_len) {
|
||||
while (is_shutting_down_.Get()) {
|
||||
NEARBY_LOGS(WARNING)
|
||||
LOG(WARNING)
|
||||
<< "Shutting down is going on, wait for 2ms to create incoming socket";
|
||||
absl::SleepFor(absl::Milliseconds(2));
|
||||
}
|
||||
@@ -131,12 +131,12 @@ MultiplexSocket* MultiplexSocket::CreateIncomingSocket(
|
||||
new (&storage_wlan) MultiplexSocket(physical_socket);
|
||||
break;
|
||||
default:
|
||||
NEARBY_LOGS(ERROR) << __func__ << "Unsupported medium: "
|
||||
LOG(ERROR) << __func__ << "Unsupported medium: "
|
||||
<< physical_socket->GetMedium();
|
||||
multiplex_incoming_socket = nullptr;
|
||||
return multiplex_incoming_socket;
|
||||
}
|
||||
NEARBY_LOGS(INFO) << "CreateIncomingSocket with serviceId=" << service_id
|
||||
LOG(INFO) << "CreateIncomingSocket with serviceId=" << service_id
|
||||
<< ", serviceIdHashSalt=" << kFakeSalt << " for medium="
|
||||
<< Medium_Name(physical_socket->GetMedium());
|
||||
|
||||
@@ -151,7 +151,7 @@ MultiplexSocket* MultiplexSocket::CreateOutgoingSocket(
|
||||
std::shared_ptr<MediumSocket> physical_socket,
|
||||
const std::string& service_id, const std::string& service_id_hash_salt) {
|
||||
while (is_shutting_down_.Get()) {
|
||||
NEARBY_LOGS(WARNING)
|
||||
LOG(WARNING)
|
||||
<< "Shutting down is going on, wait for 2ms to create outgoing socket";
|
||||
absl::SleepFor(absl::Milliseconds(2));
|
||||
}
|
||||
@@ -175,11 +175,11 @@ MultiplexSocket* MultiplexSocket::CreateOutgoingSocket(
|
||||
new (&storage_wlan) MultiplexSocket(physical_socket);
|
||||
break;
|
||||
default:
|
||||
NEARBY_LOGS(ERROR) << __func__ << "Unsupported medium: "
|
||||
LOG(ERROR) << __func__ << "Unsupported medium: "
|
||||
<< physical_socket->GetMedium();
|
||||
return multiplex_outgoing_socket;
|
||||
}
|
||||
NEARBY_LOGS(INFO) << "CreateOutgoingSocket with serviceId=" << service_id
|
||||
LOG(INFO) << "CreateOutgoingSocket with serviceId=" << service_id
|
||||
<< ", serviceIdHashSalt=" << service_id_hash_salt
|
||||
<< " for medium="
|
||||
<< Medium_Name(physical_socket->GetMedium());
|
||||
@@ -206,7 +206,7 @@ MediumSocket* MultiplexSocket::CreateFirstVirtualSocket(
|
||||
MutexLock lock(&virtual_socket_mutex_);
|
||||
std::string salted_service_id_hash_key =
|
||||
GenerateServiceIdHashKeyWithSalt(service_id, service_id_hash_salt);
|
||||
NEARBY_LOGS(INFO) << __func__ << " for service_id=" << service_id
|
||||
LOG(INFO) << __func__ << " for service_id=" << service_id
|
||||
<< ", salt=" << service_id_hash_salt
|
||||
<< ", salted_service_id_hash_key="
|
||||
<< salted_service_id_hash_key;
|
||||
@@ -218,7 +218,7 @@ MediumSocket* MultiplexSocket::CreateFirstVirtualSocket(
|
||||
[this, service_id]() { OnVirtualSocketClosed(service_id); }));
|
||||
|
||||
if (!IsEnabled()) {
|
||||
NEARBY_LOGS(INFO) << __func__ << ": Register multiplex enabled callback";
|
||||
LOG(INFO) << __func__ << ": Register multiplex enabled callback";
|
||||
virtual_socket->RegisterMultiplexEnabledCallback(enable_cb_);
|
||||
}
|
||||
|
||||
@@ -233,7 +233,7 @@ MediumSocket* MultiplexSocket::CreateVirtualSocket(
|
||||
std::string salted_service_id_hash_key =
|
||||
GenerateServiceIdHashKeyWithSalt(service_id, service_id_hash_salt);
|
||||
|
||||
NEARBY_LOGS(INFO) << __func__ << "service_id=" << service_id
|
||||
LOG(INFO) << __func__ << "service_id=" << service_id
|
||||
<< ", salt=" << service_id_hash_salt
|
||||
<< ", salted_service_id_hash_key="
|
||||
<< salted_service_id_hash_key;
|
||||
@@ -250,13 +250,13 @@ MediumSocket* MultiplexSocket::CreateVirtualSocket(
|
||||
|
||||
MediumSocket* MultiplexSocket::GetVirtualSocket(const std::string& service_id) {
|
||||
MutexLock lock(&virtual_socket_mutex_);
|
||||
NEARBY_LOGS(INFO) << __func__ << " service_id=" << service_id << ", Salt="
|
||||
LOG(INFO) << __func__ << " service_id=" << service_id << ", Salt="
|
||||
<< multiplex_output_stream_.GetServiceIdHashSalt(service_id)
|
||||
<< ", virtual_sockets_.size()=" << virtual_sockets_.size();
|
||||
auto item = virtual_sockets_.find(GenerateServiceIdHashKeyWithSalt(
|
||||
service_id, multiplex_output_stream_.GetServiceIdHashSalt(service_id)));
|
||||
if (item == virtual_sockets_.end()) {
|
||||
NEARBY_LOGS(INFO) << "Not found!";
|
||||
LOG(INFO) << "Not found!";
|
||||
return nullptr;
|
||||
}
|
||||
return item->second.get();
|
||||
@@ -268,10 +268,10 @@ int MultiplexSocket::GetVirtualSocketCount() {
|
||||
}
|
||||
|
||||
void MultiplexSocket::ListVirtualSocket() {
|
||||
NEARBY_LOGS(INFO) << __func__
|
||||
LOG(INFO) << __func__
|
||||
<< " virtual_sockets_.size()=" << virtual_sockets_.size();
|
||||
for (auto& [service_id_hash_key, virtual_socket] : virtual_sockets_) {
|
||||
NEARBY_LOGS(INFO) << __func__
|
||||
LOG(INFO) << __func__
|
||||
<< " service_id_hash_key=" << service_id_hash_key
|
||||
<< ", virtual_socket=" << virtual_socket;
|
||||
}
|
||||
@@ -293,7 +293,7 @@ void MultiplexSocket::UnRegisterConnectionResponse(
|
||||
MediumSocket* MultiplexSocket::EstablishVirtualSocket(
|
||||
const std::string& service_id) {
|
||||
if (!IsEnabled()) {
|
||||
NEARBY_LOGS(ERROR)
|
||||
LOG(ERROR)
|
||||
<< "MultiplexSocket is disabled, cannot establish virtual socket.";
|
||||
return nullptr;
|
||||
}
|
||||
@@ -308,7 +308,7 @@ MediumSocket* MultiplexSocket::EstablishVirtualSocket(
|
||||
.GetFlags()
|
||||
.multiplex_socket_connection_response_timeout_millis);
|
||||
if (!result.ok()) {
|
||||
NEARBY_LOGS(ERROR) << __func__
|
||||
LOG(ERROR) << __func__
|
||||
<< "EstablishVirtualSocket failed with response code="
|
||||
<< result.exception();
|
||||
return nullptr;
|
||||
@@ -317,19 +317,19 @@ MediumSocket* MultiplexSocket::EstablishVirtualSocket(
|
||||
ConnectionResponseCode response_code = result.GetResult();
|
||||
switch (response_code) {
|
||||
case ConnectionResponseFrame::CONNECTION_ACCEPTED:
|
||||
NEARBY_LOGS(INFO) << "EstablishVirtualSocket after remote response to"
|
||||
LOG(INFO) << "EstablishVirtualSocket after remote response to"
|
||||
" accept the connection with service_id="
|
||||
<< service_id
|
||||
<< ", service_id_hash_salt=" << service_id_hash_salt;
|
||||
return CreateVirtualSocket(service_id, service_id_hash_salt);
|
||||
case ConnectionResponseFrame::NOT_LISTENING:
|
||||
NEARBY_LOGS(ERROR) << "EstablishVirtualSocket failed for service_id="
|
||||
LOG(ERROR) << "EstablishVirtualSocket failed for service_id="
|
||||
<< service_id
|
||||
<< ", service_id_hash_salt=" << service_id_hash_salt
|
||||
<< " with response code=NOT_LISTENING";
|
||||
break;
|
||||
default:
|
||||
NEARBY_LOGS(ERROR) << "EstablishVirtualSocket failed for service_id="
|
||||
LOG(ERROR) << "EstablishVirtualSocket failed for service_id="
|
||||
<< service_id
|
||||
<< ", service_id_hash_salt=" << service_id_hash_salt
|
||||
<< " with response code=UNKNOWN_RESPONSE_CODE";
|
||||
@@ -340,13 +340,13 @@ MediumSocket* MultiplexSocket::EstablishVirtualSocket(
|
||||
|
||||
void MultiplexSocket::StartReaderThread(std::int32_t first_frame_len) {
|
||||
if (is_shutdown_) {
|
||||
NEARBY_LOGS(WARNING) << "Stop to start reader thread since socket is "
|
||||
LOG(WARNING) << "Stop to start reader thread since socket is "
|
||||
"shutdown.";
|
||||
return;
|
||||
}
|
||||
reader_thread_shutdown_barrier_ = std::make_unique<CountDownLatch>(1);
|
||||
physical_reader_thread_.Execute([this, first_frame_len]() {
|
||||
NEARBY_LOGS(INFO) << __func__ << " Reader thread starts.";
|
||||
LOG(INFO) << __func__ << " Reader thread starts.";
|
||||
auto first_frame_len_copy = first_frame_len;
|
||||
while (!is_shutdown_) {
|
||||
bool fail = false;
|
||||
@@ -359,19 +359,19 @@ void MultiplexSocket::StartReaderThread(std::int32_t first_frame_len) {
|
||||
read_int = Base64Utils::ReadInt(physical_reader_);
|
||||
}
|
||||
if (!read_int.ok()) {
|
||||
NEARBY_LOGS(WARNING)
|
||||
LOG(WARNING)
|
||||
<< __func__ << "Failed to read. Exception:" << read_int.exception();
|
||||
fail = true;
|
||||
} else {
|
||||
auto length = read_int.result();
|
||||
NEARBY_VLOG(1) << __func__ << " length:" << length;
|
||||
VLOG(1) << __func__ << " length:" << length;
|
||||
|
||||
if (length < 0 || length > FeatureFlags::GetInstance()
|
||||
.GetFlags()
|
||||
.connection_max_frame_length) {
|
||||
// Ignore the failure because not only one client use this
|
||||
// connection.
|
||||
NEARBY_LOGS(WARNING)
|
||||
LOG(WARNING)
|
||||
<< __func__ << "Failed to read because received a invalid length "
|
||||
<< length << ", but continue to read.";
|
||||
continue;
|
||||
@@ -379,7 +379,7 @@ void MultiplexSocket::StartReaderThread(std::int32_t first_frame_len) {
|
||||
|
||||
bytes = physical_reader_->ReadExactly(length);
|
||||
if (!bytes.ok()) {
|
||||
NEARBY_LOGS(WARNING)
|
||||
LOG(WARNING)
|
||||
<< __func__ << "Read data exception:" << bytes.exception();
|
||||
fail = true;
|
||||
}
|
||||
@@ -402,7 +402,7 @@ void MultiplexSocket::StartReaderThread(std::int32_t first_frame_len) {
|
||||
// the remote, it means that the remote and the local both
|
||||
// support multiplex as well. So it is safe to just turn on
|
||||
// the feature at this point.
|
||||
NEARBY_LOGS(INFO)
|
||||
LOG(INFO)
|
||||
<< __func__
|
||||
<< " Received a multiplex frame while not enabled, enable "
|
||||
"multiplex.";
|
||||
@@ -420,12 +420,12 @@ void MultiplexSocket::StartReaderThread(std::int32_t first_frame_len) {
|
||||
frame.control_frame());
|
||||
break;
|
||||
case MultiplexFrame::DATA_FRAME:
|
||||
NEARBY_VLOG(1) << "service_id_hash_salt: " << service_id_hash_salt;
|
||||
VLOG(1) << "service_id_hash_salt: " << service_id_hash_salt;
|
||||
HandleDataFrame(salted_service_id_hash, service_id_hash_salt,
|
||||
frame.data_frame());
|
||||
break;
|
||||
default:
|
||||
NEARBY_LOGS(WARNING)
|
||||
LOG(WARNING)
|
||||
<< __func__ << " Received MultiplexFrame with unknown frame type "
|
||||
<< frame.frame_type();
|
||||
}
|
||||
@@ -435,15 +435,15 @@ void MultiplexSocket::StartReaderThread(std::int32_t first_frame_len) {
|
||||
|
||||
void MultiplexSocket::HandleOfflineFrame(const ByteArray& bytes) {
|
||||
MutexLock lock(&virtual_socket_mutex_);
|
||||
NEARBY_LOGS(INFO) << __func__
|
||||
LOG(INFO) << __func__
|
||||
<< " Virtual_socket num:" << virtual_sockets_.size();
|
||||
if (virtual_sockets_.size() == 1) {
|
||||
auto item = virtual_sockets_.begin();
|
||||
if (item->second == nullptr) {
|
||||
NEARBY_LOGS(WARNING) << "Expected one live socket, but found null.";
|
||||
LOG(WARNING) << "Expected one live socket, but found null.";
|
||||
return;
|
||||
}
|
||||
NEARBY_LOGS(INFO) << __func__ << "FeedIncomingData:" << std::string(bytes);
|
||||
LOG(INFO) << __func__ << "FeedIncomingData:" << std::string(bytes);
|
||||
item->second->FeedIncomingData(Base64Utils::IntToBytes(bytes.size()));
|
||||
item->second->FeedIncomingData(bytes);
|
||||
}
|
||||
@@ -461,7 +461,7 @@ void MultiplexSocket::HandleControlFrame(
|
||||
});
|
||||
break;
|
||||
case MultiplexControlFrame::CONNECTION_RESPONSE:
|
||||
NEARBY_LOGS(INFO)
|
||||
LOG(INFO)
|
||||
<< __func__ << "Received an CONNECTION_RESPONSE frame."
|
||||
<< " salted_service_id_hash: " << std::string(salted_service_id_hash)
|
||||
<< ", service_id_hash_salt: " << service_id_hash_salt
|
||||
@@ -481,7 +481,7 @@ void MultiplexSocket::HandleControlFrame(
|
||||
});
|
||||
break;
|
||||
default:
|
||||
NEARBY_LOGS(WARNING) << __func__ << "Received an unknown frame type "
|
||||
LOG(WARNING) << __func__ << "Received an unknown frame type "
|
||||
<< frame.control_frame_type();
|
||||
break;
|
||||
}
|
||||
@@ -491,7 +491,7 @@ void MultiplexSocket::HandleConnectionRequest(
|
||||
const ByteArray& salted_service_id_hash,
|
||||
const std::string& service_id_hash_salt) {
|
||||
if (!IsEnabled()) {
|
||||
NEARBY_LOGS(WARNING) << "Received a CONNECTION_REQUEST frame on medium "
|
||||
LOG(WARNING) << "Received a CONNECTION_REQUEST frame on medium "
|
||||
<< Medium_Name(medium_)
|
||||
<< " but status is disabled, ignore it.";
|
||||
return;
|
||||
@@ -512,21 +512,21 @@ void MultiplexSocket::HandleConnectionRequest(
|
||||
}
|
||||
|
||||
if (incoming_connection_callback == nullptr || listening_service_id.empty()) {
|
||||
NEARBY_LOGS(INFO) << "There's no client listening for hash salt : "
|
||||
LOG(INFO) << "There's no client listening for hash salt : "
|
||||
<< service_id_hash_salt
|
||||
<< ", hash key : " << salted_service_id_hash_key
|
||||
<< " on medium " << Medium_Name(medium_);
|
||||
|
||||
NEARBY_LOGS(INFO) << "The size of incomingConnectionCallbacks : "
|
||||
LOG(INFO) << "The size of incomingConnectionCallbacks : "
|
||||
<< GetIncomingConnectionCallbacks().size();
|
||||
if (!multiplex_output_stream_.WriteConnectionResponseFrame(
|
||||
salted_service_id_hash, service_id_hash_salt,
|
||||
ConnectionResponseFrame::NOT_LISTENING)) {
|
||||
NEARBY_LOGS(INFO) << __func__ << "Failed to write NOT_LISTENING frame.";
|
||||
LOG(INFO) << __func__ << "Failed to write NOT_LISTENING frame.";
|
||||
}
|
||||
return;
|
||||
}
|
||||
NEARBY_LOGS(INFO) << "Accept new virtual socket request service ID : "
|
||||
LOG(INFO) << "Accept new virtual socket request service ID : "
|
||||
<< listening_service_id
|
||||
<< ", hash salt : " << service_id_hash_salt
|
||||
<< ", hash key : " << salted_service_id_hash_key
|
||||
@@ -535,11 +535,11 @@ void MultiplexSocket::HandleConnectionRequest(
|
||||
if (!multiplex_output_stream_.WriteConnectionResponseFrame(
|
||||
salted_service_id_hash, service_id_hash_salt,
|
||||
ConnectionResponseFrame::CONNECTION_ACCEPTED)) {
|
||||
NEARBY_LOGS(INFO) << "Failed to write CONNECTION_ACCEPTED frame.";
|
||||
LOG(INFO) << "Failed to write CONNECTION_ACCEPTED frame.";
|
||||
return;
|
||||
}
|
||||
|
||||
NEARBY_VLOG(1)
|
||||
VLOG(1)
|
||||
<< "EstablishVirtualSocket after local device accept the connection "
|
||||
"with serviceId="
|
||||
<< listening_service_id << ", serviceIdHashSalt=" << service_id_hash_salt;
|
||||
@@ -553,14 +553,14 @@ void MultiplexSocket::HandleConnectionResponse(
|
||||
const ByteArray& salted_service_id_hash,
|
||||
const std::string& service_id_hash_salt,
|
||||
const ConnectionResponseFrame& frame) {
|
||||
NEARBY_LOGS(INFO) << __func__ << "connection_response_code: "
|
||||
LOG(INFO) << __func__ << "connection_response_code: "
|
||||
<< frame.connection_response_code();
|
||||
for (auto& [service_id, future] : connection_response_futures_) {
|
||||
if (GenerateServiceIdHashWithSalt(service_id, service_id_hash_salt) ==
|
||||
salted_service_id_hash) {
|
||||
if (future != nullptr) {
|
||||
future->Set(frame.connection_response_code());
|
||||
NEARBY_LOGS(INFO) << __func__
|
||||
LOG(INFO) << __func__
|
||||
<< "Set the future for serviceId=" << service_id
|
||||
<< ", serviceIdHashSalt=" << service_id_hash_salt
|
||||
<< " with response code="
|
||||
@@ -570,7 +570,7 @@ void MultiplexSocket::HandleConnectionResponse(
|
||||
}
|
||||
}
|
||||
|
||||
NEARBY_LOGS(WARNING)
|
||||
LOG(WARNING)
|
||||
<< __func__
|
||||
<< "Received a CONNECTION_RESPONSE frame but no client waiting for "
|
||||
"service ID Hash Key"
|
||||
@@ -585,12 +585,12 @@ void MultiplexSocket::HandleDisconnection(
|
||||
MutexLock lock(&virtual_socket_mutex_);
|
||||
auto item = virtual_sockets_.find(salted_service_id_hash_key);
|
||||
if (item != virtual_sockets_.end()) {
|
||||
NEARBY_LOGS(INFO)
|
||||
LOG(INFO)
|
||||
<< "Received a DISCONNECTION frame to disconnect virtual socket for "
|
||||
"salted service ID Hash Key "
|
||||
<< salted_service_id_hash_key;
|
||||
} else {
|
||||
NEARBY_LOGS(WARNING)
|
||||
LOG(WARNING)
|
||||
<< "Received a DISCONNECTION frame but there's no alive socket to "
|
||||
"disconnect for service ID Hash Key "
|
||||
<< salted_service_id_hash_key;
|
||||
@@ -618,13 +618,13 @@ void MultiplexSocket::HandleDataFrame(const ByteArray& salted_service_id_hash,
|
||||
}
|
||||
|
||||
if (virtual_socket != nullptr) {
|
||||
NEARBY_VLOG(1)
|
||||
VLOG(1)
|
||||
<< "Received a DATA frame to feed virtual socket for salted service ID "
|
||||
"Hash Key "
|
||||
<< salted_service_id_hash_key;
|
||||
virtual_socket->FeedIncomingData(ByteArray(frame.data()));
|
||||
} else {
|
||||
NEARBY_LOGS(WARNING)
|
||||
LOG(WARNING)
|
||||
<< "Received a DATA frame but there's no alive socket to feed for "
|
||||
"salted service ID Hash Key "
|
||||
<< salted_service_id_hash_key;
|
||||
@@ -636,47 +636,47 @@ void MultiplexSocket::OnPhysicalSocketClosed() {
|
||||
}
|
||||
|
||||
void MultiplexSocket::OnVirtualSocketClosed(const std::string& service_id) {
|
||||
NEARBY_LOGS(INFO) << __func__ << " for service_id:" << service_id;
|
||||
LOG(INFO) << __func__ << " for service_id:" << service_id;
|
||||
CountDownLatch latch(1);
|
||||
bool shutdown = false;
|
||||
RunOffloadThread("VirtualSocketClosed", [this, service_id, &latch,
|
||||
&shutdown]() {
|
||||
NEARBY_LOGS(INFO) << "Try to close Virtual socket: " << service_id;
|
||||
LOG(INFO) << "Try to close Virtual socket: " << service_id;
|
||||
MediumSocket* virtual_socket = GetVirtualSocket(service_id);
|
||||
{
|
||||
MutexLock lock(&virtual_socket_mutex_);
|
||||
NEARBY_LOGS(INFO) << "virtual_socket:" << virtual_socket;
|
||||
LOG(INFO) << "virtual_socket:" << virtual_socket;
|
||||
if (virtual_socket != nullptr) {
|
||||
auto salted_service_id_hash_key = GenerateServiceIdHashKeyWithSalt(
|
||||
service_id,
|
||||
multiplex_output_stream_.GetServiceIdHashSalt(service_id));
|
||||
multiplex_output_stream_.Close(service_id);
|
||||
virtual_sockets_.erase(salted_service_id_hash_key);
|
||||
NEARBY_LOGS(INFO) << "Erase Virtual socket with service_id: "
|
||||
LOG(INFO) << "Erase Virtual socket with service_id: "
|
||||
<< service_id
|
||||
<< ", hash_key: " << salted_service_id_hash_key;
|
||||
ListVirtualSocket();
|
||||
|
||||
if (virtual_sockets_.empty()) {
|
||||
NEARBY_LOGS(INFO) << "Close the physical socket because all virtual "
|
||||
LOG(INFO) << "Close the physical socket because all virtual "
|
||||
"sockets disconnected.";
|
||||
is_shutting_down_.Set(true);
|
||||
Shutdown();
|
||||
shutdown = true;
|
||||
}
|
||||
} else {
|
||||
NEARBY_LOGS(INFO) << "Virtual socket(" << service_id << ") not found";
|
||||
LOG(INFO) << "Virtual socket(" << service_id << ") not found";
|
||||
}
|
||||
}
|
||||
latch.CountDown();
|
||||
});
|
||||
|
||||
if (!latch.Await(absl::Milliseconds(1000)).result()) {
|
||||
NEARBY_LOGS(ERROR) << "Timeout to close virtual socket";
|
||||
LOG(ERROR) << "Timeout to close virtual socket";
|
||||
}
|
||||
|
||||
if (shutdown) {
|
||||
NEARBY_LOGS(INFO)
|
||||
LOG(INFO)
|
||||
<< "Shutdown single_thread_offloader_ and physical_reader_thread_";
|
||||
single_thread_offloader_.Shutdown();
|
||||
physical_reader_thread_.Shutdown();
|
||||
@@ -689,7 +689,7 @@ MediumSocket* MultiplexSocket::ReMapAndGetVirtualSocket(
|
||||
const std::string& service_id_hash_salt) {
|
||||
std::string salted_service_id_hash_key =
|
||||
GenerateServiceIdHashKey(salted_service_id_hash);
|
||||
NEARBY_VLOG(1) << "ReMapAndGetVirtualSocket with serviceIdHashSalt="
|
||||
VLOG(1) << "ReMapAndGetVirtualSocket with serviceIdHashSalt="
|
||||
<< service_id_hash_salt
|
||||
<< ", saltedServiceIdHashKey=" << salted_service_id_hash_key;
|
||||
{
|
||||
@@ -708,10 +708,10 @@ MediumSocket* MultiplexSocket::ReMapAndGetVirtualSocket(
|
||||
(hash_key == salted_service_id_hash_key)) {
|
||||
return virtual_socket.get();
|
||||
} else {
|
||||
NEARBY_LOGS(INFO) << "Remap the virtualSockets.";
|
||||
LOG(INFO) << "Remap the virtualSockets.";
|
||||
output_stream->SetserviceIdHashSalt(service_id_hash_salt);
|
||||
auto virtual_socket_tmp = virtual_socket;
|
||||
NEARBY_LOGS(INFO) << "virtual_socket before:" << virtual_socket;
|
||||
LOG(INFO) << "virtual_socket before:" << virtual_socket;
|
||||
virtual_sockets_.erase(hash_key);
|
||||
virtual_sockets_[salted_service_id_hash_key] = virtual_socket_tmp;
|
||||
ListVirtualSocket();
|
||||
@@ -720,7 +720,7 @@ MediumSocket* MultiplexSocket::ReMapAndGetVirtualSocket(
|
||||
}
|
||||
}
|
||||
|
||||
NEARBY_LOGS(INFO) << "Failed to remap the virtualSockets.";
|
||||
LOG(INFO) << "Failed to remap the virtualSockets.";
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
@@ -730,9 +730,9 @@ void MultiplexSocket::RunOffloadThread(const std::string& name,
|
||||
}
|
||||
|
||||
void MultiplexSocket::Shutdown() {
|
||||
NEARBY_LOGS(INFO) << __func__ << " start";
|
||||
LOG(INFO) << __func__ << " start";
|
||||
if (is_shutdown_) {
|
||||
NEARBY_LOGS(INFO) << __func__ << " Already shutdown";
|
||||
LOG(INFO) << __func__ << " Already shutdown";
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -748,13 +748,13 @@ void MultiplexSocket::Shutdown() {
|
||||
|
||||
is_shutdown_ = true;
|
||||
enabled_.Set(false);
|
||||
NEARBY_LOGS(INFO) << __func__ << " end";
|
||||
LOG(INFO) << __func__ << " end";
|
||||
}
|
||||
|
||||
void MultiplexSocket::ShutdownAll() {
|
||||
NEARBY_LOGS(INFO) << __func__ << " start";
|
||||
LOG(INFO) << __func__ << " start";
|
||||
if (is_shutdown_) {
|
||||
NEARBY_LOGS(WARNING) << __func__ << " Already shutdown";
|
||||
LOG(WARNING) << __func__ << " Already shutdown";
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -776,14 +776,14 @@ void MultiplexSocket::ShutdownAll() {
|
||||
.mediums_frame_write_timeout_millis +
|
||||
absl::Milliseconds(100))
|
||||
.result()) {
|
||||
NEARBY_LOGS(ERROR) << "Timeout to close virtual socket";
|
||||
LOG(ERROR) << "Timeout to close virtual socket";
|
||||
}
|
||||
|
||||
NEARBY_LOGS(INFO)
|
||||
LOG(INFO)
|
||||
<< "Shutdown single_thread_offloader_ and physical_reader_thread_";
|
||||
single_thread_offloader_.Shutdown();
|
||||
physical_reader_thread_.Shutdown();
|
||||
NEARBY_LOGS(INFO) << __func__ << " end";
|
||||
LOG(INFO) << __func__ << " end";
|
||||
}
|
||||
|
||||
} // namespace multiplex
|
||||
|
||||
@@ -92,7 +92,7 @@ class MultiplexSocket {
|
||||
|
||||
bool IsEnabled() { return enabled_.Get(); }
|
||||
void Enable() {
|
||||
NEARBY_LOGS(INFO) << "Enable the Multiplex MediumSocket.";
|
||||
LOG(INFO) << "Enable the Multiplex MediumSocket.";
|
||||
enabled_.Set(true);
|
||||
}
|
||||
|
||||
|
||||
@@ -66,7 +66,7 @@ class FakeSocket : public MediumSocket {
|
||||
pipe_2_ = CreatePipe();
|
||||
reader_2_ = std::move(pipe_2_.first);
|
||||
writer_2_ = std::move(pipe_2_.second);
|
||||
NEARBY_LOGS(WARNING) << "Physical Socket Medium:"
|
||||
LOG(WARNING) << "Physical Socket Medium:"
|
||||
<< Medium_Name(GetMedium());
|
||||
};
|
||||
~FakeSocket() override = default;
|
||||
@@ -92,11 +92,11 @@ class FakeSocket : public MediumSocket {
|
||||
OutputStream& GetOutputStream() override { return *writer_2_; }
|
||||
Exception Close() override {
|
||||
if (IsVirtualSocket()) {
|
||||
NEARBY_LOGS(INFO) << "Multiplex: Closing virtual socket: " << this;
|
||||
LOG(INFO) << "Multiplex: Closing virtual socket: " << this;
|
||||
CloseLocal();
|
||||
return {Exception::kSuccess};
|
||||
}
|
||||
NEARBY_LOGS(INFO) << "Multiplex: Closing physical socket: " << this;
|
||||
LOG(INFO) << "Multiplex: Closing physical socket: " << this;
|
||||
reader_1_->Close();
|
||||
reader_2_->Close();
|
||||
writer_1_->Close();
|
||||
@@ -110,13 +110,13 @@ class FakeSocket : public MediumSocket {
|
||||
absl::flat_hash_map<std::string, std::shared_ptr<MediumSocket>>*
|
||||
virtual_sockets_ptr) override {
|
||||
if (IsVirtualSocket()) {
|
||||
NEARBY_LOGS(WARNING)
|
||||
LOG(WARNING)
|
||||
<< "Creating the virtual socket on a virtual socket is not allowed.";
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
auto virtual_socket = std::make_shared<FakeSocket>(medium, outputstream);
|
||||
NEARBY_LOGS(WARNING) << "Created the virtual socket for Medium: "
|
||||
LOG(WARNING) << "Created the virtual socket for Medium: "
|
||||
<< Medium_Name(virtual_socket->GetMedium());
|
||||
|
||||
if (virtual_sockets_ptr_ == nullptr) {
|
||||
@@ -124,14 +124,14 @@ class FakeSocket : public MediumSocket {
|
||||
}
|
||||
|
||||
(*virtual_sockets_ptr_)[salted_service_id_hash_key] = virtual_socket;
|
||||
NEARBY_LOGS(INFO) << "virtual_sockets_ size: "
|
||||
LOG(INFO) << "virtual_sockets_ size: "
|
||||
<< virtual_sockets_ptr_->size();
|
||||
return virtual_socket.get();
|
||||
}
|
||||
|
||||
void FeedIncomingData(ByteArray data) override {
|
||||
bytes_read_future_.Set(data);
|
||||
NEARBY_LOGS(INFO) << "FeedIncomingData. Size of receive data: "
|
||||
LOG(INFO) << "FeedIncomingData. Size of receive data: "
|
||||
<< data.size() << ", bytes content:" << std::string(data);
|
||||
}
|
||||
|
||||
@@ -167,7 +167,7 @@ TEST(MultiplexSocketTest, CreateSuccessAndReaderThreadStarted) {
|
||||
(FakeSocket*)multiplex_socket_incoming->GetVirtualSocket(
|
||||
std::string(SERVICE_ID_1));
|
||||
if (virtual_socket == nullptr) {
|
||||
NEARBY_LOGS(INFO) << "Virtual socket not found for " << SERVICE_ID_1;
|
||||
LOG(INFO) << "Virtual socket not found for " << SERVICE_ID_1;
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -181,11 +181,11 @@ TEST(MultiplexSocketTest, CreateSuccessAndReaderThreadStarted) {
|
||||
.local_endpoint_info = ByteArray("endpoint1 info"),
|
||||
});
|
||||
auto& writer = socket->writer_1_;
|
||||
NEARBY_LOGS(INFO) << "writer_1_ Write start";
|
||||
LOG(INFO) << "writer_1_ Write start";
|
||||
writer->Write(Base64Utils::IntToBytes(connection_req_frame.size()));
|
||||
writer->Write(connection_req_frame);
|
||||
writer->Flush();
|
||||
NEARBY_LOGS(INFO) << "writer_1_ Write end";
|
||||
LOG(INFO) << "writer_1_ Write end";
|
||||
latch.CountDown();
|
||||
});
|
||||
|
||||
@@ -195,7 +195,7 @@ TEST(MultiplexSocketTest, CreateSuccessAndReaderThreadStarted) {
|
||||
ADD_FAILURE() << "Read error: " << result.GetException().value;
|
||||
}
|
||||
ByteArray data = result.result();
|
||||
NEARBY_LOGS(INFO) << "Received " << data.size() << " bytes of data.";
|
||||
LOG(INFO) << "Received " << data.size() << " bytes of data.";
|
||||
EXPECT_NE(data.size(), 0);
|
||||
absl::SleepFor(absl::Milliseconds(100));
|
||||
socket->reader_1_->Close();
|
||||
@@ -235,7 +235,7 @@ TEST(MultiplexSocketTest,
|
||||
(FakeSocket*)multiplex_socket->GetVirtualSocket(
|
||||
std::string(SERVICE_ID_1));
|
||||
if (virtual_socket == nullptr) {
|
||||
NEARBY_LOGS(INFO) << "Virtual socket not found for " << SERVICE_ID_1;
|
||||
LOG(INFO) << "Virtual socket not found for " << SERVICE_ID_1;
|
||||
return;
|
||||
}
|
||||
fake_socket_ptr->reader_1_->Close();
|
||||
@@ -258,31 +258,31 @@ TEST(MultiplexSocketTest,
|
||||
FakeSocket* virtual_socket = (FakeSocket*)multiplex_socket->GetVirtualSocket(
|
||||
std::string(SERVICE_ID_1));
|
||||
if (virtual_socket == nullptr) {
|
||||
NEARBY_LOGS(INFO) << "Virtual socket not found for " << SERVICE_ID_1;
|
||||
LOG(INFO) << "Virtual socket not found for " << SERVICE_ID_1;
|
||||
return;
|
||||
}
|
||||
|
||||
SingleThreadExecutor executor;
|
||||
CountDownLatch latch(1);
|
||||
executor.Execute([&multiplex_socket, &latch]() {
|
||||
NEARBY_LOGS(INFO) << "EstablishVirtualSocket";
|
||||
LOG(INFO) << "EstablishVirtualSocket";
|
||||
MediumSocket* socket =
|
||||
multiplex_socket->EstablishVirtualSocket(std::string(SERVICE_ID_2));
|
||||
NEARBY_LOGS(INFO) << "EstablishVirtualSocket finished";
|
||||
LOG(INFO) << "EstablishVirtualSocket finished";
|
||||
EXPECT_EQ(socket, nullptr);
|
||||
latch.CountDown();
|
||||
});
|
||||
latch.Await(absl::Milliseconds(3000));
|
||||
|
||||
auto reader = fake_socket_ptr->reader_2_.get();
|
||||
NEARBY_LOGS(INFO) << "reader_2_ Read start";
|
||||
LOG(INFO) << "reader_2_ Read start";
|
||||
ExceptionOr<std::int32_t> read_int = Base64Utils::ReadInt(reader);
|
||||
if (!read_int.ok()) {
|
||||
ADD_FAILURE() << "Failed to read. Exception:"
|
||||
<< read_int.exception();
|
||||
}
|
||||
auto length = read_int.result();
|
||||
NEARBY_LOGS(INFO) << " length:" << length;
|
||||
LOG(INFO) << " length:" << length;
|
||||
EXPECT_GT(length, 0);
|
||||
EXPECT_EQ(multiplex_socket->GetVirtualSocket(std::string(SERVICE_ID_2)),
|
||||
nullptr);
|
||||
@@ -309,14 +309,14 @@ TEST(MultiplexSocketTest,
|
||||
|
||||
SingleThreadExecutor executor;
|
||||
executor.Execute([&multiplex_socket]() {
|
||||
NEARBY_LOGS(INFO) << "EstablishVirtualSocket";
|
||||
LOG(INFO) << "EstablishVirtualSocket";
|
||||
MediumSocket* socket =
|
||||
multiplex_socket->EstablishVirtualSocket(std::string(SERVICE_ID_2));
|
||||
EXPECT_NE(socket, nullptr);
|
||||
});
|
||||
|
||||
auto reader = fake_socket_ptr->reader_2_.get();
|
||||
NEARBY_LOGS(INFO) << "reader_2_ Waiting for CONNECTION_REQUEST frame.";
|
||||
LOG(INFO) << "reader_2_ Waiting for CONNECTION_REQUEST frame.";
|
||||
ExceptionOr<std::int32_t> read_int = Base64Utils::ReadInt(reader);
|
||||
if (!read_int.ok()) {
|
||||
ADD_FAILURE() << "Failed to read length.Exception:" << read_int.exception();
|
||||
@@ -355,18 +355,18 @@ TEST(MultiplexSocketTest,
|
||||
auto control_frame = frame.control_frame();
|
||||
ASSERT_EQ(control_frame.control_frame_type(),
|
||||
MultiplexControlFrame::CONNECTION_REQUEST);
|
||||
NEARBY_LOGS(INFO) << "Recieved MultiplexControlFrame::CONNECTION_REQUEST "
|
||||
LOG(INFO) << "Recieved MultiplexControlFrame::CONNECTION_REQUEST "
|
||||
"frame, now send CONNECTION_RESPONSE frame.";
|
||||
|
||||
ByteArray connection_response_frame =
|
||||
ForConnectionResponse(salted_service_id_hash, service_id_hash_salt,
|
||||
ConnectionResponseFrame::CONNECTION_ACCEPTED);
|
||||
auto& writer = fake_socket_ptr->writer_1_;
|
||||
NEARBY_LOGS(INFO) << "writer_1_ Write start";
|
||||
LOG(INFO) << "writer_1_ Write start";
|
||||
writer->Write(Base64Utils::IntToBytes(connection_response_frame.size()));
|
||||
writer->Write(connection_response_frame);
|
||||
writer->Flush();
|
||||
NEARBY_LOGS(INFO) << "writer_1_ Write end";
|
||||
LOG(INFO) << "writer_1_ Write end";
|
||||
absl::SleepFor(absl::Milliseconds(100));
|
||||
EXPECT_NE(multiplex_socket->GetVirtualSocket(std::string(SERVICE_ID_2)),
|
||||
nullptr);
|
||||
|
||||
@@ -102,13 +102,13 @@ bool WebRtc::StartAcceptingConnections(const std::string& service_id,
|
||||
bool non_cellular) {
|
||||
MutexLock lock(&mutex_);
|
||||
if (!IsAvailable()) {
|
||||
NEARBY_LOGS(WARNING) << "Cannot start accepting WebRTC connections because "
|
||||
LOG(WARNING) << "Cannot start accepting WebRTC connections because "
|
||||
"WebRTC is not available.";
|
||||
return false;
|
||||
}
|
||||
|
||||
if (IsAcceptingConnectionsLocked(service_id)) {
|
||||
NEARBY_LOGS(WARNING)
|
||||
LOG(WARNING)
|
||||
<< "Cannot start accepting WebRTC connections because service "
|
||||
<< service_id << "is already accepting WebRTC connections.";
|
||||
return false;
|
||||
@@ -150,7 +150,7 @@ bool WebRtc::StartAcceptingConnections(const std::string& service_id,
|
||||
// Now that we're set up to receive messages, we'll save our state and return
|
||||
// a successful result.
|
||||
accepting_connections_info_.emplace(service_id, std::move(info));
|
||||
NEARBY_LOGS(INFO) << "Started listening for WebRTC connections as "
|
||||
LOG(INFO) << "Started listening for WebRTC connections as "
|
||||
<< self_peer_id.GetId() << " on service " << service_id;
|
||||
return true;
|
||||
}
|
||||
@@ -158,7 +158,7 @@ bool WebRtc::StartAcceptingConnections(const std::string& service_id,
|
||||
void WebRtc::StopAcceptingConnections(const std::string& service_id) {
|
||||
MutexLock lock(&mutex_);
|
||||
if (!IsAcceptingConnectionsLocked(service_id)) {
|
||||
NEARBY_LOGS(WARNING)
|
||||
LOG(WARNING)
|
||||
<< "Cannot stop accepting WebRTC connections because service "
|
||||
<< service_id << "is not accepting WebRTC connections.";
|
||||
return;
|
||||
@@ -205,7 +205,7 @@ void WebRtc::StopAcceptingConnections(const std::string& service_id) {
|
||||
|
||||
// Clean up our state. We're now no longer listening for connections.
|
||||
accepting_connections_info_.erase(service_id);
|
||||
NEARBY_LOGS(INFO) << "Stopped listening for WebRTC connections for service "
|
||||
LOG(INFO) << "Stopped listening for WebRTC connections for service "
|
||||
<< service_id;
|
||||
}
|
||||
|
||||
@@ -220,7 +220,7 @@ ErrorOr<WebRtcSocketWrapper> WebRtc::Connect(
|
||||
while (service_id_to_connect_attempts_count_map_[service_id] <=
|
||||
kConnectAttemptsLimit) {
|
||||
if (cancellation_flag->Cancelled()) {
|
||||
NEARBY_LOGS(WARNING)
|
||||
LOG(WARNING)
|
||||
<< "Attempt #"
|
||||
<< service_id_to_connect_attempts_count_map_[service_id]
|
||||
<< ": Cannot Connect with WebRtc due to cancel.";
|
||||
@@ -229,7 +229,7 @@ ErrorOr<WebRtcSocketWrapper> WebRtc::Connect(
|
||||
CLIENT_CANCELLATION_CANCEL_WEB_RTC_OUTGOING_CONNECTION)};
|
||||
}
|
||||
|
||||
NEARBY_LOGS(INFO) << "Attempt #"
|
||||
LOG(INFO) << "Attempt #"
|
||||
<< service_id_to_connect_attempts_count_map_[service_id]
|
||||
<< ": Beginning connection.";
|
||||
wrapper_result = AttemptToConnect(service_id, remote_peer_id, location_hint,
|
||||
@@ -241,7 +241,7 @@ ErrorOr<WebRtcSocketWrapper> WebRtc::Connect(
|
||||
service_id_to_connect_attempts_count_map_[service_id]++;
|
||||
}
|
||||
|
||||
NEARBY_LOGS(WARNING) << "Giving up after " << kConnectAttemptsLimit
|
||||
LOG(WARNING) << "Giving up after " << kConnectAttemptsLimit
|
||||
<< " attempts";
|
||||
return {Error(wrapper_result.error().operation_result_code().value())};
|
||||
}
|
||||
@@ -259,7 +259,7 @@ ErrorOr<WebRtcSocketWrapper> WebRtc::AttemptToConnect(
|
||||
// is complete.
|
||||
CancellationFlagListener listener(
|
||||
cancellation_flag, [this, &service_id, &socket_future]() {
|
||||
NEARBY_LOGS(WARNING)
|
||||
LOG(WARNING)
|
||||
<< "Attempt # "
|
||||
<< service_id_to_connect_attempts_count_map_[service_id]
|
||||
<< " to connect with WebRtc stopped due to cancel.";
|
||||
@@ -269,7 +269,7 @@ ErrorOr<WebRtcSocketWrapper> WebRtc::AttemptToConnect(
|
||||
{
|
||||
MutexLock lock(&mutex_);
|
||||
if (!IsAvailable()) {
|
||||
NEARBY_LOGS(WARNING) << "Cannot connect to WebRTC peer "
|
||||
LOG(WARNING) << "Cannot connect to WebRTC peer "
|
||||
<< remote_peer_id.GetId()
|
||||
<< " because WebRTC is not available.";
|
||||
return {
|
||||
@@ -280,7 +280,7 @@ ErrorOr<WebRtcSocketWrapper> WebRtc::AttemptToConnect(
|
||||
std::unique_ptr<ConnectionFlow> connection_flow =
|
||||
CreateConnectionFlow(service_id, remote_peer_id);
|
||||
if (!connection_flow) {
|
||||
NEARBY_LOGS(INFO) << "Cannot connect to WebRTC peer "
|
||||
LOG(INFO) << "Cannot connect to WebRTC peer "
|
||||
<< remote_peer_id.GetId()
|
||||
<< " because we failed to create a ConnectionFlow.";
|
||||
return {Error(OperationResultCode::NEARBY_WEB_RTC_CONNECTION_FLOW_NULL)};
|
||||
@@ -290,7 +290,7 @@ ErrorOr<WebRtcSocketWrapper> WebRtc::AttemptToConnect(
|
||||
info.signaling_messenger = medium_->GetSignalingMessenger(
|
||||
info.self_peer_id.GetId(), location_hint);
|
||||
if (!info.signaling_messenger->IsValid()) {
|
||||
NEARBY_LOGS(INFO) << "Cannot connect to WebRTC peer "
|
||||
LOG(INFO) << "Cannot connect to WebRTC peer "
|
||||
<< remote_peer_id.GetId()
|
||||
<< " because we failed to create a SignalingMessenger.";
|
||||
return {
|
||||
@@ -308,7 +308,7 @@ ErrorOr<WebRtcSocketWrapper> WebRtc::AttemptToConnect(
|
||||
if (!info.signaling_messenger->StartReceivingMessages(
|
||||
absl::bind_front(&WebRtc::OnSignalingMessage, this, service_id),
|
||||
signaling_complete_callback)) {
|
||||
NEARBY_LOGS(INFO)
|
||||
LOG(INFO)
|
||||
<< "Cannot connect to WebRTC peer " << remote_peer_id.GetId()
|
||||
<< " because we failed to start receiving messages over Tachyon.";
|
||||
info.signaling_messenger.reset();
|
||||
@@ -320,7 +320,7 @@ ErrorOr<WebRtcSocketWrapper> WebRtc::AttemptToConnect(
|
||||
if (!info.signaling_messenger->SendMessage(
|
||||
remote_peer_id.GetId(),
|
||||
webrtc_frames::EncodeReadyForSignalingPoke(info.self_peer_id))) {
|
||||
NEARBY_LOGS(INFO) << "Cannot connect to WebRTC peer "
|
||||
LOG(INFO) << "Cannot connect to WebRTC peer "
|
||||
<< remote_peer_id.GetId()
|
||||
<< " because we failed to poke the peer over Tachyon.";
|
||||
info.signaling_messenger.reset();
|
||||
@@ -351,7 +351,7 @@ ErrorOr<WebRtcSocketWrapper> WebRtc::AttemptToConnect(
|
||||
|
||||
// Verify that the connection went through.
|
||||
if (!socket_result.ok()) {
|
||||
NEARBY_LOGS(INFO) << "Failed to connect to WebRTC peer "
|
||||
LOG(INFO) << "Failed to connect to WebRTC peer "
|
||||
<< remote_peer_id.GetId();
|
||||
RemoveConnectionFlow(remote_peer_id);
|
||||
info.signaling_messenger.reset();
|
||||
@@ -385,11 +385,11 @@ void WebRtc::ProcessLocalIceCandidate(
|
||||
webrtc_frames::EncodeIceCandidates(
|
||||
connection_request_entry->second.self_peer_id,
|
||||
{ice_candidate}))) {
|
||||
NEARBY_LOGS(INFO) << "Failed to send ice candidate to "
|
||||
LOG(INFO) << "Failed to send ice candidate to "
|
||||
<< remote_peer_id.GetId();
|
||||
}
|
||||
|
||||
NEARBY_LOGS(INFO) << "Sent ice candidate to " << remote_peer_id.GetId();
|
||||
LOG(INFO) << "Sent ice candidate to " << remote_peer_id.GetId();
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -405,15 +405,15 @@ void WebRtc::ProcessLocalIceCandidate(
|
||||
webrtc_frames::EncodeIceCandidates(
|
||||
accepting_connection_entry->second.self_peer_id,
|
||||
{ice_candidate}))) {
|
||||
NEARBY_LOGS(INFO) << "Failed to send ice candidate to "
|
||||
LOG(INFO) << "Failed to send ice candidate to "
|
||||
<< remote_peer_id.GetId();
|
||||
}
|
||||
|
||||
NEARBY_LOGS(INFO) << "Sent ice candidate to " << remote_peer_id.GetId();
|
||||
LOG(INFO) << "Sent ice candidate to " << remote_peer_id.GetId();
|
||||
return;
|
||||
}
|
||||
|
||||
NEARBY_LOGS(INFO) << "Skipping restart listening for tachyon inbox messages "
|
||||
LOG(INFO) << "Skipping restart listening for tachyon inbox messages "
|
||||
"since we are not accepting connections for service "
|
||||
<< service_id;
|
||||
}
|
||||
@@ -426,7 +426,7 @@ void WebRtc::OnSignalingMessage(const std::string& service_id,
|
||||
}
|
||||
|
||||
void WebRtc::OnSignalingComplete(const std::string& service_id, bool success) {
|
||||
NEARBY_LOGS(INFO) << "Signaling completed with status: " << success;
|
||||
LOG(INFO) << "Signaling completed with status: " << success;
|
||||
if (success) {
|
||||
return;
|
||||
}
|
||||
@@ -456,13 +456,13 @@ void WebRtc::ProcessTachyonInboxMessage(const std::string& service_id,
|
||||
// Attempt to parse the incoming message as a WebRtcSignalingFrame.
|
||||
location::nearby::mediums::WebRtcSignalingFrame frame;
|
||||
if (!frame.ParseFromString(std::string(message))) {
|
||||
NEARBY_LOGS(WARNING) << "Failed to parse signaling message.";
|
||||
LOG(WARNING) << "Failed to parse signaling message.";
|
||||
return;
|
||||
}
|
||||
|
||||
// Ensure that the frame is valid (no missing fields).
|
||||
if (!frame.has_sender_id()) {
|
||||
NEARBY_LOGS(WARNING) << "Invalid WebRTC frame: Sender ID is missing.";
|
||||
LOG(WARNING) << "Invalid WebRTC frame: Sender ID is missing.";
|
||||
return;
|
||||
}
|
||||
WebrtcPeerId remote_peer_id = WebrtcPeerId(frame.sender_id().id());
|
||||
@@ -480,7 +480,7 @@ void WebRtc::ProcessTachyonInboxMessage(const std::string& service_id,
|
||||
ReceiveIceCandidates(remote_peer_id,
|
||||
webrtc_frames::DecodeIceCandidates(frame));
|
||||
} else {
|
||||
NEARBY_LOGS(INFO) << "Received unknown WebRTC frame: ignoring.";
|
||||
LOG(INFO) << "Received unknown WebRTC frame: ignoring.";
|
||||
}
|
||||
} else if (IsAcceptingConnectionsLocked(service_id)) {
|
||||
// We don't have an outgoing connection request with this peer, but we are
|
||||
@@ -495,10 +495,10 @@ void WebRtc::ProcessTachyonInboxMessage(const std::string& service_id,
|
||||
ReceiveIceCandidates(remote_peer_id,
|
||||
webrtc_frames::DecodeIceCandidates(frame));
|
||||
} else {
|
||||
NEARBY_LOGS(INFO) << "Received unknown WebRTC frame: ignoring.";
|
||||
LOG(INFO) << "Received unknown WebRTC frame: ignoring.";
|
||||
}
|
||||
} else {
|
||||
NEARBY_LOGS(INFO)
|
||||
LOG(INFO)
|
||||
<< "Ignoring Tachyon message since we are not accepting connections.";
|
||||
}
|
||||
}
|
||||
@@ -508,14 +508,14 @@ void WebRtc::SendOffer(const std::string& service_id,
|
||||
std::unique_ptr<ConnectionFlow> connection_flow =
|
||||
CreateConnectionFlow(service_id, remote_peer_id);
|
||||
if (!connection_flow) {
|
||||
NEARBY_LOGS(INFO)
|
||||
LOG(INFO)
|
||||
<< "Unable to send offer. Failed to create a ConnectionFlow.";
|
||||
return;
|
||||
}
|
||||
|
||||
SessionDescriptionWrapper offer = connection_flow->CreateOffer();
|
||||
if (!offer.IsValid()) {
|
||||
NEARBY_LOGS(INFO)
|
||||
LOG(INFO)
|
||||
<< "Unable to send offer. Failed to create our offer locally.";
|
||||
RemoveConnectionFlow(remote_peer_id);
|
||||
return;
|
||||
@@ -523,7 +523,7 @@ void WebRtc::SendOffer(const std::string& service_id,
|
||||
|
||||
const webrtc::SessionDescriptionInterface& sdp = offer.GetSdp();
|
||||
if (!connection_flow->SetLocalSessionDescription(offer)) {
|
||||
NEARBY_LOGS(INFO)
|
||||
LOG(INFO)
|
||||
<< "Unable to send offer. Failed to register our offer locally.";
|
||||
RemoveConnectionFlow(remote_peer_id);
|
||||
return;
|
||||
@@ -536,7 +536,7 @@ void WebRtc::SendOffer(const std::string& service_id,
|
||||
if (!info.signaling_messenger->SendMessage(
|
||||
remote_peer_id.GetId(),
|
||||
webrtc_frames::EncodeOffer(info.self_peer_id, sdp))) {
|
||||
NEARBY_LOGS(INFO)
|
||||
LOG(INFO)
|
||||
<< "Unable to send offer. Failed to write the offer to the remote peer "
|
||||
<< remote_peer_id.GetId();
|
||||
RemoveConnectionFlow(remote_peer_id);
|
||||
@@ -545,20 +545,20 @@ void WebRtc::SendOffer(const std::string& service_id,
|
||||
|
||||
// Store the ConnectionFlow so that other methods can use it later.
|
||||
connection_flows_.emplace(remote_peer_id.GetId(), std::move(connection_flow));
|
||||
NEARBY_LOGS(INFO) << "Sent offer to " << remote_peer_id.GetId();
|
||||
LOG(INFO) << "Sent offer to " << remote_peer_id.GetId();
|
||||
}
|
||||
|
||||
void WebRtc::ReceiveOffer(const WebrtcPeerId& remote_peer_id,
|
||||
SessionDescriptionWrapper offer) {
|
||||
const auto& entry = connection_flows_.find(remote_peer_id.GetId());
|
||||
if (entry == connection_flows_.end()) {
|
||||
NEARBY_LOGS(INFO)
|
||||
LOG(INFO)
|
||||
<< "Unable to receive offer. Failed to create a ConnectionFlow.";
|
||||
return;
|
||||
}
|
||||
|
||||
if (!entry->second->OnOfferReceived(offer)) {
|
||||
NEARBY_LOGS(INFO)
|
||||
LOG(INFO)
|
||||
<< "Unable to receive offer. Failed to process the offer.";
|
||||
RemoveConnectionFlow(remote_peer_id);
|
||||
}
|
||||
@@ -567,14 +567,14 @@ void WebRtc::ReceiveOffer(const WebrtcPeerId& remote_peer_id,
|
||||
void WebRtc::SendAnswer(const WebrtcPeerId& remote_peer_id) {
|
||||
const auto& entry = connection_flows_.find(remote_peer_id.GetId());
|
||||
if (entry == connection_flows_.end()) {
|
||||
NEARBY_LOGS(INFO)
|
||||
LOG(INFO)
|
||||
<< "Unable to send answer. Failed to create a ConnectionFlow.";
|
||||
return;
|
||||
}
|
||||
|
||||
SessionDescriptionWrapper answer = entry->second->CreateAnswer();
|
||||
if (!answer.IsValid()) {
|
||||
NEARBY_LOGS(INFO)
|
||||
LOG(INFO)
|
||||
<< "Unable to send answer. Failed to create our answer locally.";
|
||||
RemoveConnectionFlow(remote_peer_id);
|
||||
return;
|
||||
@@ -582,7 +582,7 @@ void WebRtc::SendAnswer(const WebrtcPeerId& remote_peer_id) {
|
||||
|
||||
const webrtc::SessionDescriptionInterface& sdp = answer.GetSdp();
|
||||
if (!entry->second->SetLocalSessionDescription(answer)) {
|
||||
NEARBY_LOGS(INFO)
|
||||
LOG(INFO)
|
||||
<< "Unable to send answer. Failed to register our answer locally.";
|
||||
RemoveConnectionFlow(remote_peer_id);
|
||||
return;
|
||||
@@ -592,7 +592,7 @@ void WebRtc::SendAnswer(const WebrtcPeerId& remote_peer_id) {
|
||||
const auto& connection_request_entry =
|
||||
requesting_connections_info_.find(remote_peer_id.GetId());
|
||||
if (connection_request_entry == requesting_connections_info_.end()) {
|
||||
NEARBY_LOGS(INFO) << "Unable to send answer. Failed to find an outgoing "
|
||||
LOG(INFO) << "Unable to send answer. Failed to find an outgoing "
|
||||
"connection request.";
|
||||
RemoveConnectionFlow(remote_peer_id);
|
||||
return;
|
||||
@@ -603,7 +603,7 @@ void WebRtc::SendAnswer(const WebrtcPeerId& remote_peer_id) {
|
||||
remote_peer_id.GetId(),
|
||||
webrtc_frames::EncodeAnswer(
|
||||
connection_request_entry->second.self_peer_id, sdp))) {
|
||||
NEARBY_LOGS(INFO)
|
||||
LOG(INFO)
|
||||
<< "Unable to send answer. Failed to write the answer to the remote "
|
||||
"peer "
|
||||
<< remote_peer_id.GetId();
|
||||
@@ -611,20 +611,20 @@ void WebRtc::SendAnswer(const WebrtcPeerId& remote_peer_id) {
|
||||
return;
|
||||
}
|
||||
|
||||
NEARBY_LOGS(INFO) << "Sent answer to " << remote_peer_id.GetId();
|
||||
LOG(INFO) << "Sent answer to " << remote_peer_id.GetId();
|
||||
}
|
||||
|
||||
void WebRtc::ReceiveAnswer(const WebrtcPeerId& remote_peer_id,
|
||||
SessionDescriptionWrapper answer) {
|
||||
const auto& entry = connection_flows_.find(remote_peer_id.GetId());
|
||||
if (entry == connection_flows_.end()) {
|
||||
NEARBY_LOGS(INFO)
|
||||
LOG(INFO)
|
||||
<< "Unable to receive answer. Failed to create a ConnectionFlow.";
|
||||
return;
|
||||
}
|
||||
|
||||
if (!entry->second->OnAnswerReceived(answer)) {
|
||||
NEARBY_LOGS(INFO)
|
||||
LOG(INFO)
|
||||
<< "Unable to receive answer. Failed to process the answer.";
|
||||
RemoveConnectionFlow(remote_peer_id);
|
||||
}
|
||||
@@ -636,7 +636,7 @@ void WebRtc::ReceiveIceCandidates(
|
||||
ice_candidates) {
|
||||
const auto& entry = connection_flows_.find(remote_peer_id.GetId());
|
||||
if (entry == connection_flows_.end()) {
|
||||
NEARBY_LOGS(INFO) << "Unable to receive ice candidates. Failed to create a "
|
||||
LOG(INFO) << "Unable to receive ice candidates. Failed to create a "
|
||||
"ConnectionFlow.";
|
||||
return;
|
||||
}
|
||||
@@ -652,7 +652,7 @@ void WebRtc::ProcessRestartTachyonReceiveMessages(
|
||||
|
||||
void WebRtc::RestartTachyonReceiveMessages(const std::string& service_id) {
|
||||
if (!IsAcceptingConnectionsLocked(service_id)) {
|
||||
NEARBY_LOGS(INFO)
|
||||
LOG(INFO)
|
||||
<< "Skipping restart listening for tachyon inbox messages since we are "
|
||||
"not accepting connections for service "
|
||||
<< service_id;
|
||||
@@ -669,14 +669,14 @@ void WebRtc::RestartTachyonReceiveMessages(const std::string& service_id) {
|
||||
if (!info.signaling_messenger->StartReceivingMessages(
|
||||
absl::bind_front(&WebRtc::OnSignalingMessage, this, service_id),
|
||||
absl::bind_front(&WebRtc::OnSignalingComplete, this, service_id))) {
|
||||
NEARBY_LOGS(WARNING)
|
||||
LOG(WARNING)
|
||||
<< "Failed to restart listening for tachyon inbox messages for "
|
||||
"service "
|
||||
<< service_id << " since we failed to reach Tachyon.";
|
||||
return;
|
||||
}
|
||||
|
||||
NEARBY_LOGS(INFO) << "Successfully restarted listening for tachyon inbox "
|
||||
LOG(INFO) << "Successfully restarted listening for tachyon inbox "
|
||||
"messages on service "
|
||||
<< service_id;
|
||||
}
|
||||
@@ -705,14 +705,14 @@ void WebRtc::ProcessDataChannelOpen(const std::string& service_id,
|
||||
|
||||
// No one to handle the newly created DataChannel, so we'll just close it.
|
||||
socket_wrapper.Close();
|
||||
NEARBY_LOGS(INFO) << "Ignoring new DataChannel because we are not accepting "
|
||||
LOG(INFO) << "Ignoring new DataChannel because we are not accepting "
|
||||
"connections for service "
|
||||
<< service_id;
|
||||
}
|
||||
|
||||
void WebRtc::ProcessDataChannelClosed(const WebrtcPeerId& remote_peer_id) {
|
||||
MutexLock lock(&mutex_);
|
||||
NEARBY_LOGS(INFO)
|
||||
LOG(INFO)
|
||||
<< "Data channel has closed, removing connection flow for peer "
|
||||
<< remote_peer_id.GetId();
|
||||
|
||||
|
||||
@@ -70,7 +70,7 @@ class CreateSessionDescriptionObserverImpl
|
||||
}
|
||||
|
||||
void OnFailure(webrtc::RTCError error) override {
|
||||
NEARBY_LOGS(ERROR) << "Error when creating session description: "
|
||||
LOG(ERROR) << "Error when creating session description: "
|
||||
<< error.message();
|
||||
settable_future_.SetException({Exception::kFailed});
|
||||
}
|
||||
@@ -146,10 +146,10 @@ ConnectionFlow::ConnectionFlow(
|
||||
adapter_type_listener_(std::move(adapter_type_listener)) {}
|
||||
|
||||
ConnectionFlow::~ConnectionFlow() {
|
||||
NEARBY_LOGS(INFO) << "~ConnectionFlow";
|
||||
LOG(INFO) << "~ConnectionFlow";
|
||||
RunOnSignalingThread([this] { CloseOnSignalingThread(); });
|
||||
shutdown_latch_.Await();
|
||||
NEARBY_LOGS(INFO) << "~ConnectionFlow done";
|
||||
LOG(INFO) << "~ConnectionFlow done";
|
||||
}
|
||||
|
||||
SessionDescriptionWrapper ConnectionFlow::CreateOffer() {
|
||||
@@ -158,14 +158,14 @@ SessionDescriptionWrapper ConnectionFlow::CreateOffer() {
|
||||
if (!RunOnSignalingThread([this, success_future] {
|
||||
CreateOfferOnSignalingThread(success_future);
|
||||
})) {
|
||||
NEARBY_LOGS(ERROR) << "Failed to create offer";
|
||||
LOG(ERROR) << "Failed to create offer";
|
||||
return SessionDescriptionWrapper();
|
||||
}
|
||||
ExceptionOr<SessionDescriptionWrapper> result = success_future.Get(kTimeout);
|
||||
if (result.ok()) {
|
||||
return std::move(result.result());
|
||||
}
|
||||
NEARBY_LOGS(ERROR) << "Failed to create offer: " << result.exception();
|
||||
LOG(ERROR) << "Failed to create offer: " << result.exception();
|
||||
return SessionDescriptionWrapper();
|
||||
}
|
||||
|
||||
@@ -200,14 +200,14 @@ SessionDescriptionWrapper ConnectionFlow::CreateAnswer() {
|
||||
if (!RunOnSignalingThread([this, success_future] {
|
||||
CreateAnswerOnSignalingThread(success_future);
|
||||
})) {
|
||||
NEARBY_LOGS(ERROR) << "Failed to create answer";
|
||||
LOG(ERROR) << "Failed to create answer";
|
||||
return SessionDescriptionWrapper();
|
||||
}
|
||||
ExceptionOr<SessionDescriptionWrapper> result = success_future.Get(kTimeout);
|
||||
if (result.ok()) {
|
||||
return std::move(result.result());
|
||||
}
|
||||
NEARBY_LOGS(ERROR) << "Failed to create answer: " << result.exception();
|
||||
LOG(ERROR) << "Failed to create answer: " << result.exception();
|
||||
return SessionDescriptionWrapper();
|
||||
}
|
||||
|
||||
@@ -251,7 +251,7 @@ bool ConnectionFlow::SetLocalSessionDescription(SessionDescriptionWrapper sdp) {
|
||||
ExceptionOr<bool> result = observer->GetResult(kTimeout);
|
||||
bool success = result.ok() && result.result();
|
||||
if (!success) {
|
||||
NEARBY_LOGS(ERROR) << "Failed to set local session description: "
|
||||
LOG(ERROR) << "Failed to set local session description: "
|
||||
<< result.exception();
|
||||
}
|
||||
return success;
|
||||
@@ -284,7 +284,7 @@ bool ConnectionFlow::SetRemoteSessionDescription(SessionDescriptionWrapper sdp,
|
||||
ExceptionOr<bool> result = observer->GetResult(kTimeout);
|
||||
bool success = result.ok() && result.result();
|
||||
if (!success) {
|
||||
NEARBY_LOGS(ERROR) << "Failed to set remote description: "
|
||||
LOG(ERROR) << "Failed to set remote description: "
|
||||
<< result.exception();
|
||||
}
|
||||
return success;
|
||||
@@ -330,7 +330,7 @@ void ConnectionFlow::AddIceCandidatesOnSignalingThread(
|
||||
ice_candidates) {
|
||||
CHECK(IsRunningOnSignalingThread());
|
||||
if (state_ == State::kEnded) {
|
||||
NEARBY_LOGS(WARNING)
|
||||
LOG(WARNING)
|
||||
<< "You cannot add ice candidates to a disconnected session.";
|
||||
return;
|
||||
}
|
||||
@@ -344,7 +344,7 @@ void ConnectionFlow::AddIceCandidatesOnSignalingThread(
|
||||
auto pc = GetPeerConnection();
|
||||
for (auto&& ice_candidate : ice_candidates) {
|
||||
if (!pc->AddIceCandidate(ice_candidate.get())) {
|
||||
NEARBY_LOGS(WARNING) << "Unable to add remote ice candidate.";
|
||||
LOG(WARNING) << "Unable to add remote ice candidate.";
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -397,7 +397,7 @@ bool ConnectionFlow::InitPeerConnection(WebRtcMedium& webrtc_medium) {
|
||||
bool success = result.ok() && result.result();
|
||||
if (!success) {
|
||||
shutdown_latch_.CountDown();
|
||||
NEARBY_LOGS(ERROR) << "Failed to create peer connection: "
|
||||
LOG(ERROR) << "Failed to create peer connection: "
|
||||
<< result.exception();
|
||||
}
|
||||
return success;
|
||||
@@ -408,7 +408,7 @@ void ConnectionFlow::OnSignalingStable() {
|
||||
auto pc = GetPeerConnection();
|
||||
for (auto&& ice_candidate : cached_remote_ice_candidates_) {
|
||||
if (!pc->AddIceCandidate(ice_candidate.get())) {
|
||||
NEARBY_LOGS(WARNING) << "Unable to add remote ice candidate.";
|
||||
LOG(WARNING) << "Unable to add remote ice candidate.";
|
||||
}
|
||||
}
|
||||
cached_remote_ice_candidates_.clear();
|
||||
@@ -416,14 +416,14 @@ void ConnectionFlow::OnSignalingStable() {
|
||||
|
||||
void ConnectionFlow::CreateSocketFromDataChannel(
|
||||
webrtc::scoped_refptr<webrtc::DataChannelInterface> data_channel) {
|
||||
NEARBY_LOGS(INFO) << "Creating data channel socket";
|
||||
LOG(INFO) << "Creating data channel socket";
|
||||
auto socket =
|
||||
std::make_unique<WebRtcSocket>("WebRtcSocket", std::move(data_channel));
|
||||
socket->SetSocketListener({
|
||||
.socket_ready_cb = {[this](WebRtcSocket* socket) {
|
||||
CHECK(IsRunningOnSignalingThread());
|
||||
if (!TransitionState(State::kWaitingToConnect, State::kConnected)) {
|
||||
NEARBY_LOGS(ERROR) << "Data channel socket is open but connection "
|
||||
LOG(ERROR) << "Data channel socket is open but connection "
|
||||
"flow was not in the required state";
|
||||
socket->Close();
|
||||
return;
|
||||
@@ -447,7 +447,7 @@ void ConnectionFlow::OnIceCandidate(
|
||||
|
||||
void ConnectionFlow::OnSignalingChange(
|
||||
webrtc::PeerConnectionInterface::SignalingState new_state) {
|
||||
NEARBY_LOGS(INFO) << "OnSignalingChange: " << new_state;
|
||||
LOG(INFO) << "OnSignalingChange: " << new_state;
|
||||
CHECK(IsRunningOnSignalingThread());
|
||||
if (new_state == webrtc::PeerConnectionInterface::SignalingState::kStable) {
|
||||
OnSignalingStable();
|
||||
@@ -456,38 +456,38 @@ void ConnectionFlow::OnSignalingChange(
|
||||
|
||||
void ConnectionFlow::OnDataChannel(
|
||||
webrtc::scoped_refptr<webrtc::DataChannelInterface> data_channel) {
|
||||
NEARBY_LOGS(INFO) << "OnDataChannel";
|
||||
LOG(INFO) << "OnDataChannel";
|
||||
CHECK(IsRunningOnSignalingThread());
|
||||
CreateSocketFromDataChannel(std::move(data_channel));
|
||||
}
|
||||
|
||||
void ConnectionFlow::OnIceGatheringChange(
|
||||
webrtc::PeerConnectionInterface::IceGatheringState new_state) {
|
||||
NEARBY_LOGS(INFO) << "OnIceGatheringChange: " << new_state;
|
||||
LOG(INFO) << "OnIceGatheringChange: " << new_state;
|
||||
CHECK(IsRunningOnSignalingThread());
|
||||
}
|
||||
|
||||
void ConnectionFlow::OnConnectionChange(
|
||||
webrtc::PeerConnectionInterface::PeerConnectionState new_state) {
|
||||
NEARBY_LOGS(INFO) << "OnConnectionChange: " << static_cast<int>(new_state);
|
||||
LOG(INFO) << "OnConnectionChange: " << static_cast<int>(new_state);
|
||||
CHECK(IsRunningOnSignalingThread());
|
||||
if (new_state == PeerConnectionState::kClosed ||
|
||||
new_state == PeerConnectionState::kFailed ||
|
||||
new_state == PeerConnectionState::kDisconnected) {
|
||||
NEARBY_LOGS(INFO) << "Closing due to peer connection state change: "
|
||||
LOG(INFO) << "Closing due to peer connection state change: "
|
||||
<< static_cast<int>(new_state);
|
||||
CloseOnSignalingThread();
|
||||
}
|
||||
}
|
||||
|
||||
void ConnectionFlow::OnRenegotiationNeeded() {
|
||||
NEARBY_LOGS(INFO) << "OnRenegotiationNeeded";
|
||||
LOG(INFO) << "OnRenegotiationNeeded";
|
||||
CHECK(IsRunningOnSignalingThread());
|
||||
}
|
||||
|
||||
void ConnectionFlow::OnIceSelectedCandidatePairChanged(
|
||||
const webrtc::CandidatePairChangeEvent& event) {
|
||||
NEARBY_LOGS(INFO) << "OnIceSelectedCandidatePairChanged";
|
||||
LOG(INFO) << "OnIceSelectedCandidatePairChanged";
|
||||
CHECK(IsRunningOnSignalingThread());
|
||||
// TODO(edwinwu) - Implement the unit test for this. We should be able to get
|
||||
// the adapter type from the PeerConnection.
|
||||
@@ -498,13 +498,13 @@ void ConnectionFlow::OnIceSelectedCandidatePairChanged(
|
||||
bool ConnectionFlow::TransitionState(State current_state, State new_state) {
|
||||
CHECK(IsRunningOnSignalingThread());
|
||||
if (current_state != state_) {
|
||||
NEARBY_LOGS(WARNING) << "Invalid state transition to "
|
||||
LOG(WARNING) << "Invalid state transition to "
|
||||
<< static_cast<int>(new_state) << ": current state is "
|
||||
<< static_cast<int>(state_) << " but expected "
|
||||
<< static_cast<int>(current_state);
|
||||
return false;
|
||||
}
|
||||
NEARBY_LOGS(INFO) << "Transition: " << static_cast<int>(state_) << "->"
|
||||
LOG(INFO) << "Transition: " << static_cast<int>(state_) << "->"
|
||||
<< static_cast<int>(new_state);
|
||||
state_ = new_state;
|
||||
return true;
|
||||
@@ -524,11 +524,11 @@ bool ConnectionFlow::CloseOnSignalingThread() {
|
||||
// object.
|
||||
auto pc = GetAndResetPeerConnection();
|
||||
|
||||
NEARBY_LOGS(INFO) << "Closing WebRTC peer connection.";
|
||||
LOG(INFO) << "Closing WebRTC peer connection.";
|
||||
// NOTE: Closing the peer connection will close the data channel and thus the
|
||||
// socket implicitly.
|
||||
if (pc) pc->Close();
|
||||
NEARBY_LOGS(INFO) << "Closed WebRTC peer connection.";
|
||||
LOG(INFO) << "Closed WebRTC peer connection.";
|
||||
// Prevent any already queued tasks from running on the signaling thread
|
||||
can_run_tasks_.reset();
|
||||
// If anyone was waiting for shutdown to be done let them know.
|
||||
@@ -540,7 +540,7 @@ bool ConnectionFlow::RunOnSignalingThread(Runnable&& runnable) {
|
||||
CHECK(!IsRunningOnSignalingThread());
|
||||
auto pc = GetPeerConnection();
|
||||
if (!pc) {
|
||||
NEARBY_LOGS(WARNING)
|
||||
LOG(WARNING)
|
||||
<< "Peer connection not available. Cannot schedule tasks.";
|
||||
return false;
|
||||
}
|
||||
@@ -554,7 +554,7 @@ bool ConnectionFlow::RunOnSignalingThread(Runnable&& runnable) {
|
||||
// (signaling thread). This guarantees that if the weak_ptr is valid
|
||||
// when this task starts, it will stay valid until the task ends.
|
||||
if (!can_run_tasks.lock()) {
|
||||
NEARBY_LOGS(INFO) << "Peer connection already closed. Cannot run tasks.";
|
||||
LOG(INFO) << "Peer connection already closed. Cannot run tasks.";
|
||||
return;
|
||||
}
|
||||
task();
|
||||
|
||||
@@ -34,19 +34,19 @@ namespace mediums {
|
||||
// OutputStreamImpl
|
||||
Exception WebRtcSocket::OutputStreamImpl::Write(const ByteArray& data) {
|
||||
if (data.size() > kMaxDataSize) {
|
||||
NEARBY_LOGS(WARNING) << "Sending data larger than 1MB";
|
||||
LOG(WARNING) << "Sending data larger than 1MB";
|
||||
return {Exception::kIo};
|
||||
}
|
||||
|
||||
socket_->BlockUntilSufficientSpaceInBuffer(data.size());
|
||||
|
||||
if (socket_->IsClosed()) {
|
||||
NEARBY_LOGS(WARNING) << "Tried sending message while socket is closed";
|
||||
LOG(WARNING) << "Tried sending message while socket is closed";
|
||||
return {Exception::kIo};
|
||||
}
|
||||
|
||||
if (!socket_->SendMessage(data)) {
|
||||
NEARBY_LOGS(INFO) << "Unable to write data to socket.";
|
||||
LOG(INFO) << "Unable to write data to socket.";
|
||||
return {Exception::kIo};
|
||||
}
|
||||
return {Exception::kSuccess};
|
||||
@@ -67,14 +67,14 @@ WebRtcSocket::WebRtcSocket(
|
||||
const std::string& name,
|
||||
webrtc::scoped_refptr<webrtc::DataChannelInterface> data_channel)
|
||||
: name_(name), data_channel_(std::move(data_channel)) {
|
||||
NEARBY_LOGS(INFO) << "WebRtcSocket::WebRtcSocket(" << name_
|
||||
LOG(INFO) << "WebRtcSocket::WebRtcSocket(" << name_
|
||||
<< ") this: " << this;
|
||||
std::tie(pipe_input_, pipe_output_) = CreatePipe();
|
||||
data_channel_->RegisterObserver(this);
|
||||
}
|
||||
|
||||
WebRtcSocket::~WebRtcSocket() {
|
||||
NEARBY_LOGS(INFO) << "WebRtcSocket::~WebRtcSocket(" << name_
|
||||
LOG(INFO) << "WebRtcSocket::~WebRtcSocket(" << name_
|
||||
<< ") this: " << this;
|
||||
|
||||
if (!IsClosed()) {
|
||||
@@ -82,7 +82,7 @@ WebRtcSocket::~WebRtcSocket() {
|
||||
Close();
|
||||
}
|
||||
|
||||
NEARBY_LOGS(INFO) << "WebRtcSocket::~WebRtcSocket(" << name_
|
||||
LOG(INFO) << "WebRtcSocket::~WebRtcSocket(" << name_
|
||||
<< ") this: " << this << " done";
|
||||
}
|
||||
|
||||
@@ -91,7 +91,7 @@ InputStream& WebRtcSocket::GetInputStream() { return *pipe_input_; }
|
||||
OutputStream& WebRtcSocket::GetOutputStream() { return output_stream_; }
|
||||
|
||||
Exception WebRtcSocket::Close() {
|
||||
NEARBY_LOGS(INFO) << "WebRtcSocket::Close(" << name_ << ") this: " << this;
|
||||
LOG(INFO) << "WebRtcSocket::Close(" << name_ << ") this: " << this;
|
||||
if (closed_.Set(true)) return {Exception::kSuccess};
|
||||
|
||||
ClosePipe();
|
||||
@@ -99,14 +99,14 @@ Exception WebRtcSocket::Close() {
|
||||
// to 'closing' but does not block until 'closed' is sent so the data channel
|
||||
// is not fully closed when this call is done.
|
||||
data_channel_->Close();
|
||||
NEARBY_LOGS(INFO) << "WebRtcSocket::Close(" << name_ << ") this: " << this
|
||||
LOG(INFO) << "WebRtcSocket::Close(" << name_ << ") this: " << this
|
||||
<< " done";
|
||||
return {Exception::kSuccess};
|
||||
}
|
||||
|
||||
void WebRtcSocket::OnStateChange() {
|
||||
// Running on the signaling thread right now.
|
||||
NEARBY_LOGS(ERROR)
|
||||
LOG(ERROR)
|
||||
<< "WebRtcSocket::OnStateChange() webrtc data channel state: "
|
||||
<< webrtc::DataChannelInterface::DataStateString(data_channel_->state());
|
||||
switch (data_channel_->state()) {
|
||||
@@ -120,7 +120,7 @@ void WebRtcSocket::OnStateChange() {
|
||||
case webrtc::DataChannelInterface::DataState::kClosing:
|
||||
break;
|
||||
case webrtc::DataChannelInterface::DataState::kClosed:
|
||||
NEARBY_LOGS(ERROR) << "WebRtcSocket::OnStateChange() unregistering data "
|
||||
LOG(ERROR) << "WebRtcSocket::OnStateChange() unregistering data "
|
||||
"channel observer.";
|
||||
// This will trigger a destruction of the owning connection flow
|
||||
// We implicitly depend on the |socket_listener_| to offload from
|
||||
@@ -163,7 +163,7 @@ bool WebRtcSocket::SendMessage(const ByteArray& data) {
|
||||
bool WebRtcSocket::IsClosed() { return closed_.Get(); }
|
||||
|
||||
void WebRtcSocket::ClosePipe() {
|
||||
NEARBY_LOGS(INFO) << "WebRtcSocket::ClosePipe(" << name_
|
||||
LOG(INFO) << "WebRtcSocket::ClosePipe(" << name_
|
||||
<< ") this: " << this;
|
||||
// This is thread-safe to close these sockets even if a read or write is in
|
||||
// process on another thread, Close will wait for the exclusive mutex before
|
||||
@@ -171,7 +171,7 @@ void WebRtcSocket::ClosePipe() {
|
||||
pipe_input_->Close();
|
||||
pipe_output_->Close();
|
||||
WakeUpWriter();
|
||||
NEARBY_LOGS(INFO) << "WebRtcSocket::ClosePipe(" << name_ << ") this: " << this
|
||||
LOG(INFO) << "WebRtcSocket::ClosePipe(" << name_ << ") this: " << this
|
||||
<< " done";
|
||||
}
|
||||
|
||||
|
||||
@@ -78,7 +78,7 @@ bool WifiDirect::IsGOStarted() {
|
||||
bool WifiDirect::StartWifiDirect() {
|
||||
MutexLock lock(&mutex_);
|
||||
if (is_go_started_) {
|
||||
NEARBY_LOGS(INFO) << "No need to start GO because it is already started.";
|
||||
LOG(INFO) << "No need to start GO because it is already started.";
|
||||
return true;
|
||||
}
|
||||
is_go_started_ = medium_.StartWifiDirect();
|
||||
@@ -88,7 +88,7 @@ bool WifiDirect::StartWifiDirect() {
|
||||
bool WifiDirect::StopWifiDirect() {
|
||||
MutexLock lock(&mutex_);
|
||||
if (!is_go_started_) {
|
||||
NEARBY_LOGS(INFO) << "No need to stop GO because it is not started.";
|
||||
LOG(INFO) << "No need to stop GO because it is not started.";
|
||||
return true;
|
||||
}
|
||||
is_go_started_ = false;
|
||||
@@ -106,7 +106,7 @@ bool WifiDirect::ConnectWifiDirect(const std::string& ssid,
|
||||
const std::string& password) {
|
||||
MutexLock lock(&mutex_);
|
||||
if (is_connected_to_go_) {
|
||||
NEARBY_LOGS(INFO)
|
||||
LOG(INFO)
|
||||
<< "No need to connect to GO because it is already connected.";
|
||||
return true;
|
||||
}
|
||||
@@ -117,7 +117,7 @@ bool WifiDirect::ConnectWifiDirect(const std::string& ssid,
|
||||
bool WifiDirect::DisconnectWifiDirect() {
|
||||
MutexLock lock(&mutex_);
|
||||
if (!is_connected_to_go_) {
|
||||
NEARBY_LOGS(INFO)
|
||||
LOG(INFO)
|
||||
<< "No need to disconnect to GO because it is not connected.";
|
||||
return true;
|
||||
}
|
||||
@@ -133,7 +133,7 @@ WifiDirectCredentials* WifiDirect::GetCredentials(
|
||||
|
||||
const auto& it = server_sockets_.find(service_id);
|
||||
if (it == server_sockets_.end()) {
|
||||
NEARBY_LOGS(INFO) << "No server socket found for service_id:" << service_id
|
||||
LOG(INFO) << "No server socket found for service_id:" << service_id
|
||||
<< ". Use default credentials";
|
||||
return crendential;
|
||||
}
|
||||
@@ -149,21 +149,21 @@ bool WifiDirect::StartAcceptingConnections(
|
||||
MutexLock lock(&mutex_);
|
||||
|
||||
if (service_id.empty()) {
|
||||
NEARBY_LOGS(INFO)
|
||||
LOG(INFO)
|
||||
<< "Can not to start accepting WifiDirect GC's connections; "
|
||||
"service_id is empty.";
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!IsGOAvailableLocked()) {
|
||||
NEARBY_LOGS(INFO)
|
||||
LOG(INFO)
|
||||
<< "Can't start accepting WifiDirect GC's connections [service_id="
|
||||
<< service_id << "]; WifiDirct GO is not available.";
|
||||
return false;
|
||||
}
|
||||
|
||||
if (IsAcceptingConnectionsLocked(service_id)) {
|
||||
NEARBY_LOGS(INFO)
|
||||
LOG(INFO)
|
||||
<< "Refusing to start accepting WifiDirect GC's connections [service="
|
||||
<< service_id
|
||||
<< "]; WifiDirect GO server is already in-progress with the same name.";
|
||||
@@ -173,7 +173,7 @@ bool WifiDirect::StartAcceptingConnections(
|
||||
// "port=0" to let the platform to select an available port for the socket
|
||||
WifiDirectServerSocket server_socket = medium_.ListenForService(/*port=*/0);
|
||||
if (!server_socket.IsValid()) {
|
||||
NEARBY_LOGS(INFO)
|
||||
LOG(INFO)
|
||||
<< "Failed to start to listen on WifiDirect GO server for service_id="
|
||||
<< service_id;
|
||||
return false;
|
||||
@@ -211,7 +211,7 @@ bool WifiDirect::StopAcceptingConnections(const std::string& service_id) {
|
||||
MutexLock lock(&mutex_);
|
||||
|
||||
if (service_id.empty()) {
|
||||
NEARBY_LOGS(INFO)
|
||||
LOG(INFO)
|
||||
<< "Unable to stop accepting WifiDirect GC's connections because "
|
||||
"the service_id is empty.";
|
||||
return false;
|
||||
@@ -219,7 +219,7 @@ bool WifiDirect::StopAcceptingConnections(const std::string& service_id) {
|
||||
|
||||
const auto& it = server_sockets_.find(service_id);
|
||||
if (it == server_sockets_.end()) {
|
||||
NEARBY_LOGS(INFO) << "Can't stop accepting WifiDirect GC's connections for "
|
||||
LOG(INFO) << "Can't stop accepting WifiDirect GC's connections for "
|
||||
<< service_id << " because it was never started.";
|
||||
return false;
|
||||
}
|
||||
@@ -241,7 +241,7 @@ bool WifiDirect::StopAcceptingConnections(const std::string& service_id) {
|
||||
|
||||
// Finally, close the WifiDirectServerSocket.
|
||||
if (!listening_socket.Close().Ok()) {
|
||||
NEARBY_LOGS(INFO)
|
||||
LOG(INFO)
|
||||
<< "Failed to close WifiDirect server socket for service_id:"
|
||||
<< service_id;
|
||||
return false;
|
||||
@@ -267,20 +267,20 @@ ErrorOr<WifiDirectSocket> WifiDirect::Connect(
|
||||
WifiDirectSocket socket;
|
||||
|
||||
if (service_id.empty()) {
|
||||
NEARBY_LOGS(INFO) << "Refusing to create client WifiDirect socket because "
|
||||
LOG(INFO) << "Refusing to create client WifiDirect socket because "
|
||||
"service_id is empty.";
|
||||
return {Error(OperationResultCode::NEARBY_LOCAL_CLIENT_STATE_WRONG)};
|
||||
}
|
||||
|
||||
if (!IsGCAvailableLocked()) {
|
||||
NEARBY_LOGS(INFO) << "Can't create WifiDirect client socket [service_id="
|
||||
LOG(INFO) << "Can't create WifiDirect client socket [service_id="
|
||||
<< service_id << "]; WifiDirect GC isn't available.";
|
||||
return {Error(
|
||||
OperationResultCode::MEDIUM_UNAVAILABLE_WIFI_DIRECT_NOT_AVAILABLE)};
|
||||
}
|
||||
|
||||
if (cancellation_flag->Cancelled()) {
|
||||
NEARBY_LOGS(INFO) << "Can't create WifiDirect client socket due to cancel";
|
||||
LOG(INFO) << "Can't create WifiDirect client socket due to cancel";
|
||||
return {
|
||||
Error(OperationResultCode::
|
||||
CLIENT_CANCELLATION_CANCEL_WIFI_DIRECT_OUTGOING_CONNECTION)};
|
||||
@@ -288,7 +288,7 @@ ErrorOr<WifiDirectSocket> WifiDirect::Connect(
|
||||
|
||||
socket = medium_.ConnectToService(ip_address, port, cancellation_flag);
|
||||
if (!socket.IsValid()) {
|
||||
NEARBY_LOGS(INFO) << "Failed to Connect via WifiDirect Server [service_id="
|
||||
LOG(INFO) << "Failed to Connect via WifiDirect Server [service_id="
|
||||
<< service_id << "]";
|
||||
return {Error(OperationResultCode::
|
||||
CONNECTIVITY_WIFI_DIRECT_CLIENT_SOCKET_CREATION_FAILURE)};
|
||||
|
||||
@@ -75,7 +75,7 @@ bool WifiHotspot::IsHotspotStarted() {
|
||||
bool WifiHotspot::StartWifiHotspot() {
|
||||
MutexLock lock(&mutex_);
|
||||
if (is_hotspot_started_) {
|
||||
NEARBY_LOGS(INFO)
|
||||
LOG(INFO)
|
||||
<< "No need to start Hotspot because it is already started.";
|
||||
return true;
|
||||
}
|
||||
@@ -86,7 +86,7 @@ bool WifiHotspot::StartWifiHotspot() {
|
||||
bool WifiHotspot::StopWifiHotspot() {
|
||||
MutexLock lock(&mutex_);
|
||||
if (!is_hotspot_started_) {
|
||||
NEARBY_LOGS(INFO) << "No need to stop Hotspot because it is not started.";
|
||||
LOG(INFO) << "No need to stop Hotspot because it is not started.";
|
||||
return true;
|
||||
}
|
||||
is_hotspot_started_ = false;
|
||||
@@ -104,7 +104,7 @@ bool WifiHotspot::ConnectWifiHotspot(
|
||||
const HotspotCredentials& hotspot_credentials) {
|
||||
MutexLock lock(&mutex_);
|
||||
if (is_connected_to_hotspot_) {
|
||||
NEARBY_LOGS(INFO)
|
||||
LOG(INFO)
|
||||
<< "No need to connect to Hotspot because it is already connected.";
|
||||
return true;
|
||||
}
|
||||
@@ -115,7 +115,7 @@ bool WifiHotspot::ConnectWifiHotspot(
|
||||
bool WifiHotspot::DisconnectWifiHotspot() {
|
||||
MutexLock lock(&mutex_);
|
||||
if (!is_connected_to_hotspot_) {
|
||||
NEARBY_LOGS(INFO)
|
||||
LOG(INFO)
|
||||
<< "No need to disconnect to Hotspot because it is not connected.";
|
||||
return true;
|
||||
}
|
||||
@@ -131,7 +131,7 @@ HotspotCredentials* WifiHotspot::GetCredentials(absl::string_view service_id) {
|
||||
|
||||
const auto& it = server_sockets_.find(service_id);
|
||||
if (it == server_sockets_.end()) {
|
||||
NEARBY_LOGS(INFO) << "No server socket found for service_id:" << service_id
|
||||
LOG(INFO) << "No server socket found for service_id:" << service_id
|
||||
<< ". Use default credentials";
|
||||
return crendential;
|
||||
}
|
||||
@@ -147,20 +147,20 @@ bool WifiHotspot::StartAcceptingConnections(
|
||||
MutexLock lock(&mutex_);
|
||||
|
||||
if (service_id.empty()) {
|
||||
NEARBY_LOGS(INFO) << "Can not to start accepting WifiHotspot connections; "
|
||||
LOG(INFO) << "Can not to start accepting WifiHotspot connections; "
|
||||
"service_id is empty.";
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!IsAPAvailableLocked()) {
|
||||
NEARBY_LOGS(INFO)
|
||||
LOG(INFO)
|
||||
<< "Can't start accepting WifiHotspot connections [service_id="
|
||||
<< service_id << "]; WifiHotspot not available.";
|
||||
return false;
|
||||
}
|
||||
|
||||
if (IsAcceptingConnectionsLocked(service_id)) {
|
||||
NEARBY_LOGS(INFO)
|
||||
LOG(INFO)
|
||||
<< "Refusing to start accepting WifiHotspot connections [service="
|
||||
<< service_id
|
||||
<< "]; WifiHotspot server is already in-progress with the same name.";
|
||||
@@ -170,7 +170,7 @@ bool WifiHotspot::StartAcceptingConnections(
|
||||
// "port=0" to let the platform to select an available port for the socket
|
||||
WifiHotspotServerSocket server_socket = medium_.ListenForService(/*port=*/0);
|
||||
if (!server_socket.IsValid()) {
|
||||
NEARBY_LOGS(INFO)
|
||||
LOG(INFO)
|
||||
<< "Failed to start accepting WifiHotspot connections for service_id="
|
||||
<< service_id;
|
||||
return false;
|
||||
@@ -208,7 +208,7 @@ bool WifiHotspot::StopAcceptingConnections(const std::string& service_id) {
|
||||
MutexLock lock(&mutex_);
|
||||
|
||||
if (service_id.empty()) {
|
||||
NEARBY_LOGS(INFO)
|
||||
LOG(INFO)
|
||||
<< "Unable to stop accepting WifiHotspot connections because "
|
||||
"the service_id is empty.";
|
||||
return false;
|
||||
@@ -216,7 +216,7 @@ bool WifiHotspot::StopAcceptingConnections(const std::string& service_id) {
|
||||
|
||||
const auto& it = server_sockets_.find(service_id);
|
||||
if (it == server_sockets_.end()) {
|
||||
NEARBY_LOGS(INFO) << "Can't stop accepting WifiHotspot connections for "
|
||||
LOG(INFO) << "Can't stop accepting WifiHotspot connections for "
|
||||
<< service_id << " because it was never started.";
|
||||
return false;
|
||||
}
|
||||
@@ -238,7 +238,7 @@ bool WifiHotspot::StopAcceptingConnections(const std::string& service_id) {
|
||||
|
||||
// Finally, close the WifiHotspotServerSocket.
|
||||
if (!listening_socket.Close().Ok()) {
|
||||
NEARBY_LOGS(INFO)
|
||||
LOG(INFO)
|
||||
<< "Failed to close WifiHotspot server socket for service_id:"
|
||||
<< service_id;
|
||||
return false;
|
||||
@@ -264,20 +264,20 @@ ErrorOr<WifiHotspotSocket> WifiHotspot::Connect(
|
||||
WifiHotspotSocket socket;
|
||||
|
||||
if (service_id.empty()) {
|
||||
NEARBY_LOGS(INFO) << "Refusing to create client WifiHotspot socket because "
|
||||
LOG(INFO) << "Refusing to create client WifiHotspot socket because "
|
||||
"service_id is empty.";
|
||||
return {Error(OperationResultCode::NEARBY_LOCAL_CLIENT_STATE_WRONG)};
|
||||
}
|
||||
|
||||
if (!IsClientAvailableLocked()) {
|
||||
NEARBY_LOGS(INFO) << "Can't create client WifiHotspot socket [service_id="
|
||||
LOG(INFO) << "Can't create client WifiHotspot socket [service_id="
|
||||
<< service_id << "]; WifiHotspot isn't available.";
|
||||
return {Error(
|
||||
OperationResultCode::MEDIUM_UNAVAILABLE_WIFI_HOTSPOT_NOT_AVAILABLE)};
|
||||
}
|
||||
|
||||
if (cancellation_flag->Cancelled()) {
|
||||
NEARBY_LOGS(INFO) << "Can't create client WifiHotspot socket due to cancel";
|
||||
LOG(INFO) << "Can't create client WifiHotspot socket due to cancel";
|
||||
return {
|
||||
Error(OperationResultCode::
|
||||
CLIENT_CANCELLATION_CANCEL_WIFI_HOTSPOT_OUTGOING_CONNECTION)};
|
||||
@@ -285,7 +285,7 @@ ErrorOr<WifiHotspotSocket> WifiHotspot::Connect(
|
||||
|
||||
socket = medium_.ConnectToService(ip_address, port, cancellation_flag);
|
||||
if (!socket.IsValid()) {
|
||||
NEARBY_LOGS(INFO) << "Failed to Connect via WifiHotspot [service_id="
|
||||
LOG(INFO) << "Failed to Connect via WifiHotspot [service_id="
|
||||
<< service_id << "]";
|
||||
return {
|
||||
Error(OperationResultCode::
|
||||
|
||||
@@ -59,10 +59,10 @@ WifiLan::~WifiLan() {
|
||||
{
|
||||
MutexLock lock(&mutex_);
|
||||
if (is_multiplex_enabled_) {
|
||||
NEARBY_LOGS(INFO) << "Closing multiplex sockets for "
|
||||
LOG(INFO) << "Closing multiplex sockets for "
|
||||
<< multiplex_sockets_.size() << " IPs";
|
||||
for (auto& [ip_addr, multiplex_socket] : multiplex_sockets_) {
|
||||
NEARBY_LOGS(INFO) << "Closing multiplex sockets for: " << ip_addr;
|
||||
LOG(INFO) << "Closing multiplex sockets for: " << ip_addr;
|
||||
multiplex_socket->~MultiplexSocket();
|
||||
}
|
||||
multiplex_sockets_.clear();
|
||||
@@ -87,26 +87,26 @@ ErrorOr<bool> WifiLan::StartAdvertising(const std::string& service_id,
|
||||
MutexLock lock(&mutex_);
|
||||
|
||||
if (!IsAvailableLocked()) {
|
||||
NEARBY_LOGS(INFO)
|
||||
LOG(INFO)
|
||||
<< "Can't turn on WifiLan advertising. WifiLan is not available.";
|
||||
return {Error(OperationResultCode::MEDIUM_UNAVAILABLE_LAN_NOT_AVAILABLE)};
|
||||
}
|
||||
|
||||
if (!nsd_service_info.IsValid()) {
|
||||
NEARBY_LOGS(INFO)
|
||||
LOG(INFO)
|
||||
<< "Refusing to turn on WifiLan advertising. nsd_service_info is not "
|
||||
"valid.";
|
||||
return {Error(OperationResultCode::MEDIUM_UNAVAILABLE_NSD_NOT_AVAILABLE)};
|
||||
}
|
||||
|
||||
if (IsAdvertisingLocked(service_id)) {
|
||||
NEARBY_LOGS(INFO)
|
||||
LOG(INFO)
|
||||
<< "Failed to WifiLan advertise because we're already advertising.";
|
||||
return {Error(OperationResultCode::CLIENT_WIFI_LAN_DUPLICATE_ADVERTISING)};
|
||||
}
|
||||
|
||||
if (!IsAcceptingConnectionsLocked(service_id)) {
|
||||
NEARBY_LOGS(INFO)
|
||||
LOG(INFO)
|
||||
<< "Failed to turn on WifiLan advertising with nsd_service_info="
|
||||
<< &nsd_service_info
|
||||
<< ", service_name=" << nsd_service_info.GetServiceName()
|
||||
@@ -123,7 +123,7 @@ ErrorOr<bool> WifiLan::StartAdvertising(const std::string& service_id,
|
||||
nsd_service_info.SetPort(it->second.GetPort());
|
||||
}
|
||||
if (!medium_.StartAdvertising(nsd_service_info)) {
|
||||
NEARBY_LOGS(INFO)
|
||||
LOG(INFO)
|
||||
<< "Failed to turn on WifiLan advertising with nsd_service_info="
|
||||
<< &nsd_service_info
|
||||
<< ", service_name=" << nsd_service_info.GetServiceName()
|
||||
@@ -132,7 +132,7 @@ ErrorOr<bool> WifiLan::StartAdvertising(const std::string& service_id,
|
||||
OperationResultCode::CONNECTIVITY_WIFI_LAN_START_ADVERTISING_FAILURE)};
|
||||
}
|
||||
|
||||
NEARBY_LOGS(INFO) << "Turned on WifiLan advertising with nsd_service_info="
|
||||
LOG(INFO) << "Turned on WifiLan advertising with nsd_service_info="
|
||||
<< &nsd_service_info
|
||||
<< ", service_name=" << nsd_service_info.GetServiceName()
|
||||
<< ", service_id=" << service_id;
|
||||
@@ -144,12 +144,12 @@ bool WifiLan::StopAdvertising(const std::string& service_id) {
|
||||
MutexLock lock(&mutex_);
|
||||
|
||||
if (!IsAdvertisingLocked(service_id)) {
|
||||
NEARBY_LOGS(INFO)
|
||||
LOG(INFO)
|
||||
<< "Can't turn off WifiLan advertising; it is already off";
|
||||
return false;
|
||||
}
|
||||
|
||||
NEARBY_LOGS(INFO) << "Turned off WifiLan advertising with service_id="
|
||||
LOG(INFO) << "Turned off WifiLan advertising with service_id="
|
||||
<< service_id;
|
||||
bool ret =
|
||||
medium_.StopAdvertising(*advertising_info_.GetServiceInfo(service_id));
|
||||
@@ -174,20 +174,20 @@ ErrorOr<bool> WifiLan::StartDiscovery(const std::string& service_id,
|
||||
MutexLock lock(&mutex_);
|
||||
|
||||
if (service_id.empty()) {
|
||||
NEARBY_LOGS(INFO)
|
||||
LOG(INFO)
|
||||
<< "Refusing to start WifiLan discovering with empty service_id.";
|
||||
return {Error(OperationResultCode::NEARBY_LOCAL_CLIENT_STATE_WRONG)};
|
||||
}
|
||||
|
||||
if (!IsAvailableLocked()) {
|
||||
NEARBY_LOGS(INFO)
|
||||
LOG(INFO)
|
||||
<< "Can't discover WifiLan services because WifiLan isn't available.";
|
||||
return {Error(
|
||||
OperationResultCode::MEDIUM_UNAVAILABLE_WIFI_AWARE_NOT_AVAILABLE)};
|
||||
}
|
||||
|
||||
if (IsDiscoveringLocked(service_id)) {
|
||||
NEARBY_LOGS(INFO)
|
||||
LOG(INFO)
|
||||
<< "Refusing to start discovery of WifiLan services because another "
|
||||
"discovery is already in-progress.";
|
||||
return {Error(OperationResultCode::CLIENT_WIFI_LAN_DUPLICATE_DISCOVERING)};
|
||||
@@ -197,12 +197,12 @@ ErrorOr<bool> WifiLan::StartDiscovery(const std::string& service_id,
|
||||
bool ret =
|
||||
medium_.StartDiscovery(service_id, service_type, std::move(callback));
|
||||
if (!ret) {
|
||||
NEARBY_LOGS(INFO) << "Failed to start discovery of WifiLan services.";
|
||||
LOG(INFO) << "Failed to start discovery of WifiLan services.";
|
||||
return {Error(
|
||||
OperationResultCode::CONNECTIVITY_WIFI_LAN_START_DISCOVERY_FAILURE)};
|
||||
}
|
||||
|
||||
NEARBY_LOGS(INFO) << "Turned on WifiLan discovering with service_id="
|
||||
LOG(INFO) << "Turned on WifiLan discovering with service_id="
|
||||
<< service_id;
|
||||
// Mark the fact that we're currently performing a WifiLan discovering.
|
||||
discovering_info_.Add(service_id);
|
||||
@@ -213,14 +213,14 @@ bool WifiLan::StopDiscovery(const std::string& service_id) {
|
||||
MutexLock lock(&mutex_);
|
||||
|
||||
if (!IsDiscoveringLocked(service_id)) {
|
||||
NEARBY_LOGS(INFO)
|
||||
LOG(INFO)
|
||||
<< "Can't turn off WifiLan discovering because we never started "
|
||||
"discovering.";
|
||||
return false;
|
||||
}
|
||||
|
||||
std::string service_type = GenerateServiceType(service_id);
|
||||
NEARBY_LOGS(INFO) << "Turned off WifiLan discovering with service_id="
|
||||
LOG(INFO) << "Turned off WifiLan discovering with service_id="
|
||||
<< service_id << ", service_type=" << service_type;
|
||||
bool ret = medium_.StopDiscovery(service_type);
|
||||
discovering_info_.Remove(service_id);
|
||||
@@ -241,13 +241,13 @@ ErrorOr<bool> WifiLan::StartAcceptingConnections(
|
||||
MutexLock lock(&mutex_);
|
||||
|
||||
if (service_id.empty()) {
|
||||
NEARBY_LOGS(INFO) << "Refusing to start accepting WifiLan connections; "
|
||||
LOG(INFO) << "Refusing to start accepting WifiLan connections; "
|
||||
"service_id is empty.";
|
||||
return {Error(OperationResultCode::NEARBY_LOCAL_CLIENT_STATE_WRONG)};
|
||||
}
|
||||
|
||||
if (!IsAvailableLocked()) {
|
||||
NEARBY_LOGS(INFO)
|
||||
LOG(INFO)
|
||||
<< "Can't start accepting WifiLan connections [service_id="
|
||||
<< service_id << "]; WifiLan not available.";
|
||||
return {Error(
|
||||
@@ -255,7 +255,7 @@ ErrorOr<bool> WifiLan::StartAcceptingConnections(
|
||||
}
|
||||
|
||||
if (IsAcceptingConnectionsLocked(service_id)) {
|
||||
NEARBY_LOGS(INFO)
|
||||
LOG(INFO)
|
||||
<< "Refusing to start accepting WifiLan connections [service="
|
||||
<< service_id
|
||||
<< "]; WifiLan server is already in-progress with the same name.";
|
||||
@@ -275,7 +275,7 @@ ErrorOr<bool> WifiLan::StartAcceptingConnections(
|
||||
}
|
||||
WifiLanServerSocket server_socket = medium_.ListenForService(port);
|
||||
if (!server_socket.IsValid()) {
|
||||
NEARBY_LOGS(INFO)
|
||||
LOG(INFO)
|
||||
<< "Failed to start accepting WifiLan connections for service_id="
|
||||
<< service_id;
|
||||
return {Error(OperationResultCode::
|
||||
@@ -313,7 +313,7 @@ ErrorOr<bool> WifiLan::StartAcceptingConnections(
|
||||
server_socket.Close();
|
||||
break;
|
||||
}
|
||||
NEARBY_LOGS(INFO) << "Accepted connection for " << service_id;
|
||||
LOG(INFO) << "Accepted connection for " << service_id;
|
||||
bool callback_called = false;
|
||||
{
|
||||
MutexLock lock(&mutex_);
|
||||
@@ -331,7 +331,7 @@ ErrorOr<bool> WifiLan::StartAcceptingConnections(
|
||||
ExceptionOr<std::int32_t> read_int =
|
||||
Base64Utils::ReadInt(&client_socket.GetInputStream());
|
||||
if (!read_int.ok()) {
|
||||
NEARBY_LOGS(WARNING)
|
||||
LOG(WARNING)
|
||||
<< __func__
|
||||
<< "Failed to read. Exception:" << read_int.exception()
|
||||
<< "Discard the connection.";
|
||||
@@ -350,7 +350,7 @@ ErrorOr<bool> WifiLan::StartAcceptingConnections(
|
||||
multiplex_socket);
|
||||
MultiplexSocket::StopListeningForIncomingConnection(
|
||||
service_id, Medium::WIFI_LAN);
|
||||
NEARBY_LOGS(INFO) << "Multiplex virtaul socket created for "
|
||||
LOG(INFO) << "Multiplex virtaul socket created for "
|
||||
<< server_socket.GetIPAddress();
|
||||
if (callback) {
|
||||
callback(
|
||||
@@ -363,7 +363,7 @@ ErrorOr<bool> WifiLan::StartAcceptingConnections(
|
||||
}
|
||||
}
|
||||
if (callback && !callback_called) {
|
||||
NEARBY_LOGS(INFO) << "Call back triggered for physical socket.";
|
||||
LOG(INFO) << "Call back triggered for physical socket.";
|
||||
callback(service_id, std::move(client_socket));
|
||||
}
|
||||
}
|
||||
@@ -376,14 +376,14 @@ bool WifiLan::StopAcceptingConnections(const std::string& service_id) {
|
||||
MutexLock lock(&mutex_);
|
||||
|
||||
if (service_id.empty()) {
|
||||
NEARBY_LOGS(INFO) << "Unable to stop accepting WifiLan connections because "
|
||||
LOG(INFO) << "Unable to stop accepting WifiLan connections because "
|
||||
"the service_id is empty.";
|
||||
return false;
|
||||
}
|
||||
|
||||
const auto& it = server_sockets_.find(service_id);
|
||||
if (it == server_sockets_.end()) {
|
||||
NEARBY_LOGS(INFO) << "Can't stop accepting WifiLan connections for "
|
||||
LOG(INFO) << "Can't stop accepting WifiLan connections for "
|
||||
<< service_id << " because it was never started.";
|
||||
return false;
|
||||
}
|
||||
@@ -409,7 +409,7 @@ bool WifiLan::StopAcceptingConnections(const std::string& service_id) {
|
||||
|
||||
// Finally, close the WifiLanServerSocket.
|
||||
if (!listening_socket.Close().Ok()) {
|
||||
NEARBY_LOGS(INFO) << "Failed to close WifiLan server socket for service_id="
|
||||
LOG(INFO) << "Failed to close WifiLan server socket for service_id="
|
||||
<< service_id;
|
||||
return false;
|
||||
}
|
||||
@@ -434,19 +434,19 @@ ErrorOr<WifiLanSocket> WifiLan::Connect(const std::string& service_id,
|
||||
WifiLanSocket socket;
|
||||
|
||||
if (service_id.empty()) {
|
||||
NEARBY_LOGS(INFO) << "Refusing to create client WifiLan socket because "
|
||||
LOG(INFO) << "Refusing to create client WifiLan socket because "
|
||||
"service_id is empty.";
|
||||
return {Error(OperationResultCode::NEARBY_LOCAL_CLIENT_STATE_WRONG)};
|
||||
}
|
||||
|
||||
if (!IsAvailableLocked()) {
|
||||
NEARBY_LOGS(INFO) << "Can't create client WifiLan socket [service_id="
|
||||
LOG(INFO) << "Can't create client WifiLan socket [service_id="
|
||||
<< service_id << "]; WifiLan isn't available.";
|
||||
return {Error(OperationResultCode::MEDIUM_UNAVAILABLE_LAN_NOT_AVAILABLE)};
|
||||
}
|
||||
|
||||
if (cancellation_flag->Cancelled()) {
|
||||
NEARBY_LOGS(INFO) << "Can't create client WifiLan socket due to cancel.";
|
||||
LOG(INFO) << "Can't create client WifiLan socket due to cancel.";
|
||||
return {Error(OperationResultCode::
|
||||
CLIENT_CANCELLATION_CANCEL_LAN_OUTGOING_CONNECTION)};
|
||||
}
|
||||
@@ -459,7 +459,7 @@ ErrorOr<WifiLanSocket> WifiLan::Connect(const std::string& service_id,
|
||||
|
||||
socket = medium_.ConnectToService(service_info, cancellation_flag);
|
||||
if (!socket.IsValid()) {
|
||||
NEARBY_LOGS(INFO) << "Failed to Connect via WifiLan [service_id="
|
||||
LOG(INFO) << "Failed to Connect via WifiLan [service_id="
|
||||
<< service_id << "]";
|
||||
return {Error(
|
||||
OperationResultCode::CONNECTIVITY_LAN_CLIENT_SOCKET_CREATION_FAILURE)};
|
||||
@@ -468,14 +468,14 @@ ErrorOr<WifiLanSocket> WifiLan::Connect(const std::string& service_id,
|
||||
CreateOutgoingMultiplexSocketLocked(socket, service_id,
|
||||
service_info.GetIPAddress());
|
||||
if (virtual_socket.ok()) {
|
||||
NEARBY_LOGS(INFO)
|
||||
LOG(INFO)
|
||||
<< "Successfully connected via Multiplex WifiLan [service_id="
|
||||
<< service_id << "]";
|
||||
return virtual_socket.result();
|
||||
}
|
||||
}
|
||||
|
||||
NEARBY_LOGS(INFO) << "Successfully connected via WifiLan [service_id="
|
||||
LOG(INFO) << "Successfully connected via WifiLan [service_id="
|
||||
<< service_id << "]";
|
||||
return socket;
|
||||
}
|
||||
@@ -488,19 +488,19 @@ ErrorOr<WifiLanSocket> WifiLan::Connect(const std::string& service_id,
|
||||
WifiLanSocket socket;
|
||||
|
||||
if (service_id.empty()) {
|
||||
NEARBY_LOGS(INFO) << "Refusing to create client WifiLan socket because "
|
||||
LOG(INFO) << "Refusing to create client WifiLan socket because "
|
||||
"service_id is empty.";
|
||||
return {Error(OperationResultCode::NEARBY_LOCAL_CLIENT_STATE_WRONG)};
|
||||
}
|
||||
|
||||
if (!IsAvailableLocked()) {
|
||||
NEARBY_LOGS(INFO) << "Can't create client WifiLan socket [service_id="
|
||||
LOG(INFO) << "Can't create client WifiLan socket [service_id="
|
||||
<< service_id << "]; WifiLan isn't available.";
|
||||
return {Error(OperationResultCode::MEDIUM_UNAVAILABLE_LAN_NOT_AVAILABLE)};
|
||||
}
|
||||
|
||||
if (cancellation_flag->Cancelled()) {
|
||||
NEARBY_LOGS(INFO) << "Can't create client WifiLan socket due to cancel.";
|
||||
LOG(INFO) << "Can't create client WifiLan socket due to cancel.";
|
||||
return {Error(OperationResultCode::
|
||||
CLIENT_CANCELLATION_CANCEL_LAN_OUTGOING_CONNECTION)};
|
||||
}
|
||||
@@ -513,7 +513,7 @@ ErrorOr<WifiLanSocket> WifiLan::Connect(const std::string& service_id,
|
||||
|
||||
socket = medium_.ConnectToService(ip_address, port, cancellation_flag);
|
||||
if (!socket.IsValid()) {
|
||||
NEARBY_LOGS(INFO) << "Failed to Connect via WifiLan [service_id="
|
||||
LOG(INFO) << "Failed to Connect via WifiLan [service_id="
|
||||
<< service_id << "]";
|
||||
return {Error(
|
||||
OperationResultCode::CONNECTIVITY_LAN_CLIENT_SOCKET_CREATION_FAILURE)};
|
||||
@@ -521,14 +521,14 @@ ErrorOr<WifiLanSocket> WifiLan::Connect(const std::string& service_id,
|
||||
ExceptionOr<WifiLanSocket> virtual_socket =
|
||||
CreateOutgoingMultiplexSocketLocked(socket, service_id, ip_address);
|
||||
if (virtual_socket.ok()) {
|
||||
NEARBY_LOGS(INFO)
|
||||
LOG(INFO)
|
||||
<< "Successfully connected via Multiplex WifiLan [service_id="
|
||||
<< service_id << "]";
|
||||
return virtual_socket.result();
|
||||
}
|
||||
}
|
||||
|
||||
NEARBY_LOGS(INFO) << "Successfully connected via WifiLan [service_id="
|
||||
LOG(INFO) << "Successfully connected via WifiLan [service_id="
|
||||
<< service_id << "]";
|
||||
return socket;
|
||||
}
|
||||
@@ -536,13 +536,13 @@ ErrorOr<WifiLanSocket> WifiLan::Connect(const std::string& service_id,
|
||||
ExceptionOr<WifiLanSocket> WifiLan::ConnectWithMultiplexSocketLocked(
|
||||
const std::string& service_id, const std::string& ip_address) {
|
||||
if (is_multiplex_enabled_) {
|
||||
NEARBY_LOGS(INFO) << "multiplex_sockets_ size:"
|
||||
LOG(INFO) << "multiplex_sockets_ size:"
|
||||
<< multiplex_sockets_.size();
|
||||
auto it = multiplex_sockets_.find(ip_address);
|
||||
if (it != multiplex_sockets_.end()) {
|
||||
MultiplexSocket* multiplex_socket = it->second;
|
||||
if (multiplex_socket->IsShutdown()) {
|
||||
NEARBY_LOGS(INFO)
|
||||
LOG(INFO)
|
||||
<< "Erase multiplex_socket(already shutdown) for ip_address: "
|
||||
<< WifiUtils::GetHumanReadableIpAddress(ip_address);
|
||||
multiplex_socket->~MultiplexSocket();
|
||||
@@ -555,7 +555,7 @@ ExceptionOr<WifiLanSocket> WifiLan::ConnectWithMultiplexSocketLocked(
|
||||
// Should not happen.
|
||||
auto* wlan_socket = down_cast<WifiLanSocket*>(virtual_socket);
|
||||
if (wlan_socket == nullptr) {
|
||||
NEARBY_LOGS(INFO) << "Failed to cast to WifiLanSocket for "
|
||||
LOG(INFO) << "Failed to cast to WifiLanSocket for "
|
||||
<< service_id << " with ip_address: "
|
||||
<< WifiUtils::GetHumanReadableIpAddress(ip_address);
|
||||
return ExceptionOr<WifiLanSocket>(Exception::kFailed);
|
||||
@@ -581,12 +581,12 @@ ExceptionOr<WifiLanSocket> WifiLan::CreateOutgoingMultiplexSocketLocked(
|
||||
// Should not happen.
|
||||
auto* wlan_socket = down_cast<WifiLanSocket*>(virtual_socket);
|
||||
if (wlan_socket == nullptr) {
|
||||
NEARBY_LOGS(INFO) << "Failed to cast to WifiLanSocket for " << service_id
|
||||
LOG(INFO) << "Failed to cast to WifiLanSocket for " << service_id
|
||||
<< " with ip_address: "
|
||||
<< WifiUtils::GetHumanReadableIpAddress(ip_address);
|
||||
return ExceptionOr<WifiLanSocket>(Exception::kFailed);
|
||||
}
|
||||
NEARBY_LOGS(INFO) << "Multiplex socket created for ip_address: "
|
||||
LOG(INFO) << "Multiplex socket created for ip_address: "
|
||||
<< WifiUtils::GetHumanReadableIpAddress(ip_address);
|
||||
multiplex_sockets_.emplace(ip_address, multiplex_socket);
|
||||
return ExceptionOr<WifiLanSocket>(*wlan_socket);
|
||||
|
||||
@@ -93,7 +93,7 @@ TEST_P(WifiLanTest, CanConnect) {
|
||||
.service_discovered_cb =
|
||||
[&discovered_latch, &discovered_service_info](
|
||||
NsdServiceInfo service_info, const std::string& service_id) {
|
||||
NEARBY_LOGS(INFO)
|
||||
LOG(INFO)
|
||||
<< "Discovered service_info=" << &service_info;
|
||||
discovered_service_info = service_info;
|
||||
discovered_latch.CountDown();
|
||||
@@ -161,7 +161,7 @@ TEST_P(WifiLanTest, CanConnectWithMultiplex) {
|
||||
[&discovered_latch, &discovered_service_info](
|
||||
NsdServiceInfo service_info,
|
||||
const std::string& service_id) {
|
||||
NEARBY_LOGS(INFO) << "Discovered service_info="
|
||||
LOG(INFO) << "Discovered service_info="
|
||||
<< &service_info;
|
||||
discovered_service_info = service_info;
|
||||
discovered_latch.CountDown();
|
||||
@@ -224,7 +224,7 @@ TEST_P(WifiLanTest, CanCancelConnect) {
|
||||
.service_discovered_cb =
|
||||
[&discovered_latch, &discovered_service_info](
|
||||
NsdServiceInfo service_info, const std::string& service_id) {
|
||||
NEARBY_LOGS(INFO)
|
||||
LOG(INFO)
|
||||
<< "Discovered service_info=" << &service_info;
|
||||
discovered_service_info = service_info;
|
||||
discovered_latch.CountDown();
|
||||
|
||||
@@ -41,11 +41,11 @@ namespace connections {
|
||||
OfflineServiceController::~OfflineServiceController() { Stop(); }
|
||||
|
||||
void OfflineServiceController::Stop() {
|
||||
NEARBY_LOGS(INFO) << "Initiating shutdown of OfflineServiceController.";
|
||||
LOG(INFO) << "Initiating shutdown of OfflineServiceController.";
|
||||
if (stop_.Set(true)) return;
|
||||
payload_manager_.DisconnectFromEndpointManager();
|
||||
pcp_manager_.DisconnectFromEndpointManager();
|
||||
NEARBY_LOGS(INFO) << "OfflineServiceController has shut down.";
|
||||
LOG(INFO) << "OfflineServiceController has shut down.";
|
||||
}
|
||||
|
||||
Status OfflineServiceController::StartAdvertising(
|
||||
@@ -53,7 +53,7 @@ Status OfflineServiceController::StartAdvertising(
|
||||
const AdvertisingOptions& advertising_options,
|
||||
const ConnectionRequestInfo& info) {
|
||||
if (stop_) return {Status::kOutOfOrderApiCall};
|
||||
NEARBY_LOGS(INFO) << "Client " << client->GetClientId()
|
||||
LOG(INFO) << "Client " << client->GetClientId()
|
||||
<< " requested to start advertising for service_id "
|
||||
<< service_id;
|
||||
return pcp_manager_.StartAdvertising(client, service_id, advertising_options,
|
||||
@@ -62,7 +62,7 @@ Status OfflineServiceController::StartAdvertising(
|
||||
|
||||
void OfflineServiceController::StopAdvertising(ClientProxy* client) {
|
||||
if (stop_) return;
|
||||
NEARBY_LOGS(INFO) << "Client " << client->GetClientId()
|
||||
LOG(INFO) << "Client " << client->GetClientId()
|
||||
<< " requested to stop advertising for service_id "
|
||||
<< client->GetAdvertisingServiceId();
|
||||
pcp_manager_.StopAdvertising(client);
|
||||
@@ -72,7 +72,7 @@ Status OfflineServiceController::StartDiscovery(
|
||||
ClientProxy* client, const std::string& service_id,
|
||||
const DiscoveryOptions& discovery_options, DiscoveryListener listener) {
|
||||
if (stop_) return {Status::kOutOfOrderApiCall};
|
||||
NEARBY_LOGS(INFO) << "Client " << client->GetClientId()
|
||||
LOG(INFO) << "Client " << client->GetClientId()
|
||||
<< " requested to start discovery for service_id "
|
||||
<< service_id;
|
||||
return pcp_manager_.StartDiscovery(client, service_id, discovery_options,
|
||||
@@ -81,7 +81,7 @@ Status OfflineServiceController::StartDiscovery(
|
||||
|
||||
void OfflineServiceController::StopDiscovery(ClientProxy* client) {
|
||||
if (stop_) return;
|
||||
NEARBY_LOGS(INFO) << "Client " << client->GetClientId()
|
||||
LOG(INFO) << "Client " << client->GetClientId()
|
||||
<< " requested to stop discovery for service_id "
|
||||
<< client->GetDiscoveryServiceId();
|
||||
pcp_manager_.StopDiscovery(client);
|
||||
@@ -92,7 +92,7 @@ OfflineServiceController::StartListeningForIncomingConnections(
|
||||
ClientProxy* client, absl::string_view service_id,
|
||||
v3::ConnectionListener listener,
|
||||
const v3::ConnectionListeningOptions& options) {
|
||||
NEARBY_LOGS(INFO) << "Client " << client->GetClientId()
|
||||
LOG(INFO) << "Client " << client->GetClientId()
|
||||
<< " requested to start listening for service_id "
|
||||
<< service_id;
|
||||
return pcp_manager_.StartListeningForIncomingConnections(
|
||||
@@ -101,7 +101,7 @@ OfflineServiceController::StartListeningForIncomingConnections(
|
||||
|
||||
void OfflineServiceController::StopListeningForIncomingConnections(
|
||||
ClientProxy* client) {
|
||||
NEARBY_LOGS(INFO) << "Client " << client->GetClientId()
|
||||
LOG(INFO) << "Client " << client->GetClientId()
|
||||
<< " requested to stop listening for service_id "
|
||||
<< client->GetListeningForIncomingConnectionsServiceId();
|
||||
pcp_manager_.StopListeningForIncomingConnections(client);
|
||||
@@ -111,7 +111,7 @@ void OfflineServiceController::InjectEndpoint(
|
||||
ClientProxy* client, const std::string& service_id,
|
||||
const OutOfBandConnectionMetadata& metadata) {
|
||||
if (stop_) return;
|
||||
NEARBY_LOGS(INFO) << "Client " << client->GetClientId()
|
||||
LOG(INFO) << "Client " << client->GetClientId()
|
||||
<< " requested to inject endpoint {endpoint_id:"
|
||||
<< metadata.endpoint_id << ", endpoint_info:"
|
||||
<< metadata.endpoint_info.AsStringView()
|
||||
@@ -126,7 +126,7 @@ Status OfflineServiceController::RequestConnection(
|
||||
const ConnectionRequestInfo& info,
|
||||
const ConnectionOptions& connection_options) {
|
||||
if (stop_) return {Status::kOutOfOrderApiCall};
|
||||
NEARBY_LOGS(INFO) << "Client " << client->GetClientId()
|
||||
LOG(INFO) << "Client " << client->GetClientId()
|
||||
<< " requested a connection to endpoint_id " << endpoint_id;
|
||||
return pcp_manager_.RequestConnection(client, endpoint_id, info,
|
||||
connection_options);
|
||||
@@ -137,7 +137,7 @@ Status OfflineServiceController::RequestConnectionV3(
|
||||
const ConnectionRequestInfo& info,
|
||||
const ConnectionOptions& connection_options) {
|
||||
if (stop_) return {Status::kOutOfOrderApiCall};
|
||||
NEARBY_LOGS(INFO) << "Client " << client->GetClientId()
|
||||
LOG(INFO) << "Client " << client->GetClientId()
|
||||
<< " requested a connection to endpoint_id "
|
||||
<< remote_device.GetEndpointId();
|
||||
return pcp_manager_.RequestConnectionV3(client, remote_device, info,
|
||||
@@ -148,7 +148,7 @@ Status OfflineServiceController::AcceptConnection(
|
||||
ClientProxy* client, const std::string& endpoint_id,
|
||||
PayloadListener listener) {
|
||||
if (stop_) return {Status::kOutOfOrderApiCall};
|
||||
NEARBY_LOGS(INFO) << "Client " << client->GetClientId()
|
||||
LOG(INFO) << "Client " << client->GetClientId()
|
||||
<< " accepted the connection from endpoint_id "
|
||||
<< endpoint_id;
|
||||
return pcp_manager_.AcceptConnection(client, endpoint_id,
|
||||
@@ -158,7 +158,7 @@ Status OfflineServiceController::AcceptConnection(
|
||||
Status OfflineServiceController::RejectConnection(
|
||||
ClientProxy* client, const std::string& endpoint_id) {
|
||||
if (stop_) return {Status::kOutOfOrderApiCall};
|
||||
NEARBY_LOGS(INFO) << "Client " << client->GetClientId()
|
||||
LOG(INFO) << "Client " << client->GetClientId()
|
||||
<< " rejected the connection from endpoint_id "
|
||||
<< endpoint_id;
|
||||
return pcp_manager_.RejectConnection(client, endpoint_id);
|
||||
@@ -167,7 +167,7 @@ Status OfflineServiceController::RejectConnection(
|
||||
void OfflineServiceController::InitiateBandwidthUpgrade(
|
||||
ClientProxy* client, const std::string& endpoint_id) {
|
||||
if (stop_) return;
|
||||
NEARBY_LOGS(INFO) << "Client " << client->GetClientId()
|
||||
LOG(INFO) << "Client " << client->GetClientId()
|
||||
<< " initiated a manual bandwidth upgrade with endpoint_id "
|
||||
<< endpoint_id;
|
||||
bwu_manager_.InitiateBwuForEndpoint(client, endpoint_id);
|
||||
@@ -177,7 +177,7 @@ void OfflineServiceController::SendPayload(
|
||||
ClientProxy* client, const std::vector<std::string>& endpoint_ids,
|
||||
Payload payload) {
|
||||
if (stop_) return;
|
||||
NEARBY_LOGS(INFO) << "Client " << client->GetClientId()
|
||||
LOG(INFO) << "Client " << client->GetClientId()
|
||||
<< " is sending payload {id:" << payload.GetId()
|
||||
<< ", type:" << payload.GetType() << "} to endpoint_ids {"
|
||||
<< absl::StrJoin(endpoint_ids, ",") << "}";
|
||||
@@ -187,7 +187,7 @@ void OfflineServiceController::SendPayload(
|
||||
Status OfflineServiceController::CancelPayload(ClientProxy* client,
|
||||
std::int64_t payload_id) {
|
||||
if (stop_) return {Status::kOutOfOrderApiCall};
|
||||
NEARBY_LOGS(INFO) << "Client " << client->GetClientId()
|
||||
LOG(INFO) << "Client " << client->GetClientId()
|
||||
<< " cancelled payload " << payload_id;
|
||||
return payload_manager_.CancelPayload(client, payload_id);
|
||||
}
|
||||
@@ -195,7 +195,7 @@ Status OfflineServiceController::CancelPayload(ClientProxy* client,
|
||||
void OfflineServiceController::DisconnectFromEndpoint(
|
||||
ClientProxy* client, const std::string& endpoint_id) {
|
||||
if (stop_) return;
|
||||
NEARBY_LOGS(INFO) << "Client " << client->GetClientId()
|
||||
LOG(INFO) << "Client " << client->GetClientId()
|
||||
<< " requested a disconnection from endpoint_id "
|
||||
<< endpoint_id;
|
||||
endpoint_manager_.UnregisterEndpoint(client, endpoint_id);
|
||||
@@ -205,7 +205,7 @@ Status OfflineServiceController::UpdateAdvertisingOptions(
|
||||
ClientProxy* client, absl::string_view service_id,
|
||||
const AdvertisingOptions& advertising_options) {
|
||||
if (stop_) return {Status::kOutOfOrderApiCall};
|
||||
NEARBY_LOGS(INFO)
|
||||
LOG(INFO)
|
||||
<< "Client " << client->GetClientId()
|
||||
<< " requested to update advertising options for service_id "
|
||||
<< service_id;
|
||||
@@ -217,7 +217,7 @@ 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()
|
||||
LOG(INFO) << "Client " << client->GetClientId()
|
||||
<< " requested to update discovery options for service_id "
|
||||
<< service_id;
|
||||
return pcp_manager_.UpdateDiscoveryOptions(client, service_id,
|
||||
@@ -227,13 +227,13 @@ Status OfflineServiceController::UpdateDiscoveryOptions(
|
||||
void OfflineServiceController::SetCustomSavePath(ClientProxy* client,
|
||||
const std::string& path) {
|
||||
if (stop_) return;
|
||||
NEARBY_LOGS(INFO) << "Client " << client->GetClientId()
|
||||
LOG(INFO) << "Client " << client->GetClientId()
|
||||
<< " requested to set custom save path to " << path;
|
||||
payload_manager_.SetCustomSavePath(client, path);
|
||||
}
|
||||
|
||||
void OfflineServiceController::ShutdownBwuManagerExecutors() {
|
||||
NEARBY_LOGS(INFO) << "Shutting down BwuManager executors.";
|
||||
LOG(INFO) << "Shutting down BwuManager executors.";
|
||||
bwu_manager_.ShutdownExecutors();
|
||||
}
|
||||
|
||||
|
||||
@@ -107,18 +107,18 @@ class OfflineServiceControllerTest
|
||||
EXPECT_EQ(user_b.GetDiscovered().service_id, kServiceId);
|
||||
EXPECT_EQ(user_b.GetDiscovered().endpoint_info, user_a.GetInfo());
|
||||
EXPECT_FALSE(user_b.GetDiscovered().endpoint_id.empty());
|
||||
NEARBY_LOGS(INFO) << "EP-B: [discovered] "
|
||||
LOG(INFO) << "EP-B: [discovered] "
|
||||
<< user_b.GetDiscovered().endpoint_id;
|
||||
user_b.RequestConnection(&connect_latch_);
|
||||
EXPECT_TRUE(connect_latch_.Await(kLongTimeout));
|
||||
EXPECT_FALSE(user_a.GetDiscovered().endpoint_id.empty());
|
||||
NEARBY_LOGS(INFO) << "EP-A: [discovered] "
|
||||
LOG(INFO) << "EP-A: [discovered] "
|
||||
<< user_a.GetDiscovered().endpoint_id;
|
||||
NEARBY_LOGS(INFO) << "Both users discovered their peers.";
|
||||
LOG(INFO) << "Both users discovered their peers.";
|
||||
user_a.AcceptConnection(&accept_latch_);
|
||||
user_b.AcceptConnection(&accept_latch_);
|
||||
EXPECT_TRUE(accept_latch_.Await(kLongTimeout));
|
||||
NEARBY_LOGS(INFO) << "Both users reached connected state.";
|
||||
LOG(INFO) << "Both users reached connected state.";
|
||||
return user_a.IsConnected() && user_b.IsConnected();
|
||||
}
|
||||
|
||||
@@ -400,11 +400,11 @@ TEST_P(OfflineServiceControllerTest, CanDisconnect) {
|
||||
OfflineSimulationUser user_a(kDeviceA, GetParam());
|
||||
OfflineSimulationUser user_b(kDeviceB, GetParam());
|
||||
ASSERT_TRUE(SetupConnection(user_a, user_b));
|
||||
NEARBY_LOGS(INFO) << "Disconnecting";
|
||||
LOG(INFO) << "Disconnecting";
|
||||
user_b.ExpectDisconnect(disconnect_latch);
|
||||
user_b.Disconnect();
|
||||
EXPECT_TRUE(disconnect_latch.Await(kLongTimeout));
|
||||
NEARBY_LOGS(INFO) << "Disconnected";
|
||||
LOG(INFO) << "Disconnected";
|
||||
EXPECT_FALSE(user_b.IsConnected());
|
||||
user_a.Stop();
|
||||
user_b.Stop();
|
||||
@@ -418,7 +418,7 @@ TEST_P(OfflineServiceControllerTest, TestUpdateAdvertisingOptions) {
|
||||
EXPECT_THAT(user_a.StartAdvertising(std::string(kServiceId), nullptr),
|
||||
Eq(Status{Status::kSuccess}));
|
||||
EXPECT_TRUE(user_a.IsAdvertising());
|
||||
NEARBY_LOGS(INFO) << "Started advertising";
|
||||
LOG(INFO) << "Started advertising";
|
||||
AdvertisingOptions new_options = {
|
||||
{
|
||||
Strategy::kP2pCluster,
|
||||
@@ -431,9 +431,9 @@ TEST_P(OfflineServiceControllerTest, TestUpdateAdvertisingOptions) {
|
||||
EXPECT_THAT(user_a.UpdateAdvertisingOptions(kServiceId, new_options),
|
||||
Eq(Status{Status::kSuccess}));
|
||||
EXPECT_TRUE(user_a.IsAdvertising());
|
||||
NEARBY_LOGS(INFO) << "Updated advertising options";
|
||||
LOG(INFO) << "Updated advertising options";
|
||||
user_a.StopAdvertising();
|
||||
NEARBY_LOGS(INFO) << "Stopped advertising";
|
||||
LOG(INFO) << "Stopped advertising";
|
||||
user_a.Stop();
|
||||
env_.Stop();
|
||||
}
|
||||
|
||||
@@ -30,9 +30,9 @@ void OfflineSimulationUser::OnConnectionInitiated(
|
||||
const std::string& endpoint_id, const ConnectionResponseInfo& info,
|
||||
bool is_outgoing) {
|
||||
if (is_outgoing) {
|
||||
NEARBY_LOGS(INFO) << "RequestConnection: initiated_cb called";
|
||||
LOG(INFO) << "RequestConnection: initiated_cb called";
|
||||
} else {
|
||||
NEARBY_LOGS(INFO) << "StartAdvertising: initiated_cb called";
|
||||
LOG(INFO) << "StartAdvertising: initiated_cb called";
|
||||
discovered_ = DiscoveredInfo{
|
||||
.endpoint_id = endpoint_id,
|
||||
.endpoint_info = GetInfo(),
|
||||
@@ -54,7 +54,7 @@ void OfflineSimulationUser::OnConnectionRejected(const std::string& endpoint_id,
|
||||
|
||||
void OfflineSimulationUser::OnEndpointDisconnect(
|
||||
const std::string& endpoint_id) {
|
||||
NEARBY_LOGS(INFO) << "OnEndpointDisconnect: self=" << this
|
||||
LOG(INFO) << "OnEndpointDisconnect: self=" << this
|
||||
<< "; id=" << endpoint_id;
|
||||
if (disconnect_latch_) disconnect_latch_->CountDown();
|
||||
}
|
||||
@@ -62,7 +62,7 @@ void OfflineSimulationUser::OnEndpointDisconnect(
|
||||
void OfflineSimulationUser::OnEndpointFound(const std::string& endpoint_id,
|
||||
const ByteArray& endpoint_info,
|
||||
const std::string& service_id) {
|
||||
NEARBY_LOGS(INFO) << "Device discovered: id=" << endpoint_id;
|
||||
LOG(INFO) << "Device discovered: id=" << endpoint_id;
|
||||
discovered_ = DiscoveredInfo{
|
||||
.endpoint_id = endpoint_id,
|
||||
.endpoint_info = endpoint_info,
|
||||
@@ -229,7 +229,7 @@ Status OfflineSimulationUser::RejectConnection(CountDownLatch* latch) {
|
||||
}
|
||||
|
||||
void OfflineSimulationUser::Disconnect() {
|
||||
NEARBY_LOGS(INFO) << "Disconnecting from id=" << discovered_.endpoint_id;
|
||||
LOG(INFO) << "Disconnecting from id=" << discovered_.endpoint_id;
|
||||
ctrl_.DisconnectFromEndpoint(&client_, discovered_.endpoint_id);
|
||||
}
|
||||
|
||||
|
||||
@@ -80,7 +80,7 @@ constexpr BooleanMediumSelector kTestCases[] = {
|
||||
class P2pClusterPcpHandlerTest : public testing::Test {
|
||||
protected:
|
||||
void SetUp() override {
|
||||
NEARBY_LOGS(INFO) << "SetUp: begin";
|
||||
LOG(INFO) << "SetUp: begin";
|
||||
NearbyFlags::GetInstance().OverrideBoolFlagValue(
|
||||
config_package_nearby::nearby_connections_feature::kEnableAwdl, true);
|
||||
SetBleExtendedAdvertisementsAvailable(true);
|
||||
@@ -213,7 +213,7 @@ TEST_F(P2pClusterPcpHandlerTest,
|
||||
[&latch](const std::string& endpoint_id,
|
||||
const ByteArray& endpoint_info,
|
||||
const std::string& service_id) {
|
||||
NEARBY_LOGS(INFO)
|
||||
LOG(INFO)
|
||||
<< "Device discovered: id=" << endpoint_id;
|
||||
latch.CountDown();
|
||||
},
|
||||
@@ -241,7 +241,7 @@ class P2pClusterPcpHandlerTestWithParam
|
||||
/*disable_bluetooth_scanning*/ bool>> {
|
||||
protected:
|
||||
void SetUp() override {
|
||||
NEARBY_LOGS(INFO) << "SetUp: begin";
|
||||
LOG(INFO) << "SetUp: begin";
|
||||
env_.SetBleExtendedAdvertisementsAvailable(false);
|
||||
bool ble_v2_enabled = std::get<1>(GetParam());
|
||||
NearbyFlags::GetInstance().OverrideBoolFlagValue(
|
||||
@@ -255,21 +255,21 @@ class P2pClusterPcpHandlerTestWithParam
|
||||
kDisableBluetoothClassicScanning,
|
||||
is_disable_bluetooth_scanning);
|
||||
if (advertising_options_.allowed.ble) {
|
||||
NEARBY_LOGS(INFO) << "SetUp: BLE enabled";
|
||||
LOG(INFO) << "SetUp: BLE enabled";
|
||||
}
|
||||
if (advertising_options_.allowed.bluetooth) {
|
||||
NEARBY_LOGS(INFO) << "SetUp: BT enabled";
|
||||
LOG(INFO) << "SetUp: BT enabled";
|
||||
}
|
||||
if (advertising_options_.allowed.wifi_lan) {
|
||||
NEARBY_LOGS(INFO) << "SetUp: WifiLan enabled";
|
||||
LOG(INFO) << "SetUp: WifiLan enabled";
|
||||
}
|
||||
if (advertising_options_.allowed.web_rtc) {
|
||||
NEARBY_LOGS(INFO) << "SetUp: WebRTC enabled";
|
||||
LOG(INFO) << "SetUp: WebRTC enabled";
|
||||
}
|
||||
NEARBY_LOGS(INFO) << "SetUp: ble v2 enabled: " << ble_v2_enabled;
|
||||
NEARBY_LOGS(INFO) << "SetUp: is_disable_bluetooth_scanning: "
|
||||
LOG(INFO) << "SetUp: ble v2 enabled: " << ble_v2_enabled;
|
||||
LOG(INFO) << "SetUp: is_disable_bluetooth_scanning: "
|
||||
<< is_disable_bluetooth_scanning;
|
||||
NEARBY_LOGS(INFO) << "SetUp: end";
|
||||
LOG(INFO) << "SetUp: end";
|
||||
}
|
||||
|
||||
ClientProxy client_a_;
|
||||
@@ -562,7 +562,7 @@ TEST_P(P2pClusterPcpHandlerTestWithParam, CanDiscover) {
|
||||
[&latch](const std::string& endpoint_id,
|
||||
const ByteArray& endpoint_info,
|
||||
const std::string& service_id) {
|
||||
NEARBY_LOGS(INFO)
|
||||
LOG(INFO)
|
||||
<< "Device discovered: id=" << endpoint_id;
|
||||
latch.CountDown();
|
||||
},
|
||||
@@ -602,7 +602,7 @@ TEST_P(P2pClusterPcpHandlerTestWithParam, CanDiscoverLegacy) {
|
||||
[&latch](const std::string& endpoint_id,
|
||||
const ByteArray& endpoint_info,
|
||||
const std::string& service_id) {
|
||||
NEARBY_LOGS(INFO)
|
||||
LOG(INFO)
|
||||
<< "Device discovered: id=" << endpoint_id;
|
||||
latch.CountDown();
|
||||
},
|
||||
@@ -687,7 +687,7 @@ TEST_P(P2pClusterPcpHandlerTestWithParam, ResumeBluetoothClassicDiscovery) {
|
||||
[&latch](const std::string& endpoint_id,
|
||||
const ByteArray& endpoint_info,
|
||||
const std::string& service_id) {
|
||||
NEARBY_LOGS(INFO)
|
||||
LOG(INFO)
|
||||
<< "Device discovered: id=" << endpoint_id;
|
||||
latch.CountDown();
|
||||
},
|
||||
@@ -765,7 +765,7 @@ TEST_P(P2pClusterPcpHandlerTestWithParam, CanBluetoothDiscoverChangeName) {
|
||||
[&](const std::string& endpoint_id,
|
||||
const ByteArray& endpoint_info,
|
||||
const std::string& service_id) {
|
||||
NEARBY_LOGS(INFO)
|
||||
LOG(INFO)
|
||||
<< "Device discovered: id=" << endpoint_id;
|
||||
if (!first) {
|
||||
first_found_latch.CountDown();
|
||||
@@ -776,7 +776,7 @@ TEST_P(P2pClusterPcpHandlerTestWithParam, CanBluetoothDiscoverChangeName) {
|
||||
},
|
||||
.endpoint_lost_cb =
|
||||
[&](const std::string& id) {
|
||||
NEARBY_LOGS(INFO) << "Device lost: id=" << id;
|
||||
LOG(INFO) << "Device lost: id=" << id;
|
||||
lost_latch.CountDown();
|
||||
},
|
||||
}),
|
||||
@@ -885,12 +885,12 @@ TEST_P(P2pClusterPcpHandlerTestWithParam, CanUpdateDiscoveryOptionsNoLowPower) {
|
||||
mediums_a.GetWifiLan().IsDiscovering(service_id_));
|
||||
EXPECT_EQ(old_enabled.bluetooth,
|
||||
mediums_a.GetBluetoothClassic().StopDiscovery(service_id_));
|
||||
NEARBY_LOGS(INFO) << "started discovery";
|
||||
LOG(INFO) << "started discovery";
|
||||
// Update discovery options
|
||||
EXPECT_TRUE(
|
||||
handler_a.UpdateDiscoveryOptions(&client_a_, service_id_, new_options)
|
||||
.Ok());
|
||||
NEARBY_LOGS(INFO) << "updated discovery options";
|
||||
LOG(INFO) << "updated discovery options";
|
||||
if (std::get<1>(GetParam())) {
|
||||
EXPECT_EQ(new_enabled.ble, mediums_a.GetBleV2().IsScanning(service_id_));
|
||||
} else {
|
||||
@@ -944,7 +944,7 @@ TEST_P(P2pClusterPcpHandlerTestWithParam,
|
||||
auto result = handler_a.UpdateDiscoveryOptions(&client_a_, service_id_,
|
||||
discovery_options_);
|
||||
EXPECT_TRUE(result.Ok());
|
||||
NEARBY_LOGS(INFO) << "updated discovery options";
|
||||
LOG(INFO) << "updated discovery options";
|
||||
if (std::get<1>(GetParam())) {
|
||||
EXPECT_EQ(enabled.ble, mediums_a.GetBleV2().IsScanning(service_id_));
|
||||
} else {
|
||||
@@ -996,7 +996,7 @@ TEST_P(P2pClusterPcpHandlerTestWithParam, CanConnect) {
|
||||
.initiated_cb =
|
||||
[&connect_latch](const std::string& endpoint_id,
|
||||
const ConnectionResponseInfo& info) {
|
||||
NEARBY_LOGS(INFO)
|
||||
LOG(INFO)
|
||||
<< "StartAdvertising: initiated_cb called";
|
||||
connect_latch.CountDown();
|
||||
},
|
||||
@@ -1011,7 +1011,7 @@ TEST_P(P2pClusterPcpHandlerTestWithParam, CanConnect) {
|
||||
const std::string& endpoint_id,
|
||||
const ByteArray& endpoint_info,
|
||||
const std::string& service_id) {
|
||||
NEARBY_LOGS(INFO)
|
||||
LOG(INFO)
|
||||
<< "Device discovered: id=" << endpoint_id
|
||||
<< ", endpoint_info="
|
||||
<< std::string{endpoint_info};
|
||||
@@ -1047,7 +1047,7 @@ TEST_P(P2pClusterPcpHandlerTestWithParam, CanConnect) {
|
||||
.initiated_cb =
|
||||
[&connect_latch](const std::string& endpoint_id,
|
||||
const ConnectionResponseInfo& info) {
|
||||
NEARBY_LOGS(INFO)
|
||||
LOG(INFO)
|
||||
<< "RequestConnection: initiated_cb called";
|
||||
connect_latch.CountDown();
|
||||
},
|
||||
|
||||
@@ -89,26 +89,26 @@ class P2pPointToPointPcpHandlerTest
|
||||
: public testing::TestWithParam<std::tuple<BooleanMediumSelector, bool>> {
|
||||
protected:
|
||||
void SetUp() override {
|
||||
NEARBY_LOGS(INFO) << "SetUp: begin";
|
||||
LOG(INFO) << "SetUp: begin";
|
||||
NearbyFlags::GetInstance().OverrideBoolFlagValue(
|
||||
config_package_nearby::nearby_connections_feature::kEnableBleV2,
|
||||
std::get<1>(GetParam()));
|
||||
if (advertising_options_.allowed.ble) {
|
||||
NEARBY_LOGS(INFO) << "SetUp: BLE enabled";
|
||||
LOG(INFO) << "SetUp: BLE enabled";
|
||||
}
|
||||
if (advertising_options_.allowed.bluetooth) {
|
||||
NEARBY_LOGS(INFO) << "SetUp: BT enabled";
|
||||
LOG(INFO) << "SetUp: BT enabled";
|
||||
}
|
||||
if (advertising_options_.allowed.wifi_lan) {
|
||||
NEARBY_LOGS(INFO) << "SetUp: WifiLan enabled";
|
||||
LOG(INFO) << "SetUp: WifiLan enabled";
|
||||
}
|
||||
if (advertising_options_.allowed.wifi_hotspot) {
|
||||
NEARBY_LOGS(INFO) << "SetUp: WifiLan enabled";
|
||||
LOG(INFO) << "SetUp: WifiLan enabled";
|
||||
}
|
||||
if (advertising_options_.allowed.web_rtc) {
|
||||
NEARBY_LOGS(INFO) << "SetUp: WebRTC enabled";
|
||||
LOG(INFO) << "SetUp: WebRTC enabled";
|
||||
}
|
||||
NEARBY_LOGS(INFO) << "SetUp: end";
|
||||
LOG(INFO) << "SetUp: end";
|
||||
}
|
||||
|
||||
ClientProxy client_a_;
|
||||
@@ -184,7 +184,7 @@ TEST_P(P2pPointToPointPcpHandlerTest, CanConnect) {
|
||||
.initiated_cb =
|
||||
[&connect_latch](const std::string& endpoint_id,
|
||||
const ConnectionResponseInfo& info) {
|
||||
NEARBY_LOGS(INFO)
|
||||
LOG(INFO)
|
||||
<< "StartAdvertising: initiated_cb called";
|
||||
connect_latch.CountDown();
|
||||
},
|
||||
@@ -199,7 +199,7 @@ TEST_P(P2pPointToPointPcpHandlerTest, CanConnect) {
|
||||
const std::string& endpoint_id,
|
||||
const ByteArray& endpoint_info,
|
||||
const std::string& service_id) {
|
||||
NEARBY_LOGS(INFO)
|
||||
LOG(INFO)
|
||||
<< "Device discovered: id=" << endpoint_id
|
||||
<< ", endpoint_info="
|
||||
<< endpoint_info.AsStringView();
|
||||
@@ -235,7 +235,7 @@ TEST_P(P2pPointToPointPcpHandlerTest, CanConnect) {
|
||||
.initiated_cb =
|
||||
[&connect_latch](const std::string& endpoint_id,
|
||||
const ConnectionResponseInfo& info) {
|
||||
NEARBY_LOGS(INFO)
|
||||
LOG(INFO)
|
||||
<< "RequestConnection: initiated_cb called";
|
||||
connect_latch.CountDown();
|
||||
},
|
||||
|
||||
@@ -131,7 +131,7 @@ bool PayloadManager::SendPayloadLoop(
|
||||
PayloadStatus::LOCAL_ERROR);
|
||||
return false;
|
||||
}
|
||||
NEARBY_VLOG(1) << "PayloadManager successfully skipped "
|
||||
VLOG(1) << "PayloadManager successfully skipped "
|
||||
<< real_offset.GetResult() << " bytes on payload_id "
|
||||
<< pending_payload.GetInternalPayload()->GetId();
|
||||
next_chunk_offset = real_offset.GetResult();
|
||||
@@ -199,7 +199,7 @@ bool PayloadManager::SendPayloadLoop(
|
||||
payload_chunk.offset(), payload_chunk.body().size());
|
||||
}
|
||||
}
|
||||
NEARBY_VLOG(1) << "PayloadManager done sending chunk at offset "
|
||||
VLOG(1) << "PayloadManager done sending chunk at offset "
|
||||
<< next_chunk_offset << " of payload_id="
|
||||
<< pending_payload.GetInternalPayload()->GetId();
|
||||
next_chunk_offset += next_chunk_size;
|
||||
@@ -1310,7 +1310,7 @@ void PayloadManager::ProcessDataPacket(
|
||||
*payload_transfer_frame.mutable_payload_header();
|
||||
PayloadTransferFrame::PayloadChunk& payload_chunk =
|
||||
*payload_transfer_frame.mutable_payload_chunk();
|
||||
NEARBY_VLOG(1) << "PayloadManager got data OfflineFrame for payload_id="
|
||||
VLOG(1) << "PayloadManager got data OfflineFrame for payload_id="
|
||||
<< payload_header.id()
|
||||
<< " from endpoint_id=" << from_endpoint_id << " at offset "
|
||||
<< payload_chunk.offset();
|
||||
@@ -1485,7 +1485,7 @@ void PayloadManager::ProcessControlPacket(
|
||||
pending_payload->SetEndpointStatusFromControlMessage(from_endpoint_id,
|
||||
control_message);
|
||||
}
|
||||
NEARBY_VLOG(1)
|
||||
VLOG(1)
|
||||
<< "Marked "
|
||||
<< (pending_payload->IsIncoming() ? "incoming" : "outgoing")
|
||||
<< " payload_id=" << pending_payload->GetInternalPayload()->GetId()
|
||||
@@ -1605,7 +1605,7 @@ PayloadManager::EndpointInfo::ControlMessageEventToEndpointInfoStatus(
|
||||
void PayloadManager::EndpointInfo::SetStatusFromControlMessage(
|
||||
const PayloadTransferFrame::ControlMessage& control_message) {
|
||||
status.Set(ControlMessageEventToEndpointInfoStatus(control_message.event()));
|
||||
NEARBY_VLOG(1) << "Marked endpoint " << id << " with status "
|
||||
VLOG(1) << "Marked endpoint " << id << " with status "
|
||||
<< ToString(status.Get()) << " based on OOB ControlMessage";
|
||||
}
|
||||
|
||||
@@ -1766,12 +1766,12 @@ void PayloadManager::PendingPayloads::Remove(
|
||||
int refcount = it->second->DecRefCount();
|
||||
if (refcount == 0) {
|
||||
// Nobody is using the payload, we can remove it.
|
||||
NEARBY_VLOG(1) << "Erase payload " << it->second->ToString();
|
||||
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_VLOG(1) << "Bin payload " << it->second->ToString();
|
||||
VLOG(1) << "Bin payload " << it->second->ToString();
|
||||
payload_garbage_bin_.push_back(
|
||||
std::move(pending_payloads_.extract(it).mapped()));
|
||||
}
|
||||
@@ -1813,7 +1813,7 @@ void PayloadManager::PendingPayloads::ForEachPayload(
|
||||
void PayloadManager::PendingPayloads::Release(PendingPayload* payload) {
|
||||
// Called when `PendingPayloadHandle` is destroyed.
|
||||
MutexLock lock(&mutex_);
|
||||
NEARBY_VLOG(1) << __func__ << " " << payload->ToString();
|
||||
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.
|
||||
|
||||
@@ -88,7 +88,7 @@ class PayloadSimulationUser : public SimulationUser {
|
||||
BooleanMediumSelector allowed = BooleanMediumSelector())
|
||||
: SimulationUser(std::string(name), allowed) {}
|
||||
~PayloadSimulationUser() override {
|
||||
NEARBY_LOGS(INFO) << "PayloadSimulationUser: [down] name=" << info_.data();
|
||||
LOG(INFO) << "PayloadSimulationUser: [down] name=" << info_.data();
|
||||
// SystemClock::Sleep(kDefaultTimeout);
|
||||
}
|
||||
|
||||
@@ -148,18 +148,18 @@ class PayloadManagerTest
|
||||
EXPECT_EQ(user_b.GetDiscovered().service_id, kServiceId);
|
||||
EXPECT_EQ(user_b.GetDiscovered().endpoint_info, user_a.GetInfo());
|
||||
EXPECT_FALSE(user_b.GetDiscovered().endpoint_id.empty());
|
||||
NEARBY_LOGS(INFO) << "EP-B: [discovered] "
|
||||
LOG(INFO) << "EP-B: [discovered] "
|
||||
<< user_b.GetDiscovered().endpoint_id;
|
||||
user_b.RequestConnection(&connection_latch_);
|
||||
EXPECT_TRUE(connection_latch_.Await(kDefaultTimeout).result());
|
||||
EXPECT_FALSE(user_a.GetDiscovered().endpoint_id.empty());
|
||||
NEARBY_LOGS(INFO) << "EP-A: [discovered] "
|
||||
LOG(INFO) << "EP-A: [discovered] "
|
||||
<< user_a.GetDiscovered().endpoint_id;
|
||||
NEARBY_LOGS(INFO) << "Both users discovered their peers.";
|
||||
LOG(INFO) << "Both users discovered their peers.";
|
||||
user_a.AcceptConnection(&accept_latch_);
|
||||
user_b.AcceptConnection(&accept_latch_);
|
||||
EXPECT_TRUE(accept_latch_.Await(kDefaultTimeout).result());
|
||||
NEARBY_LOGS(INFO) << "Both users reached connected state.";
|
||||
LOG(INFO) << "Both users reached connected state.";
|
||||
return user_a.IsConnected() && user_b.IsConnected();
|
||||
}
|
||||
|
||||
@@ -193,7 +193,7 @@ TEST_P(PayloadManagerTest, CanSendBytePayload) {
|
||||
user_b.SendPayload(Payload(ByteArray{std::string(kMessage)}));
|
||||
EXPECT_TRUE(payload_latch_.Await(kDefaultTimeout).result());
|
||||
EXPECT_EQ(user_a.GetPayload().AsBytes(), ByteArray(std::string(kMessage)));
|
||||
NEARBY_LOGS(INFO) << "Test completed.";
|
||||
LOG(INFO) << "Test completed.";
|
||||
|
||||
user_a.Stop();
|
||||
user_b.Stop();
|
||||
@@ -232,7 +232,7 @@ TEST_P(PayloadManagerTest, CanSendStreamPayload) {
|
||||
ASSERT_TRUE(payload_latch_.Await(kDefaultTimeout).result());
|
||||
ASSERT_NE(user_a.GetPayload().AsStream(), nullptr);
|
||||
InputStream& rx = *user_a.GetPayload().AsStream();
|
||||
NEARBY_LOGS(INFO) << "Stream extracted.";
|
||||
LOG(INFO) << "Stream extracted.";
|
||||
|
||||
EXPECT_TRUE(user_a.WaitForProgress(
|
||||
[&message](const PayloadProgressInfo& info) {
|
||||
@@ -241,7 +241,7 @@ TEST_P(PayloadManagerTest, CanSendStreamPayload) {
|
||||
kProgressTimeout));
|
||||
ByteArray result = rx.Read(kChunkSize).result();
|
||||
EXPECT_EQ(result, message);
|
||||
NEARBY_LOGS(INFO) << "Packet 1 handled.";
|
||||
LOG(INFO) << "Packet 1 handled.";
|
||||
|
||||
tx->Write(message);
|
||||
EXPECT_TRUE(user_a.WaitForProgress(
|
||||
@@ -251,11 +251,11 @@ TEST_P(PayloadManagerTest, CanSendStreamPayload) {
|
||||
kProgressTimeout));
|
||||
ByteArray result2 = rx.Read(kChunkSize).result();
|
||||
EXPECT_EQ(result2, message);
|
||||
NEARBY_LOGS(INFO) << "Packet 2 handled.";
|
||||
LOG(INFO) << "Packet 2 handled.";
|
||||
|
||||
rx.Close();
|
||||
tx->Close();
|
||||
NEARBY_LOGS(INFO) << "Test completed.";
|
||||
LOG(INFO) << "Test completed.";
|
||||
user_a.Stop();
|
||||
user_b.Stop();
|
||||
env_.Stop();
|
||||
@@ -275,7 +275,7 @@ TEST_P(PayloadManagerTest, CanCancelPayloadOnReceiverSide) {
|
||||
ASSERT_TRUE(payload_latch_.Await(kDefaultTimeout).result());
|
||||
ASSERT_NE(user_a.GetPayload().AsStream(), nullptr);
|
||||
InputStream& rx = *user_a.GetPayload().AsStream();
|
||||
NEARBY_LOGS(INFO) << "Stream extracted.";
|
||||
LOG(INFO) << "Stream extracted.";
|
||||
|
||||
EXPECT_TRUE(user_a.WaitForProgress(
|
||||
[&message](const PayloadProgressInfo& info) {
|
||||
@@ -284,10 +284,10 @@ TEST_P(PayloadManagerTest, CanCancelPayloadOnReceiverSide) {
|
||||
kProgressTimeout));
|
||||
ByteArray result = rx.Read(kChunkSize).result();
|
||||
EXPECT_EQ(result, message);
|
||||
NEARBY_LOGS(INFO) << "Packet 1 handled.";
|
||||
LOG(INFO) << "Packet 1 handled.";
|
||||
|
||||
EXPECT_EQ(user_a.CancelPayload(), Status{Status::kSuccess});
|
||||
NEARBY_LOGS(INFO) << "Stream canceled on receiver side.";
|
||||
LOG(INFO) << "Stream canceled on receiver side.";
|
||||
|
||||
// Sender will only handle cancel event if it is sending.
|
||||
// Once cancel is handled, write will fail.
|
||||
@@ -303,12 +303,12 @@ TEST_P(PayloadManagerTest, CanCancelPayloadOnReceiverSide) {
|
||||
[status = PayloadProgressInfo::Status::kCanceled](
|
||||
const PayloadProgressInfo& info) { return info.status == status; },
|
||||
kProgressTimeout));
|
||||
NEARBY_LOGS(INFO) << "Stream cancelation received.";
|
||||
LOG(INFO) << "Stream cancelation received.";
|
||||
|
||||
tx->Close();
|
||||
rx.Close();
|
||||
|
||||
NEARBY_LOGS(INFO) << "Test completed.";
|
||||
LOG(INFO) << "Test completed.";
|
||||
user_a.Stop();
|
||||
user_b.Stop();
|
||||
env_.Stop();
|
||||
@@ -328,7 +328,7 @@ TEST_P(PayloadManagerTest, CanCancelPayloadOnSenderSide) {
|
||||
ASSERT_TRUE(payload_latch_.Await(kDefaultTimeout).result());
|
||||
ASSERT_NE(user_a.GetPayload().AsStream(), nullptr);
|
||||
InputStream& rx = *user_a.GetPayload().AsStream();
|
||||
NEARBY_LOGS(INFO) << "Stream extracted.";
|
||||
LOG(INFO) << "Stream extracted.";
|
||||
|
||||
EXPECT_TRUE(user_a.WaitForProgress(
|
||||
[&message](const PayloadProgressInfo& info) {
|
||||
@@ -337,10 +337,10 @@ TEST_P(PayloadManagerTest, CanCancelPayloadOnSenderSide) {
|
||||
kProgressTimeout));
|
||||
ByteArray result = rx.Read(kChunkSize).result();
|
||||
EXPECT_EQ(result, message);
|
||||
NEARBY_LOGS(INFO) << "Packet 1 handled.";
|
||||
LOG(INFO) << "Packet 1 handled.";
|
||||
|
||||
EXPECT_EQ(user_b.CancelPayload(), Status{Status::kSuccess});
|
||||
NEARBY_LOGS(INFO) << "Stream canceled on sender side.";
|
||||
LOG(INFO) << "Stream canceled on sender side.";
|
||||
|
||||
// Sender will only handle cancel event if it is sending.
|
||||
// Once cancel is handled, write will fail.
|
||||
@@ -356,12 +356,12 @@ TEST_P(PayloadManagerTest, CanCancelPayloadOnSenderSide) {
|
||||
[status = PayloadProgressInfo::Status::kCanceled](
|
||||
const PayloadProgressInfo& info) { return info.status == status; },
|
||||
kProgressTimeout));
|
||||
NEARBY_LOGS(INFO) << "Stream cancelation received.";
|
||||
LOG(INFO) << "Stream cancelation received.";
|
||||
|
||||
tx->Close();
|
||||
rx.Close();
|
||||
|
||||
NEARBY_LOGS(INFO) << "Test completed.";
|
||||
LOG(INFO) << "Test completed.";
|
||||
user_a.Stop();
|
||||
user_b.Stop();
|
||||
env_.Stop();
|
||||
@@ -386,7 +386,7 @@ TEST_P(PayloadManagerTest, SendPayloadWithSkip_StreamPayload) {
|
||||
ASSERT_TRUE(payload_latch_.Await(kDefaultTimeout).result());
|
||||
ASSERT_NE(user_a.GetPayload().AsStream(), nullptr);
|
||||
InputStream& rx = *user_a.GetPayload().AsStream();
|
||||
NEARBY_LOGS(INFO) << "Stream extracted.";
|
||||
LOG(INFO) << "Stream extracted.";
|
||||
|
||||
EXPECT_TRUE(user_a.WaitForProgress(
|
||||
[&message](const PayloadProgressInfo& info) {
|
||||
@@ -395,7 +395,7 @@ TEST_P(PayloadManagerTest, SendPayloadWithSkip_StreamPayload) {
|
||||
kProgressTimeout));
|
||||
ByteArray result = rx.Read(kChunkSize).result();
|
||||
EXPECT_EQ(result, ByteArray("sage"));
|
||||
NEARBY_LOGS(INFO) << "Packet 1 handled.";
|
||||
LOG(INFO) << "Packet 1 handled.";
|
||||
|
||||
tx->Write(message);
|
||||
EXPECT_TRUE(user_a.WaitForProgress(
|
||||
@@ -405,11 +405,11 @@ TEST_P(PayloadManagerTest, SendPayloadWithSkip_StreamPayload) {
|
||||
kProgressTimeout));
|
||||
ByteArray result2 = rx.Read(kChunkSize).result();
|
||||
EXPECT_EQ(result2, message);
|
||||
NEARBY_LOGS(INFO) << "Packet 2 handled.";
|
||||
LOG(INFO) << "Packet 2 handled.";
|
||||
|
||||
rx.Close();
|
||||
tx->Close();
|
||||
NEARBY_LOGS(INFO) << "Test completed.";
|
||||
LOG(INFO) << "Test completed.";
|
||||
user_a.Stop();
|
||||
user_b.Stop();
|
||||
env_.Stop();
|
||||
|
||||
@@ -73,9 +73,9 @@ void PcpManager::DisconnectFromEndpointManager() {
|
||||
}
|
||||
|
||||
PcpManager::~PcpManager() {
|
||||
NEARBY_LOGS(INFO) << "Initiating shutdown of PcpManager.";
|
||||
LOG(INFO) << "Initiating shutdown of PcpManager.";
|
||||
DisconnectFromEndpointManager();
|
||||
NEARBY_LOGS(INFO) << "PcpManager has shut down.";
|
||||
LOG(INFO) << "PcpManager has shut down.";
|
||||
}
|
||||
|
||||
Status PcpManager::StartAdvertising(
|
||||
@@ -215,7 +215,7 @@ bool PcpManager::SetCurrentPcpHandler(Strategy strategy) {
|
||||
current_ = GetPcpHandler(StrategyToPcp(strategy));
|
||||
|
||||
if (!current_) {
|
||||
NEARBY_LOGS(ERROR) << "Failed to set current PCP handler: strategy="
|
||||
LOG(ERROR) << "Failed to set current PCP handler: strategy="
|
||||
<< strategy.GetName();
|
||||
}
|
||||
|
||||
|
||||
@@ -54,7 +54,7 @@ class ReconnectSimulatorUser : public SimulationUser {
|
||||
: SimulationUser(std::string(name), allowed,
|
||||
SetSafeToDisconnect(true, true, false, 3)) {}
|
||||
~ReconnectSimulatorUser() override {
|
||||
NEARBY_LOGS(INFO) << "ReconnectSimulatorUser: [down] name=" << info_.data();
|
||||
LOG(INFO) << "ReconnectSimulatorUser: [down] name=" << info_.data();
|
||||
}
|
||||
|
||||
bool IsConnected() const {
|
||||
@@ -75,18 +75,18 @@ class ReconnectManagerTest
|
||||
EXPECT_EQ(user_b.GetDiscovered().service_id, kServiceId);
|
||||
EXPECT_EQ(user_b.GetDiscovered().endpoint_info, user_a.GetInfo());
|
||||
EXPECT_FALSE(user_b.GetDiscovered().endpoint_id.empty());
|
||||
NEARBY_LOGS(INFO) << "EP-B: [discovered]"
|
||||
LOG(INFO) << "EP-B: [discovered]"
|
||||
<< user_b.GetDiscovered().endpoint_id;
|
||||
user_b.RequestConnection(&connection_latch_);
|
||||
EXPECT_TRUE(connection_latch_.Await(kDefaultTimeout).result());
|
||||
EXPECT_FALSE(user_a.GetDiscovered().endpoint_id.empty());
|
||||
NEARBY_LOGS(INFO) << "EP-A: [discovered]"
|
||||
LOG(INFO) << "EP-A: [discovered]"
|
||||
<< user_a.GetDiscovered().endpoint_id;
|
||||
NEARBY_LOGS(INFO) << "Both users discovered their peers.";
|
||||
LOG(INFO) << "Both users discovered their peers.";
|
||||
user_a.AcceptConnection(&accept_latch_);
|
||||
user_b.AcceptConnection(&accept_latch_);
|
||||
EXPECT_TRUE(accept_latch_.Await(kDefaultTimeout).result());
|
||||
NEARBY_LOGS(INFO) << "Both users reached connected state.";
|
||||
LOG(INFO) << "Both users reached connected state.";
|
||||
return user_a.IsConnected() && user_b.IsConnected();
|
||||
}
|
||||
|
||||
@@ -111,14 +111,14 @@ TEST_P(ReconnectManagerTest, AllowReconnect) {
|
||||
ReconnectManager::AutoReconnectCallback auto_reconnect_callback = {
|
||||
.on_reconnect_success_cb =
|
||||
[&](ClientProxy* client, const std::string& endpoint_id) {
|
||||
NEARBY_LOGS(INFO)
|
||||
LOG(INFO)
|
||||
<< " Reconnect successfully for endpoint_id: " << endpoint_id;
|
||||
},
|
||||
.on_reconnect_failure_cb =
|
||||
[&](ClientProxy* client, const std::string& endpoint_id,
|
||||
bool send_disconnection_notification,
|
||||
DisconnectionReason disconnection_reason) {
|
||||
NEARBY_LOGS(INFO)
|
||||
LOG(INFO)
|
||||
<< " Reconnect failed for endpoint_id: " << endpoint_id;
|
||||
},
|
||||
};
|
||||
@@ -139,7 +139,7 @@ TEST_P(ReconnectManagerTest, AllowReconnect) {
|
||||
/*send_disconnection_notification=*/false,
|
||||
DisconnectionReason::UNFINISHED));
|
||||
|
||||
NEARBY_LOGS(INFO) << "Test completed.";
|
||||
LOG(INFO) << "Test completed.";
|
||||
user_a.Stop();
|
||||
user_b.Stop();
|
||||
env_.Stop();
|
||||
|
||||
@@ -91,7 +91,7 @@ v3::Quality ServiceControllerRouter::GetMediumQuality(Medium medium) {
|
||||
}
|
||||
|
||||
ServiceControllerRouter::ServiceControllerRouter() {
|
||||
NEARBY_LOGS(INFO) << "ServiceControllerRouter going up.";
|
||||
LOG(INFO) << "ServiceControllerRouter going up.";
|
||||
}
|
||||
|
||||
ServiceControllerRouter::ServiceControllerRouter(
|
||||
@@ -120,7 +120,7 @@ ServiceControllerRouter::ServiceControllerRouter(bool enable_ble_v2)
|
||||
}
|
||||
|
||||
ServiceControllerRouter::~ServiceControllerRouter() {
|
||||
NEARBY_LOGS(INFO) << "ServiceControllerRouter going down.";
|
||||
LOG(INFO) << "ServiceControllerRouter going down.";
|
||||
|
||||
if (service_controller_) {
|
||||
service_controller_->Stop();
|
||||
@@ -268,7 +268,7 @@ void ServiceControllerRouter::AcceptConnection(ClientProxy* client,
|
||||
}
|
||||
|
||||
if (client->HasLocalEndpointResponded(endpoint_id)) {
|
||||
NEARBY_LOGS(WARNING)
|
||||
LOG(WARNING)
|
||||
<< "Client " << client->GetClientId()
|
||||
<< " invoked acceptConnectionRequest() after having already "
|
||||
"accepted/rejected the connection to endpoint(id="
|
||||
@@ -297,7 +297,7 @@ void ServiceControllerRouter::RejectConnection(ClientProxy* client,
|
||||
}
|
||||
|
||||
if (client->HasLocalEndpointResponded(endpoint_id)) {
|
||||
NEARBY_LOGS(WARNING)
|
||||
LOG(WARNING)
|
||||
<< "Client " << client->GetClientId()
|
||||
<< " invoked rejectConnectionRequest() after having already "
|
||||
"accepted/rejected the connection to endpoint(id="
|
||||
@@ -510,7 +510,7 @@ void ServiceControllerRouter::RequestConnectionV3(
|
||||
Status status = GetServiceController()->RequestConnectionV3(
|
||||
client, remote_device, std::move(old_info), connection_options);
|
||||
if (!status.Ok()) {
|
||||
NEARBY_LOGS(WARNING) << "Unable to request connection to endpoint "
|
||||
LOG(WARNING) << "Unable to request connection to endpoint "
|
||||
<< endpoint_id << ": " << status.ToString();
|
||||
client->CancelEndpoint(endpoint_id);
|
||||
}
|
||||
@@ -532,7 +532,7 @@ void ServiceControllerRouter::AcceptConnectionV3(
|
||||
}
|
||||
|
||||
if (client->HasLocalEndpointResponded(endpoint_id)) {
|
||||
NEARBY_LOGS(WARNING)
|
||||
LOG(WARNING)
|
||||
<< "Client " << client->GetClientId()
|
||||
<< " invoked acceptConnectionRequest() after having already "
|
||||
"accepted/rejected the connection to endpoint(id="
|
||||
@@ -575,7 +575,7 @@ void ServiceControllerRouter::RejectConnectionV3(
|
||||
}
|
||||
|
||||
if (client->HasLocalEndpointResponded(endpoint_id)) {
|
||||
NEARBY_LOGS(WARNING)
|
||||
LOG(WARNING)
|
||||
<< "Client " << client->GetClientId()
|
||||
<< " invoked rejectConnectionRequest() after having already "
|
||||
"accepted/rejected the connection to endpoint(id="
|
||||
@@ -696,7 +696,7 @@ void ServiceControllerRouter::StopAllEndpoints(ClientProxy* client,
|
||||
RouteToServiceController(
|
||||
"scr-stop-all-endpoints",
|
||||
[this, client, callback = std::move(callback)]() mutable {
|
||||
NEARBY_LOGS(INFO) << "Client " << client->GetClientId()
|
||||
LOG(INFO) << "Client " << client->GetClientId()
|
||||
<< " has requested us to stop all endpoints. We will "
|
||||
"now reset the client.";
|
||||
FinishClientSession(client);
|
||||
@@ -710,7 +710,7 @@ void ServiceControllerRouter::SetCustomSavePath(ClientProxy* client,
|
||||
RouteToServiceController(
|
||||
"scr-set-custom-save-path", [this, client, path = std::string(path),
|
||||
callback = std::move(callback)]() mutable {
|
||||
NEARBY_LOGS(INFO) << "Client " << client->GetClientId()
|
||||
LOG(INFO) << "Client " << client->GetClientId()
|
||||
<< " has requested us to set custom save path to "
|
||||
<< path;
|
||||
GetServiceController()->SetCustomSavePath(client, path);
|
||||
|
||||
@@ -27,9 +27,9 @@ void SimulationUser::OnConnectionInitiated(const std::string& endpoint_id,
|
||||
const ConnectionResponseInfo& info,
|
||||
bool is_outgoing) {
|
||||
if (is_outgoing) {
|
||||
NEARBY_LOGS(INFO) << "RequestConnection: initiated_cb called";
|
||||
LOG(INFO) << "RequestConnection: initiated_cb called";
|
||||
} else {
|
||||
NEARBY_LOGS(INFO) << "StartAdvertising: initiated_cb called";
|
||||
LOG(INFO) << "StartAdvertising: initiated_cb called";
|
||||
discovered_ = DiscoveredInfo{
|
||||
.endpoint_id = endpoint_id,
|
||||
.endpoint_info = GetInfo(),
|
||||
@@ -51,7 +51,7 @@ void SimulationUser::OnConnectionRejected(const std::string& endpoint_id,
|
||||
void SimulationUser::OnEndpointFound(const std::string& endpoint_id,
|
||||
const ByteArray& endpoint_info,
|
||||
const std::string& service_id) {
|
||||
NEARBY_LOGS(INFO) << "Device discovered: id=" << endpoint_id;
|
||||
LOG(INFO) << "Device discovered: id=" << endpoint_id;
|
||||
discovered_ = DiscoveredInfo{
|
||||
.endpoint_id = endpoint_id,
|
||||
.endpoint_info = endpoint_info,
|
||||
@@ -210,7 +210,7 @@ void SimulationUser::StartListeningForIncomingConnections(
|
||||
auto result = mgr_.StartListeningForIncomingConnections(
|
||||
&client_, service_id, /*listener=*/{}, options);
|
||||
latch->CountDown();
|
||||
NEARBY_LOGS(INFO) << "status: " << result.first.ToString();
|
||||
LOG(INFO) << "status: " << result.first.ToString();
|
||||
EXPECT_EQ(expected_status, result.first);
|
||||
}
|
||||
|
||||
|
||||
@@ -88,7 +88,7 @@ WebrtcBwuHandler::CreateUpgradedEndpointChannel(
|
||||
if (web_rtc_credentials.has_location_hint()) {
|
||||
location_hint = web_rtc_credentials.location_hint();
|
||||
}
|
||||
NEARBY_LOGS(INFO)
|
||||
LOG(INFO)
|
||||
<< "WebRtcBwuHandler is attempting to connect to remote peer "
|
||||
<< peer_id.GetId() << ", location hint "
|
||||
<< absl::StrCat(location_hint.location());
|
||||
@@ -97,13 +97,13 @@ WebrtcBwuHandler::CreateUpgradedEndpointChannel(
|
||||
service_id, peer_id, location_hint,
|
||||
client->GetCancellationFlag(endpoint_id), client->GetWebRtcNonCellular());
|
||||
if (socket_result.has_error()) {
|
||||
NEARBY_LOGS(ERROR) << "WebRtcBwuHandler failed to connect to remote peer ("
|
||||
LOG(ERROR) << "WebRtcBwuHandler failed to connect to remote peer ("
|
||||
<< peer_id.GetId() << ") on endpoint " << endpoint_id
|
||||
<< ", aborting upgrade.";
|
||||
return {Error(socket_result.error().operation_result_code().value())};
|
||||
}
|
||||
|
||||
NEARBY_LOGS(INFO) << "WebRtcBwuHandler successfully connected to remote "
|
||||
LOG(INFO) << "WebRtcBwuHandler successfully connected to remote "
|
||||
"peer ("
|
||||
<< peer_id.GetId() << ") while upgrading endpoint "
|
||||
<< endpoint_id;
|
||||
@@ -113,7 +113,7 @@ WebrtcBwuHandler::CreateUpgradedEndpointChannel(
|
||||
service_id, /*channel_name=*/service_id, socket_result.value());
|
||||
if (channel == nullptr) {
|
||||
socket_result.value().Close();
|
||||
NEARBY_LOGS(ERROR)
|
||||
LOG(ERROR)
|
||||
<< "WebRtcBwuHandler failed to create new EndpointChannel for "
|
||||
"outgoing socket, aborting upgrade.";
|
||||
return {Error(
|
||||
@@ -126,7 +126,7 @@ WebrtcBwuHandler::CreateUpgradedEndpointChannel(
|
||||
void WebrtcBwuHandler::HandleRevertInitiatorStateForService(
|
||||
const std::string& upgrade_service_id) {
|
||||
webrtc_.StopAcceptingConnections(upgrade_service_id);
|
||||
NEARBY_LOGS(INFO)
|
||||
LOG(INFO)
|
||||
<< "WebrtcBwuHandler successfully reverted state for service "
|
||||
<< upgrade_service_id;
|
||||
}
|
||||
@@ -147,14 +147,14 @@ ByteArray WebrtcBwuHandler::HandleInitializeUpgradedMediumForEndpoint(
|
||||
absl::bind_front(&WebrtcBwuHandler::OnIncomingWebrtcConnection,
|
||||
this, client),
|
||||
client->GetWebRtcNonCellular())) {
|
||||
NEARBY_LOGS(ERROR) << "WebRtcBwuHandler couldn't initiate the WEB_RTC "
|
||||
LOG(ERROR) << "WebRtcBwuHandler couldn't initiate the WEB_RTC "
|
||||
"upgrade for endpoint "
|
||||
<< endpoint_id
|
||||
<< " because it failed to start listening for "
|
||||
"incoming WebRTC connections.";
|
||||
return {};
|
||||
}
|
||||
NEARBY_LOGS(INFO) << "WebRtcBwuHandler successfully started listening for "
|
||||
LOG(INFO) << "WebRtcBwuHandler successfully started listening for "
|
||||
"incoming WebRTC connections while upgrading endpoint "
|
||||
<< endpoint_id;
|
||||
}
|
||||
|
||||
@@ -49,7 +49,7 @@ ByteArray WifiDirectBwuHandler::HandleInitializeUpgradedMediumForEndpoint(
|
||||
const std::string& endpoint_id) {
|
||||
// Create WifiDirect GO
|
||||
if (!wifi_direct_medium_.StartWifiDirect()) {
|
||||
NEARBY_LOGS(INFO) << "Failed to start Wifi Direct!";
|
||||
LOG(INFO) << "Failed to start Wifi Direct!";
|
||||
return {};
|
||||
}
|
||||
|
||||
@@ -59,14 +59,14 @@ ByteArray WifiDirectBwuHandler::HandleInitializeUpgradedMediumForEndpoint(
|
||||
absl::bind_front(
|
||||
&WifiDirectBwuHandler::OnIncomingWifiDirectConnection, this,
|
||||
client))) {
|
||||
NEARBY_LOGS(ERROR)
|
||||
LOG(ERROR)
|
||||
<< "WifiDirectBwuHandler couldn't initiate WifiDirect upgrade for "
|
||||
<< "service " << upgrade_service_id << " and endpoint " << endpoint_id
|
||||
<< " because it failed to start listening for incoming WifiLan "
|
||||
"connections.";
|
||||
return {};
|
||||
}
|
||||
NEARBY_LOGS(INFO)
|
||||
LOG(INFO)
|
||||
<< "WifiDirectBwuHandler successfully started listening for incoming "
|
||||
"WifiDirect connections while upgrading endpoint "
|
||||
<< endpoint_id;
|
||||
@@ -83,7 +83,7 @@ ByteArray WifiDirectBwuHandler::HandleInitializeUpgradedMediumForEndpoint(
|
||||
int port = wifi_direct_crendential->GetPort();
|
||||
int freq = wifi_direct_crendential->GetFrequency();
|
||||
|
||||
NEARBY_LOGS(INFO) << "Start WifiDirect GO with SSID: " << ssid
|
||||
LOG(INFO) << "Start WifiDirect GO with SSID: " << ssid
|
||||
<< ", Password: " << password << ", Port: " << port
|
||||
<< ", Gateway: " << gateway << ", Frequency: " << freq;
|
||||
|
||||
@@ -100,7 +100,7 @@ void WifiDirectBwuHandler::HandleRevertInitiatorStateForService(
|
||||
wifi_direct_medium_.StopWifiDirect();
|
||||
wifi_direct_medium_.DisconnectWifiDirect();
|
||||
|
||||
NEARBY_LOGS(INFO)
|
||||
LOG(INFO)
|
||||
<< "WifiDirectBwuHandler successfully reverted all states for "
|
||||
<< "upgrade service ID " << upgrade_service_id;
|
||||
}
|
||||
@@ -110,7 +110,7 @@ WifiDirectBwuHandler::CreateUpgradedEndpointChannel(
|
||||
ClientProxy* client, const std::string& service_id,
|
||||
const std::string& endpoint_id, const UpgradePathInfo& upgrade_path_info) {
|
||||
if (!upgrade_path_info.has_wifi_direct_credentials()) {
|
||||
NEARBY_LOGS(INFO) << "No WifiDirect Credential";
|
||||
LOG(INFO) << "No WifiDirect Credential";
|
||||
return {Error(
|
||||
OperationResultCode::CONNECTIVITY_WIFI_DIRECT_INVALID_CREDENTIAL)};
|
||||
}
|
||||
@@ -122,12 +122,12 @@ WifiDirectBwuHandler::CreateUpgradedEndpointChannel(
|
||||
std::int32_t port = upgrade_path_info_credentials.port();
|
||||
const std::string& gateway = upgrade_path_info_credentials.gateway();
|
||||
|
||||
NEARBY_LOGS(INFO) << "Received WifiDirect credential SSID: " << ssid
|
||||
LOG(INFO) << "Received WifiDirect credential SSID: " << ssid
|
||||
<< ", Password:" << password << ", Port:" << port
|
||||
<< ", Gateway:" << gateway;
|
||||
|
||||
if (!wifi_direct_medium_.ConnectWifiDirect(ssid, password)) {
|
||||
NEARBY_LOGS(ERROR) << "Connect to WifiDiret GO failed";
|
||||
LOG(ERROR) << "Connect to WifiDiret GO failed";
|
||||
return {Error(
|
||||
OperationResultCode::CONNECTIVITY_WIFI_DIRECT_INVALID_CREDENTIAL)};
|
||||
}
|
||||
@@ -135,13 +135,13 @@ WifiDirectBwuHandler::CreateUpgradedEndpointChannel(
|
||||
ErrorOr<WifiDirectSocket> socket_result = wifi_direct_medium_.Connect(
|
||||
service_id, gateway, port, client->GetCancellationFlag(endpoint_id));
|
||||
if (socket_result.has_error()) {
|
||||
NEARBY_LOGS(ERROR)
|
||||
LOG(ERROR)
|
||||
<< "WifiDirectBwuHandler failed to connect to the WifiDirect service("
|
||||
<< port << ") for endpoint " << endpoint_id;
|
||||
return {Error(socket_result.error().operation_result_code().value())};
|
||||
}
|
||||
|
||||
NEARBY_VLOG(1)
|
||||
VLOG(1)
|
||||
<< "WifiDirectBwuHandler successfully connected to WifiDirect service ("
|
||||
<< port << ") while upgrading endpoint " << endpoint_id;
|
||||
|
||||
|
||||
@@ -75,12 +75,12 @@ TEST_F(WifiDirectTest, WFDGOBWUInit_GCCreateEndpointChannel) {
|
||||
mediums_1, [&](ClientProxy* client,
|
||||
std::unique_ptr<BwuHandler::IncomingSocketConnection>
|
||||
mutable_connection) {
|
||||
NEARBY_LOGS(WARNING) << "Server socket connection accept call back";
|
||||
LOG(WARNING) << "Server socket connection accept call back";
|
||||
std::shared_ptr<BwuHandler::IncomingSocketConnection> connection(
|
||||
mutable_connection.release());
|
||||
accept_latch.CountDown();
|
||||
EXPECT_TRUE(end_latch.Await(kWaitDuration).result());
|
||||
NEARBY_LOGS(WARNING) << "Test is done. Close the socket";
|
||||
LOG(WARNING) << "Test is done. Close the socket";
|
||||
connection->channel->Close();
|
||||
connection->socket->Close();
|
||||
});
|
||||
|
||||
@@ -38,7 +38,7 @@ WifiDirectEndpointChannel::GetMedium() const {
|
||||
void WifiDirectEndpointChannel::CloseImpl() {
|
||||
Exception status = socket_.Close();
|
||||
if (!status.Ok()) {
|
||||
NEARBY_LOGS(INFO)
|
||||
LOG(INFO)
|
||||
<< "Failed to close underlying socket for WifiDirectEndpointChannel "
|
||||
<< GetName() << " : exception = " << status.value;
|
||||
}
|
||||
|
||||
@@ -153,7 +153,7 @@ WifiHotspotBwuHandler::CreateUpgradedEndpointChannel(
|
||||
return {Error(socket_result.error().operation_result_code().value())};
|
||||
}
|
||||
|
||||
NEARBY_VLOG(1)
|
||||
VLOG(1)
|
||||
<< "WifiHotspotBwuHandler successfully connected to WifiHotspot service ("
|
||||
<< hotspot_credentials.GetGateway() << ":"
|
||||
<< hotspot_credentials.GetPort() << ") while upgrading endpoint "
|
||||
|
||||
@@ -75,7 +75,7 @@ TEST_F(WifiHotspotTest, SoftAPBWUInit_STACreateEndpointChannel) {
|
||||
mediums_1, [&](ClientProxy* client,
|
||||
std::unique_ptr<BwuHandler::IncomingSocketConnection>
|
||||
mutable_connection) {
|
||||
NEARBY_LOGS(WARNING) << "Server socket connection accept call back";
|
||||
LOG(WARNING) << "Server socket connection accept call back";
|
||||
accept_latch.CountDown();
|
||||
EXPECT_TRUE(end_latch.Await(kWaitDuration).result());
|
||||
});
|
||||
|
||||
@@ -38,7 +38,7 @@ WifiHotspotEndpointChannel::GetMedium() const {
|
||||
void WifiHotspotEndpointChannel::CloseImpl() {
|
||||
Exception status = socket_.Close();
|
||||
if (!status.Ok()) {
|
||||
NEARBY_LOGS(INFO)
|
||||
LOG(INFO)
|
||||
<< "Failed to close underlying socket for WifiHotspotEndpointChannel "
|
||||
<< GetName() << " : exception = " << status.value;
|
||||
}
|
||||
|
||||
@@ -58,28 +58,28 @@ WifiLanBwuHandler::CreateUpgradedEndpointChannel(
|
||||
upgrade_path_info.wifi_lan_socket();
|
||||
if (!upgrade_path_info_socket.has_ip_address() ||
|
||||
!upgrade_path_info_socket.has_wifi_port()) {
|
||||
NEARBY_LOGS(ERROR) << "WifiLanBwuHandler failed to parse UpgradePathInfo.";
|
||||
LOG(ERROR) << "WifiLanBwuHandler failed to parse UpgradePathInfo.";
|
||||
return {Error(OperationResultCode::CONNECTIVITY_WIFI_LAN_IP_ADDRESS_ERROR)};
|
||||
}
|
||||
|
||||
const std::string& ip_address = upgrade_path_info_socket.ip_address();
|
||||
std::int32_t port = upgrade_path_info_socket.wifi_port();
|
||||
|
||||
NEARBY_VLOG(1) << "WifiLanBwuHandler is attempting to connect to "
|
||||
VLOG(1) << "WifiLanBwuHandler is attempting to connect to "
|
||||
<< "available WifiLan service (" << ip_address << ":" << port
|
||||
<< ") for endpoint " << endpoint_id;
|
||||
|
||||
ErrorOr<WifiLanSocket> socket_result = wifi_lan_medium_.Connect(
|
||||
service_id, ip_address, port, client->GetCancellationFlag(endpoint_id));
|
||||
if (socket_result.has_error()) {
|
||||
NEARBY_LOGS(ERROR)
|
||||
LOG(ERROR)
|
||||
<< "WifiLanBwuHandler failed to connect to the WifiLan service ("
|
||||
<< WifiUtils::GetHumanReadableIpAddress(ip_address) << ":" << port
|
||||
<< ") for endpoint " << endpoint_id;
|
||||
return {Error(socket_result.error().operation_result_code().value())};
|
||||
}
|
||||
|
||||
NEARBY_VLOG(1)
|
||||
VLOG(1)
|
||||
<< "WifiLanBwuHandler successfully connected to WifiLan service ("
|
||||
<< ip_address << ":" << port << ") while upgrading endpoint "
|
||||
<< endpoint_id;
|
||||
@@ -88,7 +88,7 @@ WifiLanBwuHandler::CreateUpgradedEndpointChannel(
|
||||
auto channel = std::make_unique<WifiLanEndpointChannel>(
|
||||
service_id, /*channel_name=*/service_id, socket_result.value());
|
||||
if (channel == nullptr) {
|
||||
NEARBY_LOGS(ERROR) << "WifiLanBwuHandler failed to create WifiLan endpoint "
|
||||
LOG(ERROR) << "WifiLanBwuHandler failed to create WifiLan endpoint "
|
||||
<< "channel to the WifiLan service (" << ip_address
|
||||
<< ":" << port << ") for endpoint " << endpoint_id;
|
||||
socket_result.value().Close();
|
||||
@@ -110,14 +110,14 @@ ByteArray WifiLanBwuHandler::HandleInitializeUpgradedMediumForEndpoint(
|
||||
upgrade_service_id,
|
||||
absl::bind_front(&WifiLanBwuHandler::OnIncomingWifiLanConnection,
|
||||
this, client))) {
|
||||
NEARBY_LOGS(ERROR)
|
||||
LOG(ERROR)
|
||||
<< "WifiLanBwuHandler couldn't initiate the WifiLan upgrade for "
|
||||
<< "service " << upgrade_service_id << " and endpoint " << endpoint_id
|
||||
<< " because it failed to start listening for incoming WifiLan "
|
||||
"connections.";
|
||||
return {};
|
||||
}
|
||||
NEARBY_LOGS(INFO)
|
||||
LOG(INFO)
|
||||
<< "WifiLanBwuHandler successfully started listening for incoming "
|
||||
"WifiLan connections while upgrading endpoint "
|
||||
<< endpoint_id;
|
||||
@@ -130,14 +130,14 @@ ByteArray WifiLanBwuHandler::HandleInitializeUpgradedMediumForEndpoint(
|
||||
auto ip_address = credential.first;
|
||||
auto port = credential.second;
|
||||
if (ip_address.empty()) {
|
||||
NEARBY_LOGS(INFO)
|
||||
LOG(INFO)
|
||||
<< "WifiLanBwuHandler couldn't initiate the wifi_lan upgrade for "
|
||||
<< "service " << upgrade_service_id << " and endpoint " << endpoint_id
|
||||
<< " because the wifi_lan ip address were unable to be obtained.";
|
||||
return {};
|
||||
}
|
||||
|
||||
NEARBY_LOGS(INFO)
|
||||
LOG(INFO)
|
||||
<< "WifiLanBwuHandler retrieved WIFI_LAN credentials. IP addr: "
|
||||
<< ip_address[0] << "." << ip_address[1] << "." << ip_address[2] << "."
|
||||
<< ip_address[3] << ", Port: " << port;
|
||||
@@ -148,7 +148,7 @@ ByteArray WifiLanBwuHandler::HandleInitializeUpgradedMediumForEndpoint(
|
||||
void WifiLanBwuHandler::HandleRevertInitiatorStateForService(
|
||||
const std::string& upgrade_service_id) {
|
||||
wifi_lan_medium_.StopAcceptingConnections(upgrade_service_id);
|
||||
NEARBY_LOGS(INFO) << "WifiLanBwuHandler successfully reverted all states for "
|
||||
LOG(INFO) << "WifiLanBwuHandler successfully reverted all states for "
|
||||
<< "upgrade service ID " << upgrade_service_id;
|
||||
}
|
||||
|
||||
|
||||
@@ -37,14 +37,14 @@ location::nearby::proto::connections::Medium WifiLanEndpointChannel::GetMedium()
|
||||
void WifiLanEndpointChannel::CloseImpl() {
|
||||
auto status = socket_.Close();
|
||||
if (!status.Ok()) {
|
||||
NEARBY_LOGS(INFO)
|
||||
LOG(INFO)
|
||||
<< "Failed to close underlying socket for WifiLanEndpointChannel "
|
||||
<< GetName() << " : exception = " << status.value;
|
||||
}
|
||||
}
|
||||
|
||||
bool WifiLanEndpointChannel::EnableMultiplexSocket() {
|
||||
NEARBY_LOGS(INFO) << "WifiLanEndpointChannel MultiplexSocket will be "
|
||||
LOG(INFO) << "WifiLanEndpointChannel MultiplexSocket will be "
|
||||
"enabled if the WifiLan MultiplexSocket is valid";
|
||||
socket_.EnableMultiplexSocket();
|
||||
return true;
|
||||
|
||||
@@ -41,15 +41,15 @@ void NearbyHttpClient::StartRequest(
|
||||
MutexLock lock(&mutex_);
|
||||
executor_.Execute(
|
||||
[request = std::move(request), callback = std::move(callback)]() mutable {
|
||||
NEARBY_LOGS(INFO) << __func__ << ": Start async request to url="
|
||||
LOG(INFO) << __func__ << ": Start async request to url="
|
||||
<< request.GetUrl().GetUrlPath();
|
||||
absl::StatusOr<HttpResponse> response = InternalGetResponse(request);
|
||||
if (response.ok()) {
|
||||
NEARBY_LOGS(INFO)
|
||||
LOG(INFO)
|
||||
<< __func__
|
||||
<< ": Got response from url=" << request.GetUrl().GetUrlPath();
|
||||
} else {
|
||||
NEARBY_LOGS(ERROR) << __func__ << ": Failed to get response from url="
|
||||
LOG(ERROR) << __func__ << ": Failed to get response from url="
|
||||
<< request.GetUrl().GetUrlPath() << ", status"
|
||||
<< response.status();
|
||||
}
|
||||
@@ -57,7 +57,7 @@ void NearbyHttpClient::StartRequest(
|
||||
if (callback) {
|
||||
callback(response);
|
||||
}
|
||||
NEARBY_LOGS(INFO) << __func__ << ": Completed request to url="
|
||||
LOG(INFO) << __func__ << ": Completed request to url="
|
||||
<< request.GetUrl().GetUrlPath();
|
||||
});
|
||||
}
|
||||
@@ -67,7 +67,7 @@ void NearbyHttpClient::StartCancellableRequest(
|
||||
absl::AnyInvocable<void(const absl::StatusOr<HttpResponse>&)> callback) {
|
||||
MutexLock lock(&mutex_);
|
||||
if (cancellable_request == nullptr) {
|
||||
NEARBY_LOGS(ERROR) << __func__ << ": invalid cancellable request.";
|
||||
LOG(ERROR) << __func__ << ": invalid cancellable request.";
|
||||
callback(absl::InvalidArgumentError("invalid cancellable request"));
|
||||
return;
|
||||
}
|
||||
@@ -75,11 +75,11 @@ void NearbyHttpClient::StartCancellableRequest(
|
||||
.Execute(
|
||||
[cancellable_request = std::move(cancellable_request),
|
||||
callback = std::move(callback)]() mutable {
|
||||
NEARBY_LOGS(INFO)
|
||||
LOG(INFO)
|
||||
<< __func__ << ": Start async request to url="
|
||||
<< cancellable_request->http_request().GetUrl().GetUrlPath();
|
||||
if (cancellable_request->is_cancelled()) {
|
||||
NEARBY_LOGS(WARNING)
|
||||
LOG(WARNING)
|
||||
<< __func__ << ": Async request to url="
|
||||
<< cancellable_request->http_request().GetUrl().GetUrlPath()
|
||||
<< " is cancelled.";
|
||||
@@ -88,18 +88,18 @@ void NearbyHttpClient::StartCancellableRequest(
|
||||
absl::StatusOr<HttpResponse> response =
|
||||
InternalGetResponse(cancellable_request->http_request());
|
||||
if (response.ok()) {
|
||||
NEARBY_LOGS(INFO)
|
||||
LOG(INFO)
|
||||
<< __func__ << ": Got response from url="
|
||||
<< cancellable_request->http_request().GetUrl().GetUrlPath();
|
||||
} else {
|
||||
NEARBY_LOGS(ERROR)
|
||||
LOG(ERROR)
|
||||
<< __func__ << ": Failed to get response from url="
|
||||
<< cancellable_request->http_request().GetUrl().GetUrlPath()
|
||||
<< ", status" << response.status();
|
||||
}
|
||||
|
||||
if (cancellable_request->is_cancelled()) {
|
||||
NEARBY_LOGS(WARNING)
|
||||
LOG(WARNING)
|
||||
<< __func__ << ": Async request to url="
|
||||
<< cancellable_request->http_request().GetUrl().GetUrlPath()
|
||||
<< " is cancelled.";
|
||||
@@ -109,7 +109,7 @@ void NearbyHttpClient::StartCancellableRequest(
|
||||
if (callback) {
|
||||
callback(response);
|
||||
}
|
||||
NEARBY_LOGS(INFO)
|
||||
LOG(INFO)
|
||||
<< __func__ << ": Completed request to url="
|
||||
<< cancellable_request->http_request().GetUrl().GetUrlPath();
|
||||
});
|
||||
@@ -117,15 +117,15 @@ void NearbyHttpClient::StartCancellableRequest(
|
||||
|
||||
absl::StatusOr<HttpResponse> NearbyHttpClient::GetResponse(
|
||||
const HttpRequest& request) {
|
||||
NEARBY_LOGS(INFO) << __func__ << ": Start request to url="
|
||||
LOG(INFO) << __func__ << ": Start request to url="
|
||||
<< request.GetUrl().GetUrlPath();
|
||||
|
||||
absl::StatusOr<HttpResponse> response = InternalGetResponse(request);
|
||||
if (response.ok()) {
|
||||
NEARBY_LOGS(INFO) << __func__ << ": Got response from url="
|
||||
LOG(INFO) << __func__ << ": Got response from url="
|
||||
<< request.GetUrl().GetUrlPath();
|
||||
} else {
|
||||
NEARBY_LOGS(ERROR) << __func__ << ": Failed to get response from url="
|
||||
LOG(ERROR) << __func__ << ": Failed to get response from url="
|
||||
<< request.GetUrl().GetUrlPath() << ", status"
|
||||
<< response.status();
|
||||
}
|
||||
@@ -155,7 +155,7 @@ absl::StatusOr<HttpResponse> NearbyHttpClient::InternalGetResponse(
|
||||
request_stream << std::endl;
|
||||
request_stream << "body size: " << request.GetBody().GetRawData().size()
|
||||
<< std::endl;
|
||||
NEARBY_VLOG(1) << request_stream.str();
|
||||
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_VLOG(1) << response_stream.str();
|
||||
VLOG(1) << response_stream.str();
|
||||
}
|
||||
|
||||
HttpResponse response;
|
||||
|
||||
@@ -43,7 +43,7 @@ class ArrayBlockingQueue {
|
||||
has_space_.Wait();
|
||||
}
|
||||
queue_.push(value);
|
||||
NEARBY_LOGS(INFO) << "ArrayBlockingQueue::Put()";
|
||||
LOG(INFO) << "ArrayBlockingQueue::Put()";
|
||||
has_data_.Notify();
|
||||
}
|
||||
|
||||
@@ -54,7 +54,7 @@ class ArrayBlockingQueue {
|
||||
}
|
||||
T front = queue_.front();
|
||||
queue_.pop();
|
||||
NEARBY_LOGS(INFO) << "ArrayBlockingQueue::Take()";
|
||||
LOG(INFO) << "ArrayBlockingQueue::Take()";
|
||||
has_space_.Notify();
|
||||
return front;
|
||||
}
|
||||
|
||||
@@ -84,7 +84,7 @@ class AwdlSocket : public MediumSocket {
|
||||
// Returns Exception::kIo on error, Exception::kSuccess otherwise.
|
||||
Exception Close() override {
|
||||
if (IsVirtualSocket()) {
|
||||
NEARBY_LOGS(INFO) << "Multiplex: Closing virtual socket: " << this;
|
||||
LOG(INFO) << "Multiplex: Closing virtual socket: " << this;
|
||||
blocking_queue_input_stream_->Close();
|
||||
virtual_output_stream_->Close();
|
||||
CloseLocal(); // This will trigger MultiplexSocket::OnVirtualSocketClosed
|
||||
@@ -106,7 +106,7 @@ class AwdlSocket : public MediumSocket {
|
||||
/** Feeds the received incoming data to the client. */
|
||||
void FeedIncomingData(ByteArray data) override {
|
||||
if (!IsVirtualSocket()) {
|
||||
NEARBY_LOGS(INFO) << "Feeding data on a physical socket is not allowed.";
|
||||
LOG(INFO) << "Feeding data on a physical socket is not allowed.";
|
||||
return;
|
||||
}
|
||||
blocking_queue_input_stream_->Write(data);
|
||||
@@ -166,7 +166,7 @@ class AwdlServerSocket final {
|
||||
AwdlSocket Accept() {
|
||||
std::unique_ptr<api::AwdlSocket> socket = impl_->Accept();
|
||||
if (!socket) {
|
||||
NEARBY_LOGS(INFO) << "AwdlServerSocket Accept() failed on server socket: "
|
||||
LOG(INFO) << "AwdlServerSocket Accept() failed on server socket: "
|
||||
<< this;
|
||||
}
|
||||
return AwdlSocket(std::move(socket));
|
||||
@@ -174,7 +174,7 @@ class AwdlServerSocket final {
|
||||
|
||||
// Returns Exception::kIo on error, Exception::kSuccess otherwise.
|
||||
Exception Close() {
|
||||
NEARBY_LOGS(INFO) << "AwdlServerSocket Closing:: " << this;
|
||||
LOG(INFO) << "AwdlServerSocket Closing:: " << this;
|
||||
return impl_->Close();
|
||||
}
|
||||
|
||||
|
||||
@@ -69,7 +69,7 @@ bool BleMedium::StartScanning(
|
||||
if (peripherals_.empty()) return;
|
||||
auto context = peripherals_.find(&peripheral);
|
||||
if (context == peripherals_.end()) return;
|
||||
NEARBY_LOGS(INFO) << "Removing peripheral="
|
||||
LOG(INFO) << "Removing peripheral="
|
||||
<< context->second->peripheral.GetName()
|
||||
<< ", impl=" << &peripheral;
|
||||
discovered_peripheral_callback_.peripheral_lost_cb(
|
||||
@@ -83,7 +83,7 @@ bool BleMedium::StopScanning(const std::string& service_id) {
|
||||
MutexLock lock(&mutex_);
|
||||
discovered_peripheral_callback_ = {};
|
||||
peripherals_.clear();
|
||||
NEARBY_LOGS(INFO) << "Ble Scanning disabled: impl=" << &GetImpl();
|
||||
LOG(INFO) << "Ble Scanning disabled: impl=" << &GetImpl();
|
||||
}
|
||||
return impl_->StopScanning(service_id);
|
||||
}
|
||||
@@ -102,11 +102,11 @@ bool BleMedium::StartAcceptingConnections(const std::string& service_id,
|
||||
&socket, std::make_unique<AcceptedConnectionInfo>());
|
||||
auto& context = *pair.first->second;
|
||||
if (!pair.second) {
|
||||
NEARBY_LOGS(INFO) << "Accepting (again) socket=" << &context.socket
|
||||
LOG(INFO) << "Accepting (again) socket=" << &context.socket
|
||||
<< ", impl=" << &socket;
|
||||
} else {
|
||||
context.socket = BleSocket(&socket);
|
||||
NEARBY_LOGS(INFO)
|
||||
LOG(INFO)
|
||||
<< "Accepting socket=" << &context.socket << ", impl=" << &socket;
|
||||
}
|
||||
if (accepted_connection_callback_) {
|
||||
@@ -120,7 +120,7 @@ bool BleMedium::StopAcceptingConnections(const std::string& service_id) {
|
||||
MutexLock lock(&mutex_);
|
||||
accepted_connection_callback_ = nullptr;
|
||||
sockets_.clear();
|
||||
NEARBY_LOGS(INFO) << "Ble accepted connection disabled: impl="
|
||||
LOG(INFO) << "Ble accepted connection disabled: impl="
|
||||
<< &GetImpl();
|
||||
}
|
||||
return impl_->StopAcceptingConnections(service_id);
|
||||
@@ -131,7 +131,7 @@ BleSocket BleMedium::Connect(BlePeripheral& peripheral,
|
||||
CancellationFlag* cancellation_flag) {
|
||||
{
|
||||
MutexLock lock(&mutex_);
|
||||
NEARBY_LOGS(INFO) << "BleMedium::Connect: peripheral="
|
||||
LOG(INFO) << "BleMedium::Connect: peripheral="
|
||||
<< peripheral.GetName()
|
||||
<< ",impl=" << &peripheral.GetImpl();
|
||||
}
|
||||
|
||||
@@ -78,7 +78,7 @@ TEST_P(BleMediumTest, CanStartAcceptingConnectionsAndConnect) {
|
||||
BlePeripheral& peripheral, const std::string& service_id,
|
||||
const ByteArray& advertisement_bytes,
|
||||
bool fast_advertisement) {
|
||||
NEARBY_LOGS(INFO)
|
||||
LOG(INFO)
|
||||
<< "Discovered peripheral=" << peripheral.GetName()
|
||||
<< ", impl=" << &peripheral.GetImpl()
|
||||
<< ", fast advertisement=" << fast_advertisement;
|
||||
@@ -90,7 +90,7 @@ TEST_P(BleMediumTest, CanStartAcceptingConnectionsAndConnect) {
|
||||
fast_advertisement_service_uuid);
|
||||
ble_b.StartAcceptingConnections(
|
||||
service_id, [&](BleSocket socket, const std::string& service_id) {
|
||||
NEARBY_LOGS(INFO) << "Connection accepted: socket=" << &socket
|
||||
LOG(INFO) << "Connection accepted: socket=" << &socket
|
||||
<< ", service_id=" << service_id;
|
||||
accepted_latch.CountDown();
|
||||
});
|
||||
@@ -136,7 +136,7 @@ TEST_P(BleMediumTest, CanCancelConnect) {
|
||||
BlePeripheral& peripheral, const std::string& service_id,
|
||||
const ByteArray& advertisement_bytes,
|
||||
bool fast_advertisement) {
|
||||
NEARBY_LOGS(INFO)
|
||||
LOG(INFO)
|
||||
<< "Discovered peripheral=" << peripheral.GetName()
|
||||
<< ", impl=" << &peripheral.GetImpl()
|
||||
<< ", fast advertisement=" << fast_advertisement;
|
||||
@@ -148,7 +148,7 @@ TEST_P(BleMediumTest, CanCancelConnect) {
|
||||
fast_advertisement_service_uuid);
|
||||
ble_b.StartAcceptingConnections(
|
||||
service_id, [&](BleSocket socket, const std::string& service_id) {
|
||||
NEARBY_LOGS(INFO) << "Connection accepted: socket=" << &socket
|
||||
LOG(INFO) << "Connection accepted: socket=" << &socket
|
||||
<< ", service_id=" << service_id;
|
||||
accepted_latch.CountDown();
|
||||
});
|
||||
|
||||
@@ -74,7 +74,7 @@ void BlockingQueueStream::Write(const ByteArray& bytes) {
|
||||
is_writing_ = true;
|
||||
blocking_queue_.Put(bytes);
|
||||
is_writing_ = false;
|
||||
NEARBY_VLOG(1) << "BlockingQueueStream wrote " << bytes.size() << " bytes";
|
||||
VLOG(1) << "BlockingQueueStream wrote " << bytes.size() << " bytes";
|
||||
}
|
||||
|
||||
Exception BlockingQueueStream::Close() {
|
||||
|
||||
@@ -83,13 +83,13 @@ class BluetoothSocket : public MediumSocket {
|
||||
// Returns Exception::kIo on error, Exception::kSuccess otherwise.
|
||||
Exception Close() override {
|
||||
if (IsVirtualSocket()) {
|
||||
NEARBY_LOGS(INFO) << "Multiplex: Closing virtual socket: " << this;
|
||||
LOG(INFO) << "Multiplex: Closing virtual socket: " << this;
|
||||
blocking_queue_input_stream_->Close();
|
||||
virtual_output_stream_->Close();
|
||||
CloseLocal();
|
||||
return {Exception::kSuccess};
|
||||
}
|
||||
NEARBY_LOGS(INFO) << "Multiplex: Closing physical socket: " << this;
|
||||
LOG(INFO) << "Multiplex: Closing physical socket: " << this;
|
||||
return impl_->Close();
|
||||
}
|
||||
|
||||
@@ -106,7 +106,7 @@ class BluetoothSocket : public MediumSocket {
|
||||
/** Feeds the received incoming data to the client. */
|
||||
void FeedIncomingData(ByteArray data) override {
|
||||
if (!IsVirtualSocket()) {
|
||||
NEARBY_LOGS(INFO) << "Feeding data on a physical socket is not allowed.";
|
||||
LOG(INFO) << "Feeding data on a physical socket is not allowed.";
|
||||
return;
|
||||
}
|
||||
blocking_queue_input_stream_->Write(data);
|
||||
@@ -170,7 +170,7 @@ class BluetoothServerSocket final {
|
||||
BluetoothSocket Accept() {
|
||||
auto socket = impl_->Accept();
|
||||
if (!socket) {
|
||||
NEARBY_LOGS(INFO) << "Accept() failed on server socket: " << this;
|
||||
LOG(INFO) << "Accept() failed on server socket: " << this;
|
||||
}
|
||||
return BluetoothSocket(std::move(socket));
|
||||
}
|
||||
@@ -179,7 +179,7 @@ class BluetoothServerSocket final {
|
||||
//
|
||||
// Returns Exception::kIo on error, Exception::kSuccess otherwise.
|
||||
Exception Close() {
|
||||
NEARBY_LOGS(INFO) << "Closing server socket: " << this;
|
||||
LOG(INFO) << "Closing server socket: " << this;
|
||||
return impl_->Close();
|
||||
}
|
||||
|
||||
|
||||
@@ -130,7 +130,7 @@ TEST_P(BluetoothClassicMediumTest, CanConnectToService) {
|
||||
bt_a_->StartDiscovery(DiscoveryCallback{
|
||||
.device_discovered_cb =
|
||||
[this, &found_latch, &discovered_device](BluetoothDevice& device) {
|
||||
NEARBY_LOGS(INFO) << "Device discovered: " << device.GetName();
|
||||
LOG(INFO) << "Device discovered: " << device.GetName();
|
||||
EXPECT_EQ(device.GetName(), adapter_b_->GetName());
|
||||
discovered_device = &device;
|
||||
found_latch.CountDown();
|
||||
@@ -179,7 +179,7 @@ TEST_P(BluetoothClassicMediumTest, CanCancelConnect) {
|
||||
bt_a_->StartDiscovery(DiscoveryCallback{
|
||||
.device_discovered_cb =
|
||||
[this, &found_latch, &discovered_device](BluetoothDevice& device) {
|
||||
NEARBY_LOGS(INFO) << "Device discovered: " << device.GetName();
|
||||
LOG(INFO) << "Device discovered: " << device.GetName();
|
||||
EXPECT_EQ(device.GetName(), adapter_b_->GetName());
|
||||
discovered_device = &device;
|
||||
found_latch.CountDown();
|
||||
@@ -235,7 +235,7 @@ TEST_F(BluetoothClassicMediumTest, SendData) {
|
||||
bt_a_->StartDiscovery(DiscoveryCallback{
|
||||
.device_discovered_cb =
|
||||
[this, &found_latch, &discovered_device](BluetoothDevice& device) {
|
||||
NEARBY_LOGS(INFO) << "Device discovered: " << device.GetName();
|
||||
LOG(INFO) << "Device discovered: " << device.GetName();
|
||||
EXPECT_EQ(device.GetName(), adapter_b_->GetName());
|
||||
discovered_device = &device;
|
||||
found_latch.CountDown();
|
||||
@@ -282,7 +282,7 @@ TEST_F(BluetoothClassicMediumTest, IoOnClosedSocketReturnsEmpty) {
|
||||
bt_a_->StartDiscovery(DiscoveryCallback{
|
||||
.device_discovered_cb =
|
||||
[this, &found_latch, &discovered_device](BluetoothDevice& device) {
|
||||
NEARBY_LOGS(INFO) << "Device discovered: " << device.GetName();
|
||||
LOG(INFO) << "Device discovered: " << device.GetName();
|
||||
EXPECT_EQ(device.GetName(), adapter_b_->GetName());
|
||||
discovered_device = &device;
|
||||
found_latch.CountDown();
|
||||
@@ -351,13 +351,13 @@ TEST_F(BluetoothClassicMediumTest, CanStartDiscovery) {
|
||||
bt_a_->StartDiscovery(DiscoveryCallback{
|
||||
.device_discovered_cb =
|
||||
[this, &found_latch](BluetoothDevice& device) {
|
||||
NEARBY_LOGS(INFO) << "Device discovered: " << device.GetName();
|
||||
LOG(INFO) << "Device discovered: " << device.GetName();
|
||||
EXPECT_EQ(device.GetName(), adapter_b_->GetName());
|
||||
found_latch.CountDown();
|
||||
},
|
||||
.device_lost_cb =
|
||||
[this, &lost_latch](BluetoothDevice& device) {
|
||||
NEARBY_LOGS(INFO) << "Device lost: " << device.GetName();
|
||||
LOG(INFO) << "Device lost: " << device.GetName();
|
||||
EXPECT_EQ(device.GetName(), adapter_b_->GetName());
|
||||
lost_latch.CountDown();
|
||||
},
|
||||
@@ -386,7 +386,7 @@ TEST_F(BluetoothClassicMediumTest, DiscoveryCallbackAfterStopDiscovery) {
|
||||
.device_discovered_cb =
|
||||
[this, &executor, &found_latch](BluetoothDevice& device) {
|
||||
executor.Execute([&]() {
|
||||
NEARBY_LOGS(INFO) << "Device discovered: " << device.GetName();
|
||||
LOG(INFO) << "Device discovered: " << device.GetName();
|
||||
absl::SleepFor(absl::Milliseconds(500));
|
||||
EXPECT_EQ(device.GetName(), adapter_b_->GetName());
|
||||
found_latch.CountDown();
|
||||
@@ -409,13 +409,13 @@ TEST_F(BluetoothClassicMediumTest, CanStopDiscovery) {
|
||||
bt_a_->StartDiscovery(DiscoveryCallback{
|
||||
.device_discovered_cb =
|
||||
[this, &found_latch](BluetoothDevice& device) {
|
||||
NEARBY_LOGS(INFO) << "Device discovered: " << device.GetName();
|
||||
LOG(INFO) << "Device discovered: " << device.GetName();
|
||||
EXPECT_EQ(device.GetName(), adapter_b_->GetName());
|
||||
found_latch.CountDown();
|
||||
},
|
||||
.device_lost_cb =
|
||||
[this, &lost_latch](BluetoothDevice& device) {
|
||||
NEARBY_LOGS(INFO) << "Device lost: " << device.GetName();
|
||||
LOG(INFO) << "Device lost: " << device.GetName();
|
||||
EXPECT_EQ(device.GetName(), adapter_b_->GetName());
|
||||
lost_latch.CountDown();
|
||||
},
|
||||
@@ -436,7 +436,7 @@ TEST_F(BluetoothClassicMediumTest, CanListenForService) {
|
||||
bt_a_->StartDiscovery(DiscoveryCallback{
|
||||
.device_discovered_cb =
|
||||
[this, &found_latch](BluetoothDevice& device) {
|
||||
NEARBY_LOGS(INFO) << "Device discovered: " << device.GetName();
|
||||
LOG(INFO) << "Device discovered: " << device.GetName();
|
||||
EXPECT_EQ(device.GetName(), adapter_b_->GetName());
|
||||
found_latch.CountDown();
|
||||
},
|
||||
@@ -465,7 +465,7 @@ TEST_F(BluetoothClassicMediumTest, BluetoothPairingSuccess) {
|
||||
CountDownLatch found_latch(1);
|
||||
bt_a_->StartDiscovery(
|
||||
DiscoveryCallback{.device_discovered_cb = [&](BluetoothDevice& device) {
|
||||
NEARBY_LOGS(INFO) << "Device discovered: " << device.GetName();
|
||||
LOG(INFO) << "Device discovered: " << device.GetName();
|
||||
EXPECT_EQ(device.GetName(), adapter_b_->GetName());
|
||||
discovered_device = &device;
|
||||
found_latch.CountDown();
|
||||
@@ -537,7 +537,7 @@ TEST_F(BluetoothClassicMediumTest, BluetoothPairingFailure) {
|
||||
CountDownLatch found_latch(1);
|
||||
bt_a_->StartDiscovery(
|
||||
DiscoveryCallback{.device_discovered_cb = [&](BluetoothDevice& device) {
|
||||
NEARBY_LOGS(INFO) << "Device discovered: " << device.GetName();
|
||||
LOG(INFO) << "Device discovered: " << device.GetName();
|
||||
EXPECT_EQ(device.GetName(), adapter_b_->GetName());
|
||||
discovered_device = &device;
|
||||
found_latch.CountDown();
|
||||
@@ -599,8 +599,8 @@ TEST_F(BluetoothClassicMediumTest, CancelBluetoothPairing) {
|
||||
CountDownLatch found_latch(1);
|
||||
bt_a_->StartDiscovery(
|
||||
DiscoveryCallback{.device_discovered_cb = [&](BluetoothDevice& device) {
|
||||
NEARBY_LOGS(INFO) << "Device discovered: " << device.GetName();
|
||||
NEARBY_LOGS(INFO) << "Device discovered address: "
|
||||
LOG(INFO) << "Device discovered: " << device.GetName();
|
||||
LOG(INFO) << "Device discovered address: "
|
||||
<< device.GetMacAddress();
|
||||
EXPECT_EQ(device.GetName(), adapter_b_->GetName());
|
||||
discovered_device = &device;
|
||||
|
||||
@@ -37,17 +37,17 @@ TEST(ConditionVariableTest, CanWakeupWaiter) {
|
||||
ConditionVariable cond{&mutex};
|
||||
bool done = false;
|
||||
bool waiting = false;
|
||||
NEARBY_LOGS(INFO) << "At start; done=" << done;
|
||||
LOG(INFO) << "At start; done=" << done;
|
||||
{
|
||||
SingleThreadExecutor executor;
|
||||
executor.Execute([&cond, &mutex, &done, &waiting]() {
|
||||
MutexLock lock(&mutex);
|
||||
NEARBY_LOGS(INFO) << "Before cond.Wait(); done=" << done;
|
||||
LOG(INFO) << "Before cond.Wait(); done=" << done;
|
||||
waiting = true;
|
||||
cond.Wait();
|
||||
waiting = false;
|
||||
done = true;
|
||||
NEARBY_LOGS(INFO) << "After cond.Wait(); done=" << done;
|
||||
LOG(INFO) << "After cond.Wait(); done=" << done;
|
||||
});
|
||||
while (true) {
|
||||
{
|
||||
@@ -62,7 +62,7 @@ TEST(ConditionVariableTest, CanWakeupWaiter) {
|
||||
EXPECT_FALSE(done);
|
||||
}
|
||||
}
|
||||
NEARBY_LOGS(INFO) << "After executor shutdown: done=" << done;
|
||||
LOG(INFO) << "After executor shutdown: done=" << done;
|
||||
EXPECT_TRUE(done);
|
||||
}
|
||||
|
||||
|
||||
@@ -52,7 +52,7 @@ void ErrorCodeRecorder::LogErrorCode(Medium medium, Event event, int error,
|
||||
Description description,
|
||||
const std::string& pii_message,
|
||||
const std::string& connection_token) {
|
||||
NEARBY_LOGS(INFO) << "ErrorCodeRecorder LogErrorCode";
|
||||
LOG(INFO) << "ErrorCodeRecorder LogErrorCode";
|
||||
ErrorCodeParams params = BuildErrorCodeParams(
|
||||
medium, event, error, description, pii_message, connection_token);
|
||||
listener_(params);
|
||||
|
||||
@@ -65,7 +65,7 @@ bool BleServerSocket::Connect(BleSocket& socket) {
|
||||
absl::MutexLock lock(&mutex_);
|
||||
if (closed_) return false;
|
||||
if (socket.IsConnected()) {
|
||||
NEARBY_LOGS(ERROR)
|
||||
LOG(ERROR)
|
||||
<< "Failed to connect to Ble server socket: already connected";
|
||||
return true; // already connected.
|
||||
}
|
||||
@@ -127,7 +127,7 @@ BleMedium::~BleMedium() {
|
||||
StopScanning(scanning_info_.service_id);
|
||||
|
||||
accept_loops_runner_.Shutdown();
|
||||
NEARBY_LOGS(INFO) << "BleMedium dtor advertising_accept_thread_running_ = "
|
||||
LOG(INFO) << "BleMedium dtor advertising_accept_thread_running_ = "
|
||||
<< acceptance_thread_running_.load();
|
||||
// If acceptance thread is still running, wait to finish.
|
||||
if (acceptance_thread_running_) {
|
||||
@@ -142,7 +142,7 @@ BleMedium::~BleMedium() {
|
||||
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
|
||||
LOG(INFO) << "G3 Ble StartAdvertising: service_id=" << service_id
|
||||
<< ", advertisement bytes="
|
||||
<< absl::BytesToHexString(std::string(advertisement_bytes))
|
||||
<< "(" << advertisement_bytes.size() << "),"
|
||||
@@ -176,11 +176,11 @@ bool BleMedium::StartAdvertising(
|
||||
}
|
||||
|
||||
bool BleMedium::StopAdvertising(const std::string& service_id) {
|
||||
NEARBY_LOGS(INFO) << "G3 Ble StopAdvertising: service_id=" << service_id;
|
||||
LOG(INFO) << "G3 Ble StopAdvertising: service_id=" << service_id;
|
||||
{
|
||||
absl::MutexLock lock(&mutex_);
|
||||
if (advertising_info_.Empty()) {
|
||||
NEARBY_LOGS(INFO) << "G3 Ble StopAdvertising: Can't stop advertising "
|
||||
LOG(INFO) << "G3 Ble StopAdvertising: Can't stop advertising "
|
||||
"because we never started advertising.";
|
||||
return false;
|
||||
}
|
||||
@@ -193,7 +193,7 @@ bool BleMedium::StopAdvertising(const std::string& service_id) {
|
||||
/*enabled=*/false);
|
||||
accept_loops_runner_.Shutdown();
|
||||
if (server_socket_ == nullptr) {
|
||||
NEARBY_LOGS(ERROR) << "G3 Ble StopAdvertising: Failed to find Ble Server "
|
||||
LOG(ERROR) << "G3 Ble StopAdvertising: Failed to find Ble Server "
|
||||
"socket: service_id="
|
||||
<< service_id;
|
||||
// Fall through for server socket not found.
|
||||
@@ -201,7 +201,7 @@ bool BleMedium::StopAdvertising(const std::string& service_id) {
|
||||
}
|
||||
|
||||
if (!server_socket_->Close().Ok()) {
|
||||
NEARBY_LOGS(INFO)
|
||||
LOG(INFO)
|
||||
<< "G3 Ble StopAdvertising: Failed to close Ble server socket for "
|
||||
<< service_id;
|
||||
return false;
|
||||
@@ -213,7 +213,7 @@ bool BleMedium::StartScanning(
|
||||
const std::string& service_id,
|
||||
const std::string& fast_advertisement_service_uuid,
|
||||
DiscoveredPeripheralCallback callback) {
|
||||
NEARBY_LOGS(INFO) << "G3 Ble StartScanning: service_id=" << service_id;
|
||||
LOG(INFO) << "G3 Ble StartScanning: service_id=" << service_id;
|
||||
auto& env = MediumEnvironment::Instance();
|
||||
env.UpdateBleMediumForScanning(*this, service_id,
|
||||
fast_advertisement_service_uuid,
|
||||
@@ -226,11 +226,11 @@ bool BleMedium::StartScanning(
|
||||
}
|
||||
|
||||
bool BleMedium::StopScanning(const std::string& service_id) {
|
||||
NEARBY_LOGS(INFO) << "G3 Ble StopScanning: service_id=" << service_id;
|
||||
LOG(INFO) << "G3 Ble StopScanning: service_id=" << service_id;
|
||||
{
|
||||
absl::MutexLock lock(&mutex_);
|
||||
if (scanning_info_.Empty()) {
|
||||
NEARBY_LOGS(INFO) << "G3 Ble StopDiscovery: Can't stop scanning because "
|
||||
LOG(INFO) << "G3 Ble StopDiscovery: Can't stop scanning because "
|
||||
"we never started scanning.";
|
||||
return false;
|
||||
}
|
||||
@@ -244,7 +244,7 @@ bool BleMedium::StopScanning(const std::string& service_id) {
|
||||
|
||||
bool BleMedium::StartAcceptingConnections(const std::string& service_id,
|
||||
AcceptedConnectionCallback callback) {
|
||||
NEARBY_LOGS(INFO) << "G3 Ble StartAcceptingConnections: service_id="
|
||||
LOG(INFO) << "G3 Ble StartAcceptingConnections: service_id="
|
||||
<< service_id;
|
||||
auto& env = MediumEnvironment::Instance();
|
||||
env.UpdateBleMediumForAcceptedConnection(*this, service_id,
|
||||
@@ -253,7 +253,7 @@ bool BleMedium::StartAcceptingConnections(const std::string& service_id,
|
||||
}
|
||||
|
||||
bool BleMedium::StopAcceptingConnections(const std::string& service_id) {
|
||||
NEARBY_LOGS(INFO) << "G3 Ble StopAcceptingConnections: service_id="
|
||||
LOG(INFO) << "G3 Ble StopAcceptingConnections: service_id="
|
||||
<< service_id;
|
||||
auto& env = MediumEnvironment::Instance();
|
||||
env.UpdateBleMediumForAcceptedConnection(*this, service_id, {});
|
||||
@@ -263,7 +263,7 @@ 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_LOGS(INFO) << "G3 Ble Connect [self]: medium=" << this
|
||||
LOG(INFO) << "G3 Ble Connect [self]: medium=" << this
|
||||
<< ", adapter=" << &GetAdapter()
|
||||
<< ", peripheral=" << &GetAdapter().GetPeripheral()
|
||||
<< ", service_id=" << service_id;
|
||||
@@ -274,7 +274,7 @@ std::unique_ptr<api::BleSocket> BleMedium::Connect(
|
||||
if (!medium) return {}; // Can't find medium. Bail out.
|
||||
|
||||
BleServerSocket* remote_server_socket = nullptr;
|
||||
NEARBY_LOGS(INFO) << "G3 Ble Connect [peer]: medium=" << medium
|
||||
LOG(INFO) << "G3 Ble Connect [peer]: medium=" << medium
|
||||
<< ", adapter=" << &adapter
|
||||
<< ", peripheral=" << &remote_peripheral
|
||||
<< ", service_id=" << service_id;
|
||||
@@ -283,7 +283,7 @@ std::unique_ptr<api::BleSocket> BleMedium::Connect(
|
||||
absl::MutexLock medium_lock(&medium->mutex_);
|
||||
remote_server_socket = medium->server_socket_.get();
|
||||
if (remote_server_socket == nullptr) {
|
||||
NEARBY_LOGS(ERROR)
|
||||
LOG(ERROR)
|
||||
<< "G3 Ble Connect: Failed to find Ble Server socket: service_id="
|
||||
<< service_id;
|
||||
return {};
|
||||
@@ -291,14 +291,14 @@ std::unique_ptr<api::BleSocket> BleMedium::Connect(
|
||||
}
|
||||
|
||||
if (cancellation_flag->Cancelled()) {
|
||||
NEARBY_LOGS(ERROR) << "G3 BLE Connect: Has been cancelled: "
|
||||
LOG(ERROR) << "G3 BLE Connect: Has been cancelled: "
|
||||
"service_id="
|
||||
<< service_id;
|
||||
return {};
|
||||
}
|
||||
|
||||
CancellationFlagListener listener(cancellation_flag, [this]() {
|
||||
NEARBY_LOGS(INFO) << "G3 BLE Cancel Connect.";
|
||||
LOG(INFO) << "G3 BLE Cancel Connect.";
|
||||
if (server_socket_ != nullptr) server_socket_->Close();
|
||||
});
|
||||
|
||||
@@ -306,13 +306,13 @@ std::unique_ptr<api::BleSocket> BleMedium::Connect(
|
||||
auto socket = std::make_unique<BleSocket>(&peripheral);
|
||||
// Finally, Request to connect to this socket.
|
||||
if (!remote_server_socket->Connect(*socket)) {
|
||||
NEARBY_LOGS(ERROR) << "G3 Ble Connect: Failed to connect to existing Ble "
|
||||
LOG(ERROR) << "G3 Ble Connect: Failed to connect to existing Ble "
|
||||
"Server socket: service_id="
|
||||
<< service_id;
|
||||
return {};
|
||||
}
|
||||
|
||||
NEARBY_LOGS(INFO) << "G3 Ble Connect: connected: socket=" << socket.get();
|
||||
LOG(INFO) << "G3 Ble Connect: connected: socket=" << socket.get();
|
||||
return socket;
|
||||
}
|
||||
|
||||
|
||||
@@ -65,7 +65,7 @@ bool BluetoothServerSocket::Connect(BluetoothSocket& socket) {
|
||||
absl::MutexLock lock(&mutex_);
|
||||
if (closed_) return false;
|
||||
if (socket.IsConnected()) {
|
||||
NEARBY_LOGS(ERROR)
|
||||
LOG(ERROR)
|
||||
<< "Failed to connect to BT server socket: already connected";
|
||||
return true; // already connected.
|
||||
}
|
||||
@@ -171,7 +171,7 @@ bool BluetoothClassicMedium::StopDiscovery() {
|
||||
std::unique_ptr<api::BluetoothSocket> BluetoothClassicMedium::ConnectToService(
|
||||
api::BluetoothDevice& remote_device, const std::string& service_uuid,
|
||||
CancellationFlag* cancellation_flag) {
|
||||
NEARBY_LOGS(INFO) << "G3 ConnectToService [self]: medium=" << this
|
||||
LOG(INFO) << "G3 ConnectToService [self]: medium=" << this
|
||||
<< ", adapter=" << &GetAdapter()
|
||||
<< ", device=" << &GetAdapter().GetDevice();
|
||||
// First, find an instance of remote medium, that exposed this device.
|
||||
@@ -182,7 +182,7 @@ std::unique_ptr<api::BluetoothSocket> BluetoothClassicMedium::ConnectToService(
|
||||
if (!medium) return {}; // Adapter is not bound to medium. Bail out.
|
||||
|
||||
BluetoothServerSocket* server_socket = nullptr;
|
||||
NEARBY_LOGS(INFO) << "G3 ConnectToService [peer]: medium=" << medium
|
||||
LOG(INFO) << "G3 ConnectToService [peer]: medium=" << medium
|
||||
<< ", adapter=" << &adapter << ", device=" << &remote_device
|
||||
<< ", uuid=" << service_uuid.c_str();
|
||||
// Then, find our server socket context in this medium.
|
||||
@@ -191,35 +191,35 @@ std::unique_ptr<api::BluetoothSocket> BluetoothClassicMedium::ConnectToService(
|
||||
auto item = medium->sockets_.find(service_uuid);
|
||||
server_socket = item != medium->sockets_.end() ? item->second : nullptr;
|
||||
if (server_socket == nullptr) {
|
||||
NEARBY_LOGS(ERROR) << "Failed to find BT Server socket: uuid="
|
||||
LOG(ERROR) << "Failed to find BT Server socket: uuid="
|
||||
<< service_uuid;
|
||||
return {};
|
||||
}
|
||||
}
|
||||
|
||||
if (cancellation_flag->Cancelled()) {
|
||||
NEARBY_LOGS(ERROR) << "G3 Bluetooth Connect: Has been cancelled: "
|
||||
LOG(ERROR) << "G3 Bluetooth Connect: Has been cancelled: "
|
||||
"service_uuid="
|
||||
<< service_uuid;
|
||||
return {};
|
||||
}
|
||||
|
||||
CancellationFlagListener listener(cancellation_flag, [&server_socket]() {
|
||||
NEARBY_LOGS(INFO) << "G3 Bluetooth Cancel Connect.";
|
||||
LOG(INFO) << "G3 Bluetooth Cancel Connect.";
|
||||
if (server_socket != nullptr) server_socket->Close();
|
||||
});
|
||||
|
||||
auto socket = std::make_unique<BluetoothSocket>(&GetAdapter());
|
||||
// Finally, Request to connect to this socket.
|
||||
if (!server_socket->Connect(*socket)) {
|
||||
NEARBY_LOGS(ERROR)
|
||||
LOG(ERROR)
|
||||
<< "Failed to connect to existing BT Server socket: uuid="
|
||||
<< service_uuid;
|
||||
return {};
|
||||
}
|
||||
|
||||
if (cancellation_flag->Cancelled()) {
|
||||
NEARBY_LOGS(ERROR)
|
||||
LOG(ERROR)
|
||||
<< "G3 Bluetooth Connect: Has been cancelled after connected: "
|
||||
"service_uuid="
|
||||
<< service_uuid;
|
||||
@@ -227,7 +227,7 @@ std::unique_ptr<api::BluetoothSocket> BluetoothClassicMedium::ConnectToService(
|
||||
return {};
|
||||
}
|
||||
|
||||
NEARBY_LOGS(INFO) << "G3 ConnectToService: connected: socket="
|
||||
LOG(INFO) << "G3 ConnectToService: connected: socket="
|
||||
<< socket.get();
|
||||
return socket;
|
||||
}
|
||||
@@ -240,7 +240,7 @@ BluetoothClassicMedium::ListenForService(const std::string& service_name,
|
||||
absl::MutexLock lock(&mutex_);
|
||||
sockets_.erase(uuid);
|
||||
});
|
||||
NEARBY_LOGS(INFO) << "Adding service: medium=" << this
|
||||
LOG(INFO) << "Adding service: medium=" << this
|
||||
<< ", uuid=" << service_uuid;
|
||||
absl::MutexLock lock(&mutex_);
|
||||
sockets_.emplace(service_uuid, socket.get());
|
||||
|
||||
@@ -63,11 +63,11 @@ void CredentialStorageImpl::SaveCredentials(
|
||||
return;
|
||||
}
|
||||
if (private_credentials.empty()) {
|
||||
NEARBY_LOGS(INFO) << "There are no Private Credentials for account: ["
|
||||
LOG(INFO) << "There are no Private Credentials for account: ["
|
||||
<< account_name << "], manager app ID:[" << manager_app_id
|
||||
<< "]";
|
||||
} else {
|
||||
NEARBY_LOGS(INFO) << "G3 Save Private Credentials for account: ["
|
||||
LOG(INFO) << "G3 Save Private Credentials for account: ["
|
||||
<< account_name << "], manager app ID:[" << manager_app_id
|
||||
<< "]";
|
||||
SaveLocalCredentialsLocked(manager_app_id, account_name,
|
||||
@@ -75,11 +75,11 @@ void CredentialStorageImpl::SaveCredentials(
|
||||
}
|
||||
|
||||
if (public_credentials.empty()) {
|
||||
NEARBY_LOGS(INFO) << "There are no Public Credentials for account: ["
|
||||
LOG(INFO) << "There are no Public Credentials for account: ["
|
||||
<< account_name << "], manager app ID:[" << manager_app_id
|
||||
<< "]";
|
||||
} else {
|
||||
NEARBY_LOGS(INFO) << "G3 Save Public Credentials for account: ["
|
||||
LOG(INFO) << "G3 Save Public Credentials for account: ["
|
||||
<< account_name << "], manager app ID:[" << manager_app_id
|
||||
<< "]";
|
||||
PublicCredentialKey key = CreatePublicCredentialKey(
|
||||
@@ -87,7 +87,7 @@ void CredentialStorageImpl::SaveCredentials(
|
||||
auto public_result =
|
||||
public_credentials_map_.insert(std::make_pair(key, public_credentials));
|
||||
if (!public_result.second) {
|
||||
NEARBY_LOGS(WARNING)
|
||||
LOG(WARNING)
|
||||
<< "Credentials already saved in map. Overwriting previous creds!";
|
||||
public_credentials_map_[key] = public_credentials;
|
||||
}
|
||||
@@ -102,7 +102,7 @@ void CredentialStorageImpl::SaveLocalCredentialsLocked(
|
||||
auto private_result =
|
||||
private_credentials_map_.insert(std::make_pair(key, private_credentials));
|
||||
if (!private_result.second) {
|
||||
NEARBY_LOGS(WARNING)
|
||||
LOG(WARNING)
|
||||
<< "Credentials already saved in map. Overwriting previous creds!";
|
||||
private_credentials_map_[key] = private_credentials;
|
||||
}
|
||||
@@ -111,7 +111,7 @@ void CredentialStorageImpl::SaveLocalCredentialsLocked(
|
||||
void CredentialStorageImpl::UpdateLocalCredential(
|
||||
absl::string_view manager_app_id, absl::string_view account_name,
|
||||
LocalCredential credential, SaveCredentialsResultCallback callback) {
|
||||
NEARBY_LOGS(INFO) << "G3 Update Private Credential for for account: ["
|
||||
LOG(INFO) << "G3 Update Private Credential for for account: ["
|
||||
<< account_name << "], manager app ID:[" << manager_app_id
|
||||
<< "]";
|
||||
absl::StatusOr<std::vector<LocalCredential>> credentials =
|
||||
@@ -120,7 +120,7 @@ void CredentialStorageImpl::UpdateLocalCredential(
|
||||
.account_name = std::string(account_name),
|
||||
.identity_type = IdentityType::IDENTITY_TYPE_UNSPECIFIED});
|
||||
if (!credentials.ok()) {
|
||||
NEARBY_LOGS(WARNING) << credentials.status();
|
||||
LOG(WARNING) << credentials.status();
|
||||
credentials = std::vector<LocalCredential>();
|
||||
}
|
||||
auto it = std::find_if(
|
||||
@@ -138,7 +138,7 @@ void CredentialStorageImpl::UpdateLocalCredential(
|
||||
void CredentialStorageImpl::GetLocalCredentials(
|
||||
const CredentialSelector& credential_selector,
|
||||
GetLocalCredentialsResultCallback callback) {
|
||||
NEARBY_LOGS(INFO) << "G3 Get Private Credentials for " << credential_selector;
|
||||
LOG(INFO) << "G3 Get Private Credentials for " << credential_selector;
|
||||
std::move(callback.credentials_fetched_cb)(
|
||||
GetLocalCredentialsLocked(credential_selector));
|
||||
}
|
||||
@@ -149,7 +149,7 @@ CredentialStorageImpl::GetLocalCredentialsLocked(
|
||||
LocalCredentialKey key = CreateLocalCredentialKey(
|
||||
credential_selector.manager_app_id, credential_selector.account_name);
|
||||
if (private_credentials_map_.find(key) == private_credentials_map_.end()) {
|
||||
NEARBY_LOGS(WARNING) << "There are no Private Credentials stored for key:"
|
||||
LOG(WARNING) << "There are no Private Credentials stored for key:"
|
||||
<< std::get<0>(key) << ", " << std::get<1>(key);
|
||||
return absl::NotFoundError(
|
||||
absl::StrFormat("No private credentials for %v", credential_selector));
|
||||
@@ -168,12 +168,12 @@ void CredentialStorageImpl::GetPublicCredentials(
|
||||
const CredentialSelector& credential_selector,
|
||||
PublicCredentialType public_credential_type,
|
||||
GetPublicCredentialsResultCallback callback) {
|
||||
NEARBY_LOGS(INFO) << "G3 Get Public Credentials for " << credential_selector;
|
||||
LOG(INFO) << "G3 Get Public Credentials for " << credential_selector;
|
||||
PublicCredentialKey key = CreatePublicCredentialKey(
|
||||
credential_selector.manager_app_id, credential_selector.account_name,
|
||||
public_credential_type);
|
||||
if (public_credentials_map_.find(key) == public_credentials_map_.end()) {
|
||||
NEARBY_LOGS(WARNING) << "There are no Public Credentials stored for key:"
|
||||
LOG(WARNING) << "There are no Public Credentials stored for key:"
|
||||
<< std::get<0>(key) << ", " << std::get<1>(key) << ", "
|
||||
<< std::get<2>(key);
|
||||
std::move(callback.credentials_fetched_cb)(absl::NotFoundError(
|
||||
|
||||
@@ -183,7 +183,7 @@ void PreferencesManager::Remove(absl::string_view key) {
|
||||
// Writes data to storage.
|
||||
bool PreferencesManager::Commit() {
|
||||
if (!preferences_repository_->SavePreferences(value_)) {
|
||||
NEARBY_LOGS(ERROR) << "Failed to save preference." << std::endl;
|
||||
LOG(ERROR) << "Failed to save preference." << std::endl;
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
|
||||
@@ -63,7 +63,7 @@ bool WifiDirectServerSocket::Connect(WifiDirectSocket& socket) {
|
||||
absl::MutexLock lock(&mutex_);
|
||||
if (closed_) return false;
|
||||
if (socket.IsConnected()) {
|
||||
NEARBY_LOGS(ERROR)
|
||||
LOG(ERROR)
|
||||
<< "Failed to connect to WifiDirect server socket: already connected";
|
||||
return true; // already connected.
|
||||
}
|
||||
@@ -130,7 +130,7 @@ bool WifiDirectMedium::StartWifiDirect(
|
||||
std::string password = absl::StrFormat("%08x", Prng().NextUint32());
|
||||
wifi_direct_credentials->SetPassword(password);
|
||||
|
||||
NEARBY_LOGS(INFO) << "G3 StartWifiDirect GO: ssid=" << ssid
|
||||
LOG(INFO) << "G3 StartWifiDirect GO: ssid=" << ssid
|
||||
<< ", password:" << password;
|
||||
|
||||
auto& env = MediumEnvironment::Instance();
|
||||
@@ -142,7 +142,7 @@ bool WifiDirectMedium::StartWifiDirect(
|
||||
|
||||
bool WifiDirectMedium::StopWifiDirect() {
|
||||
absl::MutexLock lock(&mutex_);
|
||||
NEARBY_LOGS(INFO) << "G3 StopWifiDirect GO";
|
||||
LOG(INFO) << "G3 StopWifiDirect GO";
|
||||
|
||||
auto& env = MediumEnvironment::Instance();
|
||||
env.UpdateWifiDirectMediumForStartOrConnect(*this, /*credentials*/ nullptr,
|
||||
@@ -155,7 +155,7 @@ bool WifiDirectMedium::ConnectWifiDirect(
|
||||
WifiDirectCredentials* wifi_direct_credentials) {
|
||||
absl::MutexLock lock(&mutex_);
|
||||
|
||||
NEARBY_LOGS(INFO) << "G3 ConnectWifiDirect : ssid="
|
||||
LOG(INFO) << "G3 ConnectWifiDirect : ssid="
|
||||
<< wifi_direct_credentials->GetSSID()
|
||||
<< ", password:" << wifi_direct_credentials->GetPassword();
|
||||
|
||||
@@ -178,7 +178,7 @@ bool WifiDirectMedium::ConnectWifiDirect(
|
||||
bool WifiDirectMedium::DisconnectWifiDirect() {
|
||||
absl::MutexLock lock(&mutex_);
|
||||
|
||||
NEARBY_LOGS(INFO) << "G3 DisconnectWifiDirect";
|
||||
LOG(INFO) << "G3 DisconnectWifiDirect";
|
||||
|
||||
auto& env = MediumEnvironment::Instance();
|
||||
env.UpdateWifiDirectMediumForStartOrConnect(*this, /*credentials*/ nullptr,
|
||||
@@ -191,7 +191,7 @@ std::unique_ptr<api::WifiDirectSocket> WifiDirectMedium::ConnectToService(
|
||||
absl::string_view ip_address, int port,
|
||||
CancellationFlag* cancellation_flag) {
|
||||
std::string socket_name = WifiDirectServerSocket::GetName(ip_address, port);
|
||||
NEARBY_LOGS(INFO) << "G3 WifiDirect ConnectToService [self]: medium=" << this
|
||||
LOG(INFO) << "G3 WifiDirect ConnectToService [self]: medium=" << this
|
||||
<< ", ip address + port=" << socket_name;
|
||||
// First, find an instance of remote medium, that exposed this service.
|
||||
auto& env = MediumEnvironment::Instance();
|
||||
@@ -202,7 +202,7 @@ std::unique_ptr<api::WifiDirectSocket> WifiDirectMedium::ConnectToService(
|
||||
}
|
||||
|
||||
WifiDirectServerSocket* server_socket = nullptr;
|
||||
NEARBY_LOGS(INFO) << "G3 WifiDirect ConnectToService [peer]: medium="
|
||||
LOG(INFO) << "G3 WifiDirect ConnectToService [peer]: medium="
|
||||
<< remote_medium
|
||||
<< ", remote ip address + port=" << socket_name;
|
||||
// Then, find our server socket context in this medium.
|
||||
@@ -212,7 +212,7 @@ std::unique_ptr<api::WifiDirectSocket> WifiDirectMedium::ConnectToService(
|
||||
server_socket =
|
||||
item != remote_medium->server_sockets_.end() ? item->second : nullptr;
|
||||
if (server_socket == nullptr) {
|
||||
NEARBY_LOGS(ERROR) << "G3 WifiDirect Failed to find WifiDirect Server "
|
||||
LOG(ERROR) << "G3 WifiDirect Failed to find WifiDirect Server "
|
||||
"socket: socket_name="
|
||||
<< socket_name;
|
||||
return nullptr;
|
||||
@@ -220,7 +220,7 @@ std::unique_ptr<api::WifiDirectSocket> WifiDirectMedium::ConnectToService(
|
||||
}
|
||||
|
||||
if (cancellation_flag->Cancelled()) {
|
||||
NEARBY_LOGS(ERROR)
|
||||
LOG(ERROR)
|
||||
<< "G3 WifiDirect Connect: Has been cancelled: socket_name="
|
||||
<< socket_name;
|
||||
return nullptr;
|
||||
@@ -230,7 +230,7 @@ std::unique_ptr<api::WifiDirectSocket> WifiDirectMedium::ConnectToService(
|
||||
// Finally, Request to connect to this socket.
|
||||
|
||||
server_socket->Connect(*socket);
|
||||
NEARBY_LOGS(INFO) << "G3 WifiDirect GC ConnectToService: connected: socket="
|
||||
LOG(INFO) << "G3 WifiDirect GC ConnectToService: connected: socket="
|
||||
<< socket.get();
|
||||
return socket;
|
||||
}
|
||||
@@ -256,7 +256,7 @@ std::unique_ptr<api::WifiDirectServerSocket> WifiDirectMedium::ListenForService(
|
||||
absl::MutexLock lock(&mutex_);
|
||||
server_sockets_.erase(socket_name);
|
||||
});
|
||||
NEARBY_LOGS(INFO) << "G3 WifiDirect GO Adding server socket: medium=" << this
|
||||
LOG(INFO) << "G3 WifiDirect GO Adding server socket: medium=" << this
|
||||
<< ", socket_name=" << socket_name;
|
||||
absl::MutexLock lock(&mutex_);
|
||||
server_sockets_.insert({socket_name, server_socket.get()});
|
||||
|
||||
@@ -64,7 +64,7 @@ bool WifiHotspotServerSocket::Connect(WifiHotspotSocket& socket) {
|
||||
absl::MutexLock lock(&mutex_);
|
||||
if (closed_) return false;
|
||||
if (socket.IsConnected()) {
|
||||
NEARBY_LOGS(ERROR)
|
||||
LOG(ERROR)
|
||||
<< "Failed to connect to WifiHotspot server socket: already connected";
|
||||
return true; // already connected.
|
||||
}
|
||||
@@ -133,7 +133,7 @@ bool WifiHotspotMedium::StartWifiHotspot(
|
||||
std::string password = absl::StrFormat("%08x", Prng().NextUint32());
|
||||
hotspot_credentials->SetPassword(password);
|
||||
|
||||
NEARBY_LOGS(INFO) << "G3 StartWifiHotspot: ssid=" << ssid
|
||||
LOG(INFO) << "G3 StartWifiHotspot: ssid=" << ssid
|
||||
<< ", password:" << password;
|
||||
|
||||
auto& env = MediumEnvironment::Instance();
|
||||
@@ -146,7 +146,7 @@ bool WifiHotspotMedium::StartWifiHotspot(
|
||||
|
||||
bool WifiHotspotMedium::StopWifiHotspot() {
|
||||
absl::MutexLock lock(&mutex_);
|
||||
NEARBY_LOGS(INFO) << "G3 StopWifiHotspot";
|
||||
LOG(INFO) << "G3 StopWifiHotspot";
|
||||
|
||||
if (!IsInterfaceValid()) return false;
|
||||
|
||||
@@ -161,7 +161,7 @@ bool WifiHotspotMedium::ConnectWifiHotspot(
|
||||
HotspotCredentials* hotspot_credentials) {
|
||||
absl::MutexLock lock(&mutex_);
|
||||
|
||||
NEARBY_LOGS(INFO) << "G3 ConnectWifiHotspot: ssid="
|
||||
LOG(INFO) << "G3 ConnectWifiHotspot: ssid="
|
||||
<< hotspot_credentials->GetSSID()
|
||||
<< ", password:" << hotspot_credentials->GetPassword();
|
||||
|
||||
@@ -184,7 +184,7 @@ bool WifiHotspotMedium::ConnectWifiHotspot(
|
||||
bool WifiHotspotMedium::DisconnectWifiHotspot() {
|
||||
absl::MutexLock lock(&mutex_);
|
||||
|
||||
NEARBY_LOGS(INFO) << "G3 DisconnectWifiHotspot";
|
||||
LOG(INFO) << "G3 DisconnectWifiHotspot";
|
||||
|
||||
auto& env = MediumEnvironment::Instance();
|
||||
env.UpdateWifiHotspotMediumForStartOrConnect(*this, /*credentials*/ nullptr,
|
||||
@@ -197,7 +197,7 @@ std::unique_ptr<api::WifiHotspotSocket> WifiHotspotMedium::ConnectToService(
|
||||
absl::string_view ip_address, int port,
|
||||
CancellationFlag* cancellation_flag) {
|
||||
std::string socket_name = WifiHotspotServerSocket::GetName(ip_address, port);
|
||||
NEARBY_LOGS(INFO) << "G3 WifiHotspot ConnectToService [self]: medium=" << this
|
||||
LOG(INFO) << "G3 WifiHotspot ConnectToService [self]: medium=" << this
|
||||
<< ", ip address + port=" << socket_name;
|
||||
// First, find an instance of remote medium, that exposed this service.
|
||||
auto& env = MediumEnvironment::Instance();
|
||||
@@ -208,7 +208,7 @@ std::unique_ptr<api::WifiHotspotSocket> WifiHotspotMedium::ConnectToService(
|
||||
}
|
||||
|
||||
WifiHotspotServerSocket* server_socket = nullptr;
|
||||
NEARBY_LOGS(INFO) << "G3 WifiHotspot ConnectToService [peer]: medium="
|
||||
LOG(INFO) << "G3 WifiHotspot ConnectToService [peer]: medium="
|
||||
<< remote_medium
|
||||
<< ", remote ip address + port=" << socket_name;
|
||||
// Then, find our server socket context in this medium.
|
||||
@@ -218,7 +218,7 @@ std::unique_ptr<api::WifiHotspotSocket> WifiHotspotMedium::ConnectToService(
|
||||
server_socket =
|
||||
item != remote_medium->server_sockets_.end() ? item->second : nullptr;
|
||||
if (server_socket == nullptr) {
|
||||
NEARBY_LOGS(ERROR) << "G3 WifiHotspot Failed to find WifiHotspot Server "
|
||||
LOG(ERROR) << "G3 WifiHotspot Failed to find WifiHotspot Server "
|
||||
"socket: socket_name="
|
||||
<< socket_name;
|
||||
return {};
|
||||
@@ -226,14 +226,14 @@ std::unique_ptr<api::WifiHotspotSocket> WifiHotspotMedium::ConnectToService(
|
||||
}
|
||||
|
||||
if (cancellation_flag->Cancelled()) {
|
||||
NEARBY_LOGS(ERROR)
|
||||
LOG(ERROR)
|
||||
<< "G3 WifiHotspot Connect: Has been cancelled: socket_name="
|
||||
<< socket_name;
|
||||
return {};
|
||||
}
|
||||
|
||||
CancellationFlagListener listener(cancellation_flag, [&server_socket]() {
|
||||
NEARBY_LOGS(INFO) << "G3 WifiHotspot Cancel Connect.";
|
||||
LOG(INFO) << "G3 WifiHotspot Cancel Connect.";
|
||||
if (server_socket != nullptr) {
|
||||
server_socket->Close();
|
||||
}
|
||||
@@ -242,13 +242,13 @@ std::unique_ptr<api::WifiHotspotSocket> WifiHotspotMedium::ConnectToService(
|
||||
auto socket = std::make_unique<WifiHotspotSocket>();
|
||||
// Finally, Request to connect to this socket.
|
||||
if (!server_socket->Connect(*socket)) {
|
||||
NEARBY_LOGS(ERROR)
|
||||
LOG(ERROR)
|
||||
<< "G3 WifiHotspot Failed to connect to existing WifiHotspot "
|
||||
"Server socket: name="
|
||||
<< socket_name;
|
||||
return {};
|
||||
}
|
||||
NEARBY_LOGS(INFO) << "G3 WifiHotspot ConnectToService: connected: socket="
|
||||
LOG(INFO) << "G3 WifiHotspot ConnectToService: connected: socket="
|
||||
<< socket.get();
|
||||
return socket;
|
||||
}
|
||||
@@ -275,7 +275,7 @@ WifiHotspotMedium::ListenForService(int port) {
|
||||
absl::MutexLock lock(&mutex_);
|
||||
server_sockets_.erase(socket_name);
|
||||
});
|
||||
NEARBY_LOGS(INFO) << "G3 WifiHotspot Adding server socket: medium=" << this
|
||||
LOG(INFO) << "G3 WifiHotspot Adding server socket: medium=" << this
|
||||
<< ", socket_name=" << socket_name;
|
||||
absl::MutexLock lock(&mutex_);
|
||||
server_sockets_.insert({socket_name, server_socket.get()});
|
||||
|
||||
@@ -70,7 +70,7 @@ bool WifiLanServerSocket::Connect(WifiLanSocket& socket) {
|
||||
absl::MutexLock lock(&mutex_);
|
||||
if (closed_) return false;
|
||||
if (socket.IsConnected()) {
|
||||
NEARBY_LOGS(ERROR)
|
||||
LOG(ERROR)
|
||||
<< "Failed to connect to WifiLan server socket: already connected";
|
||||
return true; // already connected.
|
||||
}
|
||||
@@ -129,14 +129,14 @@ WifiLanMedium::~WifiLanMedium() {
|
||||
|
||||
bool WifiLanMedium::StartAdvertising(const NsdServiceInfo& nsd_service_info) {
|
||||
std::string service_type = nsd_service_info.GetServiceType();
|
||||
NEARBY_LOGS(INFO) << "G3 WifiLan StartAdvertising: nsd_service_info="
|
||||
LOG(INFO) << "G3 WifiLan StartAdvertising: nsd_service_info="
|
||||
<< &nsd_service_info
|
||||
<< ", service_name=" << nsd_service_info.GetServiceName()
|
||||
<< ", service_type=" << service_type;
|
||||
{
|
||||
absl::MutexLock lock(&mutex_);
|
||||
if (advertising_info_.Existed(service_type)) {
|
||||
NEARBY_LOGS(INFO)
|
||||
LOG(INFO)
|
||||
<< "G3 WifiLan StartAdvertising: Can't start advertising because "
|
||||
"service_type="
|
||||
<< service_type << ", has started already.";
|
||||
@@ -155,14 +155,14 @@ bool WifiLanMedium::StartAdvertising(const NsdServiceInfo& nsd_service_info) {
|
||||
|
||||
bool WifiLanMedium::StopAdvertising(const NsdServiceInfo& nsd_service_info) {
|
||||
std::string service_type = nsd_service_info.GetServiceType();
|
||||
NEARBY_LOGS(INFO) << "G3 WifiLan StopAdvertising: nsd_service_info="
|
||||
LOG(INFO) << "G3 WifiLan StopAdvertising: nsd_service_info="
|
||||
<< &nsd_service_info
|
||||
<< ", service_name=" << nsd_service_info.GetServiceName()
|
||||
<< ", service_type=" << service_type;
|
||||
{
|
||||
absl::MutexLock lock(&mutex_);
|
||||
if (!advertising_info_.Existed(service_type)) {
|
||||
NEARBY_LOGS(INFO)
|
||||
LOG(INFO)
|
||||
<< "G3 WifiLan StopAdvertising: Can't stop advertising because "
|
||||
"we never started advertising for service_type="
|
||||
<< service_type;
|
||||
@@ -178,12 +178,12 @@ bool WifiLanMedium::StopAdvertising(const NsdServiceInfo& nsd_service_info) {
|
||||
|
||||
bool WifiLanMedium::StartDiscovery(const std::string& service_type,
|
||||
DiscoveredServiceCallback callback) {
|
||||
NEARBY_LOGS(INFO) << "G3 WifiLan StartDiscovery: service_type="
|
||||
LOG(INFO) << "G3 WifiLan StartDiscovery: service_type="
|
||||
<< service_type;
|
||||
{
|
||||
absl::MutexLock lock(&mutex_);
|
||||
if (discovering_info_.Existed(service_type)) {
|
||||
NEARBY_LOGS(INFO)
|
||||
LOG(INFO)
|
||||
<< "G3 WifiLan StartDiscovery: Can't start discovery because "
|
||||
"service_type="
|
||||
<< service_type << " has started already.";
|
||||
@@ -201,12 +201,12 @@ bool WifiLanMedium::StartDiscovery(const std::string& service_type,
|
||||
}
|
||||
|
||||
bool WifiLanMedium::StopDiscovery(const std::string& service_type) {
|
||||
NEARBY_LOGS(INFO) << "G3 WifiLan StopDiscovery: service_type="
|
||||
LOG(INFO) << "G3 WifiLan StopDiscovery: service_type="
|
||||
<< service_type;
|
||||
{
|
||||
absl::MutexLock lock(&mutex_);
|
||||
if (!discovering_info_.Existed(service_type)) {
|
||||
NEARBY_LOGS(INFO)
|
||||
LOG(INFO)
|
||||
<< "G3 WifiLan StopDiscovery: Can't stop discovering because we "
|
||||
"never started discovering.";
|
||||
return false;
|
||||
@@ -222,7 +222,7 @@ std::unique_ptr<api::WifiLanSocket> WifiLanMedium::ConnectToService(
|
||||
const NsdServiceInfo& remote_service_info,
|
||||
CancellationFlag* cancellation_flag) {
|
||||
std::string service_type = remote_service_info.GetServiceType();
|
||||
NEARBY_LOGS(INFO) << "G3 WifiLan ConnectToService [self]: medium=" << this
|
||||
LOG(INFO) << "G3 WifiLan ConnectToService [self]: medium=" << this
|
||||
<< ", service_type=" << service_type;
|
||||
return ConnectToService(remote_service_info.GetIPAddress(),
|
||||
remote_service_info.GetPort(), cancellation_flag);
|
||||
@@ -232,7 +232,7 @@ std::unique_ptr<api::WifiLanSocket> WifiLanMedium::ConnectToService(
|
||||
const std::string& ip_address, int port,
|
||||
CancellationFlag* cancellation_flag) {
|
||||
std::string socket_name = WifiLanServerSocket::GetName(ip_address, port);
|
||||
NEARBY_LOGS(INFO) << "G3 WifiLan ConnectToService [self]: medium=" << this
|
||||
LOG(INFO) << "G3 WifiLan ConnectToService [self]: medium=" << this
|
||||
<< ", ip address + port=" << socket_name;
|
||||
// First, find an instance of remote medium, that exposed this service.
|
||||
auto& env = MediumEnvironment::Instance();
|
||||
@@ -243,7 +243,7 @@ std::unique_ptr<api::WifiLanSocket> WifiLanMedium::ConnectToService(
|
||||
}
|
||||
|
||||
WifiLanServerSocket* server_socket = nullptr;
|
||||
NEARBY_LOGS(INFO) << "G3 WifiLan ConnectToService [peer]: medium="
|
||||
LOG(INFO) << "G3 WifiLan ConnectToService [peer]: medium="
|
||||
<< remote_medium
|
||||
<< ", remote ip address + port=" << socket_name;
|
||||
// Then, find our server socket context in this medium.
|
||||
@@ -253,7 +253,7 @@ std::unique_ptr<api::WifiLanSocket> WifiLanMedium::ConnectToService(
|
||||
server_socket =
|
||||
item != remote_medium->server_sockets_.end() ? item->second : nullptr;
|
||||
if (server_socket == nullptr) {
|
||||
NEARBY_LOGS(ERROR)
|
||||
LOG(ERROR)
|
||||
<< "G3 WifiLan Failed to find WifiLan Server socket: socket_name="
|
||||
<< socket_name;
|
||||
return {};
|
||||
@@ -261,13 +261,13 @@ std::unique_ptr<api::WifiLanSocket> WifiLanMedium::ConnectToService(
|
||||
}
|
||||
|
||||
if (cancellation_flag->Cancelled()) {
|
||||
NEARBY_LOGS(ERROR) << "G3 WifiLan Connect: Has been cancelled: socket_name="
|
||||
LOG(ERROR) << "G3 WifiLan Connect: Has been cancelled: socket_name="
|
||||
<< socket_name;
|
||||
return {};
|
||||
}
|
||||
|
||||
CancellationFlagListener listener(cancellation_flag, [&server_socket]() {
|
||||
NEARBY_LOGS(INFO) << "G3 WifiLan Cancel Connect.";
|
||||
LOG(INFO) << "G3 WifiLan Cancel Connect.";
|
||||
if (server_socket != nullptr) {
|
||||
server_socket->Close();
|
||||
}
|
||||
@@ -276,12 +276,12 @@ std::unique_ptr<api::WifiLanSocket> WifiLanMedium::ConnectToService(
|
||||
auto socket = std::make_unique<WifiLanSocket>();
|
||||
// Finally, Request to connect to this socket.
|
||||
if (!server_socket->Connect(*socket)) {
|
||||
NEARBY_LOGS(ERROR) << "G3 WifiLan Failed to connect to existing WifiLan "
|
||||
LOG(ERROR) << "G3 WifiLan Failed to connect to existing WifiLan "
|
||||
"Server socket: name="
|
||||
<< socket_name;
|
||||
return {};
|
||||
}
|
||||
NEARBY_LOGS(INFO) << "G3 WifiLan ConnectToService: connected: socket="
|
||||
LOG(INFO) << "G3 WifiLan ConnectToService: connected: socket="
|
||||
<< socket.get();
|
||||
return socket;
|
||||
}
|
||||
@@ -298,7 +298,7 @@ std::unique_ptr<api::WifiLanServerSocket> WifiLanMedium::ListenForService(
|
||||
absl::MutexLock lock(&mutex_);
|
||||
server_sockets_.erase(socket_name);
|
||||
});
|
||||
NEARBY_LOGS(INFO) << "G3 WifiLan Adding server socket: medium=" << this
|
||||
LOG(INFO) << "G3 WifiLan Adding server socket: medium=" << this
|
||||
<< ", socket_name=" << socket_name;
|
||||
absl::MutexLock lock(&mutex_);
|
||||
server_sockets_.insert({socket_name, server_socket.get()});
|
||||
|
||||
@@ -122,7 +122,7 @@ bool WifiLanMdns::StartMdnsService(
|
||||
DWORD status = DnsServiceRegister(&dns_service_register_request_, nullptr);
|
||||
|
||||
if (status != DNS_REQUEST_PENDING) {
|
||||
NEARBY_LOGS(ERROR) << "Failed to start mDNS advertising for service type ="
|
||||
LOG(ERROR) << "Failed to start mDNS advertising for service type ="
|
||||
<< service_type;
|
||||
return false;
|
||||
}
|
||||
@@ -156,7 +156,7 @@ bool WifiLanMdns::StopMdnsService() {
|
||||
DWORD status = DnsServiceDeRegister(&dns_service_register_request_, nullptr);
|
||||
|
||||
if (status != DNS_REQUEST_PENDING) {
|
||||
NEARBY_LOGS(ERROR) << "Failed to stop mDNS advertising.";
|
||||
LOG(ERROR) << "Failed to stop mDNS advertising.";
|
||||
CleanUp();
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -29,12 +29,4 @@
|
||||
// IWYU pragma: end_exports
|
||||
#endif // defined(NEARBY_CHROMIUM)
|
||||
|
||||
// Public APIs
|
||||
// The stream statement must come last, or it won't compile.
|
||||
#define NEARBY_VLOG(level) VLOG(level)
|
||||
#define NEARBY_LOGS(severity) LOG(severity)
|
||||
|
||||
#define NEARBY_DLOG(severity) DLOG(severity)
|
||||
#define NEARBY_DVLOG(severity) DVLOG(severity)
|
||||
|
||||
#endif // PLATFORM_BASE_LOGGING_H_
|
||||
|
||||
@@ -176,7 +176,7 @@ void MediumEnvironment::OnBluetoothDeviceStateChanged(
|
||||
// Store device name, and report it as discovered.
|
||||
info.devices.emplace(&device, name);
|
||||
if (enable_notifications_) {
|
||||
NEARBY_VLOG(1) << "Notify about new discovered device";
|
||||
VLOG(1) << "Notify about new discovered device";
|
||||
info.callback.device_discovered_cb(device);
|
||||
for (auto& observer : observers_.GetObservers()) {
|
||||
observer->DeviceAdded(device);
|
||||
@@ -199,7 +199,7 @@ void MediumEnvironment::OnBluetoothDeviceStateChanged(
|
||||
} else {
|
||||
// Device is in discovery mode, so we are reporting it anyway.
|
||||
if (enable_notifications_) {
|
||||
NEARBY_VLOG(1) << "Notify about existing discovered device";
|
||||
VLOG(1) << "Notify about existing discovered device";
|
||||
info.callback.device_discovered_cb(device);
|
||||
for (auto& observer : observers_.GetObservers()) {
|
||||
observer->DeviceAdded(device);
|
||||
@@ -211,7 +211,7 @@ void MediumEnvironment::OnBluetoothDeviceStateChanged(
|
||||
// Known device is turned off.
|
||||
// Erase it from the map, and report as lost.
|
||||
if (enable_notifications_) {
|
||||
NEARBY_VLOG(1) << "Notify about removed device";
|
||||
VLOG(1) << "Notify about removed device";
|
||||
info.callback.device_lost_cb(device);
|
||||
for (auto& observer : observers_.GetObservers()) {
|
||||
observer->DeviceRemoved(device);
|
||||
|
||||
@@ -67,14 +67,14 @@ void PendingJobRegistry::ListJobs() {
|
||||
for (auto& job : pending_jobs_) {
|
||||
auto age = current_time - job.second;
|
||||
if (age >= kReportPendingJobsOlderThan) {
|
||||
NEARBY_LOGS(INFO) << "Task \"" << job.first << "\" is waiting for "
|
||||
LOG(INFO) << "Task \"" << job.first << "\" is waiting for "
|
||||
<< absl::ToInt64Seconds(age) << " s";
|
||||
}
|
||||
}
|
||||
for (auto& job : running_jobs_) {
|
||||
auto age = current_time - job.second;
|
||||
if (age >= kReportRunningJobsOlderThan) {
|
||||
NEARBY_LOGS(INFO) << "Task \"" << job.first << "\" is running for "
|
||||
LOG(INFO) << "Task \"" << job.first << "\" is running for "
|
||||
<< absl::ToInt64Seconds(age) << " s";
|
||||
}
|
||||
}
|
||||
@@ -86,12 +86,12 @@ void PendingJobRegistry::ListAllJobs() {
|
||||
auto current_time = SystemClock::ElapsedRealtime();
|
||||
for (auto& job : pending_jobs_) {
|
||||
auto age = current_time - job.second;
|
||||
NEARBY_LOGS(INFO) << "Task \"" << job.first << "\" is waiting for "
|
||||
LOG(INFO) << "Task \"" << job.first << "\" is waiting for "
|
||||
<< absl::ToInt64Seconds(age) << " s";
|
||||
}
|
||||
for (auto& job : running_jobs_) {
|
||||
auto age = current_time - job.second;
|
||||
NEARBY_LOGS(INFO) << "Task \"" << job.first << "\" is running for "
|
||||
LOG(INFO) << "Task \"" << job.first << "\" is running for "
|
||||
<< absl::ToInt64Seconds(age) << " s";
|
||||
}
|
||||
list_jobs_time_ = current_time;
|
||||
|
||||
@@ -63,9 +63,7 @@ class MediumSocket : public Socket {
|
||||
}
|
||||
|
||||
/** Feeds the received incoming data to the client. */
|
||||
virtual void FeedIncomingData(ByteArray data) {
|
||||
// NEARBY_LOGS(INFO) << "FeedIncomingData: do nothing";
|
||||
}
|
||||
virtual void FeedIncomingData(ByteArray data) {}
|
||||
|
||||
/** Returns true if the socket is a virtual socket. */
|
||||
virtual bool IsVirtualSocket() {
|
||||
|
||||
@@ -25,7 +25,7 @@ namespace nearby {
|
||||
bool TimerImpl::Start(int delay, int period,
|
||||
absl::AnyInvocable<void()> callback) {
|
||||
if (internal_timer_ != nullptr) {
|
||||
NEARBY_LOGS(INFO) << "The timer is already running.";
|
||||
LOG(INFO) << "The timer is already running.";
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -33,7 +33,7 @@ bool TimerImpl::Start(int delay, int period,
|
||||
period_ = period;
|
||||
internal_timer_ = api::ImplementationPlatform::CreateTimer();
|
||||
if (!internal_timer_->Create(delay, period, std::move(callback))) {
|
||||
NEARBY_LOGS(INFO) << "Failed to create timer.";
|
||||
LOG(INFO) << "Failed to create timer.";
|
||||
internal_timer_ = nullptr;
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -54,7 +54,7 @@ TEST(UuidTest, CreateFromStringWithMd5) {
|
||||
std::string uuid_str(uuid);
|
||||
std::array<char, 16> uuid_data = uuid.data();
|
||||
std::string md5_data(Crypto::Md5(kString));
|
||||
NEARBY_LOGS(INFO) << "MD5-based UUID: " << uuid_str;
|
||||
LOG(INFO) << "MD5-based UUID: " << uuid_str;
|
||||
uuid_data[6] = 0;
|
||||
uuid_data[8] = 0;
|
||||
md5_data[6] = 0;
|
||||
@@ -66,7 +66,7 @@ TEST(UuidTest, CreateFromBinaryCanOutputString) {
|
||||
Uuid uuid(kCopresenceServiceUuidMsb, kCopresenceServiceUuidLsb);
|
||||
std::array<char, 16> uuid_data = uuid.data();
|
||||
std::string uuid_str(uuid);
|
||||
NEARBY_LOGS(INFO) << "UUID: " << uuid_str;
|
||||
LOG(INFO) << "UUID: " << uuid_str;
|
||||
EXPECT_EQ(uuid_data[0],
|
||||
static_cast<char>((kCopresenceServiceUuidMsb >> 56) & 0xFF));
|
||||
EXPECT_EQ(uuid_data[1],
|
||||
|
||||
@@ -14,12 +14,16 @@
|
||||
|
||||
#include "internal/platform/wifi_direct.h"
|
||||
|
||||
#include "internal/platform/logging.h"
|
||||
#include "absl/strings/string_view.h"
|
||||
#include "internal/platform/cancellation_flag.h"
|
||||
|
||||
namespace nearby {
|
||||
|
||||
WifiDirectSocket WifiDirectMedium::ConnectToService(
|
||||
absl::string_view ip_address, int port,
|
||||
CancellationFlag* cancellation_flag) {
|
||||
NEARBY_LOGS(INFO) << "WifiDirectMedium::ConnectToService: ip address="
|
||||
LOG(INFO) << "WifiDirectMedium::ConnectToService: ip address="
|
||||
<< ip_address << ", port=" << port;
|
||||
return WifiDirectSocket(
|
||||
impl_->ConnectToService(ip_address, port, cancellation_flag));
|
||||
|
||||
@@ -122,7 +122,7 @@ class WifiDirectServerSocket final {
|
||||
WifiDirectSocket Accept() {
|
||||
std::unique_ptr<api::WifiDirectSocket> socket = impl_->Accept();
|
||||
if (!socket) {
|
||||
NEARBY_LOGS(INFO)
|
||||
LOG(INFO)
|
||||
<< "WifiDirectServerSocket Accept() failed on server socket: ";
|
||||
}
|
||||
return WifiDirectSocket(std::move(socket));
|
||||
@@ -130,7 +130,7 @@ class WifiDirectServerSocket final {
|
||||
|
||||
// Returns Exception::kIo on error, Exception::kSuccess otherwise.
|
||||
Exception Close() {
|
||||
NEARBY_LOGS(INFO) << "WifiDirectServerSocket Closing:: " << this;
|
||||
LOG(INFO) << "WifiDirectServerSocket Closing:: " << this;
|
||||
return impl_->Close();
|
||||
}
|
||||
|
||||
|
||||
@@ -133,7 +133,7 @@ class WifiHotspotServerSocket final {
|
||||
WifiHotspotSocket Accept() {
|
||||
std::unique_ptr<api::WifiHotspotSocket> socket = impl_->Accept();
|
||||
if (!socket) {
|
||||
NEARBY_LOGS(INFO)
|
||||
LOG(INFO)
|
||||
<< "WifiHotspotServerSocket Accept() failed on server socket: ";
|
||||
}
|
||||
return WifiHotspotSocket(std::move(socket));
|
||||
@@ -141,7 +141,7 @@ class WifiHotspotServerSocket final {
|
||||
|
||||
// Returns Exception::kIo on error, Exception::kSuccess otherwise.
|
||||
Exception Close() {
|
||||
NEARBY_LOGS(INFO) << "WifiHotspotServerSocket Closing:: " << this;
|
||||
LOG(INFO) << "WifiHotspotServerSocket Closing:: " << this;
|
||||
return impl_->Close();
|
||||
}
|
||||
|
||||
|
||||
@@ -36,14 +36,14 @@ MediumSocket* WifiLanSocket::CreateVirtualSocket(
|
||||
absl::flat_hash_map<std::string, std::shared_ptr<MediumSocket>>*
|
||||
virtual_sockets_ptr) {
|
||||
if (IsVirtualSocket()) {
|
||||
NEARBY_LOGS(WARNING)
|
||||
LOG(WARNING)
|
||||
<< "Creating the virtual socket on a virtual socket is not allowed.";
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
auto virtual_socket = std::make_shared<WifiLanSocket>(outputstream);
|
||||
virtual_socket->impl_ = this->impl_;
|
||||
NEARBY_LOGS(WARNING) << "Created the virtual socket for Medium: "
|
||||
LOG(WARNING) << "Created the virtual socket for Medium: "
|
||||
<< Medium_Name(virtual_socket->GetMedium());
|
||||
|
||||
if (virtual_sockets_ptr_ == nullptr) {
|
||||
@@ -51,7 +51,7 @@ MediumSocket* WifiLanSocket::CreateVirtualSocket(
|
||||
}
|
||||
|
||||
(*virtual_sockets_ptr_)[salted_service_id_hash_key] = virtual_socket;
|
||||
NEARBY_LOGS(INFO) << "virtual_sockets_ size: "
|
||||
LOG(INFO) << "virtual_sockets_ size: "
|
||||
<< virtual_sockets_ptr_->size();
|
||||
return virtual_socket.get();
|
||||
}
|
||||
@@ -70,7 +70,7 @@ bool WifiLanMedium::StartDiscovery(const std::string& service_id,
|
||||
{
|
||||
MutexLock lock(&mutex_);
|
||||
if (service_type_to_callback_map_.contains(service_type)) {
|
||||
NEARBY_LOGS(INFO) << "WifiLan Discovery already start with service_type="
|
||||
LOG(INFO) << "WifiLan Discovery already start with service_type="
|
||||
<< service_type << "; impl=" << &GetImpl();
|
||||
return false;
|
||||
}
|
||||
@@ -84,7 +84,7 @@ bool WifiLanMedium::StartDiscovery(const std::string& service_id,
|
||||
const auto& it = service_type_to_callback_map_.find(service_type);
|
||||
|
||||
if (it == service_type_to_callback_map_.end()) {
|
||||
NEARBY_LOGS(ERROR)
|
||||
LOG(ERROR)
|
||||
<< "There is no callback found for service_type="
|
||||
<< service_type;
|
||||
return;
|
||||
@@ -93,7 +93,7 @@ bool WifiLanMedium::StartDiscovery(const std::string& service_id,
|
||||
// Check whether service name is in cache.
|
||||
auto services_it = service_type_to_services_map_.find(service_type);
|
||||
if (services_it == service_type_to_services_map_.end()) {
|
||||
NEARBY_LOGS(ERROR)
|
||||
LOG(ERROR)
|
||||
<< "There is no service map found for service_type="
|
||||
<< service_type;
|
||||
return;
|
||||
@@ -102,14 +102,14 @@ bool WifiLanMedium::StartDiscovery(const std::string& service_id,
|
||||
std::string service_name = service_info.GetServiceName();
|
||||
auto pair = services_it->second.insert(service_name);
|
||||
if (!pair.second) {
|
||||
NEARBY_LOGS(INFO)
|
||||
LOG(INFO)
|
||||
<< "Discovering (again) service_info=" << &service_info
|
||||
<< ", service_type=" << service_type
|
||||
<< ", service_name=" << service_info.GetServiceName();
|
||||
return;
|
||||
}
|
||||
|
||||
NEARBY_LOGS(INFO)
|
||||
LOG(INFO)
|
||||
<< "Adding service_info=" << &service_info
|
||||
<< ", service_type=" << service_type
|
||||
<< ", service_name=" << service_info.GetServiceName();
|
||||
@@ -126,7 +126,7 @@ bool WifiLanMedium::StartDiscovery(const std::string& service_id,
|
||||
std::string service_name = service_info.GetServiceName();
|
||||
auto services_it = service_type_to_services_map_.find(service_type);
|
||||
if (services_it == service_type_to_services_map_.end()) {
|
||||
NEARBY_LOGS(ERROR)
|
||||
LOG(ERROR)
|
||||
<< "There is no service map found for service_type="
|
||||
<< service_type;
|
||||
return;
|
||||
@@ -134,7 +134,7 @@ bool WifiLanMedium::StartDiscovery(const std::string& service_id,
|
||||
|
||||
auto item = services_it->second.extract(service_name);
|
||||
if (item.empty()) return;
|
||||
NEARBY_LOGS(INFO) << "Removing service_info=" << &service_info
|
||||
LOG(INFO) << "Removing service_info=" << &service_info
|
||||
<< ", service_type=" << service_type
|
||||
<< ", service_info_name=" << service_name;
|
||||
// Callback service lost.
|
||||
@@ -169,7 +169,7 @@ bool WifiLanMedium::StartDiscovery(const std::string& service_id,
|
||||
service_type_to_callback_map_.erase(service_type);
|
||||
service_type_to_services_map_.erase(service_type);
|
||||
}
|
||||
NEARBY_LOGS(INFO) << "WifiLan Discovery started for service_type="
|
||||
LOG(INFO) << "WifiLan Discovery started for service_type="
|
||||
<< service_type << ", impl=" << &GetImpl()
|
||||
<< ", success=" << success;
|
||||
return success;
|
||||
@@ -184,7 +184,7 @@ bool WifiLanMedium::StopDiscovery(const std::string& service_type) {
|
||||
if (service_type_to_services_map_.contains(service_type)) {
|
||||
service_type_to_services_map_.erase(service_type);
|
||||
}
|
||||
NEARBY_LOGS(INFO) << "WifiLan Discovery disabled for service_type="
|
||||
LOG(INFO) << "WifiLan Discovery disabled for service_type="
|
||||
<< service_type << ", impl=" << &GetImpl();
|
||||
return impl_->StopDiscovery(service_type);
|
||||
}
|
||||
@@ -192,7 +192,7 @@ bool WifiLanMedium::StopDiscovery(const std::string& service_type) {
|
||||
WifiLanSocket WifiLanMedium::ConnectToService(
|
||||
const NsdServiceInfo& remote_service_info,
|
||||
CancellationFlag* cancellation_flag) {
|
||||
NEARBY_LOGS(INFO) << "WifiLanMedium::ConnectToService: remote_service_name="
|
||||
LOG(INFO) << "WifiLanMedium::ConnectToService: remote_service_name="
|
||||
<< remote_service_info.GetServiceName();
|
||||
return WifiLanSocket(
|
||||
impl_->ConnectToService(remote_service_info, cancellation_flag));
|
||||
@@ -201,7 +201,7 @@ WifiLanSocket WifiLanMedium::ConnectToService(
|
||||
WifiLanSocket WifiLanMedium::ConnectToService(
|
||||
const std::string& ip_address, int port,
|
||||
CancellationFlag* cancellation_flag) {
|
||||
NEARBY_LOGS(INFO) << "WifiLanMedium::ConnectToService: ip address="
|
||||
LOG(INFO) << "WifiLanMedium::ConnectToService: ip address="
|
||||
<< WifiUtils::GetHumanReadableIpAddress(ip_address)
|
||||
<< ", port=" << port;
|
||||
return WifiLanSocket(
|
||||
|
||||
@@ -82,7 +82,7 @@ class WifiLanSocket : public MediumSocket {
|
||||
// Returns Exception::kIo on error, Exception::kSuccess otherwise.
|
||||
Exception Close() override {
|
||||
if (IsVirtualSocket()) {
|
||||
NEARBY_LOGS(INFO) << "Multiplex: Closing virtual socket: " << this;
|
||||
LOG(INFO) << "Multiplex: Closing virtual socket: " << this;
|
||||
blocking_queue_input_stream_->Close();
|
||||
virtual_output_stream_->Close();
|
||||
CloseLocal(); // This will trigger MultiplexSocket::OnVirtualSocketClosed
|
||||
@@ -104,7 +104,7 @@ class WifiLanSocket : public MediumSocket {
|
||||
/** Feeds the received incoming data to the client. */
|
||||
void FeedIncomingData(ByteArray data) override {
|
||||
if (!IsVirtualSocket()) {
|
||||
NEARBY_LOGS(INFO) << "Feeding data on a physical socket is not allowed.";
|
||||
LOG(INFO) << "Feeding data on a physical socket is not allowed.";
|
||||
return;
|
||||
}
|
||||
blocking_queue_input_stream_->Write(data);
|
||||
@@ -164,7 +164,7 @@ class WifiLanServerSocket final {
|
||||
WifiLanSocket Accept() {
|
||||
std::unique_ptr<api::WifiLanSocket> socket = impl_->Accept();
|
||||
if (!socket) {
|
||||
NEARBY_LOGS(INFO)
|
||||
LOG(INFO)
|
||||
<< "WifiLanServerSocket Accept() failed on server socket: " << this;
|
||||
}
|
||||
return WifiLanSocket(std::move(socket));
|
||||
@@ -172,7 +172,7 @@ class WifiLanServerSocket final {
|
||||
|
||||
// Returns Exception::kIo on error, Exception::kSuccess otherwise.
|
||||
Exception Close() {
|
||||
NEARBY_LOGS(INFO) << "WifiLanServerSocket Closing:: " << this;
|
||||
LOG(INFO) << "WifiLanServerSocket Closing:: " << this;
|
||||
return impl_->Close();
|
||||
}
|
||||
|
||||
|
||||
@@ -38,27 +38,27 @@ bool Compare(const Descriptor* desc1, const Descriptor* desc2);
|
||||
// or type is different.
|
||||
bool Compare(const FieldDescriptor* field1, const FieldDescriptor* field2) {
|
||||
if (field1->name() != field2->name()) {
|
||||
NEARBY_LOGS(WARNING) << "Field name diff: " << field1->name() << " <=> "
|
||||
<< field2->name();
|
||||
LOG(WARNING) << "Field name diff: " << field1->name() << " <=> "
|
||||
<< field2->name();
|
||||
return false;
|
||||
}
|
||||
if (field1->number() != field2->number()) {
|
||||
NEARBY_LOGS(WARNING) << "Field " << field1->name()
|
||||
<< " number diff: " << field1->number() << " <=> "
|
||||
<< field2->number();
|
||||
LOG(WARNING) << "Field " << field1->name()
|
||||
<< " number diff: " << field1->number() << " <=> "
|
||||
<< field2->number();
|
||||
return false;
|
||||
}
|
||||
if (field1->label() != field2->label()) {
|
||||
NEARBY_LOGS(WARNING) << "Field " << field1->name()
|
||||
<< " label diff: " << field1->label() << " <=> "
|
||||
<< field2->label();
|
||||
LOG(WARNING) << "Field " << field1->name()
|
||||
<< " label diff: " << field1->label() << " <=> "
|
||||
<< field2->label();
|
||||
return false;
|
||||
}
|
||||
bool bRet = false;
|
||||
if (field1->type() != field2->type()) {
|
||||
NEARBY_LOGS(WARNING) << "Field " << field1->name()
|
||||
<< " type diff: " << field1->type() << " <=> "
|
||||
<< field2->type();
|
||||
LOG(WARNING) << "Field " << field1->name()
|
||||
<< " type diff: " << field1->type() << " <=> "
|
||||
<< field2->type();
|
||||
return bRet;
|
||||
} else if (field1->type() == FieldDescriptor::TYPE_MESSAGE) {
|
||||
const Descriptor* msg1 = field1->message_type();
|
||||
@@ -74,8 +74,8 @@ bool Compare(const FieldDescriptor* field1, const FieldDescriptor* field2) {
|
||||
|
||||
// Compares the two descriptors and return false immediately if different.
|
||||
bool Compare(const Descriptor* desc1, const Descriptor* desc2) {
|
||||
NEARBY_LOGS(INFO) << "Descriptor1 full name: " << desc1->full_name()
|
||||
<< " <=> " << desc2->full_name();
|
||||
LOG(INFO) << "Descriptor1 full name: " << desc1->full_name() << " <=> "
|
||||
<< desc2->full_name();
|
||||
for (int i = 0; i < desc1->field_count(); ++i) {
|
||||
const FieldDescriptor* field1 = desc1->field(i);
|
||||
const FieldDescriptor* field2 = desc2->FindFieldByName(field1->name());
|
||||
@@ -84,11 +84,11 @@ bool Compare(const Descriptor* desc1, const Descriptor* desc2) {
|
||||
if (field2) {
|
||||
bRet = Compare(field1, field2);
|
||||
} else {
|
||||
NEARBY_LOGS(ERROR) << "Descriptor1 full name: " << desc1->full_name()
|
||||
<< "=> Extra field1 name=" << field1->name()
|
||||
<< ", number=" << field1->number()
|
||||
<< ", label=" << field1->label()
|
||||
<< ", type=" << field1->type();
|
||||
LOG(ERROR) << "Descriptor1 full name: " << desc1->full_name()
|
||||
<< "=> Extra field1 name=" << field1->name()
|
||||
<< ", number=" << field1->number()
|
||||
<< ", label=" << field1->label()
|
||||
<< ", type=" << field1->type();
|
||||
}
|
||||
if (!bRet) {
|
||||
return false;
|
||||
@@ -98,11 +98,11 @@ bool Compare(const Descriptor* desc1, const Descriptor* desc2) {
|
||||
const FieldDescriptor* field2 = desc2->field(i);
|
||||
const FieldDescriptor* field1 = desc1->FindFieldByName(field2->name());
|
||||
if (!field1) {
|
||||
NEARBY_LOGS(ERROR) << "Descriptor2 full name: " << desc2->full_name()
|
||||
<< "=> Extra field2 name=" << field2->name()
|
||||
<< ", number=" << field2->number()
|
||||
<< ", label=" << field2->label()
|
||||
<< ", type=" << field2->type();
|
||||
LOG(ERROR) << "Descriptor2 full name: " << desc2->full_name()
|
||||
<< "=> Extra field2 name=" << field2->name()
|
||||
<< ", number=" << field2->number()
|
||||
<< ", label=" << field2->label()
|
||||
<< ", type=" << field2->type();
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -100,7 +100,7 @@ bool FakeTimer::InternalStart(int delay, int period,
|
||||
}
|
||||
|
||||
if (!timer_data_.id.empty()) {
|
||||
NEARBY_LOGS(ERROR) << __func__ << ": timer is already running";
|
||||
LOG(ERROR) << __func__ << ": timer is already running";
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
@@ -80,13 +80,13 @@ BaseSocket::BaseSocket(const Connection& connection, SocketCallback&& callback)
|
||||
}
|
||||
|
||||
BaseSocket::~BaseSocket() {
|
||||
NEARBY_LOGS(INFO) << "~BaseSocket";
|
||||
LOG(INFO) << "~BaseSocket";
|
||||
ShutDown();
|
||||
}
|
||||
|
||||
void BaseSocket::ShutDown() {
|
||||
executor_.Shutdown();
|
||||
NEARBY_LOGS(INFO) << "BaseSocket gone.";
|
||||
LOG(INFO) << "BaseSocket gone.";
|
||||
}
|
||||
|
||||
void BaseSocket::TryWriteNextControl() {
|
||||
@@ -136,11 +136,11 @@ void BaseSocket::TryWriteNextMessage() {
|
||||
|
||||
void BaseSocket::WritePacket(absl::StatusOr<Packet> packet) {
|
||||
if (!packet.ok()) {
|
||||
NEARBY_LOGS(WARNING) << "Packet status:" << packet.status();
|
||||
LOG(WARNING) << "Packet status:" << packet.status();
|
||||
return;
|
||||
}
|
||||
CHECK_OK(packet->SetPacketCounter(packet_counter_generator_.Next()));
|
||||
NEARBY_LOGS(INFO) << "transmitting packet";
|
||||
LOG(INFO) << "transmitting packet";
|
||||
connection_.Transmit(packet->GetBytes());
|
||||
}
|
||||
|
||||
@@ -155,13 +155,13 @@ void BaseSocket::OnWriteRequestWriteComplete(absl::Status status) {
|
||||
current_control_ = nullptr;
|
||||
control_request_queue_.pop_front();
|
||||
} else if (current_message_ != nullptr) {
|
||||
NEARBY_LOGS(INFO) << "OnWriteResult current is not null";
|
||||
LOG(INFO) << "OnWriteResult current is not null";
|
||||
if (current_message_->IsFinished()) {
|
||||
NEARBY_LOGS(INFO) << "OnWriteResult current finished";
|
||||
LOG(INFO) << "OnWriteResult current finished";
|
||||
current_message_->SetWriteStatus(status);
|
||||
if (!message_request_queue_.empty() &&
|
||||
current_message_ == &message_request_queue_.front()) {
|
||||
NEARBY_LOGS(INFO) << "remove message";
|
||||
LOG(INFO) << "remove message";
|
||||
message_request_queue_.pop_front();
|
||||
current_message_ = nullptr;
|
||||
}
|
||||
@@ -231,9 +231,9 @@ void BaseSocket::DisconnectQuietly() {
|
||||
current_message_ = nullptr;
|
||||
state_ = SocketConnectionState::kDisconnected;
|
||||
}
|
||||
NEARBY_LOGS(INFO) << "Socket now disconnected.";
|
||||
LOG(INFO) << "Socket now disconnected.";
|
||||
});
|
||||
NEARBY_LOGS(INFO) << "scheduled reset";
|
||||
LOG(INFO) << "scheduled reset";
|
||||
}
|
||||
|
||||
void BaseSocket::OnReceiveDataPacket(Packet packet) {
|
||||
@@ -280,7 +280,7 @@ void BaseSocket::WriteControlPacket(Packet packet) {
|
||||
}
|
||||
TryWriteNextControl();
|
||||
});
|
||||
NEARBY_LOGS(INFO) << "Scheduled TryWriteControl";
|
||||
LOG(INFO) << "Scheduled TryWriteControl";
|
||||
}
|
||||
|
||||
void BaseSocket::DisconnectInternal(absl::Status status) {
|
||||
|
||||
@@ -61,7 +61,7 @@ class BaseSocket {
|
||||
void WriteControlPacket(Packet packet);
|
||||
void OnReceiveDataPacket(Packet packet);
|
||||
void RunOnSocketThread(std::string name, Runnable&& runnable) {
|
||||
NEARBY_LOGS(INFO) << "RunOnSocketThread: " << name;
|
||||
LOG(INFO) << "RunOnSocketThread: " << name;
|
||||
executor_.Execute(name, std::move(runnable));
|
||||
}
|
||||
void ShutDown();
|
||||
|
||||
@@ -63,7 +63,7 @@ class FakeConnection : public Connection {
|
||||
packets_written_.erase(packets_written_.begin());
|
||||
return front;
|
||||
}
|
||||
NEARBY_LOGS(WARNING) << "No more packets";
|
||||
LOG(WARNING) << "No more packets";
|
||||
return "";
|
||||
}
|
||||
bool NoMorePackets() {
|
||||
@@ -143,7 +143,7 @@ class BaseSocketTest : public ::testing::Test {
|
||||
.on_error_cb =
|
||||
[this](absl::Status status) {
|
||||
error_status_ = status;
|
||||
NEARBY_LOGS(ERROR) << status;
|
||||
LOG(ERROR) << status;
|
||||
},
|
||||
}) {}
|
||||
void TransmitAndFail() {
|
||||
@@ -282,7 +282,7 @@ TEST_F(BaseSocketTest, TestWritePacketCounterRollover) {
|
||||
Packet packet = Packet::CreateDataPacket(true, true, ByteArray("\x01"));
|
||||
EXPECT_OK(packet.SetPacketCounter(i));
|
||||
nearby::Future<absl::Status> result = socket_.Write(ByteArray("\x01"));
|
||||
NEARBY_LOGS(INFO) << "sent packet " << i;
|
||||
LOG(INFO) << "sent packet " << i;
|
||||
EXPECT_OK(result.Get().GetResult());
|
||||
EXPECT_EQ(connection_.PollWrittenPacket(), packet.GetBytes());
|
||||
}
|
||||
@@ -327,7 +327,7 @@ TEST_F(BaseSocketTest, TestResetByDisconnect) {
|
||||
|
||||
// connect again
|
||||
socket_.OnConnectedProxy(kMaxPacketSize);
|
||||
NEARBY_LOGS(INFO) << "Reconnected socket";
|
||||
LOG(INFO) << "Reconnected socket";
|
||||
// sleep for 10 ms to allow for packet population
|
||||
absl::SleepFor(absl::Milliseconds(10));
|
||||
EXPECT_EQ(connection_.PollWrittenPacket(), "");
|
||||
@@ -445,18 +445,18 @@ TEST_F(BaseSocketTest, TestOnRemoteTransitEmpty) {
|
||||
TEST_F(BaseSocketTest, TestReconnect) {
|
||||
connection_.SetInstantTransmit(false);
|
||||
socket_.OnConnectedProxy(kMaxPacketSize);
|
||||
NEARBY_LOGS(INFO) << "Starting TransmitAndFail1";
|
||||
LOG(INFO) << "Starting TransmitAndFail1";
|
||||
TransmitAndFail();
|
||||
NEARBY_LOGS(INFO) << "TransmitAndFail1 completed";
|
||||
LOG(INFO) << "TransmitAndFail1 completed";
|
||||
connection_.OnTransmitProxy(absl::UnavailableError(""));
|
||||
EXPECT_EQ(error_status_.code(), absl::StatusCode::kUnavailable);
|
||||
absl::SleepFor(absl::Milliseconds(20));
|
||||
NEARBY_LOGS(INFO) << "Reconnecting";
|
||||
LOG(INFO) << "Reconnecting";
|
||||
socket_.OnConnectedProxy(kMaxPacketSize);
|
||||
absl::SleepFor(absl::Milliseconds(20));
|
||||
NEARBY_LOGS(INFO) << "Starting transmit and fail 2";
|
||||
LOG(INFO) << "Starting transmit and fail 2";
|
||||
TransmitAndFail();
|
||||
NEARBY_LOGS(INFO) << "TransmitAndFail2 completed";
|
||||
LOG(INFO) << "TransmitAndFail2 completed";
|
||||
absl::SleepFor(absl::Milliseconds(10));
|
||||
EXPECT_TRUE(connection_.NoMorePackets());
|
||||
}
|
||||
|
||||
@@ -26,16 +26,16 @@ namespace weave {
|
||||
|
||||
struct SocketCallback {
|
||||
std::function<void()> on_connected_cb = []() {
|
||||
NEARBY_LOGS(WARNING) << "Unimplemented!";
|
||||
LOG(WARNING) << "Unimplemented!";
|
||||
};
|
||||
std::function<void()> on_disconnected_cb = []() {
|
||||
NEARBY_LOGS(WARNING) << "Unimplemented!";
|
||||
LOG(WARNING) << "Unimplemented!";
|
||||
};
|
||||
std::function<void(std::string message)> on_receive_cb = [](std::string) {
|
||||
NEARBY_LOGS(WARNING) << "Unimplemented!";
|
||||
LOG(WARNING) << "Unimplemented!";
|
||||
};
|
||||
std::function<void(absl::Status)> on_error_cb = [](absl::Status) {
|
||||
NEARBY_LOGS(WARNING) << "Unimplemented!";
|
||||
LOG(WARNING) << "Unimplemented!";
|
||||
};
|
||||
};
|
||||
|
||||
|
||||
@@ -49,7 +49,7 @@ ClientSocket::ClientSocket(
|
||||
ClientSocket::~ClientSocket() {
|
||||
ShutDown();
|
||||
executor_.Shutdown();
|
||||
NEARBY_LOGS(INFO) << "ClientSocket gone.";
|
||||
LOG(INFO) << "ClientSocket gone.";
|
||||
}
|
||||
|
||||
void ClientSocket::Connect() {
|
||||
|
||||
@@ -76,7 +76,7 @@ class FakeConnection : public Connection {
|
||||
packets_written_.erase(packets_written_.begin());
|
||||
return front;
|
||||
}
|
||||
NEARBY_LOGS(WARNING) << "No more packets";
|
||||
LOG(WARNING) << "No more packets";
|
||||
return "";
|
||||
}
|
||||
bool NoMorePackets() {
|
||||
@@ -123,7 +123,7 @@ class ClientSocketTest : public ::testing::Test {
|
||||
.on_error_cb =
|
||||
[this](absl::Status status) {
|
||||
last_error_ = status;
|
||||
NEARBY_LOGS(ERROR) << status;
|
||||
LOG(ERROR) << status;
|
||||
},
|
||||
})) {}
|
||||
void SetUp() override { EXPECT_FALSE(socket_.IsConnected()); }
|
||||
@@ -134,7 +134,7 @@ class ClientSocketTest : public ::testing::Test {
|
||||
void RunConnect(int client_size, int server_size,
|
||||
absl::string_view initial_data) {
|
||||
connection_.SetMaxPacketSize(client_size);
|
||||
NEARBY_LOGS(INFO) << "connect";
|
||||
LOG(INFO) << "connect";
|
||||
socket_.Connect();
|
||||
absl::SleepFor(absl::Milliseconds(10));
|
||||
auto packet = Packet::FromBytes(ByteArray(connection_.PollWrittenPacket()));
|
||||
@@ -350,7 +350,7 @@ TEST_F(ClientSocketTest, TestSocketWithRandomDataProvider) {
|
||||
messages_read_.push_back(message);
|
||||
},
|
||||
.on_error_cb =
|
||||
[](absl::Status status) { NEARBY_LOGS(ERROR) << status; },
|
||||
[](absl::Status status) { LOG(ERROR) << status; },
|
||||
},
|
||||
std::move(provider));
|
||||
socket.Connect();
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user