PiperOrigin-RevId: 938618617
This commit is contained in:
Francis Tsui
2026-06-26 09:03:22 -07:00
committed by Copybara-Service
parent 700b3666c0
commit fa3ea7efd5
5 changed files with 45 additions and 7 deletions
+10
View File
@@ -847,6 +847,8 @@ enum SharingUseCase {
// The user was redirected from Bluetooth sharing UI to Nearby Share
USE_CASE_REDIRECTED_FROM_BLUETOOTH_SHARE = 8;
USE_CASE_TAP_TO_SHARE = 9;
// Automatic backup use case.
USE_CASE_FILE_SYNC = 10;
}
enum SharingSurface {
@@ -1067,3 +1069,11 @@ enum CloudActionType {
// The action is a retry of a previous failed upload/download.
CLOUD_ACTION_TYPE_RETRY = 2;
}
// Defines how the device is powered.
enum PowerStatus {
POWER_STATUS_UNKNOWN = 0;
POWER_STATUS_BATTERY = 1;
POWER_STATUS_AC = 2;
POWER_STATUS_BATTERY_AND_AC = 3;
}
+2
View File
@@ -249,6 +249,7 @@ cc_library(
"//internal/base:file_path",
"//internal/base:files",
"//internal/platform:types",
"//location/nearby/cpp/sharing/clients/cpp/common",
"//proto:sharing_enums_cc_proto",
"//sharing/analytics",
"//sharing/certificates",
@@ -401,6 +402,7 @@ cc_library(
"//internal/platform:types",
"//internal/platform/implementation:types",
"//location/nearby/analytics/cpp/logging:event_logger",
"//location/nearby/cpp/sharing/clients/cpp/common",
"//location/nearby/sharing/lib/account:account_manager",
"//location/nearby/sharing/lib/rpc:grpc_async_client_factory",
"//location/nearby/sharing/lib/rpc:sharing_rpc_client",
+5 -2
View File
@@ -111,7 +111,9 @@ class AnalyticsRecorder {
virtual void NewReceiveIntroduction(
int64_t session_id, const ShareTarget& share_target,
std::optional<std::string> referrer_package,
location::nearby::proto::sharing::OSType share_target_os_type) = 0;
location::nearby::proto::sharing::OSType share_target_os_type,
location::nearby::proto::sharing::SharingUseCase sharing_use_case,
location::nearby::proto::sharing::PowerStatus power_status) = 0;
virtual void NewRespondToIntroduction(
location::nearby::proto::sharing::ResponseToIntroduction action,
@@ -158,7 +160,8 @@ class AnalyticsRecorder {
virtual void NewSendIntroduction(
int64_t session_id, const ShareTarget& share_target,
int transfer_position, int concurrent_connections,
location::nearby::proto::sharing::OSType share_target_os_type) = 0;
location::nearby::proto::sharing::OSType share_target_os_type,
location::nearby::proto::sharing::PowerStatus power_status) = 0;
virtual void NewSetVisibility(
nearby::sharing::proto::DeviceVisibility src_visibility,
+22 -1
View File
@@ -31,6 +31,7 @@
#include <utility>
#include <vector>
#include "location/nearby/cpp/sharing/clients/cpp/common/nearby_sharing_common.h"
#include "location/nearby/sharing/lib/account/account_manager.h"
#include "location/nearby/sharing/lib/rpc/sharing_rpc_client.h"
#include "location/nearby/sharing/lib/sync/sync_binding_prefs.pb.h"
@@ -251,6 +252,24 @@ sync::SyncBinding::SourceDeviceType ShareTargetTypeToSourceDeviceType(
return sync::SyncBinding::SOURCE_DEVICE_TYPE_UNKNOWN;
}
}
location::nearby::proto::sharing::SharingUseCase
IntroductionUseCaseToLoggingUseCase(
IntroductionFrame::SharingUseCase use_case) {
switch (use_case) {
case IntroductionFrame::NEARBY_SHARE:
return location::nearby::proto::sharing::SharingUseCase::
USE_CASE_NEARBY_SHARE;
case IntroductionFrame::TAP_TO_SHARE:
return location::nearby::proto::sharing::SharingUseCase::
USE_CASE_TAP_TO_SHARE;
case IntroductionFrame::FILE_SYNC:
return location::nearby::proto::sharing::SharingUseCase::
USE_CASE_FILE_SYNC;
default:
return location::nearby::proto::sharing::SharingUseCase::USE_CASE_UNKNOWN;
}
}
} // namespace
NearbySharingServiceImpl::NearbySharingServiceImpl(
@@ -2736,7 +2755,9 @@ void NearbySharingServiceImpl::OnReceivedIntroduction(
// Log analytics event of receiving introduction.
analytics_recorder_.NewReceiveIntroduction(
session.session_id(), session.share_target(),
/*referrer_package=*/std::nullopt, session.os_type());
/*referrer_package=*/std::nullopt, session.os_type(),
IntroductionUseCaseToLoggingUseCase(frame.use_case()),
nearby::sharing::cpp::common::GetPowerStatus());
std::optional<size_t> available_storage =
device_info_.GetAvailableDiskSpaceInBytes(save_path);
+5 -3
View File
@@ -23,6 +23,7 @@
#include <utility>
#include <vector>
#include "location/nearby/cpp/sharing/clients/cpp/common/nearby_sharing_common.h"
#include "absl/functional/any_invocable.h"
#include "absl/strings/string_view.h"
#include "absl/time/time.h"
@@ -422,10 +423,11 @@ bool OutgoingShareSession::SendIntroduction(
}
WriteFrame(frame);
// Log analytics event of sending introduction.
analytics_recorder().NewSendIntroduction(session_id(), share_target(),
analytics_recorder().NewSendIntroduction(
session_id(), share_target(),
/*transfer_position=*/1,
/*concurrent_connections=*/1,
os_type());
/*concurrent_connections=*/1, os_type(),
nearby::sharing::cpp::common::GetPowerStatus());
VLOG(1) << "Successfully wrote the introduction frame";
ready_for_accept_ = true;
mutual_acceptance_timeout_ = std::make_unique<ThreadTimer>(