diff --git a/internal/platform/flags/nearby_platform_feature_flags.h b/internal/platform/flags/nearby_platform_feature_flags.h index 18580c9f..688143bb 100644 --- a/internal/platform/flags/nearby_platform_feature_flags.h +++ b/internal/platform/flags/nearby_platform_feature_flags.h @@ -73,10 +73,6 @@ constexpr auto kEnableMdnsIpv6 = constexpr auto kEnableNewBluetoothRefactor = flags::Flag(kConfigPackage, "45615156", false); -// Enable/Disable Wi-Fi hotspot scan in native -constexpr auto kEnableWifiHotspotNativeScan = - flags::Flag(kConfigPackage, "45670001", false); - // The send buffer size of blocking socket constexpr auto kSocketSendBufferSize = flags::Flag(kConfigPackage, "45673785", 524288); diff --git a/internal/platform/implementation/windows/wifi_hotspot_medium.cc b/internal/platform/implementation/windows/wifi_hotspot_medium.cc index 40592979..052d4fa0 100644 --- a/internal/platform/implementation/windows/wifi_hotspot_medium.cc +++ b/internal/platform/implementation/windows/wifi_hotspot_medium.cc @@ -410,21 +410,6 @@ bool WifiHotspotMedium::ConnectWifiHotspot( } } - if (NearbyFlags::GetInstance().GetBoolFlag( - platform::config_package_nearby::nearby_platform_feature:: - kEnableWifiHotspotNativeScan)) { - if (!wifi_hotspot_native_.Scan(ssid)) { - LOG(INFO) << "Hotspot " << ssid << " is not found"; - - if (intel_wifi_started) { - WifiIntel& intel_wifi{WifiIntel::GetInstance()}; - intel_wifi.ResetScanFilter(); - intel_wifi.Stop(); - } - return false; - } - } - bool connected = wifi_hotspot_native_.ConnectToWifiNetwork(ssid, password); diff --git a/internal/platform/implementation/windows/wifi_hotspot_native.cc b/internal/platform/implementation/windows/wifi_hotspot_native.cc index ca039b8f..3377c421 100644 --- a/internal/platform/implementation/windows/wifi_hotspot_native.cc +++ b/internal/platform/implementation/windows/wifi_hotspot_native.cc @@ -154,53 +154,6 @@ bool WifiHotspotNative::DisconnectWifiNetwork() { return true; } -bool WifiHotspotNative::Scan(absl::string_view ssid) { - GUID interface_guid = GetInterfaceGuid(); - if (interface_guid == GUID_NULL) { - LOG(ERROR) << __func__ << ": No available WLAN Interface to use."; - return false; - } - WlanNotificationContext context = { - .wifi_hotspot_native = *this, - }; - absl::MutexLock lock(mutex_); - if (!RegisterWlanNotificationCallback(&context)) { - LOG(ERROR) << "Failed to register WLAN notification callback."; - return false; - } - - if (ssid.length() > DOT11_SSID_MAX_LENGTH) { - LOG(ERROR) << "Invalid SSID length."; - return false; - } - - DOT11_SSID dot11_ssid; - dot11_ssid.uSSIDLength = ssid.length(); - memcpy(dot11_ssid.ucSSID, ssid.data(), dot11_ssid.uSSIDLength); - scan_latch_ = std::make_unique(1); - scanning_ssid_ = ssid; - DWORD result = WlanScan( - /*hClientHandle=*/wifi_, /*pInterfaceGuid=*/&interface_guid, - /*pDot11Ssid=*/&dot11_ssid, /*pIeData=*/nullptr, /*pReserved=*/nullptr); - - if (result != ERROR_SUCCESS) { - LOG(ERROR) << "Failed to scan Wi-Fi network with error " << result; - UnregisterWlanNotificationCallback(); - return false; - } - - ExceptionOr scan_result = scan_latch_->Await(kConnectTimeout); - UnregisterWlanNotificationCallback(); - - if (!scan_result.ok() || !scan_result.result()) { - LOG(ERROR) << "Failed to scan to Wifi network " << ssid; - return false; - } - - scan_latch_ = nullptr; - return true; -} - void WifiHotspotNative::TriggerConnected() { if (connect_latch_ == nullptr) { return; @@ -208,44 +161,6 @@ void WifiHotspotNative::TriggerConnected() { connect_latch_->CountDown(); } -void WifiHotspotNative::TriggerNetworkRefreshed() { - if (scan_latch_ == nullptr) { - return; - } - - GUID interface_guid = GetInterfaceGuid(); - if (interface_guid == GUID_NULL) { - LOG(ERROR) << __func__ << ": No available WLAN Interface to use."; - return; - } - - PWLAN_AVAILABLE_NETWORK_LIST list = nullptr; - DWORD result = WlanGetAvailableNetworkList( - /*hClientHandle=*/wifi_, /*pInterfaceGuid=*/&interface_guid, - /*dwFlags=*/WLAN_AVAILABLE_NETWORK_INCLUDE_ALL_ADHOC_PROFILES, - /*pReserved=*/nullptr, /*ppAvailableNetworkList=*/&list); - if (result != ERROR_SUCCESS) { - return; - } - - bool found_ssid = false; - for (int i = 0; i < list->dwNumberOfItems; i++) { - std::string ssid = std::string((char*)list->Network[i].dot11Ssid.ucSSID, - list->Network[i].dot11Ssid.uSSIDLength); - if (ssid == scanning_ssid_) { - found_ssid = true; - break; - } - } - - WlanFreeMemory(list); - - if (found_ssid) { - LOG(INFO) << "Found WLAN network " << scanning_ssid_; - scan_latch_->CountDown(); - } -} - void WifiHotspotNative::WlanNotificationCallback( PWLAN_NOTIFICATION_DATA wlan_notification_data, PVOID context) { VLOG(1) << "WlanNotificationCallback is called with notification code " @@ -282,7 +197,6 @@ void WifiHotspotNative::WlanNotificationCallback( } case wlan_notification_acm_scan_list_refresh: { LOG(INFO) << "Scan list refreshed."; - wlan_context->wifi_hotspot_native.TriggerNetworkRefreshed(); break; } case wlan_notification_acm_disconnecting: { diff --git a/internal/platform/implementation/windows/wifi_hotspot_native.h b/internal/platform/implementation/windows/wifi_hotspot_native.h index fbf43048..83486f4c 100644 --- a/internal/platform/implementation/windows/wifi_hotspot_native.h +++ b/internal/platform/implementation/windows/wifi_hotspot_native.h @@ -44,8 +44,6 @@ class WifiHotspotNative { bool RestoreWifiProfile() ABSL_LOCKS_EXCLUDED(mutex_); - bool Scan(absl::string_view ssid) ABSL_LOCKS_EXCLUDED(mutex_); - // Returns true if the interface has a non local scoped IPv4 address. bool HasAssignedAddress(); bool RenewIpv4Address() const; @@ -85,15 +83,12 @@ class WifiHotspotNative { bool RemoveWlanProfile(GUID interface_guid, const std::wstring& profile_name) ABSL_EXCLUSIVE_LOCKS_REQUIRED(mutex_); void TriggerConnected(); - void TriggerNetworkRefreshed(); NetworkInfo& network_info_; mutable absl::Mutex mutex_; HANDLE wifi_ = nullptr; - std::string scanning_ssid_; std::unique_ptr connect_latch_; - std::unique_ptr scan_latch_; std::wstring backup_profile_name_; };