Bug 768905 - Don't react to 'connecting' events when we're already connected. r=gal DONTBUILD

--HG--
extra : transplant_source : %CF%D1%EF%19d%25%B2%B6%98%1F1%03%F0%3B%A2%A5%96%A6%FD7
This commit is contained in:
Blake Kaplan 2012-06-27 17:09:16 +02:00
parent c1b66d40f6
commit f37aa27e92

View File

@ -500,10 +500,22 @@ var WifiManager = (function() {
}
function notifyStateChange(fields) {
// If we're already in the COMPLETED state, we might receive events from
// the supplicant that tell us that we're re-authenticating or reminding
// us that we're associated to a network. In those cases, we don't need to
// do anything, so just ignore them.
if (manager.state === "COMPLETED" &&
fields.state !== "DISCONNECTED" &&
fields.state !== "INTERFACE_DISABLED" &&
fields.state !== "INACTIVE" &&
fields.state !== "SCANNING") {
return false;
}
fields.prevState = manager.state;
manager.state = fields.state;
notify("statechange", fields);
return true;
}
function parseStatus(status, reconnected) {
@ -744,7 +756,10 @@ var WifiManager = (function() {
// Format: CTRL-EVENT-CONNECTED - Connection to 00:1e:58:ec:d5:6d completed (reauth) [id=1 id_str=]
var bssid = eventData.split(" ")[4];
var id = eventData.substr(eventData.indexOf("id=")).split(" ")[0];
notifyStateChange({ state: "CONNECTED", BSSID: bssid, id: id });
// Don't call onconnected if we ignored this state change (since we were
// already connected).
if (notifyStateChange({ state: "CONNECTED", BSSID: bssid, id: id }))
onconnected(false);
return true;
}