From 3cd3614a4acae9a2f4aef5ec64427e088730c9c3 Mon Sep 17 00:00:00 2001 From: Francis Tsui Date: Tue, 24 Sep 2024 10:29:38 -0700 Subject: [PATCH] Deprecate flags that have been fully rolled out. PiperOrigin-RevId: 678305598 --- sharing/BUILD | 1 + .../generated/nearby_sharing_feature_flags.h | 24 ++---------- sharing/nearby_connections_manager_impl.cc | 23 +++++------ .../nearby_connections_manager_impl_test.cc | 39 ++----------------- sharing/nearby_sharing_service_impl.cc | 30 +++----------- sharing/nearby_sharing_service_impl_test.cc | 4 -- 6 files changed, 23 insertions(+), 98 deletions(-) diff --git a/sharing/BUILD b/sharing/BUILD index 096c1510..69b3e50e 100644 --- a/sharing/BUILD +++ b/sharing/BUILD @@ -524,6 +524,7 @@ cc_test( "//sharing/internal/test:nearby_test", "//sharing/proto:enums_cc_proto", "@com_github_protobuf_matchers//protobuf-matchers", + "@com_google_absl//absl/container:flat_hash_set", "@com_google_absl//absl/strings:string_view", "@com_google_absl//absl/synchronization", "@com_google_absl//absl/time", diff --git a/sharing/flags/generated/nearby_sharing_feature_flags.h b/sharing/flags/generated/nearby_sharing_feature_flags.h index f63de976..bcca7cd6 100755 --- a/sharing/flags/generated/nearby_sharing_feature_flags.h +++ b/sharing/flags/generated/nearby_sharing_feature_flags.h @@ -32,21 +32,12 @@ namespace nearby_sharing_feature { // Time to delay the endpoint loss in milliseconds. constexpr auto kDelayEndpointLossMs = flags::Flag(kConfigPackage, "45632386", 500); -// When true, delete the file payload which received unexpectedly. -constexpr auto kDeleteUnexpectedReceivedFile = - flags::Flag(kConfigPackage, "45627826", true); // Enable/disable the use of BLE as a connection medium. constexpr auto kEnableBleForTransfer = flags::Flag(kConfigPackage, "45427466", false); // Enable/disable certificates dump constexpr auto kEnableCertificatesDump = flags::Flag(kConfigPackage, "45409184", false); -// Enable/disable dumping feature flags -constexpr auto kEnableDumpingFeatureFlags = - flags::Flag(kConfigPackage, "45415713", true); -// Enable/disable logging additional system info metrics -constexpr auto kEnableLoggingSystemInfoMetrics = - flags::Flag(kConfigPackage, "45412418", true); // Enable/disable WebRTC medium in Nearby Share constexpr auto kEnableMediumWebRtc = flags::Flag(kConfigPackage, "45418905", false); @@ -79,12 +70,12 @@ constexpr auto kSenderSkipsConfirmation = // Enable/disable auto-update on settings page constexpr auto kShowAutoUpdateSetting = flags::Flag(kConfigPackage, "45409033", false); -// When true, we only upgrade the bandwidth after accepting a connection. -constexpr auto kUpgradeBandwidthAfterAccept = - flags::Flag(kConfigPackage, "45627824", true); // When true, use gRpc client to access backend. constexpr auto kUseGrpcClient = flags::Flag(kConfigPackage, "45630055", false); +// When true, dedup discovered endpoints. +constexpr auto kApplyEndpointsDedup = + flags::Flag(kConfigPackage, "45656298", false); // Enable/disable QR Code UI constexpr auto kEnableQrCodeUi = flags::Flag(kConfigPackage, "45417647", false); @@ -94,17 +85,11 @@ constexpr auto kShowAdminModeWarning = // Update track constexpr auto kUpdateTrack = flags::Flag(kConfigPackage, "45409861", ""); -// Apply endpoints de-duplication algorithms. -constexpr auto kApplyEndpointsDedup = - flags::Flag(kConfigPackage, "45656298", false); inline absl::btree_map&> GetBoolFlags() { return { - {45627826, kDeleteUnexpectedReceivedFile}, {45427466, kEnableBleForTransfer}, {45409184, kEnableCertificatesDump}, - {45415713, kEnableDumpingFeatureFlags}, - {45412418, kEnableLoggingSystemInfoMetrics}, {45418905, kEnableMediumWebRtc}, {45418906, kEnableMediumWifiLan}, {45411589, kEnableRetryResumeTransfer}, @@ -114,11 +99,10 @@ inline absl::btree_map&> GetBoolFlags() { {45411620, kEnableWebrtcMedium}, {45411353, kSenderSkipsConfirmation}, {45409033, kShowAutoUpdateSetting}, - {45627824, kUpgradeBandwidthAfterAccept}, {45630055, kUseGrpcClient}, + {45656298, kApplyEndpointsDedup}, {45417647, kEnableQrCodeUi}, {45410558, kShowAdminModeWarning}, - {45656298, kApplyEndpointsDedup}, }; } diff --git a/sharing/nearby_connections_manager_impl.cc b/sharing/nearby_connections_manager_impl.cc index 0e90f4ab..f3162000 100644 --- a/sharing/nearby_connections_manager_impl.cc +++ b/sharing/nearby_connections_manager_impl.cc @@ -39,7 +39,6 @@ #include "sharing/common/nearby_share_enums.h" #include "sharing/constants.h" #include "sharing/flags/generated/nearby_sharing_feature_flags.h" -#include "sharing/internal/api/bluetooth_adapter.h" #include "sharing/internal/base/encode.h" #include "sharing/internal/public/connectivity_manager.h" #include "sharing/internal/public/context.h" @@ -790,19 +789,15 @@ void NearbyConnectionsManagerImpl::OnPayloadReceived( void NearbyConnectionsManagerImpl::ProcessUnknownFilePathsToDelete( PayloadStatus status, PayloadContent::Type type, const std::filesystem::path& path) { - if (NearbyFlags::GetInstance().GetBoolFlag( - sharing::config_package_nearby::nearby_sharing_feature:: - kDeleteUnexpectedReceivedFile)) { - // Unknown payload comes as kInProgress and kCanceled status with kFile type - // from NearbyConnections. Delete it. - if ((status == PayloadStatus::kCanceled || - status == PayloadStatus::kInProgress) && - type == PayloadContent::Type::kFile) { - NL_LOG(WARNING) << __func__ - << ": Unknown payload has been canceled, removing."; - MutexLock lock(&mutex_); - file_paths_to_delete_.insert(path); - } + // Unknown payload comes as kInProgress and kCanceled status with kFile type + // from NearbyConnections. Delete it. + if ((status == PayloadStatus::kCanceled || + status == PayloadStatus::kInProgress) && + type == PayloadContent::Type::kFile) { + NL_LOG(WARNING) << __func__ + << ": Unknown payload has been canceled, removing."; + MutexLock lock(&mutex_); + file_paths_to_delete_.insert(path); } } diff --git a/sharing/nearby_connections_manager_impl_test.cc b/sharing/nearby_connections_manager_impl_test.cc index 79e54e45..3a91b921 100644 --- a/sharing/nearby_connections_manager_impl_test.cc +++ b/sharing/nearby_connections_manager_impl_test.cc @@ -29,6 +29,7 @@ #include "gmock/gmock.h" #include "protobuf-matchers/protocol-buffer-matchers.h" #include "gtest/gtest.h" +#include "absl/container/flat_hash_set.h" #include "absl/strings/string_view.h" #include "absl/synchronization/notification.h" #include "absl/time/time.h" @@ -1788,29 +1789,11 @@ TEST_F(NearbyConnectionsManagerImplTest, payload_listener_remote.payload_cb(kRemoteEndpointId, Payload(kPayloadId, InputFile(file))); - // Flag is off. Don't add unknown file paths to the list. - NearbyFlags::GetInstance().OverrideBoolFlagValue( - config_package_nearby::nearby_sharing_feature:: - kDeleteUnexpectedReceivedFile, - false); - auto unknown_file_paths = - nearby_connections_manager_->GetUnknownFilePathsToDeleteForTesting(); - EXPECT_TRUE(unknown_file_paths.empty()); nearby_connections_manager_->OnPayloadTransferUpdateForTesting( kRemoteEndpointId, PayloadTransferUpdate(kPayloadId, PayloadStatus::kCanceled, kTotalSize, /*bytes_transferred=*/kTotalSize)); - - // Flag is on. Add unknown file paths with kCanceled to the list. - NearbyFlags::GetInstance().OverrideBoolFlagValue( - config_package_nearby::nearby_sharing_feature:: - kDeleteUnexpectedReceivedFile, - true); - nearby_connections_manager_->OnPayloadTransferUpdateForTesting( - kRemoteEndpointId, - PayloadTransferUpdate(kPayloadId, PayloadStatus::kCanceled, kTotalSize, - /*bytes_transferred=*/kTotalSize)); - unknown_file_paths = + absl::flat_hash_set unknown_file_paths = nearby_connections_manager_->GetUnknownFilePathsToDeleteForTesting(); EXPECT_EQ(unknown_file_paths.size(), 1); nearby_connections_manager_->GetAndClearUnknownFilePathsToDelete(); @@ -1828,25 +1811,9 @@ TEST_F(NearbyConnectionsManagerImplTest, TEST_F(NearbyConnectionsManagerImplTest, ProcessUnknownFilePathsToDelete) { std::filesystem::path file(std::filesystem::temp_directory_path() / "file.jpg"); - // Flag is off. Don't add unknown file paths to the list. - NearbyFlags::GetInstance().OverrideBoolFlagValue( - config_package_nearby::nearby_sharing_feature:: - kDeleteUnexpectedReceivedFile, - false); - auto unknown_file_paths = - nearby_connections_manager_->GetUnknownFilePathsToDeleteForTesting(); nearby_connections_manager_->ProcessUnknownFilePathsToDeleteForTesting( PayloadStatus::kCanceled, PayloadContent::Type::kFile, file); - EXPECT_TRUE(unknown_file_paths.empty()); - - // Flag is on. Add unknown file paths with kCanceled to the list. - NearbyFlags::GetInstance().OverrideBoolFlagValue( - config_package_nearby::nearby_sharing_feature:: - kDeleteUnexpectedReceivedFile, - true); - nearby_connections_manager_->ProcessUnknownFilePathsToDeleteForTesting( - PayloadStatus::kCanceled, PayloadContent::Type::kFile, file); - unknown_file_paths = + absl::flat_hash_set unknown_file_paths = nearby_connections_manager_->GetUnknownFilePathsToDeleteForTesting(); EXPECT_EQ(unknown_file_paths.size(), 1); nearby_connections_manager_->GetAndClearUnknownFilePathsToDelete(); diff --git a/sharing/nearby_sharing_service_impl.cc b/sharing/nearby_sharing_service_impl.cc index 9417787e..82922b13 100644 --- a/sharing/nearby_sharing_service_impl.cc +++ b/sharing/nearby_sharing_service_impl.cc @@ -2936,20 +2936,6 @@ void NearbySharingServiceImpl::OnReceivedIntroduction( session->session_id(), session->share_target(), /*referrer_package=*/std::nullopt, session->os_type()); - // Controls BWU using a flag when receiving an introduction frame, since it - // could be a problem before accepted by a user. - if (!NearbyFlags::GetInstance().GetBoolFlag( - sharing::config_package_nearby::nearby_sharing_feature:: - kUpgradeBandwidthAfterAccept)) { - if (frame->has_start_transfer() && frame->start_transfer()) { - if (session->TryUpgradeBandwidth()) { - NL_LOG(INFO) - << __func__ - << ": Upgrade bandwidth when receiving an introduction frame."; - } - } - } - if (IsOutOfStorage(device_info_, std::filesystem::u8path(settings_->GetCustomSavePath()), session->attachment_container().GetStorageSize())) { @@ -3251,16 +3237,12 @@ void NearbySharingServiceImpl::RemoveIncomingPayloads( NL_LOG(INFO) << __func__ << ": Cleaning up payloads due to transfer failure"; nearby_connections_manager_->ClearIncomingPayloads(); std::vector files_for_deletion; - if (NearbyFlags::GetInstance().GetBoolFlag( - config_package_nearby::nearby_sharing_feature:: - kDeleteUnexpectedReceivedFile)) { - auto file_paths_to_delete = - nearby_connections_manager_->GetAndClearUnknownFilePathsToDelete(); - for (auto it = file_paths_to_delete.begin(); - it != file_paths_to_delete.end(); ++it) { - NL_VLOG(1) << __func__ << ": Has unknown file path to delete."; - files_for_deletion.push_back(*it); - } + auto file_paths_to_delete = + nearby_connections_manager_->GetAndClearUnknownFilePathsToDelete(); + for (auto it = file_paths_to_delete.begin(); + it != file_paths_to_delete.end(); ++it) { + NL_VLOG(1) << __func__ << ": Has unknown file path to delete."; + files_for_deletion.push_back(*it); } std::vector payload_file_path = session.GetPayloadFilePaths(); diff --git a/sharing/nearby_sharing_service_impl_test.cc b/sharing/nearby_sharing_service_impl_test.cc index 9f28da46..181f9c38 100644 --- a/sharing/nearby_sharing_service_impl_test.cc +++ b/sharing/nearby_sharing_service_impl_test.cc @@ -4893,10 +4893,6 @@ TEST_F(NearbySharingServiceImplTest, NoAdvertisingWhenHidden) { } TEST_F(NearbySharingServiceImplTest, RemoveIncomingPayloads) { - NearbyFlags::GetInstance().OverrideBoolFlagValue( - config_package_nearby::nearby_sharing_feature:: - kDeleteUnexpectedReceivedFile, - true); fake_nearby_connections_manager_->AddUnknownFilePathsToDeleteForTesting( "test1.txt"); fake_nearby_connections_manager_->AddUnknownFilePathsToDeleteForTesting(