Bug 1023115 - Add retry count for EAP connection error. r=vchang

This commit is contained in:
Chuck Lee 2014-06-20 10:37:43 +08:00
parent 1d1c527438
commit dcd8787ac8

View File

@ -630,7 +630,7 @@ var WifiManager = (function() {
if (!dhcpInfo) { if (!dhcpInfo) {
if (++manager.dhcpFailuresCount >= MAX_RETRIES_ON_DHCP_FAILURE) { if (++manager.dhcpFailuresCount >= MAX_RETRIES_ON_DHCP_FAILURE) {
manager.dhcpFailuresCount = 0; manager.dhcpFailuresCount = 0;
notify("disconnected", {ssid: manager.connectionInfo.ssid}); notify("disconnected", {connectionInfo: manager.connectionInfo});
return; return;
} }
// NB: We have to call disconnect first. Otherwise, we only reauth with // NB: We have to call disconnect first. Otherwise, we only reauth with
@ -658,7 +658,7 @@ var WifiManager = (function() {
var driverEventMap = { STOPPED: "driverstopped", STARTED: "driverstarted", HANGED: "driverhung" }; var driverEventMap = { STOPPED: "driverstopped", STARTED: "driverstarted", HANGED: "driverhung" };
manager.getCurrentNetworkId = function (ssid, callback) { manager.getNetworkId = function (ssid, callback) {
manager.getConfiguredNetworks(function(networks) { manager.getConfiguredNetworks(function(networks) {
if (!networks) { if (!networks) {
debug("Unable to get configured networks"); debug("Unable to get configured networks");
@ -667,9 +667,10 @@ var WifiManager = (function() {
for (let net in networks) { for (let net in networks) {
let network = networks[net]; let network = networks[net];
// Trying to get netId from // Trying to get netId from
// 1. CURRENT network. // 1. network matching SSID if SSID is provided.
// 2. Trying to associate with SSID 'ssid' event // 2. current network if no SSID is provided, it's not guaranteed that
if (network.status === "CURRENT" || // current network matches requested SSID.
if ((!ssid && network.status === "CURRENT") ||
(ssid && ssid === dequote(network.ssid))) { (ssid && ssid === dequote(network.ssid))) {
return callback(net); return callback(net);
} }
@ -682,14 +683,20 @@ var WifiManager = (function() {
if (event.indexOf("CTRL-EVENT-EAP-FAILURE") !== -1) { if (event.indexOf("CTRL-EVENT-EAP-FAILURE") !== -1) {
if (event.indexOf("EAP authentication failed") !== -1) { if (event.indexOf("EAP authentication failed") !== -1) {
notify("passwordmaybeincorrect"); notify("passwordmaybeincorrect");
if (manager.authenticationFailuresCount > MAX_RETRIES_ON_AUTHENTICATION_FAILURE) {
manager.authenticationFailuresCount = 0;
notify("disconnected", {connectionInfo: manager.connectionInfo});
}
} }
return true; return true;
} }
if (event.indexOf("CTRL-EVENT-EAP-TLS-CERT-ERROR") !== -1) { if (event.indexOf("CTRL-EVENT-EAP-TLS-CERT-ERROR") !== -1) {
// Cert Error // Cert Error
manager.disconnect(function() { notify("passwordmaybeincorrect");
manager.reassociate(function(){}); if (manager.authenticationFailuresCount > MAX_RETRIES_ON_AUTHENTICATION_FAILURE) {
}); manager.authenticationFailuresCount = 0;
notify("disconnected", {connectionInfo: manager.connectionInfo});
}
return true; return true;
} }
if (event.indexOf("CTRL-EVENT-EAP-STARTED") !== -1) { if (event.indexOf("CTRL-EVENT-EAP-STARTED") !== -1) {
@ -709,7 +716,7 @@ var WifiManager = (function() {
notify("passwordmaybeincorrect"); notify("passwordmaybeincorrect");
if (manager.authenticationFailuresCount > MAX_RETRIES_ON_AUTHENTICATION_FAILURE) { if (manager.authenticationFailuresCount > MAX_RETRIES_ON_AUTHENTICATION_FAILURE) {
manager.authenticationFailuresCount = 0; manager.authenticationFailuresCount = 0;
notify("disconnected", {ssid: manager.connectionInfo.ssid}); notify("disconnected", {connectionInfo: manager.connectionInfo});
} }
return true; return true;
} }
@ -797,7 +804,7 @@ var WifiManager = (function() {
var bssid = token.split("=")[1]; var bssid = token.split("=")[1];
if (manager.authenticationFailuresCount > MAX_RETRIES_ON_AUTHENTICATION_FAILURE) { if (manager.authenticationFailuresCount > MAX_RETRIES_ON_AUTHENTICATION_FAILURE) {
manager.authenticationFailuresCount = 0; manager.authenticationFailuresCount = 0;
notify("disconnected", {ssid: manager.connectionInfo.ssid}); notify("disconnected", {connectionInfo: manager.connectionInfo});
} }
manager.connectionInfo.bssid = null; manager.connectionInfo.bssid = null;
manager.connectionInfo.ssid = null; manager.connectionInfo.ssid = null;
@ -809,7 +816,7 @@ var WifiManager = (function() {
notify("passwordmaybeincorrect"); notify("passwordmaybeincorrect");
if (manager.authenticationFailuresCount > MAX_RETRIES_ON_AUTHENTICATION_FAILURE) { if (manager.authenticationFailuresCount > MAX_RETRIES_ON_AUTHENTICATION_FAILURE) {
manager.authenticationFailuresCount = 0; manager.authenticationFailuresCount = 0;
notify("disconnected", {ssid: manager.connectionInfo.ssid}); notify("disconnected", {connectionInfo: manager.connectionInfo});
} }
return true; return true;
} }
@ -1223,7 +1230,7 @@ var WifiManager = (function() {
var errors = 0; var errors = 0;
for (var n = 1; n < lines.length; ++n) { for (var n = 1; n < lines.length; ++n) {
var result = lines[n].split("\t"); var result = lines[n].split("\t");
var netId = result[0]; var netId = parseInt(result[0], 10);
var config = networks[netId] = { netId: netId }; var config = networks[netId] = { netId: netId };
switch (result[3]) { switch (result[3]) {
case "[CURRENT]": case "[CURRENT]":
@ -1407,7 +1414,7 @@ var WifiManager = (function() {
manager.loopDetectionCount++; manager.loopDetectionCount++;
} }
if (manager.loopDetectionCount > MAX_SUPPLICANT_LOOP_ITERATIONS) { if (manager.loopDetectionCount > MAX_SUPPLICANT_LOOP_ITERATIONS) {
notify("disconnected", {ssid: manager.connectionInfo.ssid}); notify("disconnected", {connectionInfo: manager.connectionInfo});
manager.loopDetectionCount = 0; manager.loopDetectionCount = 0;
} }
} }
@ -2020,10 +2027,12 @@ function WifiWorker() {
self._needToEnableNetworks = false; self._needToEnableNetworks = false;
} }
WifiManager.getCurrentNetworkId(this.ssid, function(netId) { let connectionInfo = this.connectionInfo;
WifiManager.getNetworkId(connectionInfo.ssid, function(netId) {
// Trying to get netId from current network. // Trying to get netId from current network.
if (!netId && if (!netId &&
self.currentNetwork && self.currentNetwork &&
self.currentNetwork.ssid == dequote(connectionInfo.ssid) &&
typeof self.currentNetwork.netId !== "undefined") { typeof self.currentNetwork.netId !== "undefined") {
netId = self.currentNetwork.netId; netId = self.currentNetwork.netId;
} }
@ -3126,6 +3135,11 @@ WifiWorker.prototype = {
this._reconnectOnDisconnect = (this.currentNetwork && this._reconnectOnDisconnect = (this.currentNetwork &&
(this.currentNetwork.ssid === ssid)); (this.currentNetwork.ssid === ssid));
WifiManager.removeNetwork(configured.netId, function(ok) { WifiManager.removeNetwork(configured.netId, function(ok) {
if (self._needToEnableNetworks) {
self._enableAllNetworks();
self._needToEnableNetworks = false;
}
if (!ok) { if (!ok) {
self._sendMessage(message, false, "Unable to remove the network", msg); self._sendMessage(message, false, "Unable to remove the network", msg);
self._reconnectOnDisconnect = false; self._reconnectOnDisconnect = false;