mirror of
https://github.com/kidfromjupiter/nearby.git
synced 2026-09-16 07:36:10 -04:00
Control Wi-Fi hotspot as client by flag
PiperOrigin-RevId: 663862186
This commit is contained in:
committed by
Copybara-Service
parent
826188fb43
commit
4088e5904f
@@ -72,6 +72,7 @@
|
||||
#include "internal/platform/feature_flags.h"
|
||||
#include "internal/platform/future.h"
|
||||
#include "internal/platform/implementation/system_clock.h"
|
||||
#include "internal/platform/implementation/wifi.h"
|
||||
#include "internal/platform/logging.h"
|
||||
#include "internal/platform/mutex_lock.h"
|
||||
#include "internal/platform/prng.h"
|
||||
@@ -777,6 +778,14 @@ ConnectionInfo BasePcpHandler::FillConnectionInfo(
|
||||
}
|
||||
connection_info.supported_mediums =
|
||||
GetSupportedConnectionMediumsByPriority(connection_options);
|
||||
|
||||
if (!NearbyFlags::GetInstance().GetBoolFlag(
|
||||
config_package_nearby::nearby_connections_feature::
|
||||
kEnableWifiHotspotClient)) {
|
||||
// Remove Wi-Fi Hotspot if WiFi LAN is available.
|
||||
StripOutWifiHotspotMedium(connection_info);
|
||||
}
|
||||
|
||||
connection_info.keep_alive_interval_millis =
|
||||
connection_options.keep_alive_interval_millis;
|
||||
connection_info.keep_alive_timeout_millis =
|
||||
@@ -1239,6 +1248,25 @@ mediums::WebrtcPeerId BasePcpHandler::CreatePeerIdFromAdvertisement(
|
||||
return mediums::WebrtcPeerId::FromSeed(ByteArray(std::move(seed)));
|
||||
}
|
||||
|
||||
void BasePcpHandler::StripOutWifiHotspotMedium(
|
||||
ConnectionInfo& connection_info) {
|
||||
bool has_wifi_lan = false;
|
||||
for (auto medium : connection_info.supported_mediums) {
|
||||
if (medium == location::nearby::proto::connections::WIFI_LAN) {
|
||||
has_wifi_lan = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (has_wifi_lan) {
|
||||
connection_info.supported_mediums.erase(
|
||||
std::remove(connection_info.supported_mediums.begin(),
|
||||
connection_info.supported_mediums.end(),
|
||||
Medium::WIFI_HOTSPOT),
|
||||
connection_info.supported_mediums.end());
|
||||
}
|
||||
}
|
||||
|
||||
bool BasePcpHandler::HasOutgoingConnections(ClientProxy* client) const {
|
||||
for (const auto& item : pending_connections_) {
|
||||
auto& connection = item.second;
|
||||
|
||||
@@ -410,6 +410,8 @@ class BasePcpHandler : public PcpHandler,
|
||||
return &serial_executor_;
|
||||
}
|
||||
|
||||
void StripOutWifiHotspotMedium(ConnectionInfo& connection_info);
|
||||
|
||||
// Test only.
|
||||
int GetEndpointLostByMediumAlarmsCount() RUN_ON_PCP_HANDLER_THREAD() {
|
||||
return endpoint_lost_by_medium_alarms_.size();
|
||||
|
||||
@@ -78,6 +78,10 @@ constexpr auto kDisableBluetoothClassicScanning =
|
||||
constexpr auto kEnableInstantOnLost =
|
||||
flags::Flag<bool>(kConfigPackage, "45642180", false);
|
||||
|
||||
// When true, enable Wi-Fi Hotspot client.
|
||||
constexpr auto kEnableWifiHotspotClient =
|
||||
flags::Flag<bool>(kConfigPackage, "45648734", true);
|
||||
|
||||
} // namespace nearby_connections_feature
|
||||
} // namespace config_package_nearby
|
||||
} // namespace connections
|
||||
|
||||
Reference in New Issue
Block a user