Bug 921620 - Change trigger point of wifi down. r=vchang

This commit is contained in:
Chuck Lee 2013-11-08 16:16:16 +08:00
Родитель d8cfcfe430
Коммит 878db5dc0a
1 изменённых файлов: 22 добавлений и 13 удалений

Просмотреть файл

@ -195,12 +195,14 @@ var WifiManager = (function() {
// On properly written drivers, bringing the interface
// down powers down the interface.
callback(0);
notify("supplicantlost", { success: true });
return;
}
wifiCommand.unloadDriver(function(status) {
driverLoaded = (status < 0);
callback(status);
notify("supplicantlost", { success: true });
});
}
@ -413,6 +415,12 @@ var WifiManager = (function() {
}
function notifyStateChange(fields) {
// Don't handle any state change when and after disabling.
if (manager.state === "DISABLING" ||
manager.state === "UNINITIALIZED") {
return false;
}
// 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
@ -676,22 +684,22 @@ var WifiManager = (function() {
return true;
}
if (eventData.indexOf("CTRL-EVENT-TERMINATING") === 0) {
// If the monitor socket is closed, we have already stopped the
// supplicant and we can stop waiting for more events and
// simply exit here (we don't have to notify about having lost
// the connection).
if (eventData.indexOf("connection closed") !== -1) {
notify("supplicantlost", { success: true });
return false;
}
// As long we haven't seen too many recv errors yet, we
// will keep going for a bit longer.
if (eventData.indexOf("recv error") !== -1 && ++recvErrors < 10)
// As long the monitor socket is not closed and we haven't seen too many
// recv errors yet, we will keep going for a bit longer.
if (eventData.indexOf("connection closed") === -1 &&
eventData.indexOf("recv error") !== -1 && ++recvErrors < 10)
return true;
notifyStateChange({ state: "DISCONNECTED", BSSID: null, id: -1 });
notify("supplicantlost", { success: true });
// If the supplicant is terminated as commanded, the supplicant lost
// notification will be sent after driver unloaded. In such case, the
// manager state will be "DISABLING" or "UNINITIALIZED".
// So if supplicant terminated with incorrect manager state, implying
// unexpected condition, we should notify supplicant lost here.
if (manager.state !== "DISABLING" && manager.state !== "UNINITIALIZED") {
notify("supplicantlost", { success: true });
}
return false;
}
if (eventData.indexOf("CTRL-EVENT-DISCONNECTED") === 0) {
@ -897,6 +905,7 @@ var WifiManager = (function() {
// Note these following calls ignore errors. If we fail to kill the
// supplicant gracefully, then we need to continue telling it to die
// until it does.
manager.state = "DISABLING";
wifiCommand.terminateSupplicant(function (ok) {
manager.connectionDropped(function () {
wifiCommand.stopSupplicant(function (status) {