Index: chromeos/components/tether/wifi_hotspot_connector.cc |
diff --git a/chromeos/components/tether/wifi_hotspot_connector.cc b/chromeos/components/tether/wifi_hotspot_connector.cc |
index 1ec2bed728055bcd31cb540d956d6bf3eff788b9..9e4688dd5e7c2b5b68d8b57adbde15258b8466a5 100644 |
--- a/chromeos/components/tether/wifi_hotspot_connector.cc |
+++ b/chromeos/components/tether/wifi_hotspot_connector.cc |
@@ -36,6 +36,7 @@ WifiHotspotConnector::~WifiHotspotConnector() { |
void WifiHotspotConnector::ConnectToWifiHotspot( |
const std::string& ssid, |
const std::string& password, |
+ const std::string& tether_network_guid, |
const WifiConnectionCallback& callback) { |
DCHECK(!ssid.empty()); |
// Note: |password| can be empty in some cases. |
@@ -44,14 +45,33 @@ void WifiHotspotConnector::ConnectToWifiHotspot( |
DCHECK(timer_->IsRunning()); |
// If another connection attempt was underway but had not yet completed, |
+ // disassociate that network with the Tether network and |
Kyle Horimoto
2017/05/03 01:53:33
nit: "disassociates with" is incorrect grammatical
lesliewatkins
2017/05/03 22:00:24
Done.
|
// call the callback, passing an empty string to signal that the connection |
Kyle Horimoto
2017/05/03 01:53:33
nit: Some of this fits on the previous line. Try t
lesliewatkins
2017/05/03 22:00:24
Done.
|
// did not complete successfully. |
+ bool successful_disassociation = |
+ network_state_handler_->DisassociateTetherNetworkStateWithWifiNetwork( |
+ tether_network_guid_, wifi_network_guid_); |
+ if (successful_disassociation) { |
+ PA_LOG(INFO) << "Wifi network with ID " << wifi_network_guid_ |
Kyle Horimoto
2017/05/03 01:53:33
Just make this one sentence:
Wifi network with ID
lesliewatkins
2017/05/03 22:00:24
Done.
|
+ << " successfully disassociated " |
+ "with Tether network. Tether network ID: \"" |
+ << tether_network_guid_ << "\", Wi-Fi network ID: \"" |
+ << wifi_network_guid_ << "\""; |
+ } else { |
+ PA_LOG(INFO) << "Wifi network with ID " << wifi_network_guid_ |
+ << " failed to disassociate tether network " |
+ "with ID \"" |
+ << tether_network_guid_ << "\" to Wi-Fi network with ID: \"" |
+ << wifi_network_guid_ << "\""; |
+ } |
+ |
InvokeWifiConnectionCallback(std::string()); |
} |
ssid_ = ssid; |
password_ = password; |
- wifi_guid_ = base::GenerateGUID(); |
+ tether_network_guid_ = tether_network_guid; |
+ wifi_network_guid_ = base::GenerateGUID(); |
callback_ = callback; |
timer_->Start(FROM_HERE, |
base::TimeDelta::FromSeconds(kConnectionTimeoutSeconds), |
@@ -65,21 +85,40 @@ void WifiHotspotConnector::ConnectToWifiHotspot( |
void WifiHotspotConnector::NetworkPropertiesUpdated( |
const NetworkState* network) { |
- if (network->guid() != wifi_guid_) { |
+ if (network->guid() != wifi_network_guid_) { |
// If a different network has been connected, return early and wait for the |
- // network with ID |wifi_guid_| is updated. |
+ // network with ID |wifi_network_guid_| is updated. |
return; |
} |
if (network->IsConnectedState()) { |
// If a connection occurred, notify observers and exit early. |
- InvokeWifiConnectionCallback(wifi_guid_); |
+ InvokeWifiConnectionCallback(wifi_network_guid_); |
return; |
} |
if (network->connectable()) { |
- // If the network is now connectable, initiate a connection to it. |
- network_connect_->ConnectToNetworkId(wifi_guid_); |
+ bool successful_association = |
+ network_state_handler_->AssociateTetherNetworkStateWithWifiNetwork( |
+ tether_network_guid_, wifi_network_guid_); |
+ if (successful_association) { |
+ PA_LOG(INFO) << "Wifi network with ID " << wifi_network_guid_ |
+ << " is connectable, and successfully associated " |
+ "with Tether network. Tether network ID: \"" |
+ << tether_network_guid_ << "\", Wi-Fi network ID: \"" |
+ << wifi_network_guid_ << "\""; |
+ } else { |
+ PA_LOG(INFO) << "Wifi network with ID " << wifi_network_guid_ |
+ << " is connectable, but failed to associate tether network " |
+ "with ID \"" |
+ << tether_network_guid_ << "\" to Wi-Fi network with ID: \"" |
+ << wifi_network_guid_ << "\""; |
+ } |
+ |
+ // If the network is now connectable, associate it with a Tether network |
Kyle Horimoto
2017/05/03 01:53:33
Move this comment to above the AssociateTetherNetw
lesliewatkins
2017/05/03 22:00:24
Done.
lesliewatkins
2017/05/03 22:00:24
Done, but this is basically reverting back to: htt
Kyle Horimoto
2017/05/03 22:47:28
It's not reverting back to that. You changed the w
lesliewatkins
2017/05/04 01:40:16
Done.
|
+ // ASAP so that the correct icon will be displayed in the tray while the |
+ // network is connecting. |
+ network_connect_->ConnectToNetworkId(wifi_network_guid_); |
} |
} |
@@ -87,17 +126,17 @@ void WifiHotspotConnector::InvokeWifiConnectionCallback( |
const std::string& wifi_guid) { |
DCHECK(!callback_.is_null()); |
- // |wifi_guid| may be a reference to |wifi_guid_|, so make a copy of it first |
- // before clearing it below. |
- std::string wifi_guid_copy = wifi_guid; |
+ // |wifi_guid| may be a reference to |wifi_network_guid_|, so make a copy of |
+ // it first before clearing it below. |
+ std::string wifi_network_guid_copy = wifi_guid; |
ssid_.clear(); |
password_.clear(); |
- wifi_guid_.clear(); |
+ wifi_network_guid_.clear(); |
timer_->Stop(); |
- callback_.Run(wifi_guid_copy); |
+ callback_.Run(wifi_network_guid_copy); |
callback_.Reset(); |
} |
@@ -107,12 +146,13 @@ base::DictionaryValue WifiHotspotConnector::CreateWifiPropertyDictionary( |
PA_LOG(INFO) << "Creating network configuration. " |
<< "SSID: " << ssid << ", " |
<< "Password: " << password << ", " |
- << "Wi-Fi network GUID: " << wifi_guid_; |
+ << "Wi-Fi network GUID: " << wifi_network_guid_; |
base::DictionaryValue properties; |
shill_property_util::SetSSID(ssid, &properties); |
- properties.SetStringWithoutPathExpansion(shill::kGuidProperty, wifi_guid_); |
+ properties.SetStringWithoutPathExpansion(shill::kGuidProperty, |
+ wifi_network_guid_); |
properties.SetBooleanWithoutPathExpansion(shill::kAutoConnectProperty, false); |
properties.SetStringWithoutPathExpansion(shill::kTypeProperty, |
shill::kTypeWifi); |