зеркало из https://github.com/mozilla/gecko-dev.git
Bug 887485 - Wifi code needs to issue fwreload to netd as part of initialization. r=mrbkap
This commit is contained in:
Родитель
b30f84b689
Коммит
df25dad82d
|
@ -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
|
||||
|
||||
controlMessage: function controlMessage(params, callback) {
|
||||
|
|
|
@ -166,6 +166,18 @@ function updateUpStreamFail(params) {
|
|||
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.
|
||||
*
|
||||
|
@ -801,6 +813,18 @@ function getNetworkInterfaceStats(params) {
|
|||
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;
|
||||
if (DEBUG) {
|
||||
debug = function (s) {
|
||||
|
|
|
@ -108,10 +108,23 @@ interface nsINetworkStatsCallback : nsISupports
|
|||
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.
|
||||
*/
|
||||
[scriptable, uuid(f39a0fb6-2752-47d2-943e-a0cdd3e43494)]
|
||||
[scriptable, uuid(5b22c620-f8b9-11e2-b778-0800200c9a66)]
|
||||
interface nsINetworkManager : nsISupports
|
||||
{
|
||||
/**
|
||||
|
@ -208,4 +221,19 @@ interface nsINetworkManager : nsISupports
|
|||
*/
|
||||
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,36 +1224,46 @@ var WifiManager = (function() {
|
|||
null);
|
||||
|
||||
prepareForStartup(function() {
|
||||
loadDriver(function (status) {
|
||||
if (status < 0) {
|
||||
gNetworkManager.setWifiOperationMode(ifname,
|
||||
WIFI_FIRMWARE_STATION,
|
||||
function (status) {
|
||||
if (status) {
|
||||
callback(status);
|
||||
manager.state = "UNINITIALIZED";
|
||||
return;
|
||||
}
|
||||
|
||||
function doStartSupplicant() {
|
||||
cancelWaitForDriverReadyTimer();
|
||||
startSupplicant(function (status) {
|
||||
if (status < 0) {
|
||||
unloadDriver(function() {
|
||||
callback(status);
|
||||
loadDriver(function (status) {
|
||||
if (status < 0) {
|
||||
callback(status);
|
||||
manager.state = "UNINITIALIZED";
|
||||
return;
|
||||
}
|
||||
|
||||
function doStartSupplicant() {
|
||||
cancelWaitForDriverReadyTimer();
|
||||
startSupplicant(function (status) {
|
||||
if (status < 0) {
|
||||
unloadDriver(function() {
|
||||
callback(status);
|
||||
});
|
||||
manager.state = "UNINITIALIZED";
|
||||
return;
|
||||
}
|
||||
|
||||
manager.supplicantStarted = true;
|
||||
enableInterface(ifname, function (ok) {
|
||||
callback(ok ? 0 : -1);
|
||||
});
|
||||
manager.state = "UNINITIALIZED";
|
||||
return;
|
||||
}
|
||||
|
||||
manager.supplicantStarted = true;
|
||||
enableInterface(ifname, function (ok) {
|
||||
callback(ok ? 0 : -1);
|
||||
});
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
// Driver startup on certain platforms takes longer than it takes for us
|
||||
// to return from loadDriver, so wait 2 seconds before starting
|
||||
// the supplicant to give it a chance to start.
|
||||
createWaitForDriverReadyTimer(doStartSupplicant);
|
||||
});
|
||||
// Driver startup on certain platforms takes longer than it takes for us
|
||||
// to return from loadDriver, so wait 2 seconds before starting
|
||||
// the supplicant to give it a chance to start.
|
||||
createWaitForDriverReadyTimer(doStartSupplicant);
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
} else {
|
||||
|
|
Загрузка…
Ссылка в новой задаче