Roll forward to cl/338482889

Signed-off-by: Alexey Polyudov <apolyudov@google.com>
Change-Id: I9850950db8bd84f0904ea1a413151887f52098cf
This commit is contained in:
Alexey Polyudov
2020-10-22 10:47:34 -07:00
parent d68e53cf03
commit 2155b3ddeb
542 changed files with 15219 additions and 42295 deletions
+33 -34
View File
@@ -2,47 +2,49 @@
#define PLATFORM_API_WIFI_H_
#include <cstdint>
#include <string>
#include <vector>
#include "platform/port/string.h"
#include "platform/ptr.h"
#include "absl/strings/string_view.h"
namespace location {
namespace nearby {
namespace api {
// Possible authentication types for a WiFi network.
struct WifiAuthType {
enum Value {
UNKNOWN = 0,
OPEN = 1,
WPA_PSK = 2,
WEP = 3,
};
enum class WifiAuthType {
// WiFi Authentication type; either none (non-secured a.k.a. open) link, or
// WPA PSK (WiFi Protected Access PreShared Key), or
// see https://en.wikipedia.org/wiki/Wi-Fi_Protected_Access
// WEP (Wired Equivalent Privacy);
// see https://en.wikipedia.org/wiki/Wired_Equivalent_Privacy
kUnknown = 0,
kOpen = 1,
kWpaPsk = 2,
kWep = 3,
};
// Possible statuses of a device's connection to a WiFi network.
struct WifiConnectionStatus {
enum Value {
UNKNOWN = 0,
CONNECTED = 1,
CONNECTION_FAILURE = 2,
AUTH_FAILURE = 3,
};
enum class WifiConnectionStatus {
kUnknown = 0,
kConnected = 1,
kConnectionFailure = 2,
kAuthFailure = 3,
};
// Represents a WiFi network found during a call to WifiMedium#scan().
class WifiScanResult {
public:
virtual ~WifiScanResult() {}
virtual ~WifiScanResult() = default;
// Gets the SSID of this WiFi network.
virtual std::string getSSID() const = 0;
virtual std::string GetSsid() const = 0;
// Gets the signal strength of this WiFi network in dBm.
virtual std::int32_t getSignalStrengthDbm() const = 0;
virtual std::int32_t GetSignalStrengthDbm() const = 0;
// Gets the frequency band of this WiFi network in MHz.
virtual std::int32_t getFrequencyMhz() const = 0;
virtual std::int32_t GetFrequencyMhz() const = 0;
// Gets the authentication type of this WiFi network.
virtual WifiAuthType::Value getAuthType() const = 0;
virtual WifiAuthType GetAuthType() const = 0;
};
// Container of operations that can be performed over the WiFi medium.
@@ -52,26 +54,22 @@ class WifiMedium {
class ScanResultCallback {
public:
virtual ~ScanResultCallback() {}
virtual ~ScanResultCallback() = default;
// The ConstPtr<WifiScanResult> objects contained in scan_results will be
// owned (and destroyed) by the recipient of the callback methods (i.e. the
// creator of the concrete ScanResultCallback object).
virtual void onScanResults(
const std::vector<ConstPtr<WifiScanResult>>& scan_results) = 0;
virtual void OnScanResults(
const std::vector<WifiScanResult>& scan_results) = 0;
};
// Does not take ownership of the passed-in scan_result_callback -- destroying
// that is up to the caller.
virtual bool scan(Ptr<ScanResultCallback> scan_result_callback) = 0;
virtual bool Scan(const ScanResultCallback& scan_result_callback) = 0;
// If 'password' is an empty string, none has been provided. Returns
// WifiConnectionStatus::CONNECTED on success, or the appropriate failure code
// otherwise.
virtual WifiConnectionStatus::Value connectToNetwork(
const std::string& ssid,
const std::string& password,
WifiAuthType::Value auth_type) = 0;
virtual WifiConnectionStatus ConnectToNetwork(absl::string_view ssid,
absl::string_view password,
WifiAuthType auth_type) = 0;
// Blocks until it's certain of there being a connection to the internet, or
// returns false if it fails to do so.
@@ -79,12 +77,13 @@ class WifiMedium {
// How this method wants to verify said connection is totally up to it (so it
// can feel free to ping whatever server, download whatever resource, etc.
// that it needs to gain confidence that the internet is reachable hereon in).
virtual bool verifyInternetConnectivity() = 0;
virtual bool VerifyInternetConnectivity() = 0;
// Returns the local device's IP address in the IPv4 dotted-quad format.
virtual std::string getIPAddress() = 0;
virtual std::string GetIpAddress() = 0;
};
} // namespace api
} // namespace nearby
} // namespace location