aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorVitaly Buka <vitalybuka@google.com>2016-02-26 20:12:06 -0800
committerVitaly Buka <vitalybuka@google.com>2016-02-26 20:13:38 -0800
commit20f03a2966652cf76ea2e7449cebaedb6b457acc (patch)
tree6d6ef283876b5ab2560d11d7e58a792b19aee221
parent5db1247369bbf6abed9fbe0016e3a112a960bd4b (diff)
downloadweaved-20f03a2966652cf76ea2e7449cebaedb6b457acc.tar.gz
Implement provider::Wifi::GetConnectedSsid()
BUG: 25820726 Change-Id: Idc26aa3eb22aa40c7bf03827399e379db856578f
-rw-r--r--buffet/shill_client.cc22
-rw-r--r--buffet/shill_client.h1
2 files changed, 23 insertions, 0 deletions
diff --git a/buffet/shill_client.cc b/buffet/shill_client.cc
index 5649762..8e6e1e9 100644
--- a/buffet/shill_client.cc
+++ b/buffet/shill_client.cc
@@ -18,6 +18,7 @@
#include <base/message_loop/message_loop.h>
#include <base/stl_util.h>
+#include <base/strings/string_number_conversions.h>
#include <brillo/any.h>
#include <brillo/errors/error.h>
#include <brillo/variant_dictionary.h>
@@ -215,6 +216,27 @@ void ShillClient::StopAccessPoint() {
ap_manager_client_->Stop();
}
+std::string ShillClient::GetConnectedSsid() const {
+ for (const auto& kv : devices_) {
+ VariantDictionary properties;
+ if (!kv.second.selected_service->GetProperties(&properties, nullptr))
+ continue;
+
+ auto property_it = properties.find(shill::kWifiHexSsid);
+ if (property_it == properties.end()) continue;
+
+ string ssid_hex = property_it->second.TryGet<string>();
+ if (ssid_hex.empty()) continue;
+
+ std::vector<uint8_t> data;
+ if (!base::HexStringToBytes(ssid_hex, &data) || data.empty()) continue;
+
+ return std::string(data.begin(), data.end());
+ }
+
+ return "";
+}
+
void ShillClient::AddConnectionChangedCallback(
const ConnectionChangedCallback& listener) {
connectivity_listeners_.push_back(listener);
diff --git a/buffet/shill_client.h b/buffet/shill_client.h
index 517cd91..63cdd98 100644
--- a/buffet/shill_client.h
+++ b/buffet/shill_client.h
@@ -58,6 +58,7 @@ class ShillClient final : public weave::provider::Network,
void StopAccessPoint() override;
bool IsWifi24Supported() const override { return is_24_supported_; }
bool IsWifi50Supported() const override { return is_50_supported_; }
+ std::string GetConnectedSsid() const;
private:
struct DeviceState {