Enable WIFI_DIRECT in NC connection layer

PiperOrigin-RevId: 538827162
This commit is contained in:
hai007
2023-06-08 10:36:32 -07:00
committed by Copybara-Service
parent 0ab31f6312
commit 742f57423c
2 changed files with 15 additions and 12 deletions
+14 -11
View File
@@ -81,6 +81,7 @@ BwuManager::BwuManager(
}
if (config_.allow_upgrade_to.All(false)) {
config_.allow_upgrade_to.web_rtc = true;
config_.allow_upgrade_to.wifi_direct = true;
config_.allow_upgrade_to.wifi_lan = true;
config_.allow_upgrade_to.wifi_hotspot = true;
}
@@ -196,7 +197,7 @@ void BwuManager::InitiateBwuForEndpoint(ClientProxy* client,
(proposed_medium == Medium::WIFI_HOTSPOT)) {
NEARBY_LOGS(INFO)
<< "Some endpoint is using WIFI_LAN and proposed upgrade medium is "
"WIFI_HOTSPOT. Don't do the BWU because connecting to "
"WIFI_HOTSPOT. Don't do the BWU because STA connecting to "
"WIFI_HOTSPOT will destroy WIFI_LAN which will lead BWU fail and "
"other endpoint connection fail";
return;
@@ -415,12 +416,11 @@ void BwuManager::RevertBwuMediumForEndpoint(const std::string& service_id,
}
bool BwuManager::IsUpgradeOngoing(const std::string& endpoint_id) {
CountDownLatch latch(1);
RunOnBwuManagerThread("is_upgrade_ongoing", [&latch]() {
latch.CountDown();
});
latch.Await();
return in_progress_upgrades_.contains(endpoint_id);
CountDownLatch latch(1);
RunOnBwuManagerThread("is_upgrade_ongoing",
[&latch]() { latch.CountDown(); });
latch.Await();
return in_progress_upgrades_.contains(endpoint_id);
}
Medium BwuManager::GetBwuMediumForEndpoint(
@@ -661,12 +661,15 @@ void BwuManager::ProcessBwuPathAvailableEvent(
upgrade_medium);
if (channel_manager_->isWifiLanConnected() &&
(upgrade_medium == Medium::WIFI_HOTSPOT)) {
((upgrade_medium == Medium::WIFI_HOTSPOT) ||
((upgrade_medium == Medium::WIFI_DIRECT) &&
(client->GetLocalOsInfo().type() ==
location::nearby::connections::OsInfo::WINDOWS)))) {
NEARBY_LOGS(INFO)
<< "Some endpoint is using WIFI_LAN and proposed upgrade medium is "
"WIFI_HOTSPOT. Don't do the BWU because connecting to "
"WIFI_HOTSPOT will destroy WIFI_LAN which will lead BWU fail and "
"other endpoint connection fail";
<< location::nearby::proto::connections::Medium_Name(upgrade_medium)
<< ". Don't do the BWU because this will destroy WIFI_LAN which will "
"lead BWU fail and other endpoint connection fail";
RunUpgradeFailedProtocol(client, endpoint_id, upgrade_path_info);
return;
}
@@ -190,7 +190,7 @@ TEST(BwuManagerBaseTest, AllowToUpgradeMedium) {
std::move(channel3));
bwu_manager->InitiateBwuForEndpoint(&client, std::string(kEndpointId3),
Medium::WIFI_DIRECT);
EXPECT_FALSE(bwu_manager->IsUpgradeOngoing(std::string(kEndpointId3)));
EXPECT_TRUE(bwu_manager->IsUpgradeOngoing(std::string(kEndpointId3)));
auto channel4 = std::make_unique<FakeEndpointChannel>(
Medium::WEB_RTC, std::string(kServiceIdA));