mirror of
https://github.com/mozilla/gecko-dev.git
synced 2025-03-01 13:57:32 +00:00
Bug 1009725 - [B2G][Flame][Settings]Wi-Fi toggle button intermittently non-responsive when selected. r=chulee
This commit is contained in:
parent
cc01b50036
commit
a715be0da3
@ -903,7 +903,6 @@ var WifiManager = (function() {
|
||||
// Initial state.
|
||||
manager.state = "UNINITIALIZED";
|
||||
manager.tetheringState = "UNINITIALIZED";
|
||||
manager.enabled = false;
|
||||
manager.supplicantStarted = false;
|
||||
manager.connectionInfo = { ssid: null, bssid: null, id: -1 };
|
||||
manager.authenticationFailuresCount = 0;
|
||||
@ -911,6 +910,17 @@ var WifiManager = (function() {
|
||||
manager.dhcpFailuresCount = 0;
|
||||
manager.stopSupplicantCallback = null;
|
||||
|
||||
manager.__defineGetter__("enabled", function() {
|
||||
switch (manager.state) {
|
||||
case "UNINITIALIZED":
|
||||
case "INITIALIZING":
|
||||
case "DISABLING":
|
||||
return false;
|
||||
default:
|
||||
return true;
|
||||
}
|
||||
});
|
||||
|
||||
var waitForTerminateEventTimer = null;
|
||||
function cancelWaitForTerminateEventTimer() {
|
||||
if (waitForTerminateEventTimer) {
|
||||
@ -1957,7 +1967,10 @@ function WifiWorker() {
|
||||
|
||||
WifiManager.onsupplicantconnection = function() {
|
||||
debug("Connected to supplicant");
|
||||
WifiManager.enabled = true;
|
||||
// Give it a state other than UNINITIALIZED, INITIALIZING or DISABLING
|
||||
// defined in getter function of WifiManager.enabled. It implies that
|
||||
// we are ready to accept dom request from applications.
|
||||
WifiManager.state = "DISCONNECTED";
|
||||
self._reloadConfiguredNetworks(function(ok) {
|
||||
// Prime this.networks.
|
||||
if (!ok)
|
||||
@ -1984,7 +1997,7 @@ function WifiWorker() {
|
||||
};
|
||||
|
||||
WifiManager.onsupplicantlost = function() {
|
||||
WifiManager.enabled = WifiManager.supplicantStarted = false;
|
||||
WifiManager.supplicantStarted = false;
|
||||
WifiManager.state = "UNINITIALIZED";
|
||||
debug("Supplicant died!");
|
||||
|
||||
@ -3130,6 +3143,12 @@ WifiWorker.prototype = {
|
||||
const message = "WifiManager:wps:Return";
|
||||
let self = this;
|
||||
let detail = msg.data;
|
||||
|
||||
if (!WifiManager.enabled) {
|
||||
this._sendMessage(message, false, "Wifi is disabled", msg);
|
||||
return;
|
||||
}
|
||||
|
||||
if (detail.method === "pbc") {
|
||||
WifiManager.wpsPbc(function(ok) {
|
||||
if (ok)
|
||||
@ -3163,6 +3182,11 @@ WifiWorker.prototype = {
|
||||
let enabled = msg.data;
|
||||
let mode = enabled ? "AUTO" : "ACTIVE";
|
||||
|
||||
if (!WifiManager.enabled) {
|
||||
this._sendMessage(message, false, "Wifi is disabled", msg);
|
||||
return;
|
||||
}
|
||||
|
||||
// Some wifi drivers may not implement this command. Set power mode
|
||||
// even if suspend optimization command failed.
|
||||
WifiManager.setSuspendOptimizations(enabled, function(ok) {
|
||||
@ -3182,6 +3206,11 @@ WifiWorker.prototype = {
|
||||
let network = msg.data.network;
|
||||
let info = msg.data.info;
|
||||
|
||||
if (!WifiManager.enabled) {
|
||||
this._sendMessage(message, false, "Wifi is disabled", msg);
|
||||
return;
|
||||
}
|
||||
|
||||
WifiManager.configureHttpProxy(network, info, function(ok) {
|
||||
if (ok) {
|
||||
// If configured network is current connected network
|
||||
@ -3204,6 +3233,11 @@ WifiWorker.prototype = {
|
||||
let network = msg.data.network;
|
||||
let info = msg.data.info;
|
||||
|
||||
if (!WifiManager.enabled) {
|
||||
this._sendMessage(message, false, "Wifi is disabled", msg);
|
||||
return;
|
||||
}
|
||||
|
||||
// To compatiable with DHCP returned info structure, do translation here
|
||||
info.ipaddr_str = info.ipaddr;
|
||||
info.proxy_str = info.proxy;
|
||||
@ -3224,6 +3258,11 @@ WifiWorker.prototype = {
|
||||
const message = "WifiManager:importCert:Return";
|
||||
let self = this;
|
||||
|
||||
if (!WifiManager.enabled) {
|
||||
this._sendMessage(message, false, "Wifi is disabled", msg);
|
||||
return;
|
||||
}
|
||||
|
||||
WifiManager.importCert(msg.data, function(data) {
|
||||
if (data.status === 0) {
|
||||
let usageString = ["ServerCert"];
|
||||
@ -3248,6 +3287,11 @@ WifiWorker.prototype = {
|
||||
const message = "WifiManager:getImportedCerts:Return";
|
||||
let self = this;
|
||||
|
||||
if (!WifiManager.enabled) {
|
||||
this._sendMessage(message, false, "Wifi is disabled", msg);
|
||||
return;
|
||||
}
|
||||
|
||||
let certDB2 = Cc["@mozilla.org/security/x509certdb;1"]
|
||||
.getService(Ci.nsIX509CertDB2);
|
||||
if (!certDB2) {
|
||||
@ -3286,6 +3330,11 @@ WifiWorker.prototype = {
|
||||
const message = "WifiManager:deleteCert:Return";
|
||||
let self = this;
|
||||
|
||||
if (!WifiManager.enabled) {
|
||||
this._sendMessage(message, false, "Wifi is disabled", msg);
|
||||
return;
|
||||
}
|
||||
|
||||
WifiManager.deleteCert(msg.data, function(data) {
|
||||
self._sendMessage(message, data.status === 0, "Delete Cert failed", msg);
|
||||
});
|
||||
|
Loading…
x
Reference in New Issue
Block a user