diff --git a/connections/c/nc.cc b/connections/c/nc.cc index c212e3b1..ed470873 100644 --- a/connections/c/nc.cc +++ b/connections/c/nc.cc @@ -223,6 +223,10 @@ NC_INSTANCE NcCreateService() { NcContext nc_context; #if defined(NC_IOS_SDK) + nearby::NearbyFlags::GetInstance().OverrideBoolFlagValue( + ::nearby::connections::config_package_nearby::nearby_connections_feature:: + kEnableDct, + true); nearby::NearbyFlags::GetInstance().OverrideBoolFlagValue( ::nearby::connections::config_package_nearby::nearby_connections_feature:: kEnableAwdl, @@ -232,7 +236,6 @@ NC_INSTANCE NcCreateService() { ::nearby::connections::config_package_nearby::nearby_connections_feature:: kEnableStopBLEScanningOnWifiUpgrade, true); - #endif nc_context.router = new ::nearby::connections::ServiceControllerRouter(); diff --git a/connections/implementation/bwu_manager.cc b/connections/implementation/bwu_manager.cc index 7c089b24..9dc5c0d8 100644 --- a/connections/implementation/bwu_manager.cc +++ b/connections/implementation/bwu_manager.cc @@ -108,9 +108,10 @@ BwuManager::BwuManager( config_.allow_upgrade_to.wifi_direct = true; config_.allow_upgrade_to.wifi_lan = true; config_.allow_upgrade_to.wifi_hotspot = true; -#if defined(NC_IOS_SDK) - config_.allow_upgrade_to.awdl = true; -#endif // defined(NC_IOS_SDK) + if (NearbyFlags::GetInstance().GetBoolFlag( + config_package_nearby::nearby_connections_feature::kEnableDct)) { + config_.allow_upgrade_to.awdl = true; + } } if (!handlers.empty()) { handlers_ = std::move(handlers); diff --git a/connections/implementation/client_proxy.cc b/connections/implementation/client_proxy.cc index 45dc1267..eae82032 100644 --- a/connections/implementation/client_proxy.cc +++ b/connections/implementation/client_proxy.cc @@ -90,6 +90,8 @@ bool IsFeatureUseStableEndpointIdEnabled() { ClientProxy::ClientProxy(::nearby::analytics::EventLogger* event_logger) : client_id_(Prng().NextInt64()) { NEARBY_LOGS(INFO) << "ClientProxy ctor event_logger=" << event_logger; + is_dct_enabled_ = NearbyFlags::GetInstance().GetBoolFlag( + config_package_nearby::nearby_connections_feature::kEnableDct); analytics_recorder_ = std::make_unique(event_logger); error_code_recorder_ = std::make_unique( @@ -1317,17 +1319,7 @@ void ClientProxy::SetWebRtcNonCellular(bool webrtc_non_cellular) { webrtc_non_cellular_ = webrtc_non_cellular; } -bool ClientProxy::IsDctEnabled() const { - if (api::ImplementationPlatform::GetCurrentOS() != api::OSName::kApple) { - return false; - } - -#if defined(NC_IOS_SDK) - return true; -#else - return false; -#endif -} +bool ClientProxy::IsDctEnabled() const { return is_dct_enabled_; } uint8_t ClientProxy::GetDctDedup() const { return dct_dedup_; } diff --git a/connections/implementation/client_proxy.h b/connections/implementation/client_proxy.h index ffb3edd6..7b0a09b7 100644 --- a/connections/implementation/client_proxy.h +++ b/connections/implementation/client_proxy.h @@ -546,6 +546,8 @@ class ClientProxy final { std::int32_t local_safe_to_disconnect_version_; // Allowed to use WebRTC over non-cellular networks. bool webrtc_non_cellular_ = false; + // Whether DCT is enabled. + bool is_dct_enabled_ = false; }; } // namespace connections diff --git a/connections/implementation/p2p_point_to_point_pcp_handler.cc b/connections/implementation/p2p_point_to_point_pcp_handler.cc index 6c854c85..fd48d606 100644 --- a/connections/implementation/p2p_point_to_point_pcp_handler.cc +++ b/connections/implementation/p2p_point_to_point_pcp_handler.cc @@ -32,11 +32,12 @@ P2pPointToPointPcpHandler::P2pPointToPointPcpHandler( std::vector P2pPointToPointPcpHandler::GetConnectionMediumsByPriority() { std::vector mediums; -#if defined(NC_IOS_SDK) - if (mediums_->GetAwdl().IsAvailable()) { - mediums.push_back(location::nearby::proto::connections::AWDL); + if (NearbyFlags::GetInstance().GetBoolFlag( + config_package_nearby::nearby_connections_feature::kEnableDct)) { + if (mediums_->GetAwdl().IsAvailable()) { + mediums.push_back(location::nearby::proto::connections::AWDL); + } } -#endif // defined(NC_IOS_SDK) if (mediums_->GetWifiLan().IsAvailable()) { mediums.push_back(location::nearby::proto::connections::WIFI_LAN); }