diff options
Diffstat (limited to 'buffet/shill_client.cc')
-rw-r--r-- | buffet/shill_client.cc | 23 |
1 files changed, 7 insertions, 16 deletions
diff --git a/buffet/shill_client.cc b/buffet/shill_client.cc index 88fbc84..dea039d 100644 --- a/buffet/shill_client.cc +++ b/buffet/shill_client.cc @@ -123,7 +123,6 @@ void ShillClient::Init() { VLOG(2) << "ShillClient::Init();"; CleanupConnectingService(); devices_.clear(); - connectivity_state_ = Network::State::kOffline; VariantDictionary properties; if (!manager_proxy_.GetProperties(&properties, nullptr)) { LOG(ERROR) << "Unable to get properties from Manager, waiting for " @@ -198,7 +197,12 @@ void ShillClient::ConnectToServiceError( } Network::State ShillClient::GetConnectionState() const { - return connectivity_state_; + Network::State new_connectivity_state{Network::State::kOffline}; + for (const auto& kv : devices_) { + new_connectivity_state = + std::max(new_connectivity_state, kv.second.service_state); + } + return new_connectivity_state; } void ShillClient::StartAccessPoint(const std::string& ssid) { @@ -239,7 +243,6 @@ void ShillClient::OnShillServiceOwnerChange(const string& /*old_owner*/, if (new_owner.empty()) { CleanupConnectingService(); devices_.clear(); - connectivity_state_ = Network::State::kOffline; } else { Init(); // New service owner means shill reset! } @@ -553,19 +556,7 @@ void ShillClient::OnStateChangeForSelectedService( } void ShillClient::UpdateConnectivityState() { - // Update the connectivity state of the device by picking the - // state of the currently most connected selected service. - Network::State new_connectivity_state{Network::State::kOffline}; - for (const auto& kv : devices_) { - if (kv.second.service_state > new_connectivity_state) { - new_connectivity_state = kv.second.service_state; - } - } - VLOG(1) << "Connectivity changed: " << EnumToString(connectivity_state_) - << " -> " << EnumToString(new_connectivity_state); - // Notify listeners even if state changed to the same value. Listeners may - // want to handle this event. - connectivity_state_ = new_connectivity_state; + VLOG(1) << "Connectivity state: " << EnumToString(GetConnectionState()); // We may call UpdateConnectivityState whenever we mutate a data structure // such that our connectivity status could change. However, we don't want // to allow people to call into ShillClient while some other operation is |