mirror of
https://github.com/kidfromjupiter/nearby.git
synced 2026-09-16 15:36:12 -04:00
WIFI Direct implementation (3)
Part 3: BWU and client interface part PiperOrigin-RevId: 498218241
This commit is contained in:
@@ -31,6 +31,7 @@
|
||||
#else
|
||||
#include "connections/implementation/webrtc_bwu_handler.h"
|
||||
#endif
|
||||
#include "connections/implementation/wifi_direct_bwu_handler.h"
|
||||
#include "connections/implementation/wifi_hotspot_bwu_handler.h"
|
||||
#include "connections/implementation/wifi_lan_bwu_handler.h"
|
||||
#include "internal/platform/byte_array.h"
|
||||
@@ -108,6 +109,11 @@ void BwuManager::InitBwuHandlers() {
|
||||
Medium::WIFI_HOTSPOT,
|
||||
std::make_unique<WifiHotspotBwuHandler>(*mediums_, notifications));
|
||||
}
|
||||
if (config_.allow_upgrade_to.wifi_direct) {
|
||||
handlers_.emplace(
|
||||
Medium::WIFI_DIRECT,
|
||||
std::make_unique<WifiDirectBwuHandler>(*mediums_, notifications));
|
||||
}
|
||||
if (config_.allow_upgrade_to.wifi_lan) {
|
||||
handlers_.emplace(Medium::WIFI_LAN, std::make_unique<WifiLanBwuHandler>(
|
||||
*mediums_, notifications));
|
||||
@@ -391,16 +397,24 @@ void BwuManager::RevertBwuMediumForEndpoint(const std::string& service_id,
|
||||
// unless the BWU Medium is Hotspot. The client needs to disconnect from
|
||||
// Hotspot, then it can restore the previous AP connection right away.
|
||||
if (!IsInitiatorUpgradeServiceId(service_id)) {
|
||||
if (medium == Medium::WIFI_HOTSPOT) {
|
||||
if (medium == Medium::WIFI_HOTSPOT || medium == Medium::WIFI_DIRECT) {
|
||||
handler->RevertResponderState(service_id);
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
handler->RevertInitiatorState(service_id, endpoint_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);
|
||||
}
|
||||
|
||||
Medium BwuManager::GetBwuMediumForEndpoint(
|
||||
const std::string& endpoint_id) const {
|
||||
if (!FeatureFlags::GetInstance().GetFlags().support_multiple_bwu_mediums) {
|
||||
@@ -1219,6 +1233,9 @@ std::vector<Medium> BwuManager::StripOutUnavailableMediums(
|
||||
case Medium::WIFI_LAN:
|
||||
available = mediums_->GetWifiLan().IsAvailable();
|
||||
break;
|
||||
case Medium::WIFI_DIRECT:
|
||||
available = mediums_->GetWifiDirect().IsGOAvailable();
|
||||
break;
|
||||
case Medium::WIFI_HOTSPOT:
|
||||
available = mediums_->GetWifiHotspot().IsAPAvailable();
|
||||
break;
|
||||
|
||||
Reference in New Issue
Block a user