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:
@@ -170,6 +170,9 @@ class WifiLanMedium : public api::WifiLanMedium {
|
||||
WifiLanMedium();
|
||||
~WifiLanMedium() override;
|
||||
|
||||
// Check if a network connection to a primary router exist.
|
||||
bool IsNetworkConnected() const override { return true; }
|
||||
|
||||
// Starts WifiLan advertising.
|
||||
//
|
||||
// nsd_service_info - NsdServiceInfo data that's advertised through mDNS
|
||||
|
||||
@@ -139,6 +139,9 @@ class WifiLanMedium : public api::WifiLanMedium {
|
||||
WifiLanMedium(const WifiLanMedium&) = delete;
|
||||
WifiLanMedium& operator=(const WifiLanMedium&) = delete;
|
||||
|
||||
// Check if a network connection to a primary router exist.
|
||||
bool IsNetworkConnected() const override { return true; }
|
||||
|
||||
// api::WifiLanMedium:
|
||||
bool StartAdvertising(const NsdServiceInfo& nsd_service_info) override
|
||||
ABSL_LOCKS_EXCLUDED(mutex_);
|
||||
|
||||
@@ -76,6 +76,9 @@ class WifiLanMedium {
|
||||
public:
|
||||
virtual ~WifiLanMedium() = default;
|
||||
|
||||
// Check if a network connection to a primary router exist.
|
||||
virtual bool IsNetworkConnected() const = 0;
|
||||
|
||||
// Starts WifiLan advertising.
|
||||
//
|
||||
// nsd_service_info - NsdServiceInfo data that's advertised through mDNS
|
||||
|
||||
@@ -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