Read device "WiFi.SupportedFrequencies" from shill.
Device frequencies are needed to implement privet flags for 2.4GHz and 5GHz.
Bug: 27070625
Change-Id: I24c306a4069803db046f59f8cbe393a7bd6b0e24
diff --git a/buffet/shill_client.cc b/buffet/shill_client.cc
index c68766a..1e97246 100644
--- a/buffet/shill_client.cc
+++ b/buffet/shill_client.cc
@@ -325,18 +325,38 @@
LOG(WARNING) << "Failed to get device properties?";
return;
}
- auto prop_it = properties.find(shill::kSelectedServiceProperty);
- if (prop_it == properties.end()) {
- LOG(WARNING) << "Failed to get device's selected service?";
- return;
+
+ for (const char* prop_name : {
+ shill::kSelectedServiceProperty,
+ shill::kWifiSupportedFrequenciesProperty,
+ }) {
+ auto prop_it = properties.find(prop_name);
+ if (prop_it == properties.end()) {
+ LOG(WARNING) << "Failed to get device's " << prop_name;
+ return;
+ }
+ OnDevicePropertyChange(device_path, prop_name, prop_it->second);
}
- OnDevicePropertyChange(device_path, shill::kSelectedServiceProperty,
- prop_it->second);
}
void ShillClient::OnDevicePropertyChange(const ObjectPath& device_path,
const string& property_name,
const Any& property_value) {
+ if (property_name == shill::kWifiSupportedFrequenciesProperty) {
+ is_24_supported_ = false;
+ is_50_supported_ = false;
+ for (uint16_t val : property_value.TryGet<std::vector<uint16_t>>()) {
+ if (2400 <= val && val <= 2500)
+ is_24_supported_ = true;
+ else if (4900 <= val && val <= 5900)
+ is_50_supported_ = true;
+ }
+ LOG(INFO) << "Wifi support:"
+ << (is_24_supported_ ? " 2.4GHz" : "")
+ << (is_50_supported_ ? " 5.0GHz" : "")
+ << (!is_24_supported_ && !is_50_supported_ ? " None" : "");
+ return;
+ }
// We only care about selected services anyway.
if (property_name != shill::kSelectedServiceProperty) {
return;
diff --git a/buffet/shill_client.h b/buffet/shill_client.h
index 0499707..12fd619 100644
--- a/buffet/shill_client.h
+++ b/buffet/shill_client.h
@@ -125,6 +125,9 @@
std::string connecting_service_error_;
weave::DoneCallback connect_done_callback_;
+ bool is_24_supported_ = false;
+ bool is_50_supported_ = false;
+
// State for tracking our online connectivity.
std::map<dbus::ObjectPath, DeviceState> devices_;
State connectivity_state_{State::kOffline};