mirror of
https://github.com/kidfromjupiter/nearby.git
synced 2026-09-16 15:36:12 -04:00
Add WifiLan validation check
PiperOrigin-RevId: 452402734
This commit is contained in:
@@ -218,6 +218,9 @@ class WifiLanMedium : public api::WifiLanMedium {
|
||||
public:
|
||||
~WifiLanMedium() override = default;
|
||||
|
||||
// Check if a network connection to a primary router exist.
|
||||
bool IsNetworkConnected() const override;
|
||||
|
||||
// Starts to advertising
|
||||
bool StartAdvertising(const NsdServiceInfo& nsd_service_info) override;
|
||||
|
||||
|
||||
@@ -36,6 +36,14 @@ namespace location {
|
||||
namespace nearby {
|
||||
namespace windows {
|
||||
|
||||
bool WifiLanMedium::IsNetworkConnected() const {
|
||||
// connection_profile will be null when there's no network adapter or
|
||||
// connection to a network. For example, WiFi isn't connected to an AP/hotspot
|
||||
// and ethernet isn't connected to a router/hub/switch.
|
||||
auto connection_profile = NetworkInformation::GetInternetConnectionProfile();
|
||||
return connection_profile != nullptr;
|
||||
}
|
||||
|
||||
bool WifiLanMedium::StartAdvertising(const NsdServiceInfo& nsd_service_info) {
|
||||
absl::MutexLock lock(&mutex_);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user