Bug 887485 - Wifi code needs to issue fwreload to netd as part of initialization. r=mrbkap

This commit is contained in:
Vincent Chang 2013-07-30 16:07:13 +08:00
Родитель b30f84b689
Коммит df25dad82d
4 изменённых файлов: 106 добавлений и 23 удалений

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

@ -434,6 +434,27 @@ NetworkManager.prototype = {
}); });
}, },
setWifiOperationMode: function setWifiOperationMode(interfaceName, mode, callback) {
debug("setWifiOperationMode on " + interfaceName + " to " + mode);
let params = {
cmd: "setWifiOperationMode",
ifname: interfaceName,
mode: mode
};
params.report = true;
params.isAsync = true;
this.controlMessage(params, function(result) {
if (isError(result.resultCode)) {
callback.wifiOperationModeResult("netd command error");
} else {
callback.wifiOperationModeResult(null);
}
});
},
// Helpers // Helpers
controlMessage: function controlMessage(params, callback) { controlMessage: function controlMessage(params, callback) {

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

@ -166,6 +166,18 @@ function updateUpStreamFail(params) {
return true; return true;
} }
function wifiOperationModeFail(params) {
// Notify the main thread.
postMessage(params);
return true;
}
function wifiOperationModeSuccess(params) {
// Notify the main thread.
postMessage(params);
return true;
}
/** /**
* Get network interface properties from the system property table. * Get network interface properties from the system property table.
* *
@ -801,6 +813,18 @@ function getNetworkInterfaceStats(params) {
return true; return true;
} }
let gWifiOperationModeChain = [wifiFirmwareReload,
wifiOperationModeSuccess];
/**
* handling main thread's reload Wifi firmware request
*/
function setWifiOperationMode(params) {
debug("setWifiOperationMode: " + params.ifname + " " + params.mode);
chain(params, gWifiOperationModeChain, wifiOperationModeFail);
return true;
}
let debug; let debug;
if (DEBUG) { if (DEBUG) {
debug = function (s) { debug = function (s) {

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

@ -108,10 +108,23 @@ interface nsINetworkStatsCallback : nsISupports
in jsval date); in jsval date);
}; };
[scriptable, function, uuid(9ede8720-f8bc-11e2-b778-0800200c9a66)]
interface nsIWifiOperationModeCallback : nsISupports
{
/**
* Callback function used to report result to WifiManager.
*
* @param error
* An error message if the operation wasn't successful,
* or `null` if it was.
*/
void wifiOperationModeResult(in jsval error);
};
/** /**
* Manage network interfaces. * Manage network interfaces.
*/ */
[scriptable, uuid(f39a0fb6-2752-47d2-943e-a0cdd3e43494)] [scriptable, uuid(5b22c620-f8b9-11e2-b778-0800200c9a66)]
interface nsINetworkManager : nsISupports interface nsINetworkManager : nsISupports
{ {
/** /**
@ -208,4 +221,19 @@ interface nsINetworkManager : nsISupports
*/ */
void getNetworkInterfaceStats(in DOMString networkName, in nsINetworkStatsCallback callback); void getNetworkInterfaceStats(in DOMString networkName, in nsINetworkStatsCallback callback);
/**
* Reload Wifi firmware to specific operation mode.
*
* @param interfaceName
* Wifi Network interface name.
*
* @param mode
* AP - Access pointer mode.
* P2P - Peer to peer connection mode.
* STA - Station mode.
*
* @param callback
* Callback to notify Wifi firmware reload result.
*/
void setWifiOperationMode(in DOMString interfaceName, in DOMString mode, in nsIWifiOperationModeCallback callback);
}; };

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

@ -1224,6 +1224,15 @@ var WifiManager = (function() {
null); null);
prepareForStartup(function() { prepareForStartup(function() {
gNetworkManager.setWifiOperationMode(ifname,
WIFI_FIRMWARE_STATION,
function (status) {
if (status) {
callback(status);
manager.state = "UNINITIALIZED";
return;
}
loadDriver(function (status) { loadDriver(function (status) {
if (status < 0) { if (status < 0) {
callback(status); callback(status);
@ -1256,6 +1265,7 @@ var WifiManager = (function() {
}); });
}); });
}); });
});
} else { } else {
// Note these following calls ignore errors. If we fail to kill the // Note these following calls ignore errors. If we fail to kill the
// supplicant gracefully, then we need to continue telling it to die // supplicant gracefully, then we need to continue telling it to die