Fixed the potential advertising issue in Wi-Fi LAN

PiperOrigin-RevId: 774961389
This commit is contained in:
Guogang Li
2025-06-23 16:05:39 -07:00
committed by Copybara-Service
parent 0c0a59d8a1
commit b8246abbe4
2 changed files with 7 additions and 1 deletions
@@ -148,7 +148,7 @@ bool WifiLanMdns::StopMdnsService() {
LOG(INFO) << "StopMdnsService is called";
if (!is_service_started_) {
LOG(WARNING) << "The mDNS service is not started.";
return false;
return true;
}
dns_service_notification_ = std::make_unique<absl::Notification>();
@@ -211,6 +211,9 @@ bool WifiLanMedium::StopAdvertising(const NsdServiceInfo& nsd_service_info) {
if (NearbyFlags::GetInstance().GetBoolFlag(
nearby::platform::config_package_nearby::nearby_platform_feature::
kEnableBlockingSocket)) {
// The service may be running under WinRT when the flag is enabled.
dnssd_service_instance_ = nullptr;
bool result = wifi_lan_mdns_.StopMdnsService();
if (result) {
@@ -223,6 +226,9 @@ bool WifiLanMedium::StopAdvertising(const NsdServiceInfo& nsd_service_info) {
medium_status_ &= (~kMediumStatusAdvertising);
return false;
} else {
// The service may be running under Win32 when the flag is disabled.
wifi_lan_mdns_.StopMdnsService();
dnssd_service_instance_ = nullptr;
LOG(INFO) << "succeeded to stop mDNS advertising for service type ="