Skip to content

Commit

Permalink
Merge pull request mozilla-b2g#7435 from mrbkap/823783-settings-tethe…
Browse files Browse the repository at this point in the history
…ring-wifi

Bug 823783 - Handle various combinations of settings events and wifi events more correctly, r=kaze
  • Loading branch information
fabi1cazenave committed Jan 9, 2013
2 parents 3467e69 + d029e72 commit aa469f2
Showing 1 changed file with 21 additions and 2 deletions.
23 changes: 21 additions & 2 deletions apps/settings/js/wifi.js
Expand Up @@ -81,14 +81,33 @@ onLocalized(function wifiSettings() {
};

gWifiManager.onenabled = function onWifiEnabled() {
// enable UI toogle
// enable UI toggle
if (!lastMozSettingValue) {
// Wifi just came up, but the last known value of the setting was false.
// This either means that some external force turned it on (in which
// case we need to update the setting) or we simply haven't received the
// settings change event. Do that now and update our
// lastMozSettingValue. This will have the side-effect of not disabling
// the checkbox.
settings.createLock().set({ 'wifi.enabled': true });
lastMozSettingValue = true;
setMozSettingsEnabled(lastMozSettingValue);
}

gWifiCheckBox.disabled = false;
updateNetworkState();
gNetworkList.scan();
};

gWifiManager.ondisabled = function onWifiDisabled() {
// enable UI toogle
// enable UI toggle
if (lastMozSettingValue) {
// See the comment in onWifiEnabled for why we do this.
settings.createLock().set({ 'wifi.enabled': false });
lastMozSettingValue = false;
setMozSettingsEnabled(lastMozSettingValue);
}

gWifiCheckBox.disabled = false;
gWifiInfoBlock.textContent = _('disabled');
gNetworkList.clear(false);
Expand Down

0 comments on commit aa469f2

Please sign in to comment.