From 2cda47c30c6c8252b2e93b80d30d574ed2efae57 Mon Sep 17 00:00:00 2001 From: Francis Tsui Date: Thu, 15 Jan 2026 19:03:13 -0800 Subject: [PATCH] Deprecate DisableBluetoothClassicScanning flag. PiperOrigin-RevId: 856914065 --- .../flags/nearby_connections_feature_flags.h | 3 - .../ble/discovered_peripheral_tracker.cc | 12 ++-- .../ble/discovered_peripheral_tracker_test.cc | 12 ---- .../implementation/p2p_cluster_pcp_handler.cc | 72 +++---------------- .../p2p_cluster_pcp_handler_test.cc | 49 ++++--------- .../generated/nearby_sharing_feature_flags.h | 4 -- 6 files changed, 25 insertions(+), 127 deletions(-) diff --git a/connections/implementation/flags/nearby_connections_feature_flags.h b/connections/implementation/flags/nearby_connections_feature_flags.h index f20d9172..efb136b9 100644 --- a/connections/implementation/flags/nearby_connections_feature_flags.h +++ b/connections/implementation/flags/nearby_connections_feature_flags.h @@ -31,9 +31,6 @@ namespace nearby_connections_feature { // The timeout in millis to report peripheral device lost. constexpr auto kBlePeripheralLostTimeoutMillis = flags::Flag(kConfigPackage, "45411439", 12000); -// When true, disable Bluetooth classic scanning. -constexpr auto kDisableBluetoothClassicScanning = - flags::Flag(kConfigPackage, "45639961", false); // Disable instant on lost on BLE without extended feature. constexpr auto kDisableInstantOnLostOnBleWithoutExtended = flags::Flag(kConfigPackage, "45687098", true); diff --git a/connections/implementation/mediums/ble/discovered_peripheral_tracker.cc b/connections/implementation/mediums/ble/discovered_peripheral_tracker.cc index a89edf6a..8497fa96 100644 --- a/connections/implementation/mediums/ble/discovered_peripheral_tracker.cc +++ b/connections/implementation/mediums/ble/discovered_peripheral_tracker.cc @@ -754,14 +754,10 @@ void DiscoveredPeripheralTracker::HandleAdvertisementHeader( // Report a nearby legacy device is found when advertisement header doesn't // support extended advertisement. - if (NearbyFlags::GetInstance().GetBoolFlag( - config_package_nearby::nearby_connections_feature:: - kDisableBluetoothClassicScanning)) { - if (!advertisement_header.IsSupportExtendedAdvertisement()) { - for (auto& item : service_id_infos_) { - item.second.discovered_peripheral_callback - .legacy_device_discovered_cb(); - } + if (!advertisement_header.IsSupportExtendedAdvertisement()) { + for (auto& item : service_id_infos_) { + item.second.discovered_peripheral_callback + .legacy_device_discovered_cb(); } } diff --git a/connections/implementation/mediums/ble/discovered_peripheral_tracker_test.cc b/connections/implementation/mediums/ble/discovered_peripheral_tracker_test.cc index d2dfb49d..5c3d6888 100644 --- a/connections/implementation/mediums/ble/discovered_peripheral_tracker_test.cc +++ b/connections/implementation/mediums/ble/discovered_peripheral_tracker_test.cc @@ -191,10 +191,6 @@ class DiscoveredPeripheralTrackerTest std::tuple> { public: void SetUp() override { - NearbyFlags::GetInstance().OverrideBoolFlagValue( - config_package_nearby::nearby_connections_feature:: - kDisableBluetoothClassicScanning, - false); NearbyFlags::GetInstance().OverrideBoolFlagValue( config_package_nearby::nearby_connections_feature::kEnableInstantOnLost, false); @@ -285,13 +281,6 @@ class DiscoveredPeripheralTrackerTest return fetch_count_; } - void DisableBluetoothScanning() { - NearbyFlags::GetInstance().OverrideBoolFlagValue( - config_package_nearby::nearby_connections_feature:: - kDisableBluetoothClassicScanning, - true); - } - void EnableInstantOnLost() { NearbyFlags::GetInstance().OverrideBoolFlagValue( config_package_nearby::nearby_connections_feature::kEnableInstantOnLost, @@ -423,7 +412,6 @@ TEST_P(DiscoveredPeripheralTrackerTest, DctAdvertisementPeripheralDiscovered) { TEST_P(DiscoveredPeripheralTrackerTest, ReportFoundLegacyDeviceWhenFoundBleAdvertisementPeripheralDiscovered) { - DisableBluetoothScanning(); std::vector service_ids = {std::string(kServiceIdA)}; ByteArray advertisement_header_bytes = CreateBleAdvertisementHeader( GenerateRandomAdvertisementHash(), service_ids); diff --git a/connections/implementation/p2p_cluster_pcp_handler.cc b/connections/implementation/p2p_cluster_pcp_handler.cc index 7a9c1252..73dc47f4 100644 --- a/connections/implementation/p2p_cluster_pcp_handler.cc +++ b/connections/implementation/p2p_cluster_pcp_handler.cc @@ -789,12 +789,6 @@ void P2pClusterPcpHandler::BleInstantLostHandler( } void P2pClusterPcpHandler::BleLegacyDeviceDiscoveredHandler() { - if (!NearbyFlags::GetInstance().GetBoolFlag( - config_package_nearby::nearby_connections_feature:: - kDisableBluetoothClassicScanning)) { - return; - } - RunOnPcpHandlerThread( "p2p-ble-legacy-peripheral-discovered", [this]() RUN_ON_PCP_HANDLER_THREAD() { @@ -1119,31 +1113,9 @@ BasePcpHandler::StartOperationResult P2pClusterPcpHandler::StartDiscoveryImpl( } if (discovery_options.allowed.bluetooth) { - if (NearbyFlags::GetInstance().GetBoolFlag( - config_package_nearby::nearby_connections_feature:: - kDisableBluetoothClassicScanning)) { - StartBluetoothDiscoveryWithPause( - client, service_id, discovery_options, mediums_started_successfully, - operation_result_with_mediums, /*update_index=*/0); - } else { - ErrorOr bluetooth_result = - StartBluetoothDiscovery(client, service_id); - if (bluetooth_result.has_value()) { - LOG(INFO) << "P2pClusterPcpHandler::StartDiscoveryImpl: BT added"; - mediums_started_successfully.push_back(*bluetooth_result); - bluetooth_classic_client_id_to_service_id_map_.insert( - {client->GetClientId(), service_id}); - } - std::unique_ptr - operation_result_with_medium = - GetOperationResultWithMediumByResultCode( - client, BLUETOOTH, - /*update_index=*/0, - bluetooth_result.has_error() - ? bluetooth_result.error().operation_result_code().value() - : OperationResultCode::DETAIL_SUCCESS); - operation_result_with_mediums.push_back(*operation_result_with_medium); - } + StartBluetoothDiscoveryWithPause( + client, service_id, discovery_options, mediums_started_successfully, + operation_result_with_mediums, /*update_index=*/0); } if (mediums_started_successfully.empty()) { @@ -1186,13 +1158,8 @@ Status P2pClusterPcpHandler::StopDiscoveryImpl(ClientProxy* client) { ble_medium_.StopScanning(client->GetDiscoveryServiceId()); - if (NearbyFlags::GetInstance().GetBoolFlag( - config_package_nearby::nearby_connections_feature:: - kDisableBluetoothClassicScanning)) { - paused_bluetooth_clients_discoveries_.erase( - client->GetDiscoveryServiceId()); - } - + paused_bluetooth_clients_discoveries_.erase( + client->GetDiscoveryServiceId()); return {Status::kSuccess}; } @@ -1742,32 +1709,9 @@ P2pClusterPcpHandler::UpdateDiscoveryOptionsImpl( OperationResultCode::DETAIL_SUCCESS); operation_result_with_mediums.push_back(*operation_result_with_medium); } else { - if (NearbyFlags::GetInstance().GetBoolFlag( - config_package_nearby::nearby_connections_feature:: - kDisableBluetoothClassicScanning)) { - StartBluetoothDiscoveryWithPause( - client, std::string(service_id), discovery_options, - restarted_mediums, operation_result_with_mediums, update_index); - } else { - ErrorOr bluetooth_result = - StartBluetoothDiscovery(client, std::string(service_id)); - if (bluetooth_result.has_value()) { - restarted_mediums.push_back(BLUETOOTH); - } else { - LOG(WARNING) - << "UpdateDiscoveryOptionsImpl: unable to restart bt scanning"; - } - std::unique_ptr - operation_result_with_medium = - GetOperationResultWithMediumByResultCode( - client, BLUETOOTH, update_index, - bluetooth_result.has_error() - ? bluetooth_result.error() - .operation_result_code() - .value() - : OperationResultCode::DETAIL_SUCCESS); - operation_result_with_mediums.push_back(*operation_result_with_medium); - } + StartBluetoothDiscoveryWithPause( + client, std::string(service_id), discovery_options, restarted_mediums, + operation_result_with_mediums, update_index); } } // awdl (note: keep the awdl logic before the wifi lan logic) diff --git a/connections/implementation/p2p_cluster_pcp_handler_test.cc b/connections/implementation/p2p_cluster_pcp_handler_test.cc index 3aa0f7a1..276bdaf1 100644 --- a/connections/implementation/p2p_cluster_pcp_handler_test.cc +++ b/connections/implementation/p2p_cluster_pcp_handler_test.cc @@ -16,7 +16,6 @@ #include #include -#include #include "gtest/gtest.h" #include "absl/time/clock.h" @@ -90,20 +89,12 @@ class P2pClusterPcpHandlerTest : public testing::Test { NearbyFlags::GetInstance().OverrideBoolFlagValue( config_package_nearby::nearby_connections_feature::kEnableAwdl, true); SetBleExtendedAdvertisementsAvailable(true); - SetDisableBluetoothClassicScanning(true); } void SetBleExtendedAdvertisementsAvailable(bool available) { env_.SetBleExtendedAdvertisementsAvailable(false); } - void SetDisableBluetoothClassicScanning(bool disable) { - NearbyFlags::GetInstance().OverrideBoolFlagValue( - config_package_nearby::nearby_connections_feature:: - kDisableBluetoothClassicScanning, - disable); - } - AdvertisingOptions GetBluetoothOnlyAdvertisingOptions() { return AdvertisingOptions{ {Strategy::kP2pCluster, @@ -240,20 +231,13 @@ TEST_F(P2pClusterPcpHandlerTest, } class P2pClusterPcpHandlerTestWithParam - : public testing::TestWithParam< - /*mediums=*/std::tuple> { + : public testing::TestWithParam { protected: void SetUp() override { LOG(INFO) << "SetUp: begin"; env_.SetBleExtendedAdvertisementsAvailable(false); NearbyFlags::GetInstance().OverrideBoolFlagValue( config_package_nearby::nearby_connections_feature::kEnableAwdl, true); - bool is_disable_bluetooth_scanning = std::get<1>(GetParam()); - NearbyFlags::GetInstance().OverrideBoolFlagValue( - config_package_nearby::nearby_connections_feature:: - kDisableBluetoothClassicScanning, - is_disable_bluetooth_scanning); NearbyFlags::GetInstance().OverrideBoolFlagValue( config_package_nearby::nearby_connections_feature::kEnableDct, true); NearbyFlags::GetInstance().OverrideBoolFlagValue( @@ -277,8 +261,6 @@ class P2pClusterPcpHandlerTestWithParam if (advertising_options_.allowed.awdl) { LOG(INFO) << "SetUp: Awdl enabled"; } - LOG(INFO) << "SetUp: is_disable_bluetooth_scanning: " - << is_disable_bluetooth_scanning; LOG(INFO) << "SetUp: end"; } @@ -288,19 +270,19 @@ class P2pClusterPcpHandlerTestWithParam ConnectionOptions connection_options_{ { Strategy::kP2pCluster, - std::get<0>(GetParam()), + GetParam(), }, }; AdvertisingOptions advertising_options_{ { Strategy::kP2pCluster, - std::get<0>(GetParam()), + GetParam(), }, }; DiscoveryOptions discovery_options_{ { Strategy::kP2pCluster, - std::get<0>(GetParam()), + GetParam(), }, }; MediumEnvironment& env_{MediumEnvironment::Instance()}; @@ -385,11 +367,11 @@ TEST_P(P2pClusterPcpHandlerTestWithParam, AdvertiseForLegacyDeviceWithBt) { {.endpoint_info = ByteArray{endpoint_name}}), Status{Status::kSuccess}); // advertising for legacy device depends on both BT and BLE enabled. - if (std::get<0>(GetParam()).bluetooth) { + if (GetParam().bluetooth) { EXPECT_TRUE(mediums_a.GetBle().IsAdvertisingForLegacyDevice(service_id_)); } handler_a.StopAdvertising(&client_a_); - if (std::get<0>(GetParam()).bluetooth) { + if (GetParam().bluetooth) { EXPECT_FALSE(mediums_a.GetBle().IsAdvertisingForLegacyDevice(service_id_)); } env_.Stop(); @@ -619,7 +601,7 @@ TEST_P(P2pClusterPcpHandlerTestWithParam, CanDiscoverLegacy) { TEST_P(P2pClusterPcpHandlerTestWithParam, PauseBluetoothClassicDiscovery) { // Skip the case which not disable bluetooth scanning. - if (!std::get<1>(GetParam()) || !advertising_options_.allowed.bluetooth || + if (!advertising_options_.allowed.bluetooth || !advertising_options_.allowed.ble) { return; } @@ -648,7 +630,7 @@ TEST_P(P2pClusterPcpHandlerTestWithParam, PauseBluetoothClassicDiscovery) { TEST_P(P2pClusterPcpHandlerTestWithParam, ResumeBluetoothClassicDiscovery) { // Skip the case which not disable bluetooth scanning. - if (!std::get<1>(GetParam()) || !advertising_options_.allowed.bluetooth || + if (!advertising_options_.allowed.bluetooth || !advertising_options_.allowed.ble) { return; } @@ -802,14 +784,14 @@ TEST_P(P2pClusterPcpHandlerTestWithParam, CanUpdateDiscoveryOptions) { EXPECT_EQ( handler_a.StartDiscovery(&client_a_, service_id_, discovery_options_, {}), Status{Status::kSuccess}); - BooleanMediumSelector enabled = std::get<0>(GetParam()); + BooleanMediumSelector enabled = GetParam(); EXPECT_EQ(enabled.ble, mediums_a.GetBle().IsScanning(service_id_)); EXPECT_EQ(enabled.wifi_lan, mediums_a.GetWifiLan().IsDiscovering(service_id_)); DiscoveryOptions new_options{ { Strategy::kP2pCluster, - std::get<0>(GetParam()), + GetParam(), }, false, // auto_upgrade_bandwidth false, // enforce_topology_constraints @@ -1664,10 +1646,6 @@ class P2pLostHandlerTestWithParam : public testing::TestWithParam { NearbyFlags::GetInstance().OverrideBoolFlagValue( config_package_nearby::nearby_connections_feature::kEnableAwdl, true); env_.SetBleExtendedAdvertisementsAvailable(true); - NearbyFlags::GetInstance().OverrideBoolFlagValue( - config_package_nearby::nearby_connections_feature:: - kDisableBluetoothClassicScanning, - false); NearbyFlags::GetInstance().OverrideBoolFlagValue( config_package_nearby::nearby_connections_feature::kEnableInstantOnLost, GetParam()); @@ -1808,10 +1786,9 @@ TEST_P(P2pLostHandlerTestWithParam, CanConnectWithInstantLostEnabled) { env_.SetBleExtendedAdvertisementsAvailable(false); } -INSTANTIATE_TEST_SUITE_P( - ParametrisedPcpHandlerTest, P2pClusterPcpHandlerTestWithParam, - ::testing::Combine(/*mediums=*/::testing::ValuesIn(kTestCases), - /*disable_bluetooth_scanning=*/::testing::Bool())); +INSTANTIATE_TEST_SUITE_P(ParametrisedPcpHandlerTest, + P2pClusterPcpHandlerTestWithParam, + ::testing::ValuesIn(kTestCases)); INSTANTIATE_TEST_SUITE_P(ParametrisedP2pLostHandlerTest, P2pLostHandlerTestWithParam, testing::Bool()); diff --git a/sharing/flags/generated/nearby_sharing_feature_flags.h b/sharing/flags/generated/nearby_sharing_feature_flags.h index 085baf3c..ceb825c6 100755 --- a/sharing/flags/generated/nearby_sharing_feature_flags.h +++ b/sharing/flags/generated/nearby_sharing_feature_flags.h @@ -61,9 +61,6 @@ constexpr auto kLoggingLevel = // Enable/disable auto-update on settings page constexpr auto kShowAutoUpdateSetting = flags::Flag(kConfigPackage, "45409033", false); -// When true, use gRpc client to access backend. -constexpr auto kUseGrpcClient = - flags::Flag(kConfigPackage, "45630055", false); // When true, delete the file payload which received unexpectedly. constexpr auto kDeleteUnexpectedReceivedFileFix = flags::Flag(kConfigPackage, "45657036", false); @@ -115,7 +112,6 @@ inline absl::btree_map&> GetBoolFlags() { {45418908, kEnableSelfShareUi}, {45459748, kEnableSendingDesktopEvents}, {45409033, kShowAutoUpdateSetting}, - {45630055, kUseGrpcClient}, {45657036, kDeleteUnexpectedReceivedFileFix}, {45673628, kEnableWifiHotspotForHpRealtekDevices}, {45683539, kUseAlternateServiceUuidForDiscovery},