mirror of
https://github.com/kidfromjupiter/nearby.git
synced 2026-09-16 07:36:10 -04:00
Refactor AnalyticsRecorder into an abstract interface and decouple ClientProxy from logging protos.
PiperOrigin-RevId: 922838021
This commit is contained in:
committed by
Copybara-Service
parent
b2e4290a86
commit
f3a8df5db3
+1
-1
@@ -368,7 +368,7 @@ let package = Package(
|
||||
"connections/implementation/payload_manager_test.cc",
|
||||
"connections/implementation/offline_frames_validator_test.cc",
|
||||
"connections/implementation/service_controller_router_test.cc",
|
||||
"connections/implementation/analytics/analytics_recorder_test.cc",
|
||||
"connections/implementation/analytics/analytics_recorder_impl_test.cc",
|
||||
"connections/implementation/analytics/throughput_recorder_test.cc",
|
||||
"connections/implementation/mediums/advertisements/data_element_test.cc",
|
||||
"connections/implementation/mediums/advertisements/dct_advertisement_test.cc",
|
||||
|
||||
@@ -112,6 +112,7 @@ cc_library(
|
||||
deps = [
|
||||
"//connections:core_types",
|
||||
"//connections/implementation/analytics",
|
||||
"//connections/implementation/analytics:analytics_recorder_impl",
|
||||
"//connections/implementation/flags:connections_flags",
|
||||
"//connections/implementation/mediums/advertisements:dct_advertisement",
|
||||
"//connections/implementation/proto:offline_wire_formats_cc_proto",
|
||||
@@ -130,7 +131,6 @@ cc_library(
|
||||
"//internal/platform/implementation:comm",
|
||||
"//internal/platform/implementation:platform",
|
||||
"//internal/platform/implementation:types",
|
||||
"//internal/proto/analytics:connections_log_cc_proto",
|
||||
"//proto:connections_enums_cc_proto",
|
||||
"@com_google_absl//absl/container:flat_hash_map",
|
||||
"@com_google_absl//absl/container:flat_hash_set",
|
||||
@@ -158,7 +158,6 @@ cc_library(
|
||||
deps = [
|
||||
":client_proxy",
|
||||
":offline_frames",
|
||||
":types",
|
||||
"//connections:core_types",
|
||||
"//connections/implementation/analytics",
|
||||
"//connections/implementation/flags:connections_flags",
|
||||
@@ -167,7 +166,6 @@ cc_library(
|
||||
"//internal/platform:logging",
|
||||
"//internal/platform:types",
|
||||
"//internal/platform/implementation:types",
|
||||
"//internal/proto/analytics:connections_log_cc_proto",
|
||||
"//proto:connections_enums_cc_proto",
|
||||
"@com_google_absl//absl/base:core_headers",
|
||||
"@com_google_absl//absl/container:flat_hash_map",
|
||||
@@ -263,7 +261,6 @@ cc_library(
|
||||
"//internal/platform/implementation:platform",
|
||||
"//internal/platform/implementation:types",
|
||||
"//internal/platform/implementation:wifi_utils",
|
||||
"//internal/proto/analytics:connections_log_cc_proto",
|
||||
"//proto:connections_enums_cc_proto",
|
||||
"@com_google_absl//absl/base:core_headers",
|
||||
"@com_google_absl//absl/container:btree",
|
||||
@@ -341,22 +338,18 @@ cc_test(
|
||||
":offline_frames",
|
||||
":service_id_constants",
|
||||
"//connections:core_types",
|
||||
"//connections/implementation/analytics",
|
||||
"//connections/implementation/flags:connections_flags",
|
||||
"//connections/implementation/mediums",
|
||||
"//internal/flags:nearby_flags",
|
||||
"//internal/platform:base",
|
||||
"//internal/platform:logging",
|
||||
"//internal/platform:test_util",
|
||||
"//internal/platform:types",
|
||||
"//internal/platform/flags:platform_flags",
|
||||
"//internal/platform/implementation:platform", # build_cleaner: keep
|
||||
"//internal/platform/implementation/g3", # build_cleaner: keep
|
||||
"//internal/proto/analytics:connections_log_cc_proto",
|
||||
"//proto:connections_enums_cc_proto",
|
||||
"@com_github_protobuf_matchers//protobuf-matchers",
|
||||
"@com_google_absl//absl/container:flat_hash_map",
|
||||
"@com_google_absl//absl/strings",
|
||||
"@com_google_absl//absl/time",
|
||||
"@com_google_googletest//:gtest_main",
|
||||
],
|
||||
)
|
||||
@@ -556,13 +549,13 @@ cc_test(
|
||||
":endpoint_channel",
|
||||
":internal",
|
||||
":offline_frames",
|
||||
"//connections/implementation/analytics",
|
||||
"//connections/implementation/flags:connections_flags",
|
||||
"//internal/flags:nearby_flags",
|
||||
"//internal/platform:base",
|
||||
"//internal/platform:logging",
|
||||
"//internal/platform:types",
|
||||
"//internal/platform/implementation/g3", # build_cleaner: keep
|
||||
"//internal/proto/analytics:connections_log_cc_proto",
|
||||
"//proto:connections_enums_cc_proto",
|
||||
"@com_github_protobuf_matchers//protobuf-matchers",
|
||||
"@com_google_absl//absl/strings",
|
||||
|
||||
@@ -26,10 +26,30 @@ cc_library(
|
||||
"analytics_recorder.h",
|
||||
"connection_attempt_metadata_params.h",
|
||||
"discovery_metadata_params.h",
|
||||
"operation_result_with_medium.h",
|
||||
],
|
||||
copts = ["-DCORE_ADAPTER_DLL"],
|
||||
visibility = ["//connections:__subpackages__"],
|
||||
deps = [
|
||||
"//connections:core_types",
|
||||
"//internal/platform:error_code_recorder",
|
||||
"//proto:connections_enums_cc_proto",
|
||||
"@com_google_absl//absl/time",
|
||||
],
|
||||
)
|
||||
|
||||
cc_library(
|
||||
name = "analytics_recorder_impl",
|
||||
srcs = [
|
||||
"analytics_recorder_impl.cc",
|
||||
],
|
||||
hdrs = [
|
||||
"analytics_recorder_impl.h",
|
||||
],
|
||||
copts = ["-DCORE_ADAPTER_DLL"],
|
||||
visibility = ["//connections/implementation:__pkg__"],
|
||||
deps = [
|
||||
":analytics",
|
||||
"//connections:core_types",
|
||||
"//internal/analytics:event_logger",
|
||||
"//internal/platform:error_code_recorder",
|
||||
@@ -40,11 +60,8 @@ cc_library(
|
||||
"//proto:connections_enums_cc_proto",
|
||||
"@com_google_absl//absl/algorithm:container",
|
||||
"@com_google_absl//absl/base:core_headers",
|
||||
"@com_google_absl//absl/base:no_destructor",
|
||||
"@com_google_absl//absl/container:btree",
|
||||
"@com_google_absl//absl/container:flat_hash_map",
|
||||
"@com_google_absl//absl/strings",
|
||||
"@com_google_absl//absl/strings:str_format",
|
||||
"@com_google_absl//absl/strings:string_view",
|
||||
"@com_google_absl//absl/time",
|
||||
"@com_google_protobuf//:protobuf_lite",
|
||||
],
|
||||
@@ -54,11 +71,12 @@ cc_test(
|
||||
name = "analytics_test",
|
||||
size = "small",
|
||||
srcs = [
|
||||
"analytics_recorder_test.cc",
|
||||
"analytics_recorder_impl_test.cc",
|
||||
],
|
||||
shard_count = 16,
|
||||
deps = [
|
||||
":analytics",
|
||||
":analytics_recorder_impl",
|
||||
"//connections:core_types",
|
||||
"//internal/analytics:mock_event_logger",
|
||||
"//internal/platform:base",
|
||||
|
||||
@@ -17,7 +17,7 @@
|
||||
|
||||
#include <vector>
|
||||
|
||||
#include "internal/proto/analytics/connections_log.pb.h"
|
||||
#include "connections/implementation/analytics/operation_result_with_medium.h"
|
||||
|
||||
namespace nearby {
|
||||
|
||||
@@ -26,8 +26,7 @@ struct AdvertisingMetadataParams {
|
||||
bool is_extended_advertisement_supported = false;
|
||||
int connected_ap_frequency = 0;
|
||||
bool is_nfc_available = false;
|
||||
std::vector<location::nearby::analytics::proto::ConnectionsLog::
|
||||
OperationResultWithMedium>
|
||||
std::vector<nearby::analytics::OperationResultWithMedium>
|
||||
operation_result_with_mediums = {};
|
||||
};
|
||||
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -18,118 +18,98 @@
|
||||
#include <cstdint>
|
||||
#include <memory>
|
||||
#include <string>
|
||||
#include <utility>
|
||||
#include <vector>
|
||||
|
||||
#include "absl/base/thread_annotations.h"
|
||||
#include "absl/container/btree_map.h"
|
||||
#include "absl/strings/string_view.h"
|
||||
#include "absl/time/time.h"
|
||||
#include "connections/implementation/analytics/advertising_metadata_params.h"
|
||||
#include "connections/implementation/analytics/connection_attempt_metadata_params.h"
|
||||
#include "connections/implementation/analytics/discovery_metadata_params.h"
|
||||
#include "connections/implementation/analytics/operation_result_with_medium.h"
|
||||
#include "connections/payload_type.h"
|
||||
#include "connections/strategy.h"
|
||||
#include "internal/analytics/event_logger.h"
|
||||
#include "internal/platform/error_code_params.h"
|
||||
#include "internal/platform/implementation/system_clock.h"
|
||||
#include "internal/platform/mutex.h"
|
||||
#include "internal/proto/analytics/connections_log.pb.h"
|
||||
#include "proto/connections_enums.pb.h"
|
||||
|
||||
namespace nearby {
|
||||
namespace analytics {
|
||||
namespace nearby::analytics {
|
||||
|
||||
enum class SafeDisconnectionResult {
|
||||
kUnknown = 0,
|
||||
kSafeDisconnection = 1,
|
||||
kUnsafeDisconnection = 2,
|
||||
};
|
||||
|
||||
class AnalyticsRecorder {
|
||||
public:
|
||||
explicit AnalyticsRecorder(::nearby::analytics::EventLogger* event_logger);
|
||||
virtual ~AnalyticsRecorder();
|
||||
AnalyticsRecorder() = default;
|
||||
virtual ~AnalyticsRecorder() = default;
|
||||
|
||||
// Advertising phase
|
||||
void OnStartAdvertising(
|
||||
virtual void OnStartAdvertising(
|
||||
connections::Strategy strategy,
|
||||
const std::vector<location::nearby::proto::connections::Medium>& mediums,
|
||||
AdvertisingMetadataParams* advertising_metadata_params)
|
||||
ABSL_LOCKS_EXCLUDED(mutex_);
|
||||
void OnStopAdvertising() ABSL_LOCKS_EXCLUDED(mutex_);
|
||||
AdvertisingMetadataParams* advertising_metadata_params) = 0;
|
||||
virtual void OnStopAdvertising() = 0;
|
||||
|
||||
// In case the client calls the {@link BasePcp#updateAdvertisingOptions()}
|
||||
// multiple times, adds one index value to group the mediums results within
|
||||
// the same UpdateAdvertisingOptions call, this API is to return the largest
|
||||
// index value in current_advertising_phase.
|
||||
int GetNextAdvertisingUpdateIndex() ABSL_LOCKS_EXCLUDED(mutex_);
|
||||
virtual int GetNextAdvertisingUpdateIndex() = 0;
|
||||
|
||||
// Connection listening
|
||||
void OnStartedIncomingConnectionListening(connections::Strategy strategy)
|
||||
ABSL_LOCKS_EXCLUDED(mutex_);
|
||||
void OnStoppedIncomingConnectionListening() ABSL_LOCKS_EXCLUDED(mutex_);
|
||||
virtual void OnStartedIncomingConnectionListening(
|
||||
connections::Strategy strategy) = 0;
|
||||
virtual void OnStoppedIncomingConnectionListening() = 0;
|
||||
|
||||
// Discovery phase
|
||||
void OnStartDiscovery(
|
||||
virtual void OnStartDiscovery(
|
||||
connections::Strategy strategy,
|
||||
const std::vector<location::nearby::proto::connections::Medium>& mediums,
|
||||
DiscoveryMetadataParams* discovery_metadata_params)
|
||||
ABSL_LOCKS_EXCLUDED(mutex_);
|
||||
void OnStopDiscovery() ABSL_LOCKS_EXCLUDED(mutex_);
|
||||
DiscoveryMetadataParams* discovery_metadata_params) = 0;
|
||||
virtual void OnStopDiscovery() = 0;
|
||||
|
||||
// In case the client calls the {@link BasePcp#updateDiscoveryOptions()}
|
||||
// multiple times, adds one index value to group the medium results within the
|
||||
// same UpdateDiscoveryOptions call, this
|
||||
// API is to return the latest index value in current_discovery_phase.
|
||||
int GetNextDiscoveryUpdateIndex() ABSL_LOCKS_EXCLUDED(mutex_);
|
||||
void OnEndpointFound(location::nearby::proto::connections::Medium medium)
|
||||
ABSL_LOCKS_EXCLUDED(mutex_);
|
||||
virtual int GetNextDiscoveryUpdateIndex() = 0;
|
||||
virtual void OnEndpointFound(
|
||||
location::nearby::proto::connections::Medium medium) = 0;
|
||||
|
||||
// Connection request
|
||||
void OnRequestConnection(const connections::Strategy& strategy,
|
||||
const std::string& endpoint_id)
|
||||
ABSL_LOCKS_EXCLUDED(mutex_);
|
||||
virtual void OnRequestConnection(const connections::Strategy& strategy,
|
||||
const std::string& endpoint_id) = 0;
|
||||
|
||||
void OnConnectionRequestReceived(const std::string& remote_endpoint_id)
|
||||
ABSL_LOCKS_EXCLUDED(mutex_);
|
||||
void OnConnectionRequestSent(const std::string& remote_endpoint_id)
|
||||
ABSL_LOCKS_EXCLUDED(mutex_);
|
||||
void OnRemoteEndpointAccepted(const std::string& remote_endpoint_id)
|
||||
ABSL_LOCKS_EXCLUDED(mutex_);
|
||||
void OnLocalEndpointAccepted(const std::string& remote_endpoint_id)
|
||||
ABSL_LOCKS_EXCLUDED(mutex_);
|
||||
void OnRemoteEndpointRejected(const std::string& remote_endpoint_id)
|
||||
ABSL_LOCKS_EXCLUDED(mutex_);
|
||||
void OnLocalEndpointRejected(const std::string& remote_endpoint_id)
|
||||
ABSL_LOCKS_EXCLUDED(mutex_);
|
||||
virtual void OnConnectionRequestReceived(
|
||||
const std::string& remote_endpoint_id) = 0;
|
||||
virtual void OnConnectionRequestSent(
|
||||
const std::string& remote_endpoint_id) = 0;
|
||||
virtual void OnRemoteEndpointAccepted(
|
||||
const std::string& remote_endpoint_id) = 0;
|
||||
virtual void OnLocalEndpointAccepted(
|
||||
const std::string& remote_endpoint_id) = 0;
|
||||
virtual void OnRemoteEndpointRejected(
|
||||
const std::string& remote_endpoint_id) = 0;
|
||||
virtual void OnLocalEndpointRejected(
|
||||
const std::string& remote_endpoint_id) = 0;
|
||||
|
||||
// Connection attempt
|
||||
// Records an attempt with meta data at establishing an incoming physical
|
||||
// connection.
|
||||
void OnIncomingConnectionAttempt(
|
||||
virtual void OnIncomingConnectionAttempt(
|
||||
location::nearby::proto::connections::ConnectionAttemptType type,
|
||||
location::nearby::proto::connections::Medium medium,
|
||||
location::nearby::proto::connections::ConnectionAttemptResult result,
|
||||
absl::Duration duration, const std::string& connection_token,
|
||||
ConnectionAttemptMetadataParams* connection_attempt_metadata_params)
|
||||
ABSL_LOCKS_EXCLUDED(mutex_);
|
||||
// Records an attempt with meta data at establishing an outgoing physical
|
||||
// connection.
|
||||
void OnOutgoingConnectionAttempt(
|
||||
ConnectionAttemptMetadataParams* connection_attempt_metadata_params) = 0;
|
||||
virtual void OnOutgoingConnectionAttempt(
|
||||
const std::string& remote_endpoint_id,
|
||||
location::nearby::proto::connections::ConnectionAttemptType type,
|
||||
location::nearby::proto::connections::Medium medium,
|
||||
location::nearby::proto::connections::ConnectionAttemptResult result,
|
||||
absl::Duration duration, const std::string& connection_token,
|
||||
ConnectionAttemptMetadataParams* connection_attempt_metadata_params)
|
||||
ABSL_LOCKS_EXCLUDED(mutex_);
|
||||
ConnectionAttemptMetadataParams* connection_attempt_metadata_params) = 0;
|
||||
|
||||
static std::unique_ptr<AdvertisingMetadataParams>
|
||||
BuildAdvertisingMetadataParams(
|
||||
bool is_extended_advertisement_supported = false,
|
||||
int connected_ap_frequency = 0, bool is_nfc_available = false,
|
||||
const std::vector<location::nearby::analytics::proto::ConnectionsLog::
|
||||
OperationResultWithMedium>&
|
||||
const std::vector<OperationResultWithMedium>&
|
||||
operation_result_with_mediums = {});
|
||||
static std::unique_ptr<DiscoveryMetadataParams> BuildDiscoveryMetadataParams(
|
||||
bool is_extended_advertisement_supported = false,
|
||||
int connected_ap_frequency = 0, bool is_nfc_available = false,
|
||||
const std::vector<location::nearby::analytics::proto::ConnectionsLog::
|
||||
OperationResultWithMedium>&
|
||||
const std::vector<OperationResultWithMedium>&
|
||||
operation_result_with_mediums = {});
|
||||
|
||||
static std::unique_ptr<ConnectionAttemptMetadataParams>
|
||||
@@ -147,363 +127,78 @@ class AnalyticsRecorder {
|
||||
GetChannelIoErrorResultCodeFromMedium(
|
||||
location::nearby::proto::connections::Medium medium);
|
||||
|
||||
// Connection establishedSafeDisconnectionResult
|
||||
void OnConnectionEstablished(
|
||||
// Connection established
|
||||
virtual void OnConnectionEstablished(
|
||||
const std::string& endpoint_id,
|
||||
location::nearby::proto::connections::Medium medium,
|
||||
const std::string& connection_token) ABSL_LOCKS_EXCLUDED(mutex_);
|
||||
void OnConnectionClosed(
|
||||
const std::string& connection_token) = 0;
|
||||
virtual void OnConnectionClosed(
|
||||
const std::string& endpoint_id,
|
||||
location::nearby::proto::connections::Medium medium,
|
||||
location::nearby::proto::connections::DisconnectionReason reason,
|
||||
location::nearby::analytics::proto::ConnectionsLog::
|
||||
EstablishedConnection::SafeDisconnectionResult result)
|
||||
ABSL_LOCKS_EXCLUDED(mutex_);
|
||||
SafeDisconnectionResult result) = 0;
|
||||
|
||||
// Payload
|
||||
void OnIncomingPayloadStarted(const std::string& endpoint_id,
|
||||
std::int64_t payload_id,
|
||||
connections::PayloadType type,
|
||||
std::int64_t total_size_bytes)
|
||||
ABSL_LOCKS_EXCLUDED(mutex_);
|
||||
void OnPayloadChunkReceived(const std::string& endpoint_id,
|
||||
std::int64_t payload_id,
|
||||
std::int64_t chunk_size_bytes)
|
||||
ABSL_LOCKS_EXCLUDED(mutex_);
|
||||
void OnIncomingPayloadDone(
|
||||
virtual void OnIncomingPayloadStarted(const std::string& endpoint_id,
|
||||
std::int64_t payload_id,
|
||||
connections::PayloadType type,
|
||||
std::int64_t total_size_bytes) = 0;
|
||||
virtual void OnPayloadChunkReceived(const std::string& endpoint_id,
|
||||
std::int64_t payload_id,
|
||||
std::int64_t chunk_size_bytes) = 0;
|
||||
virtual void OnIncomingPayloadDone(
|
||||
const std::string& endpoint_id, std::int64_t payload_id,
|
||||
location::nearby::proto::connections::PayloadStatus status,
|
||||
location::nearby::proto::connections::OperationResultCode
|
||||
operation_result_code) ABSL_LOCKS_EXCLUDED(mutex_);
|
||||
void OnOutgoingPayloadStarted(const std::vector<std::string>& endpoint_ids,
|
||||
std::int64_t payload_id,
|
||||
connections::PayloadType type,
|
||||
std::int64_t total_size_bytes)
|
||||
ABSL_LOCKS_EXCLUDED(mutex_);
|
||||
void OnPayloadChunkSent(const std::string& endpoint_id,
|
||||
std::int64_t payload_id,
|
||||
std::int64_t chunk_size_bytes)
|
||||
ABSL_LOCKS_EXCLUDED(mutex_);
|
||||
void OnOutgoingPayloadDone(
|
||||
operation_result_code) = 0;
|
||||
virtual void OnOutgoingPayloadStarted(
|
||||
const std::vector<std::string>& endpoint_ids, std::int64_t payload_id,
|
||||
connections::PayloadType type, std::int64_t total_size_bytes) = 0;
|
||||
virtual void OnPayloadChunkSent(const std::string& endpoint_id,
|
||||
std::int64_t payload_id,
|
||||
std::int64_t chunk_size_bytes) = 0;
|
||||
virtual void OnOutgoingPayloadDone(
|
||||
const std::string& endpoint_id, std::int64_t payload_id,
|
||||
location::nearby::proto::connections::PayloadStatus status,
|
||||
location::nearby::proto::connections::OperationResultCode
|
||||
operation_result_code) ABSL_LOCKS_EXCLUDED(mutex_);
|
||||
operation_result_code) = 0;
|
||||
|
||||
// BandwidthUpgrade
|
||||
void OnBandwidthUpgradeStarted(
|
||||
virtual void OnBandwidthUpgradeStarted(
|
||||
const std::string& endpoint_id,
|
||||
location::nearby::proto::connections::Medium from_medium,
|
||||
location::nearby::proto::connections::Medium to_medium,
|
||||
location::nearby::proto::connections::ConnectionAttemptDirection
|
||||
direction,
|
||||
const std::string& connection_token) ABSL_LOCKS_EXCLUDED(mutex_);
|
||||
void UpdateBwUpgradeNetworkInfo(const std::string& endpoint_id,
|
||||
int num_interfaces,
|
||||
int num_ipv6_only_interfaces)
|
||||
ABSL_LOCKS_EXCLUDED(mutex_);
|
||||
void OnBandwidthUpgradeError(
|
||||
const std::string& connection_token) = 0;
|
||||
virtual void UpdateBwUpgradeNetworkInfo(const std::string& endpoint_id,
|
||||
int num_interfaces,
|
||||
int num_ipv6_only_interfaces) = 0;
|
||||
virtual void OnBandwidthUpgradeError(
|
||||
const std::string& endpoint_id,
|
||||
location::nearby::proto::connections::BandwidthUpgradeResult result,
|
||||
location::nearby::proto::connections::BandwidthUpgradeErrorStage
|
||||
error_stage,
|
||||
location::nearby::proto::connections::OperationResultCode
|
||||
operation_result_code) ABSL_LOCKS_EXCLUDED(mutex_);
|
||||
void OnBandwidthUpgradeSuccess(const std::string& endpoint_id)
|
||||
ABSL_LOCKS_EXCLUDED(mutex_);
|
||||
operation_result_code) = 0;
|
||||
virtual void OnBandwidthUpgradeSuccess(const std::string& endpoint_id) = 0;
|
||||
|
||||
// Error Code
|
||||
void OnErrorCode(const ErrorCodeParams& params);
|
||||
virtual void OnErrorCode(const ErrorCodeParams& params) = 0;
|
||||
|
||||
// Log the start client session event with start client session logging
|
||||
// resources setup (e.g. client_session_, started_client_session_time_)
|
||||
void LogStartSession() ABSL_LOCKS_EXCLUDED(mutex_);
|
||||
virtual void LogStartSession() = 0;
|
||||
virtual void LogSession() = 0;
|
||||
|
||||
// Invokes event_logger_.Log() at the end of life of client. Log action is
|
||||
// called in a separate thread to allow synchronous potentially lengthy
|
||||
// execution.
|
||||
void LogSession() ABSL_LOCKS_EXCLUDED(mutex_);
|
||||
virtual bool IsSessionLogged() = 0;
|
||||
|
||||
bool IsSessionLogged();
|
||||
|
||||
location::nearby::proto::connections::OperationResultCategory
|
||||
virtual location::nearby::proto::connections::OperationResultCategory
|
||||
GetOperationResultCategory(
|
||||
location::nearby::proto::connections::OperationResultCode result_code);
|
||||
|
||||
// Waits until all logs are sent to the backend.
|
||||
// For testing only.
|
||||
void Sync();
|
||||
|
||||
private:
|
||||
// Tracks the chunks and duration of a Payload on a particular medium.
|
||||
class PendingPayload {
|
||||
public:
|
||||
PendingPayload(location::nearby::proto::connections::PayloadType type,
|
||||
std::int64_t total_size_bytes)
|
||||
: PendingPayload(type, total_size_bytes,
|
||||
location::nearby::proto::connections::
|
||||
OperationResultCode::DETAIL_UNKNOWN) {}
|
||||
PendingPayload(location::nearby::proto::connections::PayloadType type,
|
||||
std::int64_t total_size_bytes,
|
||||
location::nearby::proto::connections::OperationResultCode
|
||||
operation_result_code)
|
||||
: start_time_(SystemClock::ElapsedRealtime()),
|
||||
type_(type),
|
||||
total_size_bytes_(total_size_bytes),
|
||||
num_bytes_transferred_(0),
|
||||
num_chunks_(0),
|
||||
operation_result_code_(operation_result_code) {}
|
||||
~PendingPayload() = default;
|
||||
|
||||
void AddChunk(std::int64_t chunk_size_bytes);
|
||||
|
||||
location::nearby::analytics::proto::ConnectionsLog::Payload GetProtoPayload(
|
||||
location::nearby::proto::connections::PayloadStatus status);
|
||||
|
||||
location::nearby::proto::connections::PayloadType type() const {
|
||||
return type_;
|
||||
}
|
||||
|
||||
std::int64_t total_size_bytes() const { return total_size_bytes_; }
|
||||
|
||||
void SetOperationResultCode(
|
||||
location::nearby::proto::connections::OperationResultCode
|
||||
operation_result_code) {
|
||||
operation_result_code_ = operation_result_code;
|
||||
}
|
||||
|
||||
private:
|
||||
absl::Time start_time_;
|
||||
location::nearby::proto::connections::PayloadType type_;
|
||||
std::int64_t total_size_bytes_;
|
||||
std::int64_t num_bytes_transferred_;
|
||||
int num_chunks_;
|
||||
location::nearby::proto::connections::OperationResultCode
|
||||
operation_result_code_ = location::nearby::proto::connections::
|
||||
OperationResultCode::DETAIL_UNKNOWN;
|
||||
};
|
||||
|
||||
class LogicalConnection {
|
||||
public:
|
||||
LogicalConnection(
|
||||
location::nearby::proto::connections::Medium initial_medium,
|
||||
const std::string& connection_token) {
|
||||
PhysicalConnectionEstablished(initial_medium, connection_token);
|
||||
}
|
||||
LogicalConnection(const LogicalConnection&) = delete;
|
||||
LogicalConnection(LogicalConnection&& other)
|
||||
: current_medium_(std::move(other.current_medium_)),
|
||||
physical_connections_(std::move(other.physical_connections_)),
|
||||
incoming_payloads_(std::move(other.incoming_payloads_)),
|
||||
outgoing_payloads_(std::move(other.outgoing_payloads_)) {}
|
||||
LogicalConnection& operator=(const LogicalConnection&) = delete;
|
||||
LogicalConnection&& operator=(LogicalConnection&&) = delete;
|
||||
~LogicalConnection() = default;
|
||||
|
||||
void PhysicalConnectionEstablished(
|
||||
location::nearby::proto::connections::Medium medium,
|
||||
const std::string& connection_token);
|
||||
void PhysicalConnectionClosed(
|
||||
location::nearby::proto::connections::Medium medium,
|
||||
location::nearby::proto::connections::DisconnectionReason reason,
|
||||
location::nearby::analytics::proto::ConnectionsLog::
|
||||
EstablishedConnection::SafeDisconnectionResult result);
|
||||
void CloseAllPhysicalConnections();
|
||||
|
||||
void IncomingPayloadStarted(
|
||||
std::int64_t payload_id,
|
||||
location::nearby::proto::connections::PayloadType type,
|
||||
std::int64_t total_size_bytes);
|
||||
void ChunkReceived(std::int64_t payload_id, std::int64_t size_bytes);
|
||||
void IncomingPayloadDone(
|
||||
std::int64_t payload_id,
|
||||
location::nearby::proto::connections::PayloadStatus status,
|
||||
location::nearby::proto::connections::OperationResultCode
|
||||
operation_result_code);
|
||||
void OutgoingPayloadStarted(
|
||||
std::int64_t payload_id,
|
||||
location::nearby::proto::connections::PayloadType type,
|
||||
std::int64_t total_size_bytes);
|
||||
void ChunkSent(std::int64_t payload_id, std::int64_t size_bytes);
|
||||
void OutgoingPayloadDone(
|
||||
std::int64_t payload_id,
|
||||
location::nearby::proto::connections::PayloadStatus status,
|
||||
location::nearby::proto::connections::OperationResultCode
|
||||
operation_result_code);
|
||||
|
||||
std::vector<location::nearby::analytics::proto::ConnectionsLog::
|
||||
EstablishedConnection>
|
||||
GetEstablisedConnections();
|
||||
|
||||
private:
|
||||
void FinishPhysicalConnection(
|
||||
location::nearby::analytics::proto::ConnectionsLog::
|
||||
EstablishedConnection* established_connection,
|
||||
location::nearby::proto::connections::DisconnectionReason reason,
|
||||
location::nearby::analytics::proto::ConnectionsLog::
|
||||
EstablishedConnection::SafeDisconnectionResult result);
|
||||
std::vector<location::nearby::analytics::proto::ConnectionsLog::Payload>
|
||||
ResolvePendingPayloads(
|
||||
absl::btree_map<std::int64_t, std::unique_ptr<PendingPayload>>&
|
||||
pending_payloads,
|
||||
location::nearby::proto::connections::DisconnectionReason reason);
|
||||
location::nearby::proto::connections::OperationResultCode
|
||||
GetPendingPayloadResultCodeFromReason(
|
||||
location::nearby::proto::connections::DisconnectionReason reason);
|
||||
|
||||
location::nearby::proto::connections::Medium current_medium_ =
|
||||
location::nearby::proto::connections::UNKNOWN_MEDIUM;
|
||||
absl::btree_map<location::nearby::proto::connections::Medium,
|
||||
std::unique_ptr<location::nearby::analytics::proto::
|
||||
ConnectionsLog::EstablishedConnection>>
|
||||
physical_connections_;
|
||||
absl::btree_map<std::int64_t, std::unique_ptr<PendingPayload>>
|
||||
incoming_payloads_;
|
||||
absl::btree_map<std::int64_t, std::unique_ptr<PendingPayload>>
|
||||
outgoing_payloads_;
|
||||
};
|
||||
|
||||
bool CanRecordAnalyticsLocked(absl::string_view method_name)
|
||||
ABSL_SHARED_LOCKS_REQUIRED(mutex_);
|
||||
|
||||
// Callbacks the ConnectionsLog proto byte array data to the EventLogger with
|
||||
// ClientSession sub-proto.
|
||||
void LogClientSessionLocked() ABSL_EXCLUSIVE_LOCKS_REQUIRED(mutex_);
|
||||
// Callbacks the ConnectionsLog proto byte array data to the EventLogger.
|
||||
void LogEvent(location::nearby::proto::connections::EventType event_type);
|
||||
|
||||
void UpdateStrategySessionLocked(
|
||||
connections::Strategy strategy,
|
||||
location::nearby::proto::connections::SessionRole role)
|
||||
ABSL_EXCLUSIVE_LOCKS_REQUIRED(mutex_);
|
||||
void RecordAdvertisingPhaseDurationAndReasonLocked(bool on_stop) const
|
||||
ABSL_SHARED_LOCKS_REQUIRED(mutex_);
|
||||
void FinishAdvertisingPhaseLocked() ABSL_EXCLUSIVE_LOCKS_REQUIRED(mutex_);
|
||||
void RecordDiscoveryPhaseDurationAndReasonLocked(bool on_stop) const
|
||||
ABSL_SHARED_LOCKS_REQUIRED(mutex_);
|
||||
void FinishDiscoveryPhaseLocked() ABSL_EXCLUSIVE_LOCKS_REQUIRED(mutex_);
|
||||
bool UpdateAdvertiserConnectionRequestLocked(
|
||||
location::nearby::analytics::proto::ConnectionsLog::ConnectionRequest*
|
||||
request) ABSL_SHARED_LOCKS_REQUIRED(mutex_);
|
||||
bool UpdateDiscovererConnectionRequestLocked(
|
||||
location::nearby::analytics::proto::ConnectionsLog::ConnectionRequest*
|
||||
request) ABSL_SHARED_LOCKS_REQUIRED(mutex_);
|
||||
bool BothEndpointsRespondedLocked(
|
||||
location::nearby::analytics::proto::ConnectionsLog::ConnectionRequest*
|
||||
request) ABSL_SHARED_LOCKS_REQUIRED(mutex_);
|
||||
void LocalEndpointRespondedLocked(
|
||||
const std::string& remote_endpoint_id,
|
||||
location::nearby::proto::connections::ConnectionRequestResponse response)
|
||||
ABSL_EXCLUSIVE_LOCKS_REQUIRED(mutex_);
|
||||
void RemoteEndpointRespondedLocked(
|
||||
const std::string& remote_endpoint_id,
|
||||
location::nearby::proto::connections::ConnectionRequestResponse response)
|
||||
ABSL_EXCLUSIVE_LOCKS_REQUIRED(mutex_);
|
||||
void MarkConnectionRequestIgnoredLocked(
|
||||
location::nearby::analytics::proto::ConnectionsLog::ConnectionRequest*
|
||||
request) ABSL_SHARED_LOCKS_REQUIRED(mutex_);
|
||||
void OnIncomingConnectionAttemptLocked(
|
||||
location::nearby::proto::connections::ConnectionAttemptType type,
|
||||
location::nearby::proto::connections::Medium medium,
|
||||
location::nearby::proto::connections::ConnectionAttemptResult result,
|
||||
absl::Duration duration, const std::string& connection_token,
|
||||
ConnectionAttemptMetadataParams* connection_attempt_metadata_params)
|
||||
ABSL_SHARED_LOCKS_REQUIRED(mutex_);
|
||||
void OnOutgoingConnectionAttemptLocked(
|
||||
const std::string& remote_endpoint_id,
|
||||
location::nearby::proto::connections::ConnectionAttemptType type,
|
||||
location::nearby::proto::connections::Medium medium,
|
||||
location::nearby::proto::connections::ConnectionAttemptResult result,
|
||||
absl::Duration duration, const std::string& connection_token,
|
||||
ConnectionAttemptMetadataParams* connection_attempt_metadata_params)
|
||||
ABSL_SHARED_LOCKS_REQUIRED(mutex_);
|
||||
bool ConnectionAttemptResultCodeExistedLocked(
|
||||
location::nearby::proto::connections::Medium medium,
|
||||
location::nearby::proto::connections::ConnectionAttemptDirection
|
||||
direction,
|
||||
const std::string& connection_token,
|
||||
location::nearby::proto::connections::ConnectionAttemptType type,
|
||||
location::nearby::proto::connections::OperationResultCode
|
||||
operation_result_code) ABSL_SHARED_LOCKS_REQUIRED(mutex_);
|
||||
bool EraseIfBandwidthUpgradeRecordExistedLocked(
|
||||
const std::string& endpoint_id,
|
||||
location::nearby::proto::connections::BandwidthUpgradeResult result,
|
||||
location::nearby::proto::connections::BandwidthUpgradeErrorStage
|
||||
error_stage,
|
||||
location::nearby::proto::connections::OperationResultCode
|
||||
operation_result_code) ABSL_SHARED_LOCKS_REQUIRED(mutex_);
|
||||
void FinishUpgradeAttemptLocked(
|
||||
const std::string& endpoint_id,
|
||||
location::nearby::proto::connections::BandwidthUpgradeResult result,
|
||||
location::nearby::proto::connections::BandwidthUpgradeErrorStage
|
||||
error_stage,
|
||||
location::nearby::proto::connections::OperationResultCode
|
||||
operation_result_code,
|
||||
bool erase_item = true) ABSL_SHARED_LOCKS_REQUIRED(mutex_);
|
||||
void FinishStrategySessionLocked() ABSL_EXCLUSIVE_LOCKS_REQUIRED(mutex_);
|
||||
result_code) = 0;
|
||||
|
||||
int GetLatestUpdateIndexLocked(
|
||||
const std::vector<location::nearby::analytics::proto::ConnectionsLog::
|
||||
OperationResultWithMedium>& list)
|
||||
ABSL_EXCLUSIVE_LOCKS_REQUIRED(mutex_);
|
||||
|
||||
location::nearby::proto::connections::ConnectionsStrategy
|
||||
StrategyToConnectionStrategy(connections::Strategy strategy);
|
||||
location::nearby::proto::connections::PayloadType
|
||||
PayloadTypeToProtoPayloadType(connections::PayloadType type);
|
||||
|
||||
// Not owned by AnalyticsRecorder. Pointer must refer to a valid object
|
||||
// that outlives the one constructed.
|
||||
::nearby::analytics::EventLogger* event_logger_;
|
||||
|
||||
// Protects all sub-protos reading and writing in ConnectionLog.
|
||||
Mutex mutex_;
|
||||
|
||||
// ClientSession
|
||||
std::unique_ptr<
|
||||
location::nearby::analytics::proto::ConnectionsLog::ClientSession>
|
||||
client_session_;
|
||||
absl::Time started_client_session_time_;
|
||||
bool session_was_logged_ ABSL_GUARDED_BY(mutex_) = false;
|
||||
bool start_client_session_was_logged_ ABSL_GUARDED_BY(mutex_) = false;
|
||||
|
||||
// Current StrategySession
|
||||
connections::Strategy current_strategy_ ABSL_GUARDED_BY(mutex_) =
|
||||
connections::Strategy::kNone;
|
||||
std::unique_ptr<
|
||||
location::nearby::analytics::proto::ConnectionsLog::StrategySession>
|
||||
current_strategy_session_ ABSL_GUARDED_BY(mutex_);
|
||||
absl::Time started_strategy_session_time_ ABSL_GUARDED_BY(mutex_);
|
||||
|
||||
// Current AdvertisingPhase
|
||||
std::unique_ptr<
|
||||
location::nearby::analytics::proto::ConnectionsLog::AdvertisingPhase>
|
||||
current_advertising_phase_;
|
||||
absl::Time started_advertising_phase_time_ = absl::InfinitePast();
|
||||
|
||||
// Current DiscoveryPhase
|
||||
std::unique_ptr<
|
||||
location::nearby::analytics::proto::ConnectionsLog::DiscoveryPhase>
|
||||
current_discovery_phase_;
|
||||
absl::Time started_discovery_phase_time_ = absl::InfinitePast();
|
||||
|
||||
absl::btree_map<std::string,
|
||||
std::unique_ptr<location::nearby::analytics::proto::
|
||||
ConnectionsLog::ConnectionRequest>>
|
||||
incoming_connection_requests_ ABSL_GUARDED_BY(mutex_);
|
||||
absl::btree_map<std::string,
|
||||
std::unique_ptr<location::nearby::analytics::proto::
|
||||
ConnectionsLog::ConnectionRequest>>
|
||||
outgoing_connection_requests_ ABSL_GUARDED_BY(mutex_);
|
||||
absl::btree_map<std::string, std::unique_ptr<LogicalConnection>>
|
||||
active_connections_ ABSL_GUARDED_BY(mutex_);
|
||||
absl::btree_map<std::string,
|
||||
std::unique_ptr<location::nearby::analytics::proto::
|
||||
ConnectionsLog::BandwidthUpgradeAttempt>>
|
||||
bandwidth_upgrade_attempts_ ABSL_GUARDED_BY(mutex_);
|
||||
virtual void Sync() = 0;
|
||||
};
|
||||
|
||||
} // namespace analytics
|
||||
} // namespace nearby
|
||||
} // namespace nearby::analytics
|
||||
|
||||
#endif // ANALYTICS_ANALYTICS_RECORDER_H_
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,459 @@
|
||||
// Copyright 2022-2023 Google LLC
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// https://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
#ifndef ANALYTICS_ANALYTICS_RECORDER_IMPL_H_
|
||||
#define ANALYTICS_ANALYTICS_RECORDER_IMPL_H_
|
||||
|
||||
#include <cstdint>
|
||||
#include <memory>
|
||||
#include <string>
|
||||
#include <utility>
|
||||
#include <vector>
|
||||
|
||||
#include "absl/base/thread_annotations.h"
|
||||
#include "absl/container/btree_map.h"
|
||||
#include "absl/strings/string_view.h"
|
||||
#include "absl/time/time.h"
|
||||
#include "connections/implementation/analytics/advertising_metadata_params.h"
|
||||
#include "connections/implementation/analytics/analytics_recorder.h"
|
||||
#include "connections/implementation/analytics/connection_attempt_metadata_params.h"
|
||||
#include "connections/implementation/analytics/discovery_metadata_params.h"
|
||||
#include "connections/payload_type.h"
|
||||
#include "connections/strategy.h"
|
||||
#include "internal/analytics/event_logger.h"
|
||||
#include "internal/platform/error_code_params.h"
|
||||
#include "internal/platform/implementation/system_clock.h"
|
||||
#include "internal/platform/mutex.h"
|
||||
#include "internal/proto/analytics/connections_log.pb.h"
|
||||
#include "proto/connections_enums.pb.h"
|
||||
|
||||
namespace nearby::analytics {
|
||||
|
||||
class AnalyticsRecorderImpl : public AnalyticsRecorder {
|
||||
public:
|
||||
explicit AnalyticsRecorderImpl(
|
||||
::nearby::analytics::EventLogger* event_logger);
|
||||
~AnalyticsRecorderImpl() override;
|
||||
|
||||
// Advertising phase
|
||||
void OnStartAdvertising(
|
||||
connections::Strategy strategy,
|
||||
const std::vector<location::nearby::proto::connections::Medium>& mediums,
|
||||
AdvertisingMetadataParams* advertising_metadata_params) override
|
||||
ABSL_LOCKS_EXCLUDED(mutex_);
|
||||
void OnStopAdvertising() override ABSL_LOCKS_EXCLUDED(mutex_);
|
||||
|
||||
int GetNextAdvertisingUpdateIndex() override ABSL_LOCKS_EXCLUDED(mutex_);
|
||||
|
||||
// Connection listening
|
||||
void OnStartedIncomingConnectionListening(
|
||||
connections::Strategy strategy) override ABSL_LOCKS_EXCLUDED(mutex_);
|
||||
void OnStoppedIncomingConnectionListening() override
|
||||
ABSL_LOCKS_EXCLUDED(mutex_);
|
||||
|
||||
// Discovery phase
|
||||
void OnStartDiscovery(
|
||||
connections::Strategy strategy,
|
||||
const std::vector<location::nearby::proto::connections::Medium>& mediums,
|
||||
DiscoveryMetadataParams* discovery_metadata_params) override
|
||||
ABSL_LOCKS_EXCLUDED(mutex_);
|
||||
void OnStopDiscovery() override ABSL_LOCKS_EXCLUDED(mutex_);
|
||||
|
||||
int GetNextDiscoveryUpdateIndex() override ABSL_LOCKS_EXCLUDED(mutex_);
|
||||
void OnEndpointFound(location::nearby::proto::connections::Medium medium)
|
||||
override ABSL_LOCKS_EXCLUDED(mutex_);
|
||||
|
||||
// Connection request
|
||||
void OnRequestConnection(const connections::Strategy& strategy,
|
||||
const std::string& endpoint_id) override
|
||||
ABSL_LOCKS_EXCLUDED(mutex_);
|
||||
|
||||
void OnConnectionRequestReceived(const std::string& remote_endpoint_id)
|
||||
override ABSL_LOCKS_EXCLUDED(mutex_);
|
||||
void OnConnectionRequestSent(const std::string& remote_endpoint_id) override
|
||||
ABSL_LOCKS_EXCLUDED(mutex_);
|
||||
void OnRemoteEndpointAccepted(const std::string& remote_endpoint_id) override
|
||||
ABSL_LOCKS_EXCLUDED(mutex_);
|
||||
void OnLocalEndpointAccepted(const std::string& remote_endpoint_id) override
|
||||
ABSL_LOCKS_EXCLUDED(mutex_);
|
||||
void OnRemoteEndpointRejected(const std::string& remote_endpoint_id) override
|
||||
ABSL_LOCKS_EXCLUDED(mutex_);
|
||||
void OnLocalEndpointRejected(const std::string& remote_endpoint_id) override
|
||||
ABSL_LOCKS_EXCLUDED(mutex_);
|
||||
|
||||
// Connection attempt
|
||||
void OnIncomingConnectionAttempt(
|
||||
location::nearby::proto::connections::ConnectionAttemptType type,
|
||||
location::nearby::proto::connections::Medium medium,
|
||||
location::nearby::proto::connections::ConnectionAttemptResult result,
|
||||
absl::Duration duration, const std::string& connection_token,
|
||||
ConnectionAttemptMetadataParams* connection_attempt_metadata_params)
|
||||
override ABSL_LOCKS_EXCLUDED(mutex_);
|
||||
void OnOutgoingConnectionAttempt(
|
||||
const std::string& remote_endpoint_id,
|
||||
location::nearby::proto::connections::ConnectionAttemptType type,
|
||||
location::nearby::proto::connections::Medium medium,
|
||||
location::nearby::proto::connections::ConnectionAttemptResult result,
|
||||
absl::Duration duration, const std::string& connection_token,
|
||||
ConnectionAttemptMetadataParams* connection_attempt_metadata_params)
|
||||
override ABSL_LOCKS_EXCLUDED(mutex_);
|
||||
|
||||
// Connection established
|
||||
void OnConnectionEstablished(
|
||||
const std::string& endpoint_id,
|
||||
location::nearby::proto::connections::Medium medium,
|
||||
const std::string& connection_token) override ABSL_LOCKS_EXCLUDED(mutex_);
|
||||
void OnConnectionClosed(
|
||||
const std::string& endpoint_id,
|
||||
location::nearby::proto::connections::Medium medium,
|
||||
location::nearby::proto::connections::DisconnectionReason reason,
|
||||
SafeDisconnectionResult result) override ABSL_LOCKS_EXCLUDED(mutex_);
|
||||
|
||||
// Payload
|
||||
void OnIncomingPayloadStarted(const std::string& endpoint_id,
|
||||
std::int64_t payload_id,
|
||||
connections::PayloadType type,
|
||||
std::int64_t total_size_bytes) override
|
||||
ABSL_LOCKS_EXCLUDED(mutex_);
|
||||
void OnPayloadChunkReceived(const std::string& endpoint_id,
|
||||
std::int64_t payload_id,
|
||||
std::int64_t chunk_size_bytes) override
|
||||
ABSL_LOCKS_EXCLUDED(mutex_);
|
||||
void OnIncomingPayloadDone(
|
||||
const std::string& endpoint_id, std::int64_t payload_id,
|
||||
location::nearby::proto::connections::PayloadStatus status,
|
||||
location::nearby::proto::connections::OperationResultCode
|
||||
operation_result_code) override ABSL_LOCKS_EXCLUDED(mutex_);
|
||||
void OnOutgoingPayloadStarted(const std::vector<std::string>& endpoint_ids,
|
||||
std::int64_t payload_id,
|
||||
connections::PayloadType type,
|
||||
std::int64_t total_size_bytes) override
|
||||
ABSL_LOCKS_EXCLUDED(mutex_);
|
||||
void OnPayloadChunkSent(const std::string& endpoint_id,
|
||||
std::int64_t payload_id,
|
||||
std::int64_t chunk_size_bytes) override
|
||||
ABSL_LOCKS_EXCLUDED(mutex_);
|
||||
void OnOutgoingPayloadDone(
|
||||
const std::string& endpoint_id, std::int64_t payload_id,
|
||||
location::nearby::proto::connections::PayloadStatus status,
|
||||
location::nearby::proto::connections::OperationResultCode
|
||||
operation_result_code) override ABSL_LOCKS_EXCLUDED(mutex_);
|
||||
|
||||
// BandwidthUpgrade
|
||||
void OnBandwidthUpgradeStarted(
|
||||
const std::string& endpoint_id,
|
||||
location::nearby::proto::connections::Medium from_medium,
|
||||
location::nearby::proto::connections::Medium to_medium,
|
||||
location::nearby::proto::connections::ConnectionAttemptDirection
|
||||
direction,
|
||||
const std::string& connection_token) override ABSL_LOCKS_EXCLUDED(mutex_);
|
||||
void UpdateBwUpgradeNetworkInfo(const std::string& endpoint_id,
|
||||
int num_interfaces,
|
||||
int num_ipv6_only_interfaces) override
|
||||
ABSL_LOCKS_EXCLUDED(mutex_);
|
||||
void OnBandwidthUpgradeError(
|
||||
const std::string& endpoint_id,
|
||||
location::nearby::proto::connections::BandwidthUpgradeResult result,
|
||||
location::nearby::proto::connections::BandwidthUpgradeErrorStage
|
||||
error_stage,
|
||||
location::nearby::proto::connections::OperationResultCode
|
||||
operation_result_code) override ABSL_LOCKS_EXCLUDED(mutex_);
|
||||
void OnBandwidthUpgradeSuccess(const std::string& endpoint_id) override
|
||||
ABSL_LOCKS_EXCLUDED(mutex_);
|
||||
|
||||
// Error Code
|
||||
void OnErrorCode(const ErrorCodeParams& params) override;
|
||||
|
||||
void LogStartSession() override ABSL_LOCKS_EXCLUDED(mutex_);
|
||||
void LogSession() override ABSL_LOCKS_EXCLUDED(mutex_);
|
||||
|
||||
bool IsSessionLogged() override;
|
||||
|
||||
location::nearby::proto::connections::OperationResultCategory
|
||||
GetOperationResultCategory(
|
||||
location::nearby::proto::connections::OperationResultCode result_code)
|
||||
override;
|
||||
|
||||
void Sync() override;
|
||||
|
||||
private:
|
||||
// Tracks the chunks and duration of a Payload on a particular medium.
|
||||
class PendingPayload {
|
||||
public:
|
||||
PendingPayload(location::nearby::proto::connections::PayloadType type,
|
||||
std::int64_t total_size_bytes)
|
||||
: PendingPayload(type, total_size_bytes,
|
||||
location::nearby::proto::connections::
|
||||
OperationResultCode::DETAIL_UNKNOWN) {}
|
||||
PendingPayload(location::nearby::proto::connections::PayloadType type,
|
||||
std::int64_t total_size_bytes,
|
||||
location::nearby::proto::connections::OperationResultCode
|
||||
operation_result_code)
|
||||
: start_time_(SystemClock::ElapsedRealtime()),
|
||||
type_(type),
|
||||
total_size_bytes_(total_size_bytes),
|
||||
num_bytes_transferred_(0),
|
||||
num_chunks_(0),
|
||||
operation_result_code_(operation_result_code) {}
|
||||
~PendingPayload() = default;
|
||||
|
||||
void AddChunk(std::int64_t chunk_size_bytes);
|
||||
|
||||
location::nearby::analytics::proto::ConnectionsLog::Payload GetProtoPayload(
|
||||
location::nearby::proto::connections::PayloadStatus status);
|
||||
|
||||
location::nearby::proto::connections::PayloadType type() const {
|
||||
return type_;
|
||||
}
|
||||
|
||||
std::int64_t total_size_bytes() const { return total_size_bytes_; }
|
||||
|
||||
void SetOperationResultCode(
|
||||
location::nearby::proto::connections::OperationResultCode
|
||||
operation_result_code) {
|
||||
operation_result_code_ = operation_result_code;
|
||||
}
|
||||
|
||||
private:
|
||||
absl::Time start_time_;
|
||||
location::nearby::proto::connections::PayloadType type_;
|
||||
std::int64_t total_size_bytes_;
|
||||
std::int64_t num_bytes_transferred_;
|
||||
int num_chunks_;
|
||||
location::nearby::proto::connections::OperationResultCode
|
||||
operation_result_code_ = location::nearby::proto::connections::
|
||||
OperationResultCode::DETAIL_UNKNOWN;
|
||||
};
|
||||
|
||||
class LogicalConnection {
|
||||
public:
|
||||
LogicalConnection(
|
||||
location::nearby::proto::connections::Medium initial_medium,
|
||||
const std::string& connection_token) {
|
||||
PhysicalConnectionEstablished(initial_medium, connection_token);
|
||||
}
|
||||
LogicalConnection(const LogicalConnection&) = delete;
|
||||
LogicalConnection(LogicalConnection&& other)
|
||||
: current_medium_(std::move(other.current_medium_)),
|
||||
physical_connections_(std::move(other.physical_connections_)),
|
||||
incoming_payloads_(std::move(other.incoming_payloads_)),
|
||||
outgoing_payloads_(std::move(other.outgoing_payloads_)) {}
|
||||
LogicalConnection& operator=(const LogicalConnection&) = delete;
|
||||
LogicalConnection&& operator=(LogicalConnection&&) = delete;
|
||||
~LogicalConnection() = default;
|
||||
|
||||
void PhysicalConnectionEstablished(
|
||||
location::nearby::proto::connections::Medium medium,
|
||||
const std::string& connection_token);
|
||||
void PhysicalConnectionClosed(
|
||||
location::nearby::proto::connections::Medium medium,
|
||||
location::nearby::proto::connections::DisconnectionReason reason,
|
||||
SafeDisconnectionResult result);
|
||||
void CloseAllPhysicalConnections();
|
||||
|
||||
void IncomingPayloadStarted(
|
||||
std::int64_t payload_id,
|
||||
location::nearby::proto::connections::PayloadType type,
|
||||
std::int64_t total_size_bytes);
|
||||
void ChunkReceived(std::int64_t payload_id, std::int64_t size_bytes);
|
||||
void IncomingPayloadDone(
|
||||
std::int64_t payload_id,
|
||||
location::nearby::proto::connections::PayloadStatus status,
|
||||
location::nearby::proto::connections::OperationResultCode
|
||||
operation_result_code);
|
||||
void OutgoingPayloadStarted(
|
||||
std::int64_t payload_id,
|
||||
location::nearby::proto::connections::PayloadType type,
|
||||
std::int64_t total_size_bytes);
|
||||
void ChunkSent(std::int64_t payload_id, std::int64_t size_bytes);
|
||||
void OutgoingPayloadDone(
|
||||
std::int64_t payload_id,
|
||||
location::nearby::proto::connections::PayloadStatus status,
|
||||
location::nearby::proto::connections::OperationResultCode
|
||||
operation_result_code);
|
||||
|
||||
std::vector<location::nearby::analytics::proto::ConnectionsLog::
|
||||
EstablishedConnection>
|
||||
GetEstablisedConnections();
|
||||
|
||||
private:
|
||||
void FinishPhysicalConnection(
|
||||
location::nearby::analytics::proto::ConnectionsLog::
|
||||
EstablishedConnection* established_connection,
|
||||
location::nearby::proto::connections::DisconnectionReason reason,
|
||||
SafeDisconnectionResult result);
|
||||
std::vector<location::nearby::analytics::proto::ConnectionsLog::Payload>
|
||||
ResolvePendingPayloads(
|
||||
absl::btree_map<std::int64_t, std::unique_ptr<PendingPayload>>&
|
||||
pending_payloads,
|
||||
location::nearby::proto::connections::DisconnectionReason reason);
|
||||
location::nearby::proto::connections::OperationResultCode
|
||||
GetPendingPayloadResultCodeFromReason(
|
||||
location::nearby::proto::connections::DisconnectionReason reason);
|
||||
|
||||
location::nearby::proto::connections::Medium current_medium_ =
|
||||
location::nearby::proto::connections::UNKNOWN_MEDIUM;
|
||||
absl::btree_map<location::nearby::proto::connections::Medium,
|
||||
std::unique_ptr<location::nearby::analytics::proto::
|
||||
ConnectionsLog::EstablishedConnection>>
|
||||
physical_connections_;
|
||||
absl::btree_map<std::int64_t, std::unique_ptr<PendingPayload>>
|
||||
incoming_payloads_;
|
||||
absl::btree_map<std::int64_t, std::unique_ptr<PendingPayload>>
|
||||
outgoing_payloads_;
|
||||
};
|
||||
|
||||
bool CanRecordAnalyticsLocked(absl::string_view method_name)
|
||||
ABSL_SHARED_LOCKS_REQUIRED(mutex_);
|
||||
|
||||
// Callbacks the ConnectionsLog proto byte array data to the EventLogger with
|
||||
// ClientSession sub-proto.
|
||||
void LogClientSessionLocked() ABSL_EXCLUSIVE_LOCKS_REQUIRED(mutex_);
|
||||
// Callbacks the ConnectionsLog proto byte array data to the EventLogger.
|
||||
void LogEvent(location::nearby::proto::connections::EventType event_type);
|
||||
|
||||
void UpdateStrategySessionLocked(
|
||||
connections::Strategy strategy,
|
||||
location::nearby::proto::connections::SessionRole role)
|
||||
ABSL_EXCLUSIVE_LOCKS_REQUIRED(mutex_);
|
||||
void RecordAdvertisingPhaseDurationAndReasonLocked(bool on_stop) const
|
||||
ABSL_SHARED_LOCKS_REQUIRED(mutex_);
|
||||
void FinishAdvertisingPhaseLocked() ABSL_EXCLUSIVE_LOCKS_REQUIRED(mutex_);
|
||||
void RecordDiscoveryPhaseDurationAndReasonLocked(bool on_stop) const
|
||||
ABSL_SHARED_LOCKS_REQUIRED(mutex_);
|
||||
void FinishDiscoveryPhaseLocked() ABSL_EXCLUSIVE_LOCKS_REQUIRED(mutex_);
|
||||
bool UpdateAdvertiserConnectionRequestLocked(
|
||||
location::nearby::analytics::proto::ConnectionsLog::ConnectionRequest*
|
||||
request) ABSL_SHARED_LOCKS_REQUIRED(mutex_);
|
||||
bool UpdateDiscovererConnectionRequestLocked(
|
||||
location::nearby::analytics::proto::ConnectionsLog::ConnectionRequest*
|
||||
request) ABSL_SHARED_LOCKS_REQUIRED(mutex_);
|
||||
bool BothEndpointsRespondedLocked(
|
||||
location::nearby::analytics::proto::ConnectionsLog::ConnectionRequest*
|
||||
request) ABSL_SHARED_LOCKS_REQUIRED(mutex_);
|
||||
void LocalEndpointRespondedLocked(
|
||||
const std::string& remote_endpoint_id,
|
||||
location::nearby::proto::connections::ConnectionRequestResponse response)
|
||||
ABSL_EXCLUSIVE_LOCKS_REQUIRED(mutex_);
|
||||
void RemoteEndpointRespondedLocked(
|
||||
const std::string& remote_endpoint_id,
|
||||
location::nearby::proto::connections::ConnectionRequestResponse response)
|
||||
ABSL_EXCLUSIVE_LOCKS_REQUIRED(mutex_);
|
||||
void MarkConnectionRequestIgnoredLocked(
|
||||
location::nearby::analytics::proto::ConnectionsLog::ConnectionRequest*
|
||||
request) ABSL_SHARED_LOCKS_REQUIRED(mutex_);
|
||||
void OnIncomingConnectionAttemptLocked(
|
||||
location::nearby::proto::connections::ConnectionAttemptType type,
|
||||
location::nearby::proto::connections::Medium medium,
|
||||
location::nearby::proto::connections::ConnectionAttemptResult result,
|
||||
absl::Duration duration, const std::string& connection_token,
|
||||
ConnectionAttemptMetadataParams* connection_attempt_metadata_params)
|
||||
ABSL_SHARED_LOCKS_REQUIRED(mutex_);
|
||||
void OnOutgoingConnectionAttemptLocked(
|
||||
const std::string& remote_endpoint_id,
|
||||
location::nearby::proto::connections::ConnectionAttemptType type,
|
||||
location::nearby::proto::connections::Medium medium,
|
||||
location::nearby::proto::connections::ConnectionAttemptResult result,
|
||||
absl::Duration duration, const std::string& connection_token,
|
||||
ConnectionAttemptMetadataParams* connection_attempt_metadata_params)
|
||||
ABSL_SHARED_LOCKS_REQUIRED(mutex_);
|
||||
bool ConnectionAttemptResultCodeExistedLocked(
|
||||
location::nearby::proto::connections::Medium medium,
|
||||
location::nearby::proto::connections::ConnectionAttemptDirection
|
||||
direction,
|
||||
const std::string& connection_token,
|
||||
location::nearby::proto::connections::ConnectionAttemptType type,
|
||||
location::nearby::proto::connections::OperationResultCode
|
||||
operation_result_code) ABSL_SHARED_LOCKS_REQUIRED(mutex_);
|
||||
bool EraseIfBandwidthUpgradeRecordExistedLocked(
|
||||
const std::string& endpoint_id,
|
||||
location::nearby::proto::connections::BandwidthUpgradeResult result,
|
||||
location::nearby::proto::connections::BandwidthUpgradeErrorStage
|
||||
error_stage,
|
||||
location::nearby::proto::connections::OperationResultCode
|
||||
operation_result_code) ABSL_SHARED_LOCKS_REQUIRED(mutex_);
|
||||
void FinishUpgradeAttemptLocked(
|
||||
const std::string& endpoint_id,
|
||||
location::nearby::proto::connections::BandwidthUpgradeResult result,
|
||||
location::nearby::proto::connections::BandwidthUpgradeErrorStage
|
||||
error_stage,
|
||||
location::nearby::proto::connections::OperationResultCode
|
||||
operation_result_code,
|
||||
bool erase_item = true) ABSL_SHARED_LOCKS_REQUIRED(mutex_);
|
||||
void FinishStrategySessionLocked() ABSL_EXCLUSIVE_LOCKS_REQUIRED(mutex_);
|
||||
|
||||
int GetLatestUpdateIndexLocked(
|
||||
const std::vector<location::nearby::analytics::proto::ConnectionsLog::
|
||||
OperationResultWithMedium>& list)
|
||||
ABSL_EXCLUSIVE_LOCKS_REQUIRED(mutex_);
|
||||
|
||||
location::nearby::proto::connections::ConnectionsStrategy
|
||||
StrategyToConnectionStrategy(connections::Strategy strategy);
|
||||
location::nearby::proto::connections::PayloadType
|
||||
PayloadTypeToProtoPayloadType(connections::PayloadType type);
|
||||
|
||||
// Not owned by AnalyticsRecorderImpl. Pointer must refer to a valid object
|
||||
// that outlives the one constructed.
|
||||
::nearby::analytics::EventLogger* event_logger_;
|
||||
|
||||
// Protects all sub-protos reading and writing in ConnectionLog.
|
||||
Mutex mutex_;
|
||||
|
||||
// ClientSession
|
||||
std::unique_ptr<
|
||||
location::nearby::analytics::proto::ConnectionsLog::ClientSession>
|
||||
client_session_;
|
||||
absl::Time started_client_session_time_;
|
||||
bool session_was_logged_ ABSL_GUARDED_BY(mutex_) = false;
|
||||
bool start_client_session_was_logged_ ABSL_GUARDED_BY(mutex_) = false;
|
||||
|
||||
// Current StrategySession
|
||||
connections::Strategy current_strategy_ ABSL_GUARDED_BY(mutex_) =
|
||||
connections::Strategy::kNone;
|
||||
std::unique_ptr<
|
||||
location::nearby::analytics::proto::ConnectionsLog::StrategySession>
|
||||
current_strategy_session_ ABSL_GUARDED_BY(mutex_);
|
||||
absl::Time started_strategy_session_time_ ABSL_GUARDED_BY(mutex_);
|
||||
|
||||
// Current AdvertisingPhase
|
||||
std::unique_ptr<
|
||||
location::nearby::analytics::proto::ConnectionsLog::AdvertisingPhase>
|
||||
current_advertising_phase_;
|
||||
absl::Time started_advertising_phase_time_ = absl::InfinitePast();
|
||||
|
||||
// Current DiscoveryPhase
|
||||
std::unique_ptr<
|
||||
location::nearby::analytics::proto::ConnectionsLog::DiscoveryPhase>
|
||||
current_discovery_phase_;
|
||||
absl::Time started_discovery_phase_time_ = absl::InfinitePast();
|
||||
|
||||
absl::btree_map<std::string,
|
||||
std::unique_ptr<location::nearby::analytics::proto::
|
||||
ConnectionsLog::ConnectionRequest>>
|
||||
incoming_connection_requests_ ABSL_GUARDED_BY(mutex_);
|
||||
absl::btree_map<std::string,
|
||||
std::unique_ptr<location::nearby::analytics::proto::
|
||||
ConnectionsLog::ConnectionRequest>>
|
||||
outgoing_connection_requests_ ABSL_GUARDED_BY(mutex_);
|
||||
absl::btree_map<std::string, std::unique_ptr<LogicalConnection>>
|
||||
active_connections_ ABSL_GUARDED_BY(mutex_);
|
||||
absl::btree_map<std::string,
|
||||
std::unique_ptr<location::nearby::analytics::proto::
|
||||
ConnectionsLog::BandwidthUpgradeAttempt>>
|
||||
bandwidth_upgrade_attempts_ ABSL_GUARDED_BY(mutex_);
|
||||
};
|
||||
|
||||
} // namespace nearby::analytics
|
||||
|
||||
#endif // ANALYTICS_ANALYTICS_RECORDER_IMPL_H_
|
||||
+49
-50
@@ -12,7 +12,7 @@
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
#include "connections/implementation/analytics/analytics_recorder.h"
|
||||
#include "connections/implementation/analytics/analytics_recorder_impl.h"
|
||||
|
||||
#include <stddef.h>
|
||||
|
||||
@@ -26,7 +26,9 @@
|
||||
#include "protobuf-matchers/protocol-buffer-matchers.h"
|
||||
#include "gtest/gtest.h"
|
||||
#include "absl/time/time.h"
|
||||
#include "connections/implementation/analytics/analytics_recorder.h"
|
||||
#include "connections/implementation/analytics/connection_attempt_metadata_params.h"
|
||||
#include "connections/implementation/analytics/operation_result_with_medium.h"
|
||||
#include "connections/payload_type.h"
|
||||
#include "connections/strategy.h"
|
||||
#include "internal/analytics/mock_event_logger.h"
|
||||
@@ -36,14 +38,13 @@
|
||||
#include "internal/platform/exception.h"
|
||||
#include "internal/platform/medium_environment.h"
|
||||
#include "internal/proto/analytics/connections_log.proto.h"
|
||||
#include "internal/test/fake_clock.h"
|
||||
#include "proto/connections_enums.proto.h"
|
||||
|
||||
namespace nearby {
|
||||
namespace analytics {
|
||||
namespace nearby::analytics {
|
||||
namespace {
|
||||
|
||||
using ::location::nearby::analytics::proto::ConnectionsLog;
|
||||
using SafeDisconnectionResult = nearby::analytics::SafeDisconnectionResult;
|
||||
using ::location::nearby::errorcode::proto::DISCONNECT;
|
||||
using ::location::nearby::errorcode::proto::DISCONNECT_NETWORK_FAILED;
|
||||
using ::location::nearby::errorcode::proto::INVALID_PARAMETER;
|
||||
@@ -158,7 +159,7 @@ class AnalyticsRecorderTest : public ::testing::Test {
|
||||
TEST_F(AnalyticsRecorderTest, SessionOnlyLoggedOnceWorks) {
|
||||
CountDownLatch client_session_done_latch(1);
|
||||
FakeEventLogger event_logger(client_session_done_latch);
|
||||
AnalyticsRecorder analytics_recorder(&event_logger);
|
||||
AnalyticsRecorderImpl analytics_recorder(&event_logger);
|
||||
|
||||
analytics_recorder.LogSession();
|
||||
analytics_recorder.LogSession();
|
||||
@@ -175,9 +176,9 @@ TEST_F(AnalyticsRecorderTest, SetFieldsCorrectlyForNestedAdvertisingCalls) {
|
||||
|
||||
CountDownLatch client_session_done_latch(1);
|
||||
FakeEventLogger event_logger(client_session_done_latch);
|
||||
AnalyticsRecorder analytics_recorder(&event_logger);
|
||||
AnalyticsRecorderImpl analytics_recorder(&event_logger);
|
||||
|
||||
ConnectionsLog::OperationResultWithMedium operation_result;
|
||||
OperationResultWithMedium operation_result;
|
||||
operation_result.set_medium(BLUETOOTH);
|
||||
operation_result.set_result_code(OperationResultCode::DETAIL_SUCCESS);
|
||||
operation_result.set_result_category(
|
||||
@@ -251,14 +252,14 @@ TEST_F(AnalyticsRecorderTest, SetFieldsCorrectlyForNestedDiscoveryCalls) {
|
||||
|
||||
CountDownLatch client_session_done_latch(1);
|
||||
FakeEventLogger event_logger(client_session_done_latch);
|
||||
AnalyticsRecorder analytics_recorder(&event_logger);
|
||||
AnalyticsRecorderImpl analytics_recorder(&event_logger);
|
||||
|
||||
ConnectionsLog::OperationResultWithMedium operation_result;
|
||||
OperationResultWithMedium operation_result;
|
||||
operation_result.set_medium(BLUETOOTH);
|
||||
operation_result.set_result_code(OperationResultCode::DETAIL_SUCCESS);
|
||||
operation_result.set_result_category(
|
||||
OperationResultCategory::CATEGORY_SUCCESS);
|
||||
ConnectionsLog::OperationResultWithMedium operation_result2;
|
||||
OperationResultWithMedium operation_result2;
|
||||
operation_result2.set_medium(BLE);
|
||||
operation_result2.set_result_code(OperationResultCode::DETAIL_SUCCESS);
|
||||
operation_result2.set_result_category(
|
||||
@@ -350,7 +351,7 @@ TEST_F(AnalyticsRecorderTest,
|
||||
|
||||
CountDownLatch client_session_done_latch(1);
|
||||
FakeEventLogger event_logger(client_session_done_latch);
|
||||
AnalyticsRecorder analytics_recorder(&event_logger);
|
||||
AnalyticsRecorderImpl analytics_recorder(&event_logger);
|
||||
|
||||
auto advertising_metadata_params =
|
||||
analytics_recorder.BuildAdvertisingMetadataParams();
|
||||
@@ -482,9 +483,9 @@ TEST_F(AnalyticsRecorderTest, AdvertiserConnectionRequestsWorks) {
|
||||
|
||||
CountDownLatch client_session_done_latch(1);
|
||||
FakeEventLogger event_logger(client_session_done_latch);
|
||||
AnalyticsRecorder analytics_recorder(&event_logger);
|
||||
AnalyticsRecorderImpl analytics_recorder(&event_logger);
|
||||
|
||||
ConnectionsLog::OperationResultWithMedium operation_result;
|
||||
OperationResultWithMedium operation_result;
|
||||
operation_result.set_medium(BLE);
|
||||
operation_result.set_result_code(OperationResultCode::DETAIL_SUCCESS);
|
||||
operation_result.set_result_category(
|
||||
@@ -586,9 +587,9 @@ TEST_F(AnalyticsRecorderTest, DiscoveryConnectionRequestsWorks) {
|
||||
|
||||
CountDownLatch client_session_done_latch(1);
|
||||
FakeEventLogger event_logger(client_session_done_latch);
|
||||
AnalyticsRecorder analytics_recorder(&event_logger);
|
||||
AnalyticsRecorderImpl analytics_recorder(&event_logger);
|
||||
|
||||
ConnectionsLog::OperationResultWithMedium operation_result;
|
||||
OperationResultWithMedium operation_result;
|
||||
operation_result.set_medium(BLUETOOTH);
|
||||
operation_result.set_result_code(OperationResultCode::DETAIL_SUCCESS);
|
||||
operation_result.set_result_category(
|
||||
@@ -691,9 +692,9 @@ TEST_F(AnalyticsRecorderTest,
|
||||
|
||||
CountDownLatch client_session_done_latch(1);
|
||||
FakeEventLogger event_logger(client_session_done_latch);
|
||||
AnalyticsRecorder analytics_recorder(&event_logger);
|
||||
AnalyticsRecorderImpl analytics_recorder(&event_logger);
|
||||
|
||||
ConnectionsLog::OperationResultWithMedium operation_result;
|
||||
OperationResultWithMedium operation_result;
|
||||
operation_result.set_medium(BLUETOOTH);
|
||||
operation_result.set_result_code(OperationResultCode::DETAIL_SUCCESS);
|
||||
operation_result.set_result_category(
|
||||
@@ -781,9 +782,9 @@ TEST_F(AnalyticsRecorderTest,
|
||||
|
||||
CountDownLatch client_session_done_latch(1);
|
||||
FakeEventLogger event_logger(client_session_done_latch);
|
||||
AnalyticsRecorder analytics_recorder(&event_logger);
|
||||
AnalyticsRecorderImpl analytics_recorder(&event_logger);
|
||||
|
||||
ConnectionsLog::OperationResultWithMedium operation_result;
|
||||
OperationResultWithMedium operation_result;
|
||||
operation_result.set_medium(BLUETOOTH);
|
||||
operation_result.set_result_code(OperationResultCode::DETAIL_SUCCESS);
|
||||
operation_result.set_result_category(
|
||||
@@ -866,9 +867,9 @@ TEST_F(AnalyticsRecorderTest,
|
||||
TEST_F(AnalyticsRecorderTest, SuccessfulIncomingConnectionAttempt) {
|
||||
CountDownLatch client_session_done_latch(1);
|
||||
FakeEventLogger event_logger(client_session_done_latch);
|
||||
AnalyticsRecorder analytics_recorder(&event_logger);
|
||||
AnalyticsRecorderImpl analytics_recorder(&event_logger);
|
||||
|
||||
ConnectionsLog::OperationResultWithMedium operation_result;
|
||||
OperationResultWithMedium operation_result;
|
||||
operation_result.set_medium(BLUETOOTH);
|
||||
operation_result.set_result_code(OperationResultCode::DETAIL_SUCCESS);
|
||||
operation_result.set_result_category(
|
||||
@@ -957,7 +958,7 @@ TEST_F(AnalyticsRecorderTest,
|
||||
|
||||
CountDownLatch client_session_done_latch(1);
|
||||
FakeEventLogger event_logger(client_session_done_latch);
|
||||
AnalyticsRecorder analytics_recorder(&event_logger);
|
||||
AnalyticsRecorderImpl analytics_recorder(&event_logger);
|
||||
|
||||
auto connections_attempt_metadata_params =
|
||||
analytics_recorder.BuildConnectionAttemptMetadataParams(
|
||||
@@ -1049,7 +1050,7 @@ TEST_F(AnalyticsRecorderTest,
|
||||
|
||||
CountDownLatch client_session_done_latch(1);
|
||||
FakeEventLogger event_logger(client_session_done_latch);
|
||||
AnalyticsRecorder analytics_recorder(&event_logger);
|
||||
AnalyticsRecorderImpl analytics_recorder(&event_logger);
|
||||
|
||||
auto advertising_metadata_params =
|
||||
analytics_recorder.BuildAdvertisingMetadataParams();
|
||||
@@ -1061,9 +1062,8 @@ TEST_F(AnalyticsRecorderTest,
|
||||
analytics_recorder.OnConnectionEstablished(endpoint_id, BLUETOOTH,
|
||||
connection_token);
|
||||
MediumEnvironment::Instance().FastForward(absl::Milliseconds(300));
|
||||
analytics_recorder.OnConnectionClosed(
|
||||
endpoint_id, BLUETOOTH, UPGRADED,
|
||||
ConnectionsLog::EstablishedConnection::UNKNOWN_SAFE_DISCONNECTION_RESULT);
|
||||
analytics_recorder.OnConnectionClosed(endpoint_id, BLUETOOTH, UPGRADED,
|
||||
SafeDisconnectionResult::kUnknown);
|
||||
MediumEnvironment::Instance().FastForward(absl::Milliseconds(400));
|
||||
analytics_recorder.OnConnectionEstablished(endpoint_id, WIFI_LAN,
|
||||
connection_token);
|
||||
@@ -1125,7 +1125,7 @@ TEST_F(AnalyticsRecorderTest, OutgoingPayloadUpgraded) {
|
||||
|
||||
CountDownLatch client_session_done_latch(1);
|
||||
FakeEventLogger event_logger(client_session_done_latch);
|
||||
AnalyticsRecorder analytics_recorder(&event_logger);
|
||||
AnalyticsRecorderImpl analytics_recorder(&event_logger);
|
||||
|
||||
auto advertising_metadata_params =
|
||||
analytics_recorder.BuildAdvertisingMetadataParams();
|
||||
@@ -1146,7 +1146,7 @@ TEST_F(AnalyticsRecorderTest, OutgoingPayloadUpgraded) {
|
||||
MediumEnvironment::Instance().FastForward(absl::Milliseconds(600));
|
||||
analytics_recorder.OnConnectionClosed(
|
||||
endpoint_id, BLUETOOTH, UPGRADED,
|
||||
ConnectionsLog::EstablishedConnection::SAFE_DISCONNECTION);
|
||||
SafeDisconnectionResult::kSafeDisconnection);
|
||||
MediumEnvironment::Instance().FastForward(absl::Milliseconds(700));
|
||||
analytics_recorder.OnConnectionEstablished(endpoint_id, WIFI_LAN,
|
||||
connection_token);
|
||||
@@ -1162,7 +1162,7 @@ TEST_F(AnalyticsRecorderTest, OutgoingPayloadUpgraded) {
|
||||
MediumEnvironment::Instance().FastForward(absl::Milliseconds(1200));
|
||||
analytics_recorder.OnConnectionClosed(
|
||||
endpoint_id, WIFI_LAN, LOCAL_DISCONNECTION,
|
||||
ConnectionsLog::EstablishedConnection::SAFE_DISCONNECTION);
|
||||
SafeDisconnectionResult::kSafeDisconnection);
|
||||
MediumEnvironment::Instance().FastForward(absl::Milliseconds(1300));
|
||||
|
||||
analytics_recorder.LogSession();
|
||||
@@ -1246,7 +1246,7 @@ TEST_F(AnalyticsRecorderTest, UpgradeAttemptWorks) {
|
||||
|
||||
CountDownLatch client_session_done_latch(1);
|
||||
FakeEventLogger event_logger(client_session_done_latch);
|
||||
AnalyticsRecorder analytics_recorder(&event_logger);
|
||||
AnalyticsRecorderImpl analytics_recorder(&event_logger);
|
||||
|
||||
auto advertising_metadata_params =
|
||||
analytics_recorder.BuildAdvertisingMetadataParams();
|
||||
@@ -1350,7 +1350,7 @@ TEST_F(AnalyticsRecorderTest, StartListeningForIncomingConnectionsWorks) {
|
||||
|
||||
CountDownLatch client_session_done_latch(1);
|
||||
FakeEventLogger event_logger(client_session_done_latch);
|
||||
AnalyticsRecorder analytics_recorder(&event_logger);
|
||||
AnalyticsRecorderImpl analytics_recorder(&event_logger);
|
||||
|
||||
MediumEnvironment::Instance().FastForward(absl::Milliseconds(100));
|
||||
analytics_recorder.OnStartedIncomingConnectionListening(
|
||||
@@ -1418,7 +1418,7 @@ TEST_F(AnalyticsRecorderTest, StartListeningForIncomingConnectionsWorks) {
|
||||
TEST_F(AnalyticsRecorderTest, SetErrorCodeFieldsCorrectly) {
|
||||
CountDownLatch client_session_done_latch(1);
|
||||
FakeEventLogger event_logger(client_session_done_latch);
|
||||
AnalyticsRecorder analytics_recorder(&event_logger);
|
||||
AnalyticsRecorderImpl analytics_recorder(&event_logger);
|
||||
|
||||
auto discovery_metadata_params =
|
||||
analytics_recorder.BuildDiscoveryMetadataParams();
|
||||
@@ -1452,7 +1452,7 @@ TEST_F(AnalyticsRecorderTest,
|
||||
SetErrorCodeFieldsCorrectlyForUnknownDescription) {
|
||||
CountDownLatch client_session_done_latch(1);
|
||||
FakeEventLogger event_logger(client_session_done_latch);
|
||||
AnalyticsRecorder analytics_recorder(&event_logger);
|
||||
AnalyticsRecorderImpl analytics_recorder(&event_logger);
|
||||
|
||||
auto discovery_metadata_params =
|
||||
analytics_recorder.BuildDiscoveryMetadataParams();
|
||||
@@ -1488,7 +1488,7 @@ TEST_F(AnalyticsRecorderTest,
|
||||
TEST_F(AnalyticsRecorderTest, SetErrorCodeFieldsCorrectlyForCommonError) {
|
||||
CountDownLatch client_session_done_latch(1);
|
||||
FakeEventLogger event_logger(client_session_done_latch);
|
||||
AnalyticsRecorder analytics_recorder(&event_logger);
|
||||
AnalyticsRecorderImpl analytics_recorder(&event_logger);
|
||||
|
||||
auto discovery_metadata_params =
|
||||
analytics_recorder.BuildDiscoveryMetadataParams();
|
||||
@@ -1521,7 +1521,7 @@ TEST_F(AnalyticsRecorderTest, SetErrorCodeFieldsCorrectlyForCommonError) {
|
||||
TEST_F(AnalyticsRecorderTest, CheckIfSessionWasLogged) {
|
||||
CountDownLatch client_session_done_latch(1);
|
||||
FakeEventLogger event_logger(client_session_done_latch);
|
||||
AnalyticsRecorder analytics_recorder(&event_logger);
|
||||
AnalyticsRecorderImpl analytics_recorder(&event_logger);
|
||||
|
||||
MediumEnvironment::Instance().FastForward(absl::Milliseconds(100));
|
||||
// LogSession to count down client_session_done_latch.
|
||||
@@ -1538,7 +1538,7 @@ TEST_F(AnalyticsRecorderTest, ConstructAnalyticsRecorder) {
|
||||
&start_client_session_done_latch);
|
||||
|
||||
// Call the constructor to count down the session_done_latch.
|
||||
AnalyticsRecorder analytics_recorder(&event_logger);
|
||||
AnalyticsRecorderImpl analytics_recorder(&event_logger);
|
||||
ASSERT_TRUE(start_client_session_done_latch.Await(kDefaultTimeout).result());
|
||||
|
||||
std::vector<EventType> event_types = event_logger.GetLoggedEventTypes();
|
||||
@@ -1555,7 +1555,7 @@ TEST_F(
|
||||
&start_client_session_done_latch);
|
||||
|
||||
// Call the constructor to count down the start_client_session_done_latch.
|
||||
AnalyticsRecorder analytics_recorder(&event_logger);
|
||||
AnalyticsRecorderImpl analytics_recorder(&event_logger);
|
||||
ASSERT_TRUE(start_client_session_done_latch.Await(kDefaultTimeout).result());
|
||||
|
||||
// Log start client session once.
|
||||
@@ -1584,7 +1584,7 @@ TEST_F(AnalyticsRecorderTest,
|
||||
&start_client_session_done_latch);
|
||||
|
||||
// Call the constructor to count down the start_client_session_done_latch.
|
||||
AnalyticsRecorder analytics_recorder(&event_logger);
|
||||
AnalyticsRecorderImpl analytics_recorder(&event_logger);
|
||||
ASSERT_TRUE(start_client_session_done_latch.Await(kDefaultTimeout).result());
|
||||
|
||||
// Log start client session once.
|
||||
@@ -1621,7 +1621,7 @@ TEST_F(AnalyticsRecorderTest,
|
||||
|
||||
CountDownLatch client_session_done_latch(1);
|
||||
FakeEventLogger event_logger(client_session_done_latch);
|
||||
AnalyticsRecorder analytics_recorder(&event_logger);
|
||||
AnalyticsRecorderImpl analytics_recorder(&event_logger);
|
||||
|
||||
auto advertising_metadata_params =
|
||||
analytics_recorder.BuildAdvertisingMetadataParams();
|
||||
@@ -1753,7 +1753,7 @@ TEST_F(AnalyticsRecorderTest,
|
||||
|
||||
CountDownLatch client_session_done_latch(1);
|
||||
FakeEventLogger event_logger(client_session_done_latch);
|
||||
AnalyticsRecorder analytics_recorder(&event_logger);
|
||||
AnalyticsRecorderImpl analytics_recorder(&event_logger);
|
||||
|
||||
auto discovery_metadata_params =
|
||||
analytics_recorder.BuildDiscoveryMetadataParams();
|
||||
@@ -1887,7 +1887,7 @@ TEST_F(AnalyticsRecorderTest, ClearcActiveConnectionsAfterSessionWasLogged) {
|
||||
|
||||
CountDownLatch client_session_done_latch(1);
|
||||
FakeEventLogger event_logger(client_session_done_latch);
|
||||
AnalyticsRecorder analytics_recorder(&event_logger);
|
||||
AnalyticsRecorderImpl analytics_recorder(&event_logger);
|
||||
|
||||
auto advertising_metadata_params =
|
||||
analytics_recorder.BuildAdvertisingMetadataParams();
|
||||
@@ -2010,7 +2010,7 @@ TEST_F(AnalyticsRecorderTest,
|
||||
|
||||
CountDownLatch client_session_done_latch(1);
|
||||
FakeEventLogger event_logger(client_session_done_latch);
|
||||
AnalyticsRecorder analytics_recorder(&event_logger);
|
||||
AnalyticsRecorderImpl analytics_recorder(&event_logger);
|
||||
|
||||
auto advertising_metadata_params =
|
||||
analytics_recorder.BuildAdvertisingMetadataParams();
|
||||
@@ -2202,7 +2202,7 @@ TEST_F(AnalyticsRecorderTest,
|
||||
|
||||
CountDownLatch client_session_done_latch(1);
|
||||
FakeEventLogger event_logger(client_session_done_latch);
|
||||
AnalyticsRecorder analytics_recorder(&event_logger);
|
||||
AnalyticsRecorderImpl analytics_recorder(&event_logger);
|
||||
|
||||
auto advertising_metadata_params =
|
||||
analytics_recorder.BuildAdvertisingMetadataParams();
|
||||
@@ -2256,7 +2256,7 @@ TEST_F(AnalyticsRecorderTest,
|
||||
NotLogSameStrategySessionProtoAfterSessionWasLogged) {
|
||||
CountDownLatch client_session_done_latch(1);
|
||||
FakeEventLogger event_logger(client_session_done_latch);
|
||||
AnalyticsRecorder analytics_recorder(&event_logger);
|
||||
AnalyticsRecorderImpl analytics_recorder(&event_logger);
|
||||
|
||||
// Via OnStartAdvertising, current_strategy_session_is set in
|
||||
// UpdateStrategySessionLocked.
|
||||
@@ -2323,7 +2323,7 @@ TEST_F(AnalyticsRecorderTest,
|
||||
NotLogDuplicateAdvertisingPhaseAfterSessionWasLogged) {
|
||||
CountDownLatch client_session_done_latch(1);
|
||||
FakeEventLogger event_logger(client_session_done_latch);
|
||||
AnalyticsRecorder analytics_recorder(&event_logger);
|
||||
AnalyticsRecorderImpl analytics_recorder(&event_logger);
|
||||
|
||||
auto advertising_metadata_params =
|
||||
analytics_recorder.BuildAdvertisingMetadataParams();
|
||||
@@ -2418,7 +2418,7 @@ TEST_F(AnalyticsRecorderTest,
|
||||
|
||||
CountDownLatch client_session_done_latch(1);
|
||||
FakeEventLogger event_logger(client_session_done_latch);
|
||||
AnalyticsRecorder analytics_recorder(&event_logger);
|
||||
AnalyticsRecorderImpl analytics_recorder(&event_logger);
|
||||
|
||||
auto discovery_metadata_params =
|
||||
analytics_recorder.BuildDiscoveryMetadataParams(
|
||||
@@ -2517,7 +2517,7 @@ TEST_F(AnalyticsRecorderTest,
|
||||
|
||||
CountDownLatch client_session_done_latch(1);
|
||||
FakeEventLogger event_logger(client_session_done_latch);
|
||||
AnalyticsRecorder analytics_recorder(&event_logger);
|
||||
AnalyticsRecorderImpl analytics_recorder(&event_logger);
|
||||
|
||||
// via OnStartAdvertising, current_strategy_session_ is set in
|
||||
// UpdateStrategySessionLocked.
|
||||
@@ -2566,7 +2566,7 @@ TEST_F(AnalyticsRecorderTest,
|
||||
MediumEnvironment::Instance().FastForward(absl::Milliseconds(500));
|
||||
analytics_recorder.OnConnectionClosed(
|
||||
endpoint_id, BLUETOOTH, UPGRADED,
|
||||
ConnectionsLog::EstablishedConnection::SAFE_DISCONNECTION);
|
||||
SafeDisconnectionResult::kSafeDisconnection);
|
||||
MediumEnvironment::Instance().FastForward(absl::Milliseconds(600));
|
||||
analytics_recorder.LogSession();
|
||||
|
||||
@@ -2576,5 +2576,4 @@ TEST_F(AnalyticsRecorderTest,
|
||||
}
|
||||
|
||||
} // namespace
|
||||
} // namespace analytics
|
||||
} // namespace nearby
|
||||
} // namespace nearby::analytics
|
||||
@@ -17,7 +17,7 @@
|
||||
|
||||
#include <vector>
|
||||
|
||||
#include "internal/proto/analytics/connections_log.pb.h"
|
||||
#include "connections/implementation/analytics/operation_result_with_medium.h"
|
||||
|
||||
namespace nearby {
|
||||
|
||||
@@ -26,8 +26,7 @@ struct DiscoveryMetadataParams {
|
||||
bool is_extended_advertisement_supported = false;
|
||||
int connected_ap_frequency = 0;
|
||||
bool is_nfc_available = false;
|
||||
std::vector<location::nearby::analytics::proto::ConnectionsLog::
|
||||
OperationResultWithMedium>
|
||||
std::vector<nearby::analytics::OperationResultWithMedium>
|
||||
operation_result_with_mediums = {};
|
||||
};
|
||||
|
||||
|
||||
@@ -0,0 +1,55 @@
|
||||
// Copyright 2026 Google LLC
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// https://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
#ifndef ANALYTICS_OPERATION_RESULT_WITH_MEDIUM_H_
|
||||
#define ANALYTICS_OPERATION_RESULT_WITH_MEDIUM_H_
|
||||
|
||||
#include <optional>
|
||||
|
||||
#include "proto/connections_enums.pb.h"
|
||||
|
||||
namespace nearby::analytics {
|
||||
|
||||
struct OperationResultWithMedium {
|
||||
location::nearby::proto::connections::Medium medium =
|
||||
location::nearby::proto::connections::UNKNOWN_MEDIUM;
|
||||
std::optional<int> update_index;
|
||||
location::nearby::proto::connections::OperationResultCategory
|
||||
result_category = location::nearby::proto::connections::CATEGORY_UNKNOWN;
|
||||
location::nearby::proto::connections::OperationResultCode result_code =
|
||||
location::nearby::proto::connections::DETAIL_UNKNOWN;
|
||||
std::optional<location::nearby::proto::connections::ConnectionMode>
|
||||
connection_mode;
|
||||
|
||||
void set_medium(location::nearby::proto::connections::Medium m) {
|
||||
medium = m;
|
||||
}
|
||||
void set_update_index(int i) { update_index = i; }
|
||||
void set_result_category(
|
||||
location::nearby::proto::connections::OperationResultCategory c) {
|
||||
result_category = c;
|
||||
}
|
||||
void set_result_code(
|
||||
location::nearby::proto::connections::OperationResultCode c) {
|
||||
result_code = c;
|
||||
}
|
||||
void set_connection_mode(
|
||||
location::nearby::proto::connections::ConnectionMode m) {
|
||||
connection_mode = m;
|
||||
}
|
||||
};
|
||||
|
||||
} // namespace nearby::analytics
|
||||
|
||||
#endif // ANALYTICS_OPERATION_RESULT_WITH_MEDIUM_H_
|
||||
@@ -40,15 +40,13 @@
|
||||
#include "internal/platform/mutex_lock.h"
|
||||
#include "internal/platform/output_stream.h"
|
||||
|
||||
namespace nearby {
|
||||
namespace connections {
|
||||
namespace nearby::connections {
|
||||
|
||||
namespace {
|
||||
using ::location::nearby::analytics::proto::ConnectionsLog;
|
||||
using ::location::nearby::proto::connections::Medium::BLE;
|
||||
using ::location::nearby::proto::connections::Medium::BLE_L2CAP;
|
||||
using DisconnectionReason =
|
||||
::location::nearby::proto::connections::DisconnectionReason;
|
||||
using ::nearby::analytics::SafeDisconnectionResult;
|
||||
using ::location::nearby::proto::connections::DisconnectionReason;
|
||||
|
||||
Exception WriteInt(OutputStream* writer, std::int32_t value) {
|
||||
return Base64Utils::WriteInt(writer, value);
|
||||
@@ -304,7 +302,7 @@ void BaseEndpointChannel::SetAnalyticsRecorder(
|
||||
|
||||
void BaseEndpointChannel::Close(
|
||||
location::nearby::proto::connections::DisconnectionReason reason) {
|
||||
Close(reason, ConnectionsLog::EstablishedConnection::SAFE_DISCONNECTION);
|
||||
Close(reason, SafeDisconnectionResult::kSafeDisconnection);
|
||||
}
|
||||
|
||||
void BaseEndpointChannel::Close(
|
||||
@@ -468,5 +466,4 @@ std::unique_ptr<std::string> BaseEndpointChannel::EncodeMessageForTests(
|
||||
return crypto_context_->EncodeMessageToPeer(data);
|
||||
}
|
||||
|
||||
} // namespace connections
|
||||
} // namespace nearby
|
||||
} // namespace nearby::connections
|
||||
|
||||
@@ -31,8 +31,7 @@
|
||||
#include "internal/platform/mutex.h"
|
||||
#include "internal/platform/output_stream.h"
|
||||
|
||||
namespace nearby {
|
||||
namespace connections {
|
||||
namespace nearby::connections {
|
||||
|
||||
class BaseEndpointChannel : public EndpointChannel {
|
||||
public:
|
||||
@@ -56,10 +55,8 @@ class BaseEndpointChannel : public EndpointChannel {
|
||||
void Close() ABSL_LOCKS_EXCLUDED(is_paused_mutex_) override;
|
||||
void Close(location::nearby::proto::connections::DisconnectionReason reason)
|
||||
override;
|
||||
void Close(
|
||||
location::nearby::proto::connections::DisconnectionReason reason,
|
||||
location::nearby::analytics::proto::ConnectionsLog::
|
||||
EstablishedConnection::SafeDisconnectionResult result) override;
|
||||
void Close(location::nearby::proto::connections::DisconnectionReason reason,
|
||||
nearby::analytics::SafeDisconnectionResult result) override;
|
||||
bool IsClosed() const ABSL_LOCKS_EXCLUDED(is_paused_mutex_) override;
|
||||
std::string GetType() const override;
|
||||
std::string GetServiceId() const override;
|
||||
@@ -171,7 +168,6 @@ class BaseEndpointChannel : public EndpointChannel {
|
||||
std::string endpoint_id_ = "";
|
||||
};
|
||||
|
||||
} // namespace connections
|
||||
} // namespace nearby
|
||||
} // namespace nearby::connections
|
||||
|
||||
#endif // CORE_INTERNAL_BASE_ENDPOINT_CHANNEL_H_
|
||||
|
||||
@@ -36,7 +36,9 @@
|
||||
#include "connections/advertising_options.h"
|
||||
#include "connections/connection_options.h"
|
||||
#include "connections/discovery_options.h"
|
||||
#include "connections/implementation/analytics/analytics_recorder.h"
|
||||
#include "connections/implementation/analytics/connection_attempt_metadata_params.h"
|
||||
#include "connections/implementation/analytics/operation_result_with_medium.h"
|
||||
#include "connections/implementation/bwu_manager.h"
|
||||
#include "connections/implementation/client_proxy.h"
|
||||
#include "connections/implementation/connections_authentication_transport.h"
|
||||
@@ -89,6 +91,20 @@
|
||||
namespace nearby::connections {
|
||||
|
||||
namespace {
|
||||
using ::location::nearby::analytics::proto::ConnectionsLog;
|
||||
using ::location::nearby::connections::ConnectionRequestFrame;
|
||||
using ::location::nearby::connections::ConnectionResponseFrame;
|
||||
using ::location::nearby::connections::ConnectionsDevice;
|
||||
using ::location::nearby::connections::MediumMetadata;
|
||||
using ::location::nearby::connections::OfflineFrame;
|
||||
using ::location::nearby::connections::OsInfo;
|
||||
using ::location::nearby::connections::PresenceDevice;
|
||||
using ::location::nearby::connections::V1Frame;
|
||||
using ::location::nearby::proto::connections::OperationResultCode;
|
||||
using ::location::nearby::proto::connections::WifiDirectAuthType;
|
||||
using ::nearby::analytics::AnalyticsRecorder;
|
||||
using ::securegcm::UKey2Handshake;
|
||||
|
||||
constexpr int kEndpointCancelAlarmTimeout = 10;
|
||||
|
||||
std::string AuthenticationStatusToString(nearby::AuthenticationStatus status) {
|
||||
@@ -101,20 +117,30 @@ std::string AuthenticationStatusToString(nearby::AuthenticationStatus status) {
|
||||
return "failure";
|
||||
}
|
||||
}
|
||||
} // namespace
|
||||
|
||||
using ::location::nearby::analytics::proto::ConnectionsLog;
|
||||
using ::location::nearby::connections::ConnectionRequestFrame;
|
||||
using ::location::nearby::connections::ConnectionResponseFrame;
|
||||
using ::location::nearby::connections::ConnectionsDevice;
|
||||
using ::location::nearby::connections::MediumMetadata;
|
||||
using ::location::nearby::connections::OfflineFrame;
|
||||
using ::location::nearby::connections::OsInfo;
|
||||
using ::location::nearby::connections::PresenceDevice;
|
||||
using ::location::nearby::connections::V1Frame;
|
||||
using ::location::nearby::proto::connections::OperationResultCode;
|
||||
using ::location::nearby::proto::connections::WifiDirectAuthType;
|
||||
using ::securegcm::UKey2Handshake;
|
||||
std::vector<analytics::OperationResultWithMedium>
|
||||
ConvertToCppOperationResultWithMediums(
|
||||
const std::vector<ConnectionsLog::OperationResultWithMedium>&
|
||||
proto_results) {
|
||||
std::vector<analytics::OperationResultWithMedium> cpp_results;
|
||||
cpp_results.reserve(proto_results.size());
|
||||
for (const auto& proto_result : proto_results) {
|
||||
analytics::OperationResultWithMedium cpp_result;
|
||||
cpp_result.medium = proto_result.medium();
|
||||
if (proto_result.has_update_index()) {
|
||||
cpp_result.update_index = proto_result.update_index();
|
||||
}
|
||||
cpp_result.result_category = proto_result.result_category();
|
||||
cpp_result.result_code = proto_result.result_code();
|
||||
if (proto_result.has_connection_mode()) {
|
||||
cpp_result.connection_mode = proto_result.connection_mode();
|
||||
}
|
||||
cpp_results.push_back(cpp_result);
|
||||
}
|
||||
return cpp_results;
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
||||
BasePcpHandler::BasePcpHandler(Mediums* mediums,
|
||||
EndpointManager* endpoint_manager,
|
||||
@@ -278,11 +304,11 @@ Status BasePcpHandler::StartAdvertising(
|
||||
// Save the advertising options for local reference in later process
|
||||
// like upgrading bandwidth.
|
||||
advertising_listener_ = info.listener;
|
||||
client->StartedAdvertising(
|
||||
service_id, GetStrategy(), info.listener,
|
||||
absl::MakeSpan(result.mediums),
|
||||
std::move(result.operation_result_with_mediums),
|
||||
compatible_advertising_options);
|
||||
client->StartedAdvertising(service_id, GetStrategy(), info.listener,
|
||||
absl::MakeSpan(result.mediums),
|
||||
ConvertToCppOperationResultWithMediums(
|
||||
result.operation_result_with_mediums),
|
||||
compatible_advertising_options);
|
||||
client->UpdateLocalEndpointInfo(info.endpoint_info.string_data());
|
||||
response.Set({Status::kSuccess});
|
||||
});
|
||||
@@ -509,11 +535,12 @@ Status BasePcpHandler::StartDiscovery(ClientProxy* client,
|
||||
MutexLock lock(&discovered_endpoint_mutex_);
|
||||
discovered_endpoints_.clear();
|
||||
}
|
||||
client->StartedDiscovery(
|
||||
service_id, GetStrategy(), std::move(listener),
|
||||
absl::MakeSpan(result.mediums),
|
||||
std::move(result.operation_result_with_mediums),
|
||||
stripped_discovery_options);
|
||||
client->StartedDiscovery(service_id, GetStrategy(),
|
||||
std::move(listener),
|
||||
absl::MakeSpan(result.mediums),
|
||||
ConvertToCppOperationResultWithMediums(
|
||||
result.operation_result_with_mediums),
|
||||
stripped_discovery_options);
|
||||
response.Set({Status::kSuccess});
|
||||
});
|
||||
return WaitForResult(absl::StrCat("StartDiscovery(", service_id, ")"),
|
||||
@@ -1011,8 +1038,8 @@ Status BasePcpHandler::RequestConnection(
|
||||
client, channel_medium, endpoint_id, channel.get(),
|
||||
/*is_incoming=*/false, /*log_failure=*/true, start_time,
|
||||
{Status::kEndpointIoError},
|
||||
client->GetAnalyticsRecorder()
|
||||
.GetChannelIoErrorResultCodeFromMedium(channel_medium),
|
||||
AnalyticsRecorder::GetChannelIoErrorResultCodeFromMedium(
|
||||
channel_medium),
|
||||
result.get());
|
||||
return;
|
||||
}
|
||||
@@ -1173,8 +1200,8 @@ Status BasePcpHandler::RequestConnectionV3(
|
||||
client, channel_medium, endpoint_id, channel.get(),
|
||||
/*is_incoming=*/false, /*log_failure=*/true, start_time,
|
||||
{Status::kEndpointIoError},
|
||||
client->GetAnalyticsRecorder()
|
||||
.GetChannelIoErrorResultCodeFromMedium(channel_medium),
|
||||
AnalyticsRecorder::GetChannelIoErrorResultCodeFromMedium(
|
||||
channel_medium),
|
||||
result.get());
|
||||
return;
|
||||
}
|
||||
@@ -2032,8 +2059,7 @@ Exception BasePcpHandler::OnIncomingConnection(
|
||||
/*is_incoming=*/true,
|
||||
/*log_failure=*/wrapped_frame.exception() != Exception::kNoData,
|
||||
start_time, {Status::kError},
|
||||
client->GetAnalyticsRecorder().GetChannelIoErrorResultCodeFromMedium(
|
||||
medium),
|
||||
AnalyticsRecorder::GetChannelIoErrorResultCodeFromMedium(medium),
|
||||
nullptr);
|
||||
}
|
||||
return wrapped_frame.GetException();
|
||||
@@ -2584,7 +2610,7 @@ void BasePcpHandler::LogConnectionAttemptFailure(
|
||||
connections_attempt_metadata_params;
|
||||
if (endpoint_channel != nullptr) {
|
||||
connections_attempt_metadata_params =
|
||||
client->GetAnalyticsRecorder().BuildConnectionAttemptMetadataParams(
|
||||
AnalyticsRecorder::BuildConnectionAttemptMetadataParams(
|
||||
endpoint_channel->GetTechnology(), endpoint_channel->GetBand(),
|
||||
endpoint_channel->GetFrequency(), endpoint_channel->GetTryCount());
|
||||
connections_attempt_metadata_params->operation_result_code =
|
||||
@@ -2610,12 +2636,11 @@ void BasePcpHandler::LogConnectionAttemptSuccess(
|
||||
connections_attempt_metadata_params;
|
||||
if (pending_connection_info.channel != nullptr) {
|
||||
connections_attempt_metadata_params =
|
||||
pending_connection_info.client->GetAnalyticsRecorder()
|
||||
.BuildConnectionAttemptMetadataParams(
|
||||
pending_connection_info.channel->GetTechnology(),
|
||||
pending_connection_info.channel->GetBand(),
|
||||
pending_connection_info.channel->GetFrequency(),
|
||||
pending_connection_info.channel->GetTryCount());
|
||||
AnalyticsRecorder::BuildConnectionAttemptMetadataParams(
|
||||
pending_connection_info.channel->GetTechnology(),
|
||||
pending_connection_info.channel->GetBand(),
|
||||
pending_connection_info.channel->GetFrequency(),
|
||||
pending_connection_info.channel->GetTryCount());
|
||||
connections_attempt_metadata_params->operation_result_code =
|
||||
OperationResultCode::DETAIL_SUCCESS;
|
||||
} else {
|
||||
|
||||
@@ -25,6 +25,7 @@
|
||||
#include "absl/functional/bind_front.h"
|
||||
#include "absl/strings/str_cat.h"
|
||||
#include "absl/time/time.h"
|
||||
#include "connections/implementation/analytics/analytics_recorder.h"
|
||||
#include "connections/implementation/analytics/connection_attempt_metadata_params.h"
|
||||
#include "connections/implementation/bwu_handler.h"
|
||||
#include "connections/implementation/client_proxy.h"
|
||||
@@ -61,6 +62,8 @@ using ::location::nearby::proto::connections::ConnectionAttemptResult;
|
||||
using ::location::nearby::proto::connections::ConnectionAttemptType;
|
||||
using ::location::nearby::proto::connections::DisconnectionReason;
|
||||
using ::location::nearby::proto::connections::OperationResultCode;
|
||||
using ::nearby::analytics::AnalyticsRecorder;
|
||||
|
||||
} // namespace
|
||||
|
||||
BwuManager::BwuManager(
|
||||
@@ -663,7 +666,7 @@ void BwuManager::OnIncomingConnection(
|
||||
connections_attempt_metadata_params;
|
||||
if (channel != nullptr) {
|
||||
connections_attempt_metadata_params =
|
||||
client->GetAnalyticsRecorder().BuildConnectionAttemptMetadataParams(
|
||||
AnalyticsRecorder::BuildConnectionAttemptMetadataParams(
|
||||
channel->GetTechnology(), channel->GetBand(),
|
||||
channel->GetFrequency(), channel->GetTryCount());
|
||||
connections_attempt_metadata_params->operation_result_code =
|
||||
@@ -874,7 +877,7 @@ void BwuManager::ProcessBwuPathAvailableEvent(
|
||||
if (channel != nullptr) {
|
||||
std::unique_ptr<ConnectionAttemptMetadataParams>
|
||||
connections_attempt_metadata_params =
|
||||
client->GetAnalyticsRecorder().BuildConnectionAttemptMetadataParams(
|
||||
AnalyticsRecorder::BuildConnectionAttemptMetadataParams(
|
||||
channel->GetTechnology(), channel->GetBand(),
|
||||
channel->GetFrequency(), channel->GetTryCount());
|
||||
connections_attempt_metadata_params->operation_result_code =
|
||||
|
||||
@@ -22,6 +22,7 @@
|
||||
#include "absl/container/flat_hash_map.h"
|
||||
#include "absl/strings/string_view.h"
|
||||
#include "connections/connection_options.h"
|
||||
#include "connections/implementation/analytics/analytics_recorder.h"
|
||||
#include "connections/implementation/bwu_handler.h"
|
||||
#include "connections/implementation/client_proxy.h"
|
||||
#include "connections/implementation/endpoint_channel.h"
|
||||
@@ -41,19 +42,17 @@
|
||||
#include "internal/platform/exception.h"
|
||||
#include "internal/platform/feature_flags.h"
|
||||
#include "internal/platform/service_address.h"
|
||||
#include "internal/proto/analytics/connections_log.pb.h"
|
||||
#include "proto/connections_enums.pb.h"
|
||||
|
||||
namespace nearby {
|
||||
namespace connections {
|
||||
namespace nearby::connections {
|
||||
namespace {
|
||||
using ::location::nearby::analytics::proto::ConnectionsLog;
|
||||
using ::location::nearby::connections::BandwidthUpgradeNegotiationFrame;
|
||||
using ::location::nearby::connections::MediumRole;
|
||||
using ::location::nearby::connections::OfflineFrame;
|
||||
using ::location::nearby::connections::OsInfo;
|
||||
using ::location::nearby::connections::V1Frame;
|
||||
using ::location::nearby::proto::connections::DisconnectionReason;
|
||||
using ::nearby::analytics::SafeDisconnectionResult;
|
||||
|
||||
constexpr absl::string_view kServiceIdA = "ServiceA";
|
||||
constexpr absl::string_view kServiceIdB = "ServiceB";
|
||||
@@ -148,7 +147,7 @@ class BwuManagerTest : public ::testing::Test {
|
||||
void UnRegisterChannelForEndpoint(absl::string_view endpoint_id) {
|
||||
ecm_.UnregisterChannelForEndpoint(
|
||||
std::string(endpoint_id), DisconnectionReason::LOCAL_DISCONNECTION,
|
||||
ConnectionsLog::EstablishedConnection::SAFE_DISCONNECTION);
|
||||
SafeDisconnectionResult::kSafeDisconnection);
|
||||
}
|
||||
|
||||
// Upgrade from |initial_medium| to |upgrade_medium|, close down the BLUETOOTH
|
||||
@@ -232,9 +231,9 @@ TEST(BwuManagerBaseTest, AllowToUpgradeMedium) {
|
||||
bwu_manager->InitiateBwuForEndpoint(&client, std::string(kEndpointId1),
|
||||
Medium::WIFI_LAN);
|
||||
EXPECT_TRUE(bwu_manager->IsUpgradeOngoing(std::string(kEndpointId1)));
|
||||
ecm.UnregisterChannelForEndpoint(
|
||||
std::string(kEndpointId1), DisconnectionReason::LOCAL_DISCONNECTION,
|
||||
ConnectionsLog::EstablishedConnection::SAFE_DISCONNECTION);
|
||||
ecm.UnregisterChannelForEndpoint(std::string(kEndpointId1),
|
||||
DisconnectionReason::LOCAL_DISCONNECTION,
|
||||
SafeDisconnectionResult::kSafeDisconnection);
|
||||
|
||||
auto channel2 = std::make_unique<FakeEndpointChannel>(
|
||||
Medium::BLUETOOTH, std::string(kServiceIdA));
|
||||
@@ -243,9 +242,9 @@ TEST(BwuManagerBaseTest, AllowToUpgradeMedium) {
|
||||
bwu_manager->InitiateBwuForEndpoint(&client, std::string(kEndpointId2),
|
||||
Medium::WIFI_HOTSPOT);
|
||||
EXPECT_TRUE(bwu_manager->IsUpgradeOngoing(std::string(kEndpointId2)));
|
||||
ecm.UnregisterChannelForEndpoint(
|
||||
std::string(kEndpointId2), DisconnectionReason::LOCAL_DISCONNECTION,
|
||||
ConnectionsLog::EstablishedConnection::SAFE_DISCONNECTION);
|
||||
ecm.UnregisterChannelForEndpoint(std::string(kEndpointId2),
|
||||
DisconnectionReason::LOCAL_DISCONNECTION,
|
||||
SafeDisconnectionResult::kSafeDisconnection);
|
||||
|
||||
auto channel3 = std::make_unique<FakeEndpointChannel>(
|
||||
Medium::BLUETOOTH, std::string(kServiceIdA));
|
||||
@@ -254,9 +253,9 @@ TEST(BwuManagerBaseTest, AllowToUpgradeMedium) {
|
||||
bwu_manager->InitiateBwuForEndpoint(&client, std::string(kEndpointId3),
|
||||
Medium::WIFI_DIRECT);
|
||||
EXPECT_TRUE(bwu_manager->IsUpgradeOngoing(std::string(kEndpointId3)));
|
||||
ecm.UnregisterChannelForEndpoint(
|
||||
std::string(kEndpointId3), DisconnectionReason::LOCAL_DISCONNECTION,
|
||||
ConnectionsLog::EstablishedConnection::SAFE_DISCONNECTION);
|
||||
ecm.UnregisterChannelForEndpoint(std::string(kEndpointId3),
|
||||
DisconnectionReason::LOCAL_DISCONNECTION,
|
||||
SafeDisconnectionResult::kSafeDisconnection);
|
||||
|
||||
auto channel4 = std::make_unique<FakeEndpointChannel>(
|
||||
Medium::WEB_RTC, std::string(kServiceIdA));
|
||||
@@ -265,9 +264,9 @@ TEST(BwuManagerBaseTest, AllowToUpgradeMedium) {
|
||||
bwu_manager->InitiateBwuForEndpoint(&client, std::string(kEndpointId4),
|
||||
Medium::BLUETOOTH);
|
||||
EXPECT_FALSE(bwu_manager->IsUpgradeOngoing(std::string(kEndpointId4)));
|
||||
ecm.UnregisterChannelForEndpoint(
|
||||
std::string(kEndpointId4), DisconnectionReason::LOCAL_DISCONNECTION,
|
||||
ConnectionsLog::EstablishedConnection::SAFE_DISCONNECTION);
|
||||
ecm.UnregisterChannelForEndpoint(std::string(kEndpointId4),
|
||||
DisconnectionReason::LOCAL_DISCONNECTION,
|
||||
SafeDisconnectionResult::kSafeDisconnection);
|
||||
|
||||
bwu_manager->Shutdown();
|
||||
}
|
||||
@@ -307,9 +306,9 @@ TEST(BwuManagerBaseTest, InitiateBwu_NeedToSwitchRole_Success) {
|
||||
Medium::WIFI_HOTSPOT);
|
||||
EXPECT_FALSE(bwu_manager->IsUpgradeOngoing(std::string(kEndpointId1)));
|
||||
|
||||
ecm.UnregisterChannelForEndpoint(
|
||||
std::string(kEndpointId1), DisconnectionReason::LOCAL_DISCONNECTION,
|
||||
ConnectionsLog::EstablishedConnection::SAFE_DISCONNECTION);
|
||||
ecm.UnregisterChannelForEndpoint(std::string(kEndpointId1),
|
||||
DisconnectionReason::LOCAL_DISCONNECTION,
|
||||
SafeDisconnectionResult::kSafeDisconnection);
|
||||
bwu_manager->Shutdown();
|
||||
NearbyFlags::GetInstance().OverrideBoolFlagValue(
|
||||
config_package_nearby::nearby_connections_feature::
|
||||
@@ -500,7 +499,7 @@ TEST_F(BwuManagerTest,
|
||||
CountDownLatch latch(1);
|
||||
ecm_.UnregisterChannelForEndpoint(
|
||||
std::string(kEndpointId1), DisconnectionReason::LOCAL_DISCONNECTION,
|
||||
ConnectionsLog::EstablishedConnection::UNSAFE_DISCONNECTION);
|
||||
SafeDisconnectionResult::kUnsafeDisconnection);
|
||||
bwu_manager_->OnEndpointDisconnect(
|
||||
&client_, upgrade_service_id, std::string(kEndpointId1), latch,
|
||||
DisconnectionReason::LOCAL_DISCONNECTION);
|
||||
@@ -514,7 +513,7 @@ TEST_F(BwuManagerTest,
|
||||
CountDownLatch latch(1);
|
||||
ecm_.UnregisterChannelForEndpoint(
|
||||
std::string(kEndpointId2), DisconnectionReason::LOCAL_DISCONNECTION,
|
||||
ConnectionsLog::EstablishedConnection::UNSAFE_DISCONNECTION);
|
||||
SafeDisconnectionResult::kUnsafeDisconnection);
|
||||
bwu_manager_->OnEndpointDisconnect(
|
||||
&client_, upgrade_service_id, std::string(kEndpointId2), latch,
|
||||
DisconnectionReason::LOCAL_DISCONNECTION);
|
||||
@@ -548,7 +547,7 @@ TEST_F(BwuManagerTest,
|
||||
CountDownLatch latch(1);
|
||||
ecm_.UnregisterChannelForEndpoint(
|
||||
std::string(kEndpointId1), DisconnectionReason::LOCAL_DISCONNECTION,
|
||||
ConnectionsLog::EstablishedConnection::UNSAFE_DISCONNECTION);
|
||||
SafeDisconnectionResult::kUnsafeDisconnection);
|
||||
bwu_manager_->OnEndpointDisconnect(
|
||||
&client_, upgrade_service_id, std::string(kEndpointId1), latch,
|
||||
DisconnectionReason::LOCAL_DISCONNECTION);
|
||||
@@ -568,7 +567,7 @@ TEST_F(BwuManagerTest,
|
||||
CountDownLatch latch(1);
|
||||
ecm_.UnregisterChannelForEndpoint(
|
||||
std::string(kEndpointId2), DisconnectionReason::LOCAL_DISCONNECTION,
|
||||
ConnectionsLog::EstablishedConnection::UNSAFE_DISCONNECTION);
|
||||
SafeDisconnectionResult::kUnsafeDisconnection);
|
||||
bwu_manager_->OnEndpointDisconnect(
|
||||
&client_, upgrade_service_id, std::string(kEndpointId2), latch,
|
||||
DisconnectionReason::LOCAL_DISCONNECTION);
|
||||
@@ -605,7 +604,7 @@ TEST_F(BwuManagerTest,
|
||||
EXPECT_EQ(2u, ecm_.GetConnectedEndpointsCount());
|
||||
ecm_.UnregisterChannelForEndpoint(
|
||||
std::string(kEndpointId1), DisconnectionReason::LOCAL_DISCONNECTION,
|
||||
ConnectionsLog::EstablishedConnection::UNSAFE_DISCONNECTION);
|
||||
SafeDisconnectionResult::kUnsafeDisconnection);
|
||||
EXPECT_EQ(1u, ecm_.GetConnectedEndpointsCount());
|
||||
bwu_manager_->OnEndpointDisconnect(
|
||||
&client_, upgrade_service_id_A, std::string(kEndpointId1), latch,
|
||||
@@ -625,7 +624,7 @@ TEST_F(BwuManagerTest,
|
||||
CountDownLatch latch(1);
|
||||
ecm_.UnregisterChannelForEndpoint(
|
||||
std::string(kEndpointId2), DisconnectionReason::LOCAL_DISCONNECTION,
|
||||
ConnectionsLog::EstablishedConnection::UNSAFE_DISCONNECTION);
|
||||
SafeDisconnectionResult::kUnsafeDisconnection);
|
||||
EXPECT_EQ(0u, ecm_.GetConnectedEndpointsCount());
|
||||
bwu_manager_->OnEndpointDisconnect(
|
||||
&client_, upgrade_service_id_B, std::string(kEndpointId2), latch,
|
||||
@@ -659,7 +658,7 @@ TEST_F(BwuManagerTest,
|
||||
EXPECT_EQ(2u, ecm_.GetConnectedEndpointsCount());
|
||||
ecm_.UnregisterChannelForEndpoint(
|
||||
std::string(kEndpointId1), DisconnectionReason::LOCAL_DISCONNECTION,
|
||||
ConnectionsLog::EstablishedConnection::UNSAFE_DISCONNECTION);
|
||||
SafeDisconnectionResult::kUnsafeDisconnection);
|
||||
EXPECT_EQ(1u, ecm_.GetConnectedEndpointsCount());
|
||||
bwu_manager_->OnEndpointDisconnect(
|
||||
&client_, upgrade_service_id_A, std::string(kEndpointId1), latch,
|
||||
@@ -679,7 +678,7 @@ TEST_F(BwuManagerTest,
|
||||
CountDownLatch latch(1);
|
||||
ecm_.UnregisterChannelForEndpoint(
|
||||
std::string(kEndpointId2), DisconnectionReason::LOCAL_DISCONNECTION,
|
||||
ConnectionsLog::EstablishedConnection::UNSAFE_DISCONNECTION);
|
||||
SafeDisconnectionResult::kUnsafeDisconnection);
|
||||
EXPECT_EQ(0u, ecm_.GetConnectedEndpointsCount());
|
||||
bwu_manager_->OnEndpointDisconnect(
|
||||
&client_, upgrade_service_id_B, std::string(kEndpointId2), latch,
|
||||
@@ -735,7 +734,7 @@ TEST_F(
|
||||
CountDownLatch latch(1);
|
||||
ecm_.UnregisterChannelForEndpoint(
|
||||
std::string(kEndpointId1), DisconnectionReason::LOCAL_DISCONNECTION,
|
||||
ConnectionsLog::EstablishedConnection::UNSAFE_DISCONNECTION);
|
||||
SafeDisconnectionResult::kUnsafeDisconnection);
|
||||
bwu_manager_->OnEndpointDisconnect(
|
||||
&client_, upgrade_service_id_A, std::string(kEndpointId1), latch,
|
||||
DisconnectionReason::LOCAL_DISCONNECTION);
|
||||
@@ -760,7 +759,7 @@ TEST_F(
|
||||
CountDownLatch latch(1);
|
||||
ecm_.UnregisterChannelForEndpoint(
|
||||
std::string(kEndpointId2), DisconnectionReason::LOCAL_DISCONNECTION,
|
||||
ConnectionsLog::EstablishedConnection::UNSAFE_DISCONNECTION);
|
||||
SafeDisconnectionResult::kUnsafeDisconnection);
|
||||
bwu_manager_->OnEndpointDisconnect(
|
||||
&client_, upgrade_service_id_A, std::string(kEndpointId2), latch,
|
||||
DisconnectionReason::LOCAL_DISCONNECTION);
|
||||
@@ -781,7 +780,7 @@ TEST_F(
|
||||
CountDownLatch latch(1);
|
||||
ecm_.UnregisterChannelForEndpoint(
|
||||
std::string(kEndpointId3), DisconnectionReason::LOCAL_DISCONNECTION,
|
||||
ConnectionsLog::EstablishedConnection::UNSAFE_DISCONNECTION);
|
||||
SafeDisconnectionResult::kUnsafeDisconnection);
|
||||
bwu_manager_->OnEndpointDisconnect(
|
||||
&client_, upgrade_service_id_B, std::string(kEndpointId3), latch,
|
||||
DisconnectionReason::LOCAL_DISCONNECTION);
|
||||
@@ -802,7 +801,7 @@ TEST_F(
|
||||
CountDownLatch latch(1);
|
||||
ecm_.UnregisterChannelForEndpoint(
|
||||
std::string(kEndpointId4), DisconnectionReason::LOCAL_DISCONNECTION,
|
||||
ConnectionsLog::EstablishedConnection::UNSAFE_DISCONNECTION);
|
||||
SafeDisconnectionResult::kUnsafeDisconnection);
|
||||
bwu_manager_->OnEndpointDisconnect(
|
||||
&client_, upgrade_service_id_B, std::string(kEndpointId4), latch,
|
||||
DisconnectionReason::LOCAL_DISCONNECTION);
|
||||
@@ -825,7 +824,7 @@ TEST_F(
|
||||
CountDownLatch latch(1);
|
||||
ecm_.UnregisterChannelForEndpoint(
|
||||
std::string(kEndpointId5), DisconnectionReason::LOCAL_DISCONNECTION,
|
||||
ConnectionsLog::EstablishedConnection::UNSAFE_DISCONNECTION);
|
||||
SafeDisconnectionResult::kUnsafeDisconnection);
|
||||
bwu_manager_->OnEndpointDisconnect(
|
||||
&client_, upgrade_service_id_B, std::string(kEndpointId5), latch,
|
||||
DisconnectionReason::LOCAL_DISCONNECTION);
|
||||
@@ -1094,5 +1093,4 @@ INSTANTIATE_TEST_SUITE_P(BwuManagerTestParam, BwuManagerTestParam,
|
||||
testing::Bool());
|
||||
|
||||
} // namespace
|
||||
} // namespace connections
|
||||
} // namespace nearby
|
||||
} // namespace nearby::connections
|
||||
|
||||
@@ -38,7 +38,9 @@
|
||||
#include "connections/discovery_options.h"
|
||||
#include "connections/implementation/analytics/advertising_metadata_params.h"
|
||||
#include "connections/implementation/analytics/analytics_recorder.h"
|
||||
#include "connections/implementation/analytics/analytics_recorder_impl.h"
|
||||
#include "connections/implementation/analytics/discovery_metadata_params.h"
|
||||
#include "connections/implementation/analytics/operation_result_with_medium.h"
|
||||
#include "connections/implementation/flags/nearby_connections_feature_flags.h"
|
||||
#include "connections/implementation/mediums/advertisements/dct_advertisement.h"
|
||||
#include "connections/listeners.h"
|
||||
@@ -79,9 +81,9 @@
|
||||
namespace nearby::connections {
|
||||
|
||||
namespace {
|
||||
using ::location::nearby::analytics::proto::ConnectionsLog;
|
||||
using ::location::nearby::connections::MediumRole;
|
||||
using ::location::nearby::connections::OsInfo;
|
||||
using ::nearby::analytics::AnalyticsRecorder;
|
||||
|
||||
constexpr char kEndpointIdChars[] = {
|
||||
'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L',
|
||||
@@ -111,7 +113,7 @@ ClientProxy::ClientProxy(::nearby::analytics::EventLogger* event_logger)
|
||||
is_dct_enabled_ = NearbyFlags::GetInstance().GetBoolFlag(
|
||||
config_package_nearby::nearby_connections_feature::kEnableDct);
|
||||
analytics_recorder_ =
|
||||
std::make_unique<analytics::AnalyticsRecorder>(event_logger);
|
||||
std::make_unique<analytics::AnalyticsRecorderImpl>(event_logger);
|
||||
error_code_recorder_ = std::make_unique<ErrorCodeRecorder>(
|
||||
[this](const ErrorCodeParams& params) {
|
||||
analytics_recorder_->OnErrorCode(params);
|
||||
@@ -262,7 +264,7 @@ void ClientProxy::StartedAdvertising(
|
||||
const std::string& service_id, Strategy strategy,
|
||||
const ConnectionListener& listener,
|
||||
absl::Span<location::nearby::proto::connections::Medium> mediums,
|
||||
const std::vector<ConnectionsLog::OperationResultWithMedium>&
|
||||
const std::vector<analytics::OperationResultWithMedium>&
|
||||
operation_result_with_mediums,
|
||||
const AdvertisingOptions& advertising_options) {
|
||||
MutexLock lock(&mutex_);
|
||||
@@ -283,9 +285,9 @@ void ClientProxy::StartedAdvertising(
|
||||
mediums.begin(), mediums.end());
|
||||
std::unique_ptr<AdvertisingMetadataParams> advertising_metadata_params;
|
||||
advertising_metadata_params =
|
||||
GetAnalyticsRecorder().BuildAdvertisingMetadataParams();
|
||||
AnalyticsRecorder::BuildAdvertisingMetadataParams();
|
||||
advertising_metadata_params->operation_result_with_mediums =
|
||||
std::move(operation_result_with_mediums);
|
||||
operation_result_with_mediums;
|
||||
analytics_recorder_->OnStartAdvertising(strategy, medium_vector,
|
||||
advertising_metadata_params.get());
|
||||
}
|
||||
@@ -401,7 +403,7 @@ void ClientProxy::StartedDiscovery(
|
||||
const std::string& service_id, Strategy strategy,
|
||||
DiscoveryListener listener,
|
||||
absl::Span<location::nearby::proto::connections::Medium> mediums,
|
||||
const std::vector<ConnectionsLog::OperationResultWithMedium>&
|
||||
const std::vector<analytics::OperationResultWithMedium>&
|
||||
operation_result_with_mediums,
|
||||
const DiscoveryOptions& discovery_options) {
|
||||
MutexLock lock(&mutex_);
|
||||
@@ -411,10 +413,9 @@ void ClientProxy::StartedDiscovery(
|
||||
const std::vector<location::nearby::proto::connections::Medium> medium_vector(
|
||||
mediums.begin(), mediums.end());
|
||||
std::unique_ptr<DiscoveryMetadataParams> discovery_metadata_params;
|
||||
discovery_metadata_params =
|
||||
GetAnalyticsRecorder().BuildDiscoveryMetadataParams();
|
||||
discovery_metadata_params = AnalyticsRecorder::BuildDiscoveryMetadataParams();
|
||||
discovery_metadata_params->operation_result_with_mediums =
|
||||
std::move(operation_result_with_mediums);
|
||||
operation_result_with_mediums;
|
||||
analytics_recorder_->OnStartDiscovery(strategy, medium_vector,
|
||||
discovery_metadata_params.get());
|
||||
}
|
||||
|
||||
@@ -32,6 +32,7 @@
|
||||
#include "connections/connection_options.h"
|
||||
#include "connections/discovery_options.h"
|
||||
#include "connections/implementation/analytics/analytics_recorder.h"
|
||||
#include "connections/implementation/analytics/operation_result_with_medium.h"
|
||||
#include "connections/implementation/proto/offline_wire_formats.pb.h"
|
||||
#include "connections/listeners.h"
|
||||
#include "connections/medium_selector.h"
|
||||
@@ -54,7 +55,6 @@
|
||||
#include "internal/platform/mutex.h"
|
||||
#include "internal/platform/os_name.h"
|
||||
#include "internal/platform/scheduled_executor.h"
|
||||
#include "internal/proto/analytics/connections_log.pb.h"
|
||||
|
||||
namespace nearby::connections {
|
||||
|
||||
@@ -109,8 +109,7 @@ class ClientProxy final {
|
||||
const std::string& service_id, Strategy strategy,
|
||||
const ConnectionListener& connection_lifecycle_listener,
|
||||
absl::Span<location::nearby::proto::connections::Medium> mediums,
|
||||
const std::vector<location::nearby::analytics::proto::ConnectionsLog::
|
||||
OperationResultWithMedium>&
|
||||
const std::vector<analytics::OperationResultWithMedium>&
|
||||
operation_result_with_medium,
|
||||
const AdvertisingOptions& advertising_options = AdvertisingOptions{});
|
||||
// Marks this client as not advertising.
|
||||
@@ -134,8 +133,7 @@ class ClientProxy final {
|
||||
const std::string& service_id, Strategy strategy,
|
||||
DiscoveryListener discovery_listener,
|
||||
absl::Span<location::nearby::proto::connections::Medium> mediums,
|
||||
const std::vector<location::nearby::analytics::proto::ConnectionsLog::
|
||||
OperationResultWithMedium>&
|
||||
const std::vector<analytics::OperationResultWithMedium>&
|
||||
operation_result_with_medium,
|
||||
const DiscoveryOptions& discovery_options = DiscoveryOptions{});
|
||||
// Marks this client as not discovering at all.
|
||||
|
||||
@@ -35,8 +35,7 @@
|
||||
#include "proto/connections_enums.pb.h"
|
||||
#include "third_party/ukey2/src/main/cpp/include/securegcm/ukey2_handshake.h"
|
||||
|
||||
namespace nearby {
|
||||
namespace connections {
|
||||
namespace nearby::connections {
|
||||
namespace {
|
||||
|
||||
using ::location::nearby::proto::connections::Medium;
|
||||
@@ -65,10 +64,8 @@ class FakeEndpointChannel : public EndpointChannel {
|
||||
override {
|
||||
Close();
|
||||
}
|
||||
void Close(
|
||||
location::nearby::proto::connections::DisconnectionReason reason,
|
||||
location::nearby::analytics::proto::ConnectionsLog::
|
||||
EstablishedConnection::SafeDisconnectionResult result) override {
|
||||
void Close(location::nearby::proto::connections::DisconnectionReason reason,
|
||||
nearby::analytics::SafeDisconnectionResult result) override {
|
||||
Close();
|
||||
}
|
||||
bool IsClosed() const override { return false; }
|
||||
@@ -410,5 +407,4 @@ TEST(EncryptionRunnerTest, ClientSendsGarbageMessage3) {
|
||||
}
|
||||
|
||||
} // namespace
|
||||
} // namespace connections
|
||||
} // namespace nearby
|
||||
} // namespace nearby::connections
|
||||
|
||||
@@ -26,8 +26,7 @@
|
||||
#include "internal/platform/byte_array.h"
|
||||
#include "internal/platform/exception.h"
|
||||
|
||||
namespace nearby {
|
||||
namespace connections {
|
||||
namespace nearby::connections {
|
||||
|
||||
class EndpointChannel {
|
||||
public:
|
||||
@@ -51,8 +50,7 @@ class EndpointChannel {
|
||||
// and safe disconnection result.
|
||||
virtual void Close(
|
||||
location::nearby::proto::connections::DisconnectionReason reason,
|
||||
location::nearby::analytics::proto::ConnectionsLog::
|
||||
EstablishedConnection::SafeDisconnectionResult result) = 0;
|
||||
nearby::analytics::SafeDisconnectionResult result) = 0;
|
||||
|
||||
// True if the EndpointChannel is currently closed.
|
||||
virtual bool IsClosed() const = 0;
|
||||
@@ -141,7 +139,6 @@ inline bool operator!=(const EndpointChannel& lhs, const EndpointChannel& rhs) {
|
||||
return !(lhs == rhs);
|
||||
}
|
||||
|
||||
} // namespace connections
|
||||
} // namespace nearby
|
||||
} // namespace nearby::connections
|
||||
|
||||
#endif // CORE_INTERNAL_ENDPOINT_CHANNEL_H_
|
||||
|
||||
@@ -29,10 +29,7 @@
|
||||
#include "internal/platform/mutex.h"
|
||||
#include "internal/platform/mutex_lock.h"
|
||||
|
||||
namespace nearby {
|
||||
namespace connections {
|
||||
using ::location::nearby::analytics::proto::ConnectionsLog;
|
||||
|
||||
namespace nearby::connections {
|
||||
namespace {
|
||||
const absl::Duration kDataTransferDelay = absl::Milliseconds(500);
|
||||
}
|
||||
@@ -183,7 +180,7 @@ void EndpointChannelManager::ChannelState::DestroyAll() {
|
||||
for (auto& item : endpoints_) {
|
||||
RemoveEndpoint(item.first, DisconnectionReason::SHUTDOWN,
|
||||
/* safe_to_disconnect_enabled */ false,
|
||||
ConnectionsLog::EstablishedConnection::SAFE_DISCONNECTION);
|
||||
SafeDisconnectionResult::kSafeDisconnection);
|
||||
}
|
||||
endpoints_.clear();
|
||||
}
|
||||
@@ -365,5 +362,4 @@ bool EndpointChannelManager::UnregisterChannelForEndpoint(
|
||||
return true;
|
||||
}
|
||||
|
||||
} // namespace connections
|
||||
} // namespace nearby
|
||||
} // namespace nearby::connections
|
||||
|
||||
@@ -21,18 +21,16 @@
|
||||
#include "absl/base/thread_annotations.h"
|
||||
#include "absl/container/flat_hash_map.h"
|
||||
#include "absl/time/time.h"
|
||||
#include "connections/implementation/analytics/analytics_recorder.h"
|
||||
#include "connections/implementation/client_proxy.h"
|
||||
#include "connections/implementation/endpoint_channel.h"
|
||||
#include "internal/platform/mutex.h"
|
||||
#include "internal/proto/analytics/connections_log.pb.h"
|
||||
#include "proto/connections_enums.pb.h"
|
||||
|
||||
namespace nearby {
|
||||
namespace connections {
|
||||
namespace nearby::connections {
|
||||
using DisconnectionReason =
|
||||
::location::nearby::proto::connections::DisconnectionReason;
|
||||
using SafeDisconnectionResult = ::location::nearby::analytics::proto::
|
||||
ConnectionsLog::EstablishedConnection::SafeDisconnectionResult;
|
||||
using SafeDisconnectionResult = nearby::analytics::SafeDisconnectionResult;
|
||||
|
||||
// NOTE(std::string):
|
||||
// All the strings in internal class public interfaces should be exchanged as
|
||||
@@ -215,7 +213,6 @@ class EndpointChannelManager final {
|
||||
ChannelState channel_state_;
|
||||
};
|
||||
|
||||
} // namespace connections
|
||||
} // namespace nearby
|
||||
} // namespace nearby::connections
|
||||
|
||||
#endif // CORE_INTERNAL_ENDPOINT_CHANNEL_MANAGER_H_
|
||||
|
||||
@@ -27,6 +27,7 @@
|
||||
#include "absl/strings/string_view.h"
|
||||
#include "absl/synchronization/mutex.h"
|
||||
#include "absl/time/time.h"
|
||||
#include "connections/implementation/analytics/analytics_recorder.h"
|
||||
#include "connections/implementation/base_endpoint_channel.h"
|
||||
#include "connections/implementation/client_proxy.h"
|
||||
#include "connections/implementation/encryption_runner.h"
|
||||
@@ -39,16 +40,14 @@
|
||||
#include "internal/platform/multi_thread_executor.h"
|
||||
#include "internal/platform/output_stream.h"
|
||||
#include "internal/platform/pipe.h"
|
||||
#include "internal/proto/analytics/connections_log.pb.h"
|
||||
#include "proto/connections_enums.pb.h"
|
||||
|
||||
namespace nearby {
|
||||
namespace connections {
|
||||
namespace nearby::connections {
|
||||
namespace {
|
||||
|
||||
using ::location::nearby::analytics::proto::ConnectionsLog;
|
||||
using ::location::nearby::proto::connections::DisconnectionReason;
|
||||
using ::location::nearby::proto::connections::Medium;
|
||||
using ::nearby::analytics::SafeDisconnectionResult;
|
||||
using EncryptionContext = BaseEndpointChannel::EncryptionContext;
|
||||
|
||||
constexpr size_t kChunkSize = 64 * 1024;
|
||||
@@ -243,10 +242,10 @@ TEST(BaseEndpointChannelManagerTest, RegisterChannelEncryptedReadwrite) {
|
||||
channel_b_raw->Close(DisconnectionReason::REMOTE_DISCONNECTION);
|
||||
ecm_a.UnregisterChannelForEndpoint(
|
||||
std::string(kEndpointId), DisconnectionReason::LOCAL_DISCONNECTION,
|
||||
ConnectionsLog::EstablishedConnection::SAFE_DISCONNECTION);
|
||||
SafeDisconnectionResult::kSafeDisconnection);
|
||||
ecm_b.UnregisterChannelForEndpoint(
|
||||
std::string(kEndpointId), DisconnectionReason::REMOTE_DISCONNECTION,
|
||||
ConnectionsLog::EstablishedConnection::SAFE_DISCONNECTION);
|
||||
SafeDisconnectionResult::kSafeDisconnection);
|
||||
}
|
||||
|
||||
TEST(BaseEndpointChannelManagerTest, ReplaceChannelNoEncrypted) {
|
||||
@@ -311,12 +310,11 @@ TEST(BaseEndpointChannelManagerTest, ReplaceChannelNoEncrypted) {
|
||||
channel_b_raw->Close(DisconnectionReason::REMOTE_DISCONNECTION);
|
||||
ecm_a.UnregisterChannelForEndpoint(
|
||||
std::string(kEndpointId), DisconnectionReason::LOCAL_DISCONNECTION,
|
||||
ConnectionsLog::EstablishedConnection::SAFE_DISCONNECTION);
|
||||
SafeDisconnectionResult::kSafeDisconnection);
|
||||
ecm_b.UnregisterChannelForEndpoint(
|
||||
std::string(kEndpointId), DisconnectionReason::REMOTE_DISCONNECTION,
|
||||
ConnectionsLog::EstablishedConnection::SAFE_DISCONNECTION);
|
||||
SafeDisconnectionResult::kSafeDisconnection);
|
||||
}
|
||||
|
||||
} // namespace
|
||||
} // namespace connections
|
||||
} // namespace nearby
|
||||
} // namespace nearby::connections
|
||||
|
||||
@@ -24,6 +24,7 @@
|
||||
#include "absl/functional/any_invocable.h"
|
||||
#include "absl/time/time.h"
|
||||
#include "connections/connection_options.h"
|
||||
#include "connections/implementation/analytics/analytics_recorder.h"
|
||||
#include "connections/implementation/client_proxy.h"
|
||||
#include "connections/implementation/endpoint_channel.h"
|
||||
#include "connections/implementation/endpoint_channel_manager.h"
|
||||
@@ -42,19 +43,17 @@
|
||||
#include "internal/platform/mutex_lock.h"
|
||||
#include "internal/platform/runnable.h"
|
||||
#include "internal/platform/single_thread_executor.h"
|
||||
#include "internal/proto/analytics/connections_log.pb.h"
|
||||
#include "proto/connections_enums.pb.h"
|
||||
|
||||
namespace nearby {
|
||||
namespace connections {
|
||||
namespace nearby::connections {
|
||||
|
||||
namespace {
|
||||
using ::location::nearby::analytics::proto::ConnectionsLog;
|
||||
using ::location::nearby::connections::KeepAliveFrame;
|
||||
using ::location::nearby::connections::OfflineFrame;
|
||||
using ::location::nearby::connections::PayloadTransferFrame;
|
||||
using ::location::nearby::connections::V1Frame;
|
||||
using ::location::nearby::proto::connections::DisconnectionReason;
|
||||
using ::nearby::analytics::SafeDisconnectionResult;
|
||||
|
||||
// We set this to 11s to provide sufficient time for an in-progress WebRTC
|
||||
// bandwidth upgrade to resolve. This is chosen to be slightly longer than the
|
||||
@@ -743,7 +742,7 @@ void EndpointManager::RemoveEndpoint(ClientProxy* client,
|
||||
<< ", reason: " << reason;
|
||||
|
||||
SafeDisconnectionResult safe_disconnect_result =
|
||||
ConnectionsLog::EstablishedConnection::SAFE_DISCONNECTION;
|
||||
SafeDisconnectionResult::kSafeDisconnection;
|
||||
|
||||
// Grab the service ID before we destroy the channel.
|
||||
EndpointChannel* channel =
|
||||
@@ -756,11 +755,13 @@ void EndpointManager::RemoveEndpoint(ClientProxy* client,
|
||||
bool is_safe_disconnection =
|
||||
ApplySafeToDisconnect(endpoint_id, channel, reason);
|
||||
safe_disconnect_result =
|
||||
is_safe_disconnection
|
||||
? ConnectionsLog::EstablishedConnection::SAFE_DISCONNECTION
|
||||
: ConnectionsLog::EstablishedConnection::UNSAFE_DISCONNECTION;
|
||||
is_safe_disconnection ? SafeDisconnectionResult::kSafeDisconnection
|
||||
: SafeDisconnectionResult::kUnsafeDisconnection;
|
||||
LOG(INFO) << "[safe-to-disconnect] safe_disconnect_result:"
|
||||
<< (safe_disconnect_result ? "true" : "false");
|
||||
<< (safe_disconnect_result ==
|
||||
SafeDisconnectionResult::kSafeDisconnection
|
||||
? "true"
|
||||
: "false");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -953,7 +954,7 @@ EndpointManager::EndpointState::~EndpointState() {
|
||||
VLOG(1) << "EndpointState destructor " << endpoint_id_;
|
||||
channel_manager_->UnregisterChannelForEndpoint(
|
||||
endpoint_id_, DisconnectionReason::SHUTDOWN,
|
||||
ConnectionsLog::EstablishedConnection::SAFE_DISCONNECTION);
|
||||
SafeDisconnectionResult::kSafeDisconnection);
|
||||
}
|
||||
|
||||
// Make sure the KeepAlive thread isn't blocking shutdown.
|
||||
@@ -982,5 +983,4 @@ void EndpointManager::RunOnEndpointManagerThread(const std::string& name,
|
||||
serial_executor_->Execute(name, std::move(runnable));
|
||||
}
|
||||
|
||||
} // namespace connections
|
||||
} // namespace nearby
|
||||
} // namespace nearby::connections
|
||||
|
||||
@@ -27,8 +27,7 @@
|
||||
#include "internal/platform/exception.h"
|
||||
#include "internal/platform/implementation/system_clock.h"
|
||||
|
||||
namespace nearby {
|
||||
namespace connections {
|
||||
namespace nearby::connections {
|
||||
|
||||
// An endpoint channel implementation used for testing. The read and write
|
||||
// output can be set.
|
||||
@@ -56,10 +55,8 @@ class FakeEndpointChannel : public EndpointChannel {
|
||||
is_closed_ = true;
|
||||
disconnection_reason_ = reason;
|
||||
}
|
||||
void Close(
|
||||
location::nearby::proto::connections::DisconnectionReason reason,
|
||||
location::nearby::analytics::proto::ConnectionsLog::
|
||||
EstablishedConnection::SafeDisconnectionResult result) override {
|
||||
void Close(location::nearby::proto::connections::DisconnectionReason reason,
|
||||
nearby::analytics::SafeDisconnectionResult result) override {
|
||||
Close(reason);
|
||||
}
|
||||
bool IsClosed() const override { return is_closed_; }
|
||||
@@ -119,7 +116,6 @@ class FakeEndpointChannel : public EndpointChannel {
|
||||
mutable uint32_t next_keep_alive_seq_no_ = 0;
|
||||
};
|
||||
|
||||
} // namespace connections
|
||||
} // namespace nearby
|
||||
} // namespace nearby::connections
|
||||
|
||||
#endif // NEARBY_CONNECTIONS_IMPLEMENTATION_FAKE_ENDPOINT_CHANNEL_H_
|
||||
|
||||
@@ -40,8 +40,7 @@ class MockEndpointChannel : public EndpointChannel {
|
||||
(override));
|
||||
MOCK_METHOD(void, Close,
|
||||
(location::nearby::proto::connections::DisconnectionReason reason,
|
||||
location::nearby::analytics::proto::ConnectionsLog::
|
||||
EstablishedConnection::SafeDisconnectionResult result),
|
||||
nearby::analytics::SafeDisconnectionResult result),
|
||||
(override));
|
||||
MOCK_METHOD(bool, IsClosed, (), (const, override));
|
||||
MOCK_METHOD(std::string, GetType, (), (const, override));
|
||||
|
||||
@@ -29,6 +29,7 @@
|
||||
#include "absl/strings/str_cat.h"
|
||||
#include "absl/strings/str_format.h"
|
||||
#include "absl/time/time.h"
|
||||
#include "connections/implementation/analytics/analytics_recorder.h"
|
||||
#include "connections/implementation/client_proxy.h"
|
||||
#include "connections/implementation/endpoint_channel_manager.h"
|
||||
#include "connections/implementation/endpoint_manager.h"
|
||||
@@ -63,7 +64,7 @@ using ::location::nearby::connections::V1Frame;
|
||||
using ::location::nearby::proto::connections::Medium;
|
||||
using ::location::nearby::proto::connections::OperationResultCode;
|
||||
using ::location::nearby::proto::connections::PayloadStatus;
|
||||
using PayloadDirection = ::nearby::connections::PayloadDirection;
|
||||
using ::nearby::analytics::AnalyticsRecorder;
|
||||
|
||||
constexpr absl::Duration kMinTransferUpdateInterval = absl::Milliseconds(50);
|
||||
} // namespace
|
||||
@@ -620,9 +621,8 @@ void PayloadManager::OnEndpointDisconnect(ClientProxy* client,
|
||||
default:
|
||||
payload_status = PayloadStatus::ENDPOINT_IO_ERROR;
|
||||
operation_result_code =
|
||||
client->GetAnalyticsRecorder()
|
||||
.GetChannelIoErrorResultCodeFromMedium(
|
||||
client->GetConnectedMedium(endpoint_id));
|
||||
AnalyticsRecorder::GetChannelIoErrorResultCodeFromMedium(
|
||||
client->GetConnectedMedium(endpoint_id));
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -839,9 +839,8 @@ void PayloadManager::SendClientCallbacksForFinishedOutgoingPayload(
|
||||
endpoint_id, payload_header.id(), status,
|
||||
(operation_result_code == OperationResultCode::DETAIL_UNKNOWN &&
|
||||
status == PayloadStatus::ENDPOINT_IO_ERROR)
|
||||
? client->GetAnalyticsRecorder()
|
||||
.GetChannelIoErrorResultCodeFromMedium(
|
||||
client->GetConnectedMedium(endpoint_id))
|
||||
? AnalyticsRecorder::GetChannelIoErrorResultCodeFromMedium(
|
||||
client->GetConnectedMedium(endpoint_id))
|
||||
: operation_result_code);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user