Add flag for filesync.

PiperOrigin-RevId: 874199291
This commit is contained in:
Francis Tsui
2026-02-23 12:27:44 -08:00
committed by Copybara-Service
parent 295f480dc1
commit 6308d5f200
6 changed files with 18 additions and 8 deletions
@@ -64,6 +64,9 @@ constexpr auto kShowAutoUpdateSetting =
// The default time in milliseconds a cached entry can be in LOST state.
constexpr auto kDiscoveryCacheLostExpiryMs =
flags::Flag<int64_t>(kConfigPackage, "45658774", 15000);
// When true, enable file sync feature.
constexpr auto kEnableFileSync =
flags::Flag<bool>(kConfigPackage, "45762616", false);
// When true, enable wifi hotspot medium for HP Realtek devices.
constexpr auto kEnableWifiHotspotForHpRealtekDevices =
flags::Flag<bool>(kConfigPackage, "45673628", false);
@@ -109,6 +112,7 @@ inline absl::btree_map<int, const flags::Flag<bool>&> GetBoolFlags() {
{45418908, kEnableSelfShareUi},
{45459748, kEnableSendingDesktopEvents},
{45409033, kShowAutoUpdateSetting},
{45762616, kEnableFileSync},
{45673628, kEnableWifiHotspotForHpRealtekDevices},
{45683539, kUseAlternateServiceUuidForDiscovery},
{45662570, kEnableBetaLabel},
+3 -2
View File
@@ -40,7 +40,7 @@ NearbySharingServiceFactory* NearbySharingServiceFactory::GetInstance() {
NearbySharingService* NearbySharingServiceFactory::CreateSharingService(
SharingPlatform& sharing_platform,
analytics::AnalyticsRecorder* analytics_recorder,
::nearby::analytics::EventLogger* event_logger) {
::nearby::analytics::EventLogger* event_logger, bool supports_file_sync) {
if (nearby_sharing_service_ != nullptr) {
return nullptr;
}
@@ -66,7 +66,8 @@ NearbySharingService* NearbySharingServiceFactory::CreateSharingService(
std::move(service_thread), context_.get(), sharing_platform,
std::move(nearby_share_client_factory),
std::move(nearby_connections_manager),
std::move(nearby_share_contact_manager), analytics_recorder);
std::move(nearby_share_contact_manager), analytics_recorder,
supports_file_sync);
return nearby_sharing_service_.get();
}
+2 -1
View File
@@ -33,7 +33,8 @@ class NearbySharingServiceFactory {
NearbySharingService* CreateSharingService(
nearby::sharing::api::SharingPlatform& sharing_platform,
analytics::AnalyticsRecorder* analytics_recorder,
nearby::analytics::EventLogger* event_logger);
nearby::analytics::EventLogger* event_logger,
bool supports_file_sync);
private:
NearbySharingServiceFactory() = default;
+4 -2
View File
@@ -237,13 +237,14 @@ NearbySharingServiceImpl::NearbySharingServiceImpl(
std::unique_ptr<SharingRpcClientFactory> nearby_share_client_factory,
std::unique_ptr<NearbyConnectionsManager> nearby_connections_manager,
std::unique_ptr<NearbyShareContactManager> contact_manager,
analytics::AnalyticsRecorder* analytics_recorder)
analytics::AnalyticsRecorder* analytics_recorder, bool supports_file_sync)
: service_thread_(std::move(service_thread)),
context_(context),
device_info_(sharing_platform.GetDeviceInfo()),
preference_manager_(sharing_platform.GetPreferenceManager()),
account_manager_(sharing_platform.GetAccountManager()),
analytics_recorder_(*analytics_recorder),
supports_file_sync_(supports_file_sync),
nearby_connections_manager_(std::move(nearby_connections_manager)),
nearby_share_client_factory_(std::move(nearby_share_client_factory)),
local_device_data_manager_(
@@ -1505,7 +1506,8 @@ NearbySharingServiceImpl::CreateEndpointInfo(
static_cast<ShareTargetType>(device_info_.GetDeviceType());
AdvertisementCapabilities capabilities{};
if (supports_file_sync_) {
if (supports_file_sync_ && NearbyFlags::GetInstance().GetBoolFlag(
config_package_nearby::nearby_sharing_feature::kEnableFileSync)) {
capabilities.Add(AdvertisementCapabilities::Capability::kFileSync);
}
std::unique_ptr<Advertisement> advertisement = Advertisement::NewInstance(
+4 -2
View File
@@ -106,7 +106,8 @@ class NearbySharingServiceImpl
nearby_share_client_factory,
std::unique_ptr<NearbyConnectionsManager> nearby_connections_manager,
std::unique_ptr<NearbyShareContactManager> contact_manager,
analytics::AnalyticsRecorder* analytics_recorder);
analytics::AnalyticsRecorder* analytics_recorder,
bool supports_file_sync);
~NearbySharingServiceImpl() override;
// NearbySharingService
@@ -410,6 +411,8 @@ class NearbySharingServiceImpl
AccountManager& account_manager_;
// Used to create analytics events.
analytics::AnalyticsRecorder& analytics_recorder_;
// Whether the device supports file sync extension.
const bool supports_file_sync_;
std::unique_ptr<NearbyConnectionsManager> nearby_connections_manager_;
std::unique_ptr<nearby::sharing::api::SharingRpcClientFactory>
@@ -524,7 +527,6 @@ class NearbySharingServiceImpl
// If true, a new endpoint id will be generated at the next advertisement.
bool force_new_endpoint_id_ = false;
OutgoingTargetsManager outgoing_targets_manager_;
bool supports_file_sync_ = false;
};
} // namespace nearby::sharing
+1 -1
View File
@@ -485,7 +485,7 @@ class NearbySharingServiceImplTest : public testing::Test {
/*nearby_share_client_factory=*/nullptr,
absl::WrapUnique(fake_nearby_connections_manager_),
absl::WrapUnique(contact_manager_),
analytics_recorder_.get());
analytics_recorder_.get(), /*supports_file_sync=*/false);
}
void SetVisibility(DeviceVisibility visibility) {