зеркало из https://github.com/mozilla/gecko-dev.git
Bug 806611 - Control wifi debug output based on a setting. r=vchang
--HG-- extra : rebase_source : 972a0956b02c7e6312ba0325d8fde1a4ee9a971d
This commit is contained in:
Родитель
279cda1e6a
Коммит
25ad9ae82e
|
@ -11,7 +11,7 @@ const {classes: Cc, interfaces: Ci, utils: Cu, results: Cr} = Components;
|
|||
Cu.import("resource://gre/modules/XPCOMUtils.jsm");
|
||||
Cu.import("resource://gre/modules/Services.jsm");
|
||||
|
||||
const DEBUG = false; // set to true to show debug messages
|
||||
var DEBUG = false; // set to true to show debug messages
|
||||
|
||||
const WIFIWORKER_CONTRACTID = "@mozilla.org/wifi/worker;1";
|
||||
const WIFIWORKER_CID = Components.ID("{a14e8977-d259-433a-a88d-58dd44657e5b}");
|
||||
|
@ -1835,9 +1835,28 @@ function WifiWorker() {
|
|||
handleError: function handleError(aErrorMessage) {
|
||||
debug("Error reading the 'wifi.enabled' setting. Default to wifi on.");
|
||||
self.setWifiEnabled({enabled: true});
|
||||
},
|
||||
}
|
||||
};
|
||||
gSettingsService.createLock().get("wifi.enabled", initWifiEnabledCb);
|
||||
|
||||
var initWifiDebuggingEnabledCb = {
|
||||
handle: function handle(aName, aResult) {
|
||||
if (aName !== "wifi.debugging.enabled")
|
||||
return;
|
||||
if (aResult === null)
|
||||
aResult = false;
|
||||
DEBUG = aResult;
|
||||
updateDebug();
|
||||
},
|
||||
handleError: function handleError(aErrorMessage) {
|
||||
debug("Error reading the 'wifi.debugging.enabled' setting. Default to debugging off.");
|
||||
DEBUG = false;
|
||||
updateDebug();
|
||||
}
|
||||
};
|
||||
|
||||
let lock = gSettingsService.createLock();
|
||||
lock.get("wifi.enabled", initWifiEnabledCb);
|
||||
lock.get("wifi.debugging.enabled", initWifiDebuggingEnabledCb);
|
||||
}
|
||||
|
||||
function translateState(state) {
|
||||
|
@ -2572,6 +2591,11 @@ WifiWorker.prototype = {
|
|||
}
|
||||
|
||||
let setting = JSON.parse(data);
|
||||
if (setting.key === "wifi.debugging.enabled") {
|
||||
DEBUG = setting.value;
|
||||
updateDebug();
|
||||
return;
|
||||
}
|
||||
if (setting.key !== "wifi.enabled" &&
|
||||
setting.key !== "tethering.wifi.enabled") {
|
||||
return;
|
||||
|
@ -2596,10 +2620,13 @@ WifiWorker.prototype = {
|
|||
this.NSGetFactory = XPCOMUtils.generateNSGetFactory([WifiWorker]);
|
||||
|
||||
let debug;
|
||||
if (DEBUG) {
|
||||
debug = function (s) {
|
||||
dump("-*- WifiWorker component: " + s + "\n");
|
||||
};
|
||||
} else {
|
||||
debug = function (s) {};
|
||||
function updateDebug() {
|
||||
if (DEBUG) {
|
||||
debug = function (s) {
|
||||
dump("-*- WifiWorker component: " + s + "\n");
|
||||
};
|
||||
} else {
|
||||
debug = function (s) {};
|
||||
}
|
||||
}
|
||||
updateDebug();
|
||||
|
|
Загрузка…
Ссылка в новой задаче