зеркало из https://github.com/mozilla/gecko-dev.git
Bug 806611 - Make wpa_supplicant noisy when debug is enabled for wifi. r=vchang a=bbajaj
This commit is contained in:
Родитель
d0e8777db0
Коммит
621ea6c6fc
|
@ -283,6 +283,48 @@ var WifiManager = (function() {
|
||||||
doBooleanCommand("SCAN", "OK", callback);
|
doBooleanCommand("SCAN", "OK", callback);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var debugEnabled = false;
|
||||||
|
function setLogLevel(level, callback) {
|
||||||
|
doBooleanCommand("LOG_LEVEL " + level, "OK", callback);
|
||||||
|
}
|
||||||
|
|
||||||
|
function syncDebug() {
|
||||||
|
if (debugEnabled !== DEBUG) {
|
||||||
|
let wanted = DEBUG;
|
||||||
|
setLogLevel(wanted ? "DEBUG" : "INFO", function(ok) {
|
||||||
|
if (ok)
|
||||||
|
debugEnabled = wanted;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function getLogLevel(callback) {
|
||||||
|
doStringCommand("LOG_LEVEL", callback);
|
||||||
|
}
|
||||||
|
|
||||||
|
function getDebugEnabled(callback) {
|
||||||
|
getLogLevel(function(level) {
|
||||||
|
if (level === null) {
|
||||||
|
debug("Unable to get wpa_supplicant's log level");
|
||||||
|
callback(false);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
var lines = level.split("\n");
|
||||||
|
for (let i = 0; i < lines.length; ++i) {
|
||||||
|
let match = /Current level: (.*)/.exec(lines[i]);
|
||||||
|
if (match) {
|
||||||
|
debugEnabled = match[1].toLowerCase() === "debug";
|
||||||
|
callback(true);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// If we're here, we didn't get the current level.
|
||||||
|
callback(false);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
function setScanModeCommand(setActive, callback) {
|
function setScanModeCommand(setActive, callback) {
|
||||||
scanModeActive = setActive;
|
scanModeActive = setActive;
|
||||||
doSetScanModeCommand(setActive, callback);
|
doSetScanModeCommand(setActive, callback);
|
||||||
|
@ -919,6 +961,9 @@ var WifiManager = (function() {
|
||||||
waitForEvent();
|
waitForEvent();
|
||||||
|
|
||||||
// Load up the supplicant state.
|
// Load up the supplicant state.
|
||||||
|
getDebugEnabled(function(ok) {
|
||||||
|
syncDebug();
|
||||||
|
});
|
||||||
statusCommand(function(status) {
|
statusCommand(function(status) {
|
||||||
parseStatus(status);
|
parseStatus(status);
|
||||||
notify("supplicantconnection");
|
notify("supplicantconnection");
|
||||||
|
@ -1247,6 +1292,7 @@ var WifiManager = (function() {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
manager.syncDebug = syncDebug;
|
||||||
manager.stateOrdinal = function(state) {
|
manager.stateOrdinal = function(state) {
|
||||||
return supplicantStatesMap.indexOf(state);
|
return supplicantStatesMap.indexOf(state);
|
||||||
}
|
}
|
||||||
|
@ -2628,5 +2674,6 @@ function updateDebug() {
|
||||||
} else {
|
} else {
|
||||||
debug = function (s) {};
|
debug = function (s) {};
|
||||||
}
|
}
|
||||||
|
WifiManager.syncDebug();
|
||||||
}
|
}
|
||||||
updateDebug();
|
updateDebug();
|
||||||
|
|
Загрузка…
Ссылка в новой задаче