Bug 823400 - Wifi toggle should not write settings db twice. r=mrbkap

This commit is contained in:
Vincent Chang 2012-12-24 17:23:16 +08:00
Родитель 06644285ee
Коммит 2a165ea847
1 изменённых файлов: 4 добавлений и 28 удалений

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

@ -740,7 +740,7 @@ var WifiManager = (function() {
}
retryTimer = null;
notify("supplicantfailed");
notify("supplicantlost", { success: false });
}
manager.connectionDropped = function(callback) {
@ -891,7 +891,7 @@ var WifiManager = (function() {
// simply exit here (we don't have to notify about having lost
// the connection).
if (eventData.indexOf("connection closed") !== -1) {
notify("supplicantlost");
notify("supplicantlost", { success: true });
return false;
}
@ -901,7 +901,7 @@ var WifiManager = (function() {
return true;
notifyStateChange({ state: "DISCONNECTED", BSSID: null, id: -1 });
notify("supplicantlost");
notify("supplicantlost", { success: true });
return false;
}
if (eventData.indexOf("CTRL-EVENT-DISCONNECTED") === 0) {
@ -1767,7 +1767,6 @@ function WifiWorker() {
WifiManager.onsupplicantconnection = function() {
debug("Connected to supplicant");
WifiManager.enabled = true;
self._updateWifiSetting(true);
WifiManager.getMacAddress(function (mac) {
self.macAddress = mac;
debug("Got mac: " + mac);
@ -1803,27 +1802,16 @@ function WifiWorker() {
WifiManager.onsupplicantlost = function() {
WifiManager.enabled = WifiManager.supplicantStarted = false;
self._updateWifiSetting(false);
WifiManager.state = "UNINITIALIZED";
debug("Supplicant died!");
// Check if we need to dequeue requests first.
self._notifyAfterStateChange(true, false);
self._notifyAfterStateChange(this.success, false);
// Notify everybody, even if they didn't ask us to come up.
self._fireEvent("wifiDown", {});
};
WifiManager.onsupplicantfailed = function() {
WifiManager.enabled = WifiManager.supplicantStarted = false;
self._updateWifiSetting(false);
WifiManager.state = "UNINITIALIZED";
debug("Couldn't connect to supplicant");
// Check if we need to dequeue requests first.
self._notifyAfterStateChange(false, false);
};
WifiManager.onpasswordmaybeincorrect = function() {
WifiManager.authenticationFailuresCount++;
};
@ -2868,18 +2856,6 @@ WifiWorker.prototype = {
}
},
_updateWifiSetting: function(enabled) {
// This is used to update the setting value, whenever the
// WifiManager.enabled is re-assigned based on supplicant
// connection/lost/failed.
//
// To avoid WifiWorker setting the wifi again, we mark the
// "fromInternalSetting" so WifiWorker won't deal with such
// an internal "mozsettings-changed" event when receiving it.
gSettingsService.createLock().set(
"wifi.enabled", enabled, null, "fromInternalSetting");
},
// nsIObserver implementation
observe: function observe(subject, topic, data) {
// Note that this function gets called for any and all settings changes,