Merge b2ginbound to central, a=merge

This commit is contained in:
Wes Kocher 2015-07-29 20:19:12 -07:00
Родитель 10301118e8 b4ca9f4672
Коммит 1ca8b1de87
55 изменённых файлов: 837 добавлений и 762 удалений

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

@ -201,9 +201,9 @@ var shell = {
debugCrashReport('Not online, postponing.');
Services.obs.addObserver(function observer(subject, topic, state) {
let network = subject.QueryInterface(Ci.nsINetworkInterface);
if (network.state == Ci.nsINetworkInterface.NETWORK_STATE_CONNECTED
&& network.type == Ci.nsINetworkInterface.NETWORK_TYPE_WIFI) {
let network = subject.QueryInterface(Ci.nsINetworkInfo);
if (network.state == Ci.nsINetworkInfo.NETWORK_STATE_CONNECTED
&& network.type == Ci.nsINetworkInfo.NETWORK_TYPE_WIFI) {
shell.submitQueuedCrashes();
Services.obs.removeObserver(observer, topic);

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

@ -15,7 +15,7 @@
<project name="platform_build" path="build" remote="b2g" revision="e862ab9177af664f00b4522e2350f4cb13866d73">
<copyfile dest="Makefile" src="core/root.mk"/>
</project>
<project name="gaia" path="gaia" remote="mozillaorg" revision="088f350b39baf8f86c7c1161fd4be178ce822b7b"/>
<project name="gaia" path="gaia" remote="mozillaorg" revision="bf8565e0c3ad216ccb3f109c17f8a2eb2c42f6b8"/>
<project name="fake-libdvm" path="dalvik" remote="b2g" revision="d50ae982b19f42f0b66d08b9eb306be81687869f"/>
<project name="gonk-misc" path="gonk-misc" remote="b2g" revision="9f45c1988fe72749f0659409e6e3320fabf7b79a"/>
<project name="librecovery" path="librecovery" remote="b2g" revision="1b3591a50ed352fc6ddb77462b7b35d0bfa555a3"/>

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

@ -15,7 +15,7 @@
<project name="platform_build" path="build" remote="b2g" revision="e862ab9177af664f00b4522e2350f4cb13866d73">
<copyfile dest="Makefile" src="core/root.mk"/>
</project>
<project name="gaia" path="gaia" remote="mozillaorg" revision="088f350b39baf8f86c7c1161fd4be178ce822b7b"/>
<project name="gaia" path="gaia" remote="mozillaorg" revision="bf8565e0c3ad216ccb3f109c17f8a2eb2c42f6b8"/>
<project name="fake-libdvm" path="dalvik" remote="b2g" revision="d50ae982b19f42f0b66d08b9eb306be81687869f"/>
<project name="gonk-misc" path="gonk-misc" remote="b2g" revision="9f45c1988fe72749f0659409e6e3320fabf7b79a"/>
<project name="librecovery" path="librecovery" remote="b2g" revision="1b3591a50ed352fc6ddb77462b7b35d0bfa555a3"/>

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

@ -19,7 +19,7 @@
<copyfile dest="Makefile" src="core/root.mk"/>
</project>
<project name="fake-dalvik" path="dalvik" remote="b2g" revision="ca1f327d5acc198bb4be62fa51db2c039032c9ce"/>
<project name="gaia.git" path="gaia" remote="mozillaorg" revision="088f350b39baf8f86c7c1161fd4be178ce822b7b"/>
<project name="gaia.git" path="gaia" remote="mozillaorg" revision="bf8565e0c3ad216ccb3f109c17f8a2eb2c42f6b8"/>
<project name="gonk-misc" path="gonk-misc" remote="b2g" revision="9f45c1988fe72749f0659409e6e3320fabf7b79a"/>
<project name="rilproxy" path="rilproxy" remote="b2g" revision="5ef30994f4778b4052e58a4383dbe7890048c87e"/>
<project name="platform_hardware_ril" path="hardware/ril" remote="b2g" revision="8bc59310552179f9a8bc6cdd0188e2475df52fb7"/>

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

@ -17,7 +17,7 @@
</project>
<project name="rilproxy" path="rilproxy" remote="b2g" revision="5ef30994f4778b4052e58a4383dbe7890048c87e"/>
<project name="fake-libdvm" path="dalvik" remote="b2g" revision="d50ae982b19f42f0b66d08b9eb306be81687869f"/>
<project name="gaia" path="gaia" remote="mozillaorg" revision="088f350b39baf8f86c7c1161fd4be178ce822b7b"/>
<project name="gaia" path="gaia" remote="mozillaorg" revision="bf8565e0c3ad216ccb3f109c17f8a2eb2c42f6b8"/>
<project name="gonk-misc" path="gonk-misc" remote="b2g" revision="9f45c1988fe72749f0659409e6e3320fabf7b79a"/>
<project name="moztt" path="external/moztt" remote="b2g" revision="657894b4a1dc0a926117f4812e0940229f9f676f"/>
<project name="apitrace" path="external/apitrace" remote="apitrace" revision="5bb657ada461be666c35f419dbe072ed2ce632fc"/>

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

@ -15,7 +15,7 @@
<project name="platform_build" path="build" remote="b2g" revision="e862ab9177af664f00b4522e2350f4cb13866d73">
<copyfile dest="Makefile" src="core/root.mk"/>
</project>
<project name="gaia" path="gaia" remote="mozillaorg" revision="088f350b39baf8f86c7c1161fd4be178ce822b7b"/>
<project name="gaia" path="gaia" remote="mozillaorg" revision="bf8565e0c3ad216ccb3f109c17f8a2eb2c42f6b8"/>
<project name="fake-libdvm" path="dalvik" remote="b2g" revision="d50ae982b19f42f0b66d08b9eb306be81687869f"/>
<project name="gonk-misc" path="gonk-misc" remote="b2g" revision="9f45c1988fe72749f0659409e6e3320fabf7b79a"/>
<project name="librecovery" path="librecovery" remote="b2g" revision="1b3591a50ed352fc6ddb77462b7b35d0bfa555a3"/>

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

@ -15,7 +15,7 @@
<project name="platform_build" path="build" remote="b2g" revision="07c383a786f188904311a37f6062c2cb84c9b61d">
<copyfile dest="Makefile" src="core/root.mk"/>
</project>
<project name="gaia" path="gaia" remote="mozillaorg" revision="088f350b39baf8f86c7c1161fd4be178ce822b7b"/>
<project name="gaia" path="gaia" remote="mozillaorg" revision="bf8565e0c3ad216ccb3f109c17f8a2eb2c42f6b8"/>
<project name="fake-libdvm" path="dalvik" remote="b2g" revision="d50ae982b19f42f0b66d08b9eb306be81687869f"/>
<project name="gonk-misc" path="gonk-misc" remote="b2g" revision="9f45c1988fe72749f0659409e6e3320fabf7b79a"/>
<project name="librecovery" path="librecovery" remote="b2g" revision="1b3591a50ed352fc6ddb77462b7b35d0bfa555a3"/>

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

@ -19,7 +19,7 @@
<copyfile dest="Makefile" src="core/root.mk"/>
</project>
<project name="fake-dalvik" path="dalvik" remote="b2g" revision="ca1f327d5acc198bb4be62fa51db2c039032c9ce"/>
<project name="gaia.git" path="gaia" remote="mozillaorg" revision="088f350b39baf8f86c7c1161fd4be178ce822b7b"/>
<project name="gaia.git" path="gaia" remote="mozillaorg" revision="bf8565e0c3ad216ccb3f109c17f8a2eb2c42f6b8"/>
<project name="gonk-misc" path="gonk-misc" remote="b2g" revision="9f45c1988fe72749f0659409e6e3320fabf7b79a"/>
<project name="rilproxy" path="rilproxy" remote="b2g" revision="5ef30994f4778b4052e58a4383dbe7890048c87e"/>
<project name="platform_hardware_ril" path="hardware/ril" remote="b2g" revision="8bc59310552179f9a8bc6cdd0188e2475df52fb7"/>

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

@ -15,7 +15,7 @@
<project name="platform_build" path="build" remote="b2g" revision="e862ab9177af664f00b4522e2350f4cb13866d73">
<copyfile dest="Makefile" src="core/root.mk"/>
</project>
<project name="gaia" path="gaia" remote="mozillaorg" revision="088f350b39baf8f86c7c1161fd4be178ce822b7b"/>
<project name="gaia" path="gaia" remote="mozillaorg" revision="bf8565e0c3ad216ccb3f109c17f8a2eb2c42f6b8"/>
<project name="fake-libdvm" path="dalvik" remote="b2g" revision="d50ae982b19f42f0b66d08b9eb306be81687869f"/>
<project name="gonk-misc" path="gonk-misc" remote="b2g" revision="9f45c1988fe72749f0659409e6e3320fabf7b79a"/>
<project name="librecovery" path="librecovery" remote="b2g" revision="1b3591a50ed352fc6ddb77462b7b35d0bfa555a3"/>

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

@ -1,9 +1,9 @@
{
"git": {
"git_revision": "088f350b39baf8f86c7c1161fd4be178ce822b7b",
"git_revision": "bf8565e0c3ad216ccb3f109c17f8a2eb2c42f6b8",
"remote": "https://git.mozilla.org/releases/gaia.git",
"branch": ""
},
"revision": "97666dae0fe5da2a0da4f57f41fcb12e9c2fe709",
"revision": "3b5be8b229de20ea6cdcd3089558bf631c184c58",
"repo_path": "integration/gaia-central"
}

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

@ -17,7 +17,7 @@
</project>
<project name="rilproxy" path="rilproxy" remote="b2g" revision="5ef30994f4778b4052e58a4383dbe7890048c87e"/>
<project name="fake-libdvm" path="dalvik" remote="b2g" revision="d50ae982b19f42f0b66d08b9eb306be81687869f"/>
<project name="gaia" path="gaia" remote="mozillaorg" revision="088f350b39baf8f86c7c1161fd4be178ce822b7b"/>
<project name="gaia" path="gaia" remote="mozillaorg" revision="bf8565e0c3ad216ccb3f109c17f8a2eb2c42f6b8"/>
<project name="gonk-misc" path="gonk-misc" remote="b2g" revision="9f45c1988fe72749f0659409e6e3320fabf7b79a"/>
<project name="moztt" path="external/moztt" remote="b2g" revision="657894b4a1dc0a926117f4812e0940229f9f676f"/>
<project name="apitrace" path="external/apitrace" remote="apitrace" revision="5bb657ada461be666c35f419dbe072ed2ce632fc"/>

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

@ -15,7 +15,7 @@
<project name="platform_build" path="build" remote="b2g" revision="07c383a786f188904311a37f6062c2cb84c9b61d">
<copyfile dest="Makefile" src="core/root.mk"/>
</project>
<project name="gaia" path="gaia" remote="mozillaorg" revision="088f350b39baf8f86c7c1161fd4be178ce822b7b"/>
<project name="gaia" path="gaia" remote="mozillaorg" revision="bf8565e0c3ad216ccb3f109c17f8a2eb2c42f6b8"/>
<project name="fake-libdvm" path="dalvik" remote="b2g" revision="d50ae982b19f42f0b66d08b9eb306be81687869f"/>
<project name="gonk-misc" path="gonk-misc" remote="b2g" revision="9f45c1988fe72749f0659409e6e3320fabf7b79a"/>
<project name="librecovery" path="librecovery" remote="b2g" revision="1b3591a50ed352fc6ddb77462b7b35d0bfa555a3"/>

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

@ -25,7 +25,7 @@ function isNetworkReady() {
for (var i = 0; i < num; i++) {
var ips = {};
var prefixLengths = {};
var length = itfList.getInterface(i).getAddresses(ips, prefixLengths);
var length = itfList.getInterfaceInfo(i).getAddresses(ips, prefixLengths);
for (var j = 0; j < length; j++) {
var ip = ips.value[j];

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

@ -708,10 +708,10 @@ MobileConnectionProvider.prototype = {
updateDataInfo: function(aNewInfo, aBatch = false) {
// For the data connection, the `connected` flag indicates whether
// there's an active data call. We get correct `connected` state here.
let active = gNetworkManager.active;
let active = gNetworkManager.activeNetworkInfo;
aNewInfo.connected = false;
if (active &&
active.type === Ci.nsINetworkInterface.NETWORK_TYPE_MOBILE &&
active.type === Ci.nsINetworkInfo.NETWORK_TYPE_MOBILE &&
active.serviceId === this._clientId) {
aNewInfo.connected = true;
}
@ -1599,11 +1599,10 @@ MobileConnectionService.prototype = {
}
break;
case NS_DATA_CALL_ERROR_TOPIC_ID:
let network = aSubject;
try {
if (network instanceof Ci.nsIRilNetworkInterface) {
let rilNetwork = network.QueryInterface(Ci.nsIRilNetworkInterface);
this.notifyDataError(rilNetwork.serviceId, rilNetwork);
if (aSubject instanceof Ci.nsIRilNetworkInfo) {
let rilInfo = aSubject.QueryInterface(Ci.nsIRilNetworkInfo);
this.notifyDataError(rilInfo.serviceId, aData);
}
} catch (e) {}
break;

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

@ -227,10 +227,10 @@ MmsConnection.prototype = {
mmsProxy: "",
mmsPort: -1,
setApnSetting: function(network) {
this.mmsc = network.mmsc;
this.mmsProxy = network.mmsProxy;
this.mmsPort = network.mmsPort;
setApnSetting: function(networkInfo) {
this.mmsc = networkInfo.mmsc;
this.mmsProxy = networkInfo.mmsProxy;
this.mmsPort = networkInfo.mmsPort;
},
get proxyInfo() {
@ -268,8 +268,8 @@ MmsConnection.prototype = {
// cache of hosts to be accessed when this connection is alive.
hostsToRoute: null,
// cache of the networkInterface acquired during this connection.
networkInterface: null,
// cache of the networkInfo acquired during this connection.
networkInfo: null,
connectTimer: null,
@ -303,14 +303,14 @@ MmsConnection.prototype = {
// Clear cache.
this.hostsToRoute = [];
this.networkInterface = null;
this.networkInfo = null;
this.radioInterface.deactivateDataCallByType(Ci.nsINetworkInterface.NETWORK_TYPE_MOBILE_MMS);
this.radioInterface.deactivateDataCallByType(Ci.nsINetworkInfo.NETWORK_TYPE_MOBILE_MMS);
};
let promises =
this.hostsToRoute.map((aHost) => {
return gNetworkManager.removeHostRoute(this.networkInterface, aHost);
return gNetworkManager.removeHostRoute(this.networkInfo, aHost);
});
return Promise.all(promises)
@ -442,7 +442,7 @@ MmsConnection.prototype = {
// Bug 1059110: Ensure all the initialization are done before setup data call.
if (DEBUG) debug("acquire: buffer the MMS request and setup the MMS data call.");
this.radioInterface.setupDataCallByType(Ci.nsINetworkInterface.NETWORK_TYPE_MOBILE_MMS);
this.radioInterface.setupDataCallByType(Ci.nsINetworkInfo.NETWORK_TYPE_MOBILE_MMS);
return false;
}
@ -494,7 +494,7 @@ MmsConnection.prototype = {
host = uri.host;
} catch (e) {}
return gNetworkManager.addHostRoute(this.networkInterface, host)
return gNetworkManager.addHostRoute(this.networkInfo, host)
.then(() => {
if (this.hostsToRoute.indexOf(host) < 0) {
this.hostsToRoute.push(host);
@ -517,20 +517,20 @@ MmsConnection.prototype = {
observe: function(subject, topic, data) {
switch (topic) {
case kNetworkConnStateChangedTopic: {
// The network for MMS connection must be nsIRilNetworkInterface.
if (!(subject instanceof Ci.nsIRilNetworkInterface)) {
// The network info for MMS connection must be nsIRilNetworkInfo.
if (!(subject instanceof Ci.nsIRilNetworkInfo)) {
return;
}
// Check if the network state change belongs to this service.
let network = subject.QueryInterface(Ci.nsIRilNetworkInterface);
if (network.serviceId != this.serviceId ||
network.type != Ci.nsINetworkInterface.NETWORK_TYPE_MOBILE_MMS) {
let networkInfo = subject.QueryInterface(Ci.nsIRilNetworkInfo);
if (networkInfo.serviceId != this.serviceId ||
networkInfo.type != Ci.nsINetworkInfo.NETWORK_TYPE_MOBILE_MMS) {
return;
}
let connected =
network.state == Ci.nsINetworkInterface.NETWORK_STATE_CONNECTED;
networkInfo.state == Ci.nsINetworkInfo.NETWORK_STATE_CONNECTED;
// Return if the MMS network state doesn't change, where the network
// state change can come from other non-MMS networks.
@ -541,16 +541,16 @@ MmsConnection.prototype = {
this.connected = connected;
if (!this.connected) {
this.hostsToRoute = [];
this.networkInterface = null;
this.networkInfo = null;
return;
}
// Set up the MMS APN setting based on the connected MMS network,
// which is going to be used for the HTTP requests later.
this.setApnSetting(network);
this.setApnSetting(networkInfo);
// Cache connected network.
this.networkInterface = network;
// Cache connected network info.
this.networkInfo = networkInfo;
if (DEBUG) debug("Got the MMS network connected! Resend the buffered " +
"MMS requests: number: " + this.pendingCallbacks.length);
@ -745,7 +745,7 @@ XPCOMUtils.defineLazyGetter(this, "gMmsTransactionHelper", function() {
// TODO: |getNetId| will be implemented as a sync call in nsINetworkManager
// once Bug 1141903 is landed.
mmsConnection.ensureRouting(url)
.then(() => gNetworkService.getNetId(mmsConnection.networkInterface.name))
.then(() => gNetworkService.getNetId(mmsConnection.networkInfo.name))
.then((netId) => startTransaction(netId))
.catch((aReason) => onRejected(aReason));
});

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

@ -26,8 +26,8 @@ const NET_NETWORKSTATSSERVICE_CID = Components.ID("{18725604-e9ac-488a-8aa0-2471
const TOPIC_BANDWIDTH_CONTROL = "netd-bandwidth-control"
const TOPIC_CONNECTION_STATE_CHANGED = "network-connection-state-changed";
const NET_TYPE_WIFI = Ci.nsINetworkInterface.NETWORK_TYPE_WIFI;
const NET_TYPE_MOBILE = Ci.nsINetworkInterface.NETWORK_TYPE_MOBILE;
const NET_TYPE_WIFI = Ci.nsINetworkInfo.NETWORK_TYPE_WIFI;
const NET_TYPE_MOBILE = Ci.nsINetworkInfo.NETWORK_TYPE_MOBILE;
// Networks have different status that NetworkStats API needs to be aware of.
// Network is present and ready, so NetworkManager provides the whole info.
@ -192,10 +192,10 @@ this.NetworkStatsService = {
// the stats are updated for the new interface without waiting to
// complete the updating period.
let network = aSubject.QueryInterface(Ci.nsINetworkInterface);
debug("Network " + network.name + " of type " + network.type + " status change");
let networkInfo = aSubject.QueryInterface(Ci.nsINetworkInfo);
debug("Network " + networkInfo.name + " of type " + networkInfo.type + " status change");
let netId = this.convertNetworkInterface(network);
let netId = this.convertNetworkInfo(networkInfo);
if (!netId) {
break;
}
@ -269,33 +269,33 @@ this.NetworkStatsService = {
return networks;
},
convertNetworkInterface: function(aNetwork) {
if (aNetwork.type != NET_TYPE_MOBILE &&
aNetwork.type != NET_TYPE_WIFI) {
convertNetworkInfo: function(aNetworkInfo) {
if (aNetworkInfo.type != NET_TYPE_MOBILE &&
aNetworkInfo.type != NET_TYPE_WIFI) {
return null;
}
let id = '0';
if (aNetwork.type == NET_TYPE_MOBILE) {
if (!(aNetwork instanceof Ci.nsIRilNetworkInterface)) {
debug("Error! Mobile network should be an nsIRilNetworkInterface!");
if (aNetworkInfo.type == NET_TYPE_MOBILE) {
if (!(aNetworkInfo instanceof Ci.nsIRilNetworkInfo)) {
debug("Error! Mobile network should be an nsIRilNetworkInfo!");
return null;
}
let rilNetwork = aNetwork.QueryInterface(Ci.nsIRilNetworkInterface);
let rilNetwork = aNetworkInfo.QueryInterface(Ci.nsIRilNetworkInfo);
id = rilNetwork.iccId;
}
let netId = this.getNetworkId(id, aNetwork.type);
let netId = this.getNetworkId(id, aNetworkInfo.type);
if (!this._networks[netId]) {
this._networks[netId] = Object.create(null);
this._networks[netId].network = { id: id,
type: aNetwork.type };
type: aNetworkInfo.type };
}
this._networks[netId].status = NETWORK_STATUS_READY;
this._networks[netId].interfaceName = aNetwork.name;
this._networks[netId].interfaceName = aNetworkInfo.name;
return netId;
},
@ -738,10 +738,10 @@ this.NetworkStatsService = {
/*
* Function responsible for receiving stats which are not from netd.
*/
saveStats: function saveStats(aAppId, aIsInBrowser, aServiceType, aNetwork,
saveStats: function saveStats(aAppId, aIsInBrowser, aServiceType, aNetworkInfo,
aTimeStamp, aRxBytes, aTxBytes, aIsAccumulative,
aCallback) {
let netId = this.convertNetworkInterface(aNetwork);
let netId = this.convertNetworkInfo(aNetworkInfo);
if (!netId) {
if (aCallback) {
aCallback(false, "Invalid network type");

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

@ -29,19 +29,19 @@ NetworkStatsServiceProxy.prototype = {
* Function called in the protocol layer (HTTP, FTP, WebSocket ...etc)
* to pass the per-app stats to NetworkStatsService.
*/
saveAppStats: function saveAppStats(aAppId, aIsInBrowser, aNetwork, aTimeStamp,
saveAppStats: function saveAppStats(aAppId, aIsInBrowser, aNetworkInfo, aTimeStamp,
aRxBytes, aTxBytes, aIsAccumulative,
aCallback) {
if (!aNetwork) {
if (!aNetworkInfo) {
if (DEBUG) {
debug("|aNetwork| is not specified. Failed to save stats. Returning.");
debug("|aNetworkInfo| is not specified. Failed to save stats. Returning.");
}
return;
}
if (DEBUG) {
debug("saveAppStats: " + aAppId + " " + aIsInBrowser + " " +
aNetwork.type + " " + aTimeStamp + " " +
aNetworkInfo.type + " " + aTimeStamp + " " +
aRxBytes + " " + aTxBytes + " " + aIsAccumulative);
}
@ -49,7 +49,7 @@ NetworkStatsServiceProxy.prototype = {
aCallback = aCallback.notify;
}
NetworkStatsService.saveStats(aAppId, aIsInBrowser, "", aNetwork,
NetworkStatsService.saveStats(aAppId, aIsInBrowser, "", aNetworkInfo,
aTimeStamp, aRxBytes, aTxBytes,
aIsAccumulative, aCallback);
},
@ -58,18 +58,18 @@ NetworkStatsServiceProxy.prototype = {
* Function called in the points of different system services
* to pass the per-service stats to NetworkStatsService.
*/
saveServiceStats: function saveServiceStats(aServiceType, aNetwork,
saveServiceStats: function saveServiceStats(aServiceType, aNetworkInfo,
aTimeStamp, aRxBytes, aTxBytes,
aIsAccumulative, aCallback) {
if (!aNetwork) {
if (!aNetworkInfo) {
if (DEBUG) {
debug("|aNetwork| is not specified. Failed to save stats. Returning.");
debug("|aNetworkInfo| is not specified. Failed to save stats. Returning.");
}
return;
}
if (DEBUG) {
debug("saveServiceStats: " + aServiceType + " " + aNetwork.type + " " +
debug("saveServiceStats: " + aServiceType + " " + aNetworkInfo.type + " " +
aTimeStamp + " " + aRxBytes + " " + aTxBytes + " " +
aIsAccumulative);
}
@ -78,7 +78,7 @@ NetworkStatsServiceProxy.prototype = {
aCallback = aCallback.notify;
}
NetworkStatsService.saveStats(0, false, aServiceType ,aNetwork, aTimeStamp,
NetworkStatsService.saveStats(0, false, aServiceType , aNetworkInfo, aTimeStamp,
aRxBytes, aTxBytes, aIsAccumulative,
aCallback);
},

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

@ -185,7 +185,7 @@ TCPSocket.prototype = {
_rxBytes: 0,
_appId: Ci.nsIScriptSecurityManager.NO_APP_ID,
_inBrowser: false,
_activeNetwork: null,
_activeNetworkInfo: null,
#endif
// Public accessors.
@ -374,7 +374,7 @@ TCPSocket.prototype = {
LOG("Error: Ci.nsINetworkStatsServiceProxy service is not available.");
return;
}
nssProxy.saveAppStats(this._appId, this._inBrowser, this._activeNetwork,
nssProxy.saveAppStats(this._appId, this._inBrowser, this._activeNetworkInfo,
Date.now(), this._rxBytes, this._txBytes, false);
// Reset the counters once the statistics is saved to NetworkStatsServiceProxy.
@ -616,12 +616,12 @@ TCPSocket.prototype = {
that._initStream(that._binaryType);
#ifdef MOZ_WIDGET_GONK
// Set _activeNetwork, which is only required for network statistics.
// Set _activeNetworkInfo, which is only required for network statistics.
// Note that nsINetworkManager, as well as nsINetworkStatsServiceProxy, is
// Gonk-specific.
let networkManager = Cc["@mozilla.org/network/manager;1"].getService(Ci.nsINetworkManager);
if (networkManager) {
that._activeNetwork = networkManager.active;
that._activeNetworkInfo = networkManager.activeNetworkInfo;
}
#endif

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

@ -4,7 +4,7 @@
#include "nsISupports.idl"
interface nsINetworkInterface;
interface nsINetworkInfo;
[scriptable, function, uuid(5f821529-1d80-4ab5-a933-4e1b3585b6bc)]
interface nsINetworkStatsServiceProxyCallback : nsISupports
@ -16,7 +16,7 @@ interface nsINetworkStatsServiceProxyCallback : nsISupports
void notify(in boolean aResult, in jsval aMessage);
};
[scriptable, uuid(98fd8f69-784e-4626-aa59-56d6436a3c24)]
[scriptable, uuid(f4f3e901-e102-499d-9d37-dc9951f52df7)]
interface nsINetworkStatsServiceProxy : nsISupports
{
/*
@ -32,7 +32,7 @@ interface nsINetworkStatsServiceProxy : nsISupports
*/
void saveAppStats(in unsigned long aAppId,
in boolean aIsInBrowser,
in nsINetworkInterface aNetwork,
in nsINetworkInfo aNetworkInfo,
in unsigned long long aTimeStamp,
in unsigned long long aRxBytes,
in unsigned long long aTxBytes,
@ -50,7 +50,7 @@ interface nsINetworkStatsServiceProxy : nsISupports
* @param aCallback an optional callback
*/
void saveServiceStats(in string aServiceType,
in nsINetworkInterface aNetwork,
in nsINetworkInfo aNetworkInfo,
in unsigned long long aTimeStamp,
in unsigned long long aRxBytes,
in unsigned long long aTxBytes,

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

@ -936,7 +936,7 @@ add_test(function test_addAlarm() {
netStatsDb.addAlarm(alarms[0], function(error, result) {
do_check_eq(error, null);
alarmsDbId = result;
netStatsDb.getAlarms(Ci.nsINetworkInterface.NETWORK_TYPE_WIFI, exampleManifestURL, function(error, result) {
netStatsDb.getAlarms(Ci.nsINetworkInfo.NETWORK_TYPE_WIFI, exampleManifestURL, function(error, result) {
do_check_eq(error, null);
do_check_eq(result.length, 1);
do_check_eq(result[0].id, alarmsDbId);

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

@ -260,7 +260,7 @@ add_test(function test_fireAlarm() {
NetworkStatsService._networks[wifiId].status = NETWORK_STATUS_STANDBY;
NetworkStatsService._db.addAlarm(alarm, function addSuccessCb(error, newId) {
NetworkStatsService._db.getAlarms(Ci.nsINetworkInterface.NETWORK_TYPE_WIFI,
NetworkStatsService._db.getAlarms(Ci.nsINetworkInfo.NETWORK_TYPE_WIFI,
testManifestURL, function onGet(error, result) {
do_check_eq(error, null);
do_check_eq(result.length, 1);
@ -272,7 +272,7 @@ add_test(function test_fireAlarm() {
result[0].manifestURL = testManifestURL;
NetworkStatsService._fireAlarm(result[0], false);
NetworkStatsService._db.getAlarms(Ci.nsINetworkInterface.NETWORK_TYPE_WIFI,
NetworkStatsService._db.getAlarms(Ci.nsINetworkInfo.NETWORK_TYPE_WIFI,
testManifestURL, function onGet(error, result) {
do_check_eq(error, undefined);
do_check_eq(result.length, 0);

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

@ -9,24 +9,24 @@ XPCOMUtils.defineLazyServiceGetter(this, "nssProxy",
"@mozilla.org/networkstatsServiceProxy;1",
"nsINetworkStatsServiceProxy");
function mokConvertNetworkInterface() {
NetworkStatsService.convertNetworkInterface = function(aNetwork) {
if (aNetwork.type != Ci.nsINetworkInterface.NETWORK_TYPE_MOBILE &&
aNetwork.type != Ci.nsINetworkInterface.NETWORK_TYPE_WIFI) {
function mokConvertNetworkInfo() {
NetworkStatsService.convertNetworkInfo = function(aNetworkInfo) {
if (aNetworkInfo.type != Ci.nsINetworkInfo.NETWORK_TYPE_MOBILE &&
aNetworkInfo.type != Ci.nsINetworkInfo.NETWORK_TYPE_WIFI) {
return null;
}
let id = '0';
if (aNetwork.type == Ci.nsINetworkInterface.NETWORK_TYPE_MOBILE) {
if (aNetworkInfo.type == Ci.nsINetworkInfo.NETWORK_TYPE_MOBILE) {
id = '1234'
}
let netId = this.getNetworkId(id, aNetwork.type);
let netId = this.getNetworkId(id, aNetworkInfo.type);
if (!this._networks[netId]) {
this._networks[netId] = Object.create(null);
this._networks[netId].network = { id: id,
type: aNetwork.type };
type: aNetworkInfo.type };
}
return netId;
@ -37,13 +37,12 @@ add_test(function test_saveAppStats() {
var cachedStats = NetworkStatsService.cachedStats;
var timestamp = NetworkStatsService.cachedStatsDate.getTime();
// Create to fake nsINetworkInterfaces. As nsINetworkInterface can not
// be instantiated, these two vars will emulate it by filling the properties
// that will be used.
var wifi = {type: Ci.nsINetworkInterface.NETWORK_TYPE_WIFI, id: "0"};
var mobile = {type: Ci.nsINetworkInterface.NETWORK_TYPE_MOBILE, id: "1234"};
// Create to fake nsINetworkInfos. As nsINetworkInfo can not be instantiated,
// these two vars will emulate it by filling the properties that will be used.
var wifi = {type: Ci.nsINetworkInfo.NETWORK_TYPE_WIFI, id: "0"};
var mobile = {type: Ci.nsINetworkInfo.NETWORK_TYPE_MOBILE, id: "1234"};
// Insert fake mobile network interface in NetworkStatsService
// Insert fake mobile network info in NetworkStatsService
var mobileNetId = NetworkStatsService.getNetworkId(mobile.id, mobile.type);
do_check_eq(Object.keys(cachedStats).length, 0);
@ -83,13 +82,12 @@ add_test(function test_saveAppStats() {
add_test(function test_saveServiceStats() {
var timestamp = NetworkStatsService.cachedStatsDate.getTime();
// Create to fake nsINetworkInterfaces. As nsINetworkInterface can not
// be instantiated, these two vars will emulate it by filling the properties
// that will be used.
var wifi = {type: Ci.nsINetworkInterface.NETWORK_TYPE_WIFI, id: "0"};
var mobile = {type: Ci.nsINetworkInterface.NETWORK_TYPE_MOBILE, id: "1234"};
// Create to fake nsINetworkInfos. As nsINetworkInfo can not be instantiated,
// these two vars will emulate it by filling the properties that will be used.
var wifi = {type: Ci.nsINetworkInfo.NETWORK_TYPE_WIFI, id: "0"};
var mobile = {type: Ci.nsINetworkInfo.NETWORK_TYPE_MOBILE, id: "1234"};
// Insert fake mobile network interface in NetworkStatsService
// Insert fake mobile network info in NetworkStatsService
var mobileNetId = NetworkStatsService.getNetworkId(mobile.id, mobile.type);
NetworkStatsService.updateCachedStats(function (success, msg) {
@ -138,7 +136,7 @@ add_test(function test_saveStatsWithDifferentDates() {
var today = NetworkStatsService.cachedStatsDate;
var tomorrow = new Date(today.getTime() + (24 * 60 * 60 * 1000));
var mobile = {type: Ci.nsINetworkInterface.NETWORK_TYPE_MOBILE, id: "1234"};
var mobile = {type: Ci.nsINetworkInfo.NETWORK_TYPE_MOBILE, id: "1234"};
NetworkStatsService.updateCachedStats(function (success, message) {
do_check_eq(success, true);
@ -173,7 +171,7 @@ add_test(function test_saveStatsWithDifferentDates() {
add_test(function test_saveStatsWithMaxCachedTraffic() {
var timestamp = NetworkStatsService.cachedStatsDate.getTime();
var maxtraffic = NetworkStatsService.maxCachedTraffic;
var wifi = {type: Ci.nsINetworkInterface.NETWORK_TYPE_WIFI, id: "0"};
var wifi = {type: Ci.nsINetworkInfo.NETWORK_TYPE_WIFI, id: "0"};
NetworkStatsService.updateCachedStats(function (success, message) {
do_check_eq(success, true);
@ -199,11 +197,11 @@ add_test(function test_saveAppStats() {
var cachedStats = NetworkStatsService.cachedStats;
var timestamp = NetworkStatsService.cachedStatsDate.getTime();
// Create to fake nsINetworkInterfaces. As nsINetworkInterface can not
// Create to fake nsINetworkInfo. As nsINetworkInfo can not
// be instantiated, these two vars will emulate it by filling the properties
// that will be used.
var wifi = {type: Ci.nsINetworkInterface.NETWORK_TYPE_WIFI, id: "0"};
var mobile = {type: Ci.nsINetworkInterface.NETWORK_TYPE_MOBILE, id: "1234"};
var wifi = {type: Ci.nsINetworkInfo.NETWORK_TYPE_WIFI, id: "0"};
var mobile = {type: Ci.nsINetworkInfo.NETWORK_TYPE_MOBILE, id: "1234"};
// Insert fake mobile network interface in NetworkStatsService
var mobileNetId = NetworkStatsService.getNetworkId(mobile.id, mobile.type);
@ -232,9 +230,9 @@ function run_test() {
Cu.import("resource://gre/modules/NetworkStatsService.jsm");
// Function convertNetworkInterface of NetworkStatsService causes errors when dealing
// Function convertNetworkInfo of NetworkStatsService causes errors when dealing
// with RIL to get the iccid, so overwrite it.
mokConvertNetworkInterface();
mokConvertNetworkInfo();
run_next_test();
}

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

@ -1256,8 +1256,8 @@ let PushNetworkInfo = {
let nm = Cc["@mozilla.org/network/manager;1"]
.getService(Ci.nsINetworkManager);
if (nm.active &&
nm.active.type == Ci.nsINetworkInterface.NETWORK_TYPE_MOBILE) {
if (nm.activeNetworkInfo &&
nm.activeNetworkInfo.type == Ci.nsINetworkInfo.NETWORK_TYPE_MOBILE) {
let iccService = Cc["@mozilla.org/icc/iccservice;1"]
.getService(Ci.nsIIccService);
// TODO: Bug 927721 - PushService for multi-sim
@ -1273,7 +1273,7 @@ let PushNetworkInfo = {
let ips = {};
let prefixLengths = {};
nm.active.getAddresses(ips, prefixLengths);
nm.activeNetworkInfo.getAddresses(ips, prefixLengths);
return {
mcc: iccInfo.mcc,

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

@ -1774,7 +1774,8 @@ this.PushService = {
}
let nm = Cc["@mozilla.org/network/manager;1"].getService(Ci.nsINetworkManager);
if (nm.active && nm.active.type == Ci.nsINetworkInterface.NETWORK_TYPE_MOBILE) {
if (nm.activeNetworkInfo &&
nm.activeNetworkInfo.type == Ci.nsINetworkInfo.NETWORK_TYPE_MOBILE) {
let iccService = Cc["@mozilla.org/icc/iccservice;1"].getService(Ci.nsIIccService);
// TODO: Bug 927721 - PushService for multi-sim
// In Multi-sim, there is more than one client in iccService. Each
@ -1789,7 +1790,7 @@ this.PushService = {
let ips = {};
let prefixLengths = {};
nm.active.getAddresses(ips, prefixLengths);
nm.activeNetworkInfo.getAddresses(ips, prefixLengths);
return {
mcc: iccInfo.mcc,

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

@ -53,7 +53,9 @@ const DATACALLMANAGER_CID =
const DATACALLHANDLER_CID =
Components.ID("{132b650f-c4d8-4731-96c5-83785cb31dee}");
const RILNETWORKINTERFACE_CID =
Components.ID("{8c11bef9-9b4f-4d96-bed7-f5a1f48eabda}");
Components.ID("{9574ee84-5d0d-4814-b9e6-8b279e03dcf4}");
const RILNETWORKINFO_CID =
Components.ID("{dd6cf2f0-f0e3-449f-a69e-7c34fdcb8d4b}");
const TOPIC_XPCOM_SHUTDOWN = "xpcom-shutdown";
const TOPIC_MOZSETTINGS_CHANGED = "mozsettings-changed";
@ -61,20 +63,20 @@ const TOPIC_PREF_CHANGED = "nsPref:changed";
const TOPIC_DATA_CALL_ERROR = "data-call-error";
const PREF_RIL_DEBUG_ENABLED = "ril.debugging.enabled";
const NETWORK_TYPE_UNKNOWN = Ci.nsINetworkInterface.NETWORK_TYPE_UNKNOWN;
const NETWORK_TYPE_WIFI = Ci.nsINetworkInterface.NETWORK_TYPE_WIFI;
const NETWORK_TYPE_MOBILE = Ci.nsINetworkInterface.NETWORK_TYPE_MOBILE;
const NETWORK_TYPE_MOBILE_MMS = Ci.nsINetworkInterface.NETWORK_TYPE_MOBILE_MMS;
const NETWORK_TYPE_MOBILE_SUPL = Ci.nsINetworkInterface.NETWORK_TYPE_MOBILE_SUPL;
const NETWORK_TYPE_MOBILE_IMS = Ci.nsINetworkInterface.NETWORK_TYPE_MOBILE_IMS;
const NETWORK_TYPE_MOBILE_DUN = Ci.nsINetworkInterface.NETWORK_TYPE_MOBILE_DUN;
const NETWORK_TYPE_MOBILE_FOTA = Ci.nsINetworkInterface.NETWORK_TYPE_MOBILE_FOTA;
const NETWORK_TYPE_UNKNOWN = Ci.nsINetworkInfo.NETWORK_TYPE_UNKNOWN;
const NETWORK_TYPE_WIFI = Ci.nsINetworkInfo.NETWORK_TYPE_WIFI;
const NETWORK_TYPE_MOBILE = Ci.nsINetworkInfo.NETWORK_TYPE_MOBILE;
const NETWORK_TYPE_MOBILE_MMS = Ci.nsINetworkInfo.NETWORK_TYPE_MOBILE_MMS;
const NETWORK_TYPE_MOBILE_SUPL = Ci.nsINetworkInfo.NETWORK_TYPE_MOBILE_SUPL;
const NETWORK_TYPE_MOBILE_IMS = Ci.nsINetworkInfo.NETWORK_TYPE_MOBILE_IMS;
const NETWORK_TYPE_MOBILE_DUN = Ci.nsINetworkInfo.NETWORK_TYPE_MOBILE_DUN;
const NETWORK_TYPE_MOBILE_FOTA = Ci.nsINetworkInfo.NETWORK_TYPE_MOBILE_FOTA;
const NETWORK_STATE_UNKNOWN = Ci.nsINetworkInterface.NETWORK_STATE_UNKNOWN;
const NETWORK_STATE_CONNECTING = Ci.nsINetworkInterface.NETWORK_STATE_CONNECTING;
const NETWORK_STATE_CONNECTED = Ci.nsINetworkInterface.NETWORK_STATE_CONNECTED;
const NETWORK_STATE_DISCONNECTING = Ci.nsINetworkInterface.NETWORK_STATE_DISCONNECTING;
const NETWORK_STATE_DISCONNECTED = Ci.nsINetworkInterface.NETWORK_STATE_DISCONNECTED;
const NETWORK_STATE_UNKNOWN = Ci.nsINetworkInfo.NETWORK_STATE_UNKNOWN;
const NETWORK_STATE_CONNECTING = Ci.nsINetworkInfo.NETWORK_STATE_CONNECTING;
const NETWORK_STATE_CONNECTED = Ci.nsINetworkInfo.NETWORK_STATE_CONNECTED;
const NETWORK_STATE_DISCONNECTING = Ci.nsINetworkInfo.NETWORK_STATE_DISCONNECTING;
const NETWORK_STATE_DISCONNECTED = Ci.nsINetworkInfo.NETWORK_STATE_DISCONNECTED;
const INT32_MAX = 2147483647;
@ -415,7 +417,7 @@ DataCallHandler.prototype = {
this._dataCalls = [];
this.clientId = null;
this.dataCallinterface.unregisterListener(this);
this.dataCallInterface.unregisterListener(this);
this.dataCallInterface = null;
let mobileConnection =
@ -625,8 +627,8 @@ DataCallHandler.prototype = {
return;
}
let wifi_active = false;
if (gNetworkManager.active &&
gNetworkManager.active.type == NETWORK_TYPE_WIFI) {
if (gNetworkManager.activeNetworkInfo &&
gNetworkManager.activeNetworkInfo.type == NETWORK_TYPE_WIFI) {
wifi_active = true;
}
@ -709,7 +711,7 @@ DataCallHandler.prototype = {
if (!networkInterface) {
return NETWORK_STATE_UNKNOWN;
}
return networkInterface.state;
return networkInterface.info.state;
},
setupDataCallByType: function(aNetworkType) {
@ -760,8 +762,8 @@ DataCallHandler.prototype = {
let dataDisconnecting = false;
this.dataNetworkInterfaces.forEach(function(networkInterface) {
if (networkInterface.enabled) {
if (networkInterface.state != NETWORK_STATE_UNKNOWN &&
networkInterface.state != NETWORK_STATE_DISCONNECTED) {
if (networkInterface.info.state != NETWORK_STATE_UNKNOWN &&
networkInterface.info.state != NETWORK_STATE_DISCONNECTED) {
dataDisconnecting = true;
}
networkInterface.disconnect();
@ -836,23 +838,14 @@ DataCallHandler.prototype = {
/**
* Notify about data call setup error, called from DataCall.
*/
notifyDataCallError: function(aMessage) {
notifyDataCallError: function(aDataCall, aErrorMsg) {
// Notify data call error only for data APN
let networkInterface = this.dataNetworkInterfaces.get(NETWORK_TYPE_MOBILE);
if (networkInterface && networkInterface.enabled) {
let dataCall = networkInterface.dataCall;
// If there is a cid, compare cid; otherwise it is probably an error on
// data call setup.
if (aMessage.cid !== undefined) {
if (aMessage.linkInfo.cid == dataCall.linkInfo.cid) {
Services.obs.notifyObservers(networkInterface, TOPIC_DATA_CALL_ERROR,
null);
}
} else {
if (this._compareDataCallOptions(dataCall, aMessage)) {
Services.obs.notifyObservers(networkInterface, TOPIC_DATA_CALL_ERROR,
null);
}
if (this._compareDataCallOptions(dataCall, aDataCall)) {
Services.obs.notifyObservers(networkInterface.info,
TOPIC_DATA_CALL_ERROR, aErrorMsg);
}
}
},
@ -1065,7 +1058,7 @@ DataCall.prototype = {
}
// Let DataCallHandler notify MobileConnectionService
this.dataCallHandler.notifyDataCallError(this);
this.dataCallHandler.notifyDataCallError(this, errorMsg);
// For suggestedRetryTime, the value of INT32_MAX(0x7fffffff) means no retry.
if (aDataCall.suggestedRetryTime === INT32_MAX ||
@ -1242,7 +1235,7 @@ DataCall.prototype = {
inRequestedTypes: function(aType) {
for (let i = 0; i < this.requestedNetworkIfaces.length; i++) {
if (this.requestedNetworkIfaces[i].type == aType) {
if (this.requestedNetworkIfaces[i].info.type == aType) {
return true;
}
}
@ -1279,7 +1272,7 @@ DataCall.prototype = {
},
connect: function(aNetworkInterface) {
if (DEBUG) this.debug("connect: " + aNetworkInterface.type);
if (DEBUG) this.debug("connect: " + aNetworkInterface.info.type);
if (this.requestedNetworkIfaces.indexOf(aNetworkInterface) == -1) {
this.requestedNetworkIfaces.push(aNetworkInterface);
@ -1295,7 +1288,7 @@ DataCall.prototype = {
Services.tm.currentThread.dispatch(() => {
// Do not notify if state changed while this event was being dispatched,
// the state probably was notified already or need not to be notified.
if (aNetworkInterface.state == RIL.GECKO_NETWORK_STATE_CONNECTED) {
if (aNetworkInterface.info.state == RIL.GECKO_NETWORK_STATE_CONNECTED) {
aNetworkInterface.notifyRILNetworkInterface();
}
}, Ci.nsIEventTarget.DISPATCH_NORMAL);
@ -1405,7 +1398,7 @@ DataCall.prototype = {
},
disconnect: function(aNetworkInterface) {
if (DEBUG) this.debug("disconnect: " + aNetworkInterface.type);
if (DEBUG) this.debug("disconnect: " + aNetworkInterface.info.type);
let index = this.requestedNetworkIfaces.indexOf(aNetworkInterface);
if (index != -1) {
@ -1426,7 +1419,7 @@ DataCall.prototype = {
Services.tm.currentThread.dispatch(() => {
// Do not notify if state changed while this event was being dispatched,
// the state probably was notified already or need not to be notified.
if (aNetworkInterface.state == RIL.GECKO_NETWORK_STATE_DISCONNECTED) {
if (aNetworkInterface.info.state == RIL.GECKO_NETWORK_STATE_DISCONNECTED) {
aNetworkInterface.notifyRILNetworkInterface();
// Clear link info after notifying NetworkManager.
@ -1449,7 +1442,7 @@ DataCall.prototype = {
},
deactivate: function() {
let reason = Ci.nsINetworkInterface.DATACALL_DEACTIVATE_NO_REASON;
let reason = Ci.nsIDataCallInterface.DATACALL_DEACTIVATE_NO_REASON;
if (DEBUG) {
this.debug("Going to disconnect data connection cid " + this.linkInfo.cid);
}
@ -1481,61 +1474,56 @@ DataCall.prototype = {
}
};
function RILNetworkInterface(aDataCallHandler, aType, aApnSetting, aDataCall) {
if (!aDataCall) {
throw new Error("No dataCall for RILNetworkInterface: " + type);
}
this.dataCallHandler = aDataCallHandler;
function RILNetworkInfo(aClientId, aType, aNetworkInterface)
{
this.serviceId = aClientId;
this.type = aType;
this.apnSetting = aApnSetting;
this.dataCall = aDataCall;
this.enabled = false;
this.networkInterface = aNetworkInterface;
}
RILNetworkInfo.prototype = {
classID: RILNETWORKINFO_CID,
classInfo: XPCOMUtils.generateCI({classID: RILNETWORKINFO_CID,
classDescription: "RILNetworkInfo",
interfaces: [Ci.nsINetworkInfo,
Ci.nsIRilNetworkInfo]}),
QueryInterface: XPCOMUtils.generateQI([Ci.nsINetworkInfo,
Ci.nsIRilNetworkInfo]),
RILNetworkInterface.prototype = {
classID: RILNETWORKINTERFACE_CID,
classInfo: XPCOMUtils.generateCI({classID: RILNETWORKINTERFACE_CID,
classDescription: "RILNetworkInterface",
interfaces: [Ci.nsINetworkInterface,
Ci.nsIRilNetworkInterface]}),
QueryInterface: XPCOMUtils.generateQI([Ci.nsINetworkInterface,
Ci.nsIRilNetworkInterface]),
networkInterface: null,
// Hold reference to DataCall object which is determined at initilization.
dataCall: null,
getDataCall: function() {
return this.networkInterface.dataCall;
},
// If this RILNetworkInterface type is enabled or not.
enabled: null,
getApnSetting: function() {
return this.networkInterface.apnSetting;
},
debug: function(aMsg) {
dump("-*- RILNetworkInfo[" + this.serviceId + ":" + this.type + "]: " +
aMsg + "\n");
},
/**
* nsINetworkInterface Implementation
* nsINetworkInfo Implementation
*/
get state() {
if (!this.dataCall.inRequestedTypes(this.type)) {
let dataCall = this.getDataCall();
if (!dataCall.inRequestedTypes(this.type)) {
return NETWORK_STATE_DISCONNECTED;
}
return this.dataCall.state;
return dataCall.state;
},
type: null,
get name() {
return this.dataCall.linkInfo.ifname;
},
get httpProxyHost() {
return this.apnSetting.proxy || "";
},
get httpProxyPort() {
return this.apnSetting.port || "";
return this.getDataCall().linkInfo.ifname;
},
getAddresses: function(aIps, aPrefixLengths) {
let addresses = this.dataCall.linkInfo.addresses;
let addresses = this.getDataCall().linkInfo.addresses;
let ips = [];
let prefixLengths = [];
@ -1552,33 +1540,33 @@ RILNetworkInterface.prototype = {
},
getGateways: function(aCount) {
let linkInfo = this.dataCall.linkInfo;
let linkInfo = this.getDataCall().linkInfo;
if (aCount) {
aCount.value = linkInfo.gateways.length;
}
return linkInfo.gateways.slice();
},
getDnses: function(aCount) {
let linkInfo = this.dataCall.linkInfo;
let linkInfo = this.getDataCall().linkInfo;
if (aCount) {
aCount.value = linkInfo.dnses.length;
}
return linkInfo.dnses.slice();
},
/**
* nsIRilNetworkInterface Implementation
* nsIRilNetworkInfo Implementation
*/
get serviceId() {
return this.dataCallHandler.clientId;
},
serviceId: 0,
get iccId() {
let icc = gIccService.getIccByServiceId(this.dataCallHandler.clientId);
let icc = gIccService.getIccByServiceId(this.serviceId);
let iccInfo = icc && icc.iccInfo;
return iccInfo && iccInfo.iccid;
@ -1590,7 +1578,7 @@ RILNetworkInterface.prototype = {
throw Cr.NS_ERROR_UNEXPECTED;
}
return this.apnSetting.mmsc || "";
return this.getApnSetting().mmsc || "";
},
get mmsProxy() {
@ -1599,7 +1587,7 @@ RILNetworkInterface.prototype = {
throw Cr.NS_ERROR_UNEXPECTED;
}
return this.apnSetting.mmsproxy || "";
return this.getApnSetting().mmsproxy || "";
},
get mmsPort() {
@ -1610,26 +1598,66 @@ RILNetworkInterface.prototype = {
// Note: Port 0 is reserved, so we treat it as invalid as well.
// See http://www.iana.org/assignments/port-numbers
return this.apnSetting.mmsport || -1;
return this.getApnSetting().mmsport || -1;
},
};
function RILNetworkInterface(aDataCallHandler, aType, aApnSetting, aDataCall) {
if (!aDataCall) {
throw new Error("No dataCall for RILNetworkInterface: " + type);
}
this.dataCallHandler = aDataCallHandler;
this.enabled = false;
this.dataCall = aDataCall;
this.apnSetting = aApnSetting;
this.info = new RILNetworkInfo(aDataCallHandler.clientId, aType, this);
}
RILNetworkInterface.prototype = {
classID: RILNETWORKINTERFACE_CID,
classInfo: XPCOMUtils.generateCI({classID: RILNETWORKINTERFACE_CID,
classDescription: "RILNetworkInterface",
interfaces: [Ci.nsINetworkInterface]}),
QueryInterface: XPCOMUtils.generateQI([Ci.nsINetworkInterface]),
// If this RILNetworkInterface type is enabled or not.
enabled: null,
apnSetting: null,
dataCall: null,
/**
* nsINetworkInterface Implementation
*/
info: null,
get httpProxyHost() {
return this.apnSetting.proxy || "";
},
get httpProxyPort() {
return this.apnSetting.port || "";
},
// Helpers
debug: function(aMsg) {
dump("-*- RILNetworkInterface[" + this.dataCallHandler.clientId + ":" +
this.type + "]: " + aMsg + "\n");
this.info.type + "]: " + aMsg + "\n");
},
apnSetting: null,
get connected() {
return this.state == NETWORK_STATE_CONNECTED;
return this.info.state == NETWORK_STATE_CONNECTED;
},
notifyRILNetworkInterface: function() {
if (DEBUG) {
this.debug("notifyRILNetworkInterface type: " + this.type + ", state: " +
this.state);
this.debug("notifyRILNetworkInterface type: " + this.info.type +
", state: " + this.info.state);
}
gNetworkManager.updateNetworkInterface(this);

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

@ -25,7 +25,7 @@
#include "nsContentUtils.h"
#include "nsGeoPosition.h"
#include "nsIInterfaceRequestorUtils.h"
#include "nsINetworkManager.h"
#include "nsINetworkInterface.h"
#include "nsIObserverService.h"
#include "nsJSUtils.h"
#include "nsPrintfCString.h"
@ -359,12 +359,12 @@ int32_t
GonkGPSGeolocationProvider::GetDataConnectionState()
{
if (!mRadioInterface) {
return nsINetworkInterface::NETWORK_STATE_UNKNOWN;
return nsINetworkInfo::NETWORK_STATE_UNKNOWN;
}
int32_t state;
mRadioInterface->GetDataCallStateByType(
nsINetworkInterface::NETWORK_TYPE_MOBILE_SUPL, &state);
nsINetworkInfo::NETWORK_TYPE_MOBILE_SUPL, &state);
return state;
}
@ -383,7 +383,7 @@ GonkGPSGeolocationProvider::SetAGpsDataConn(nsAString& aApn)
int32_t connectionState = GetDataConnectionState();
NS_ConvertUTF16toUTF8 apn(aApn);
if (connectionState == nsINetworkInterface::NETWORK_STATE_CONNECTED) {
if (connectionState == nsINetworkInfo::NETWORK_STATE_CONNECTED) {
// The definition of availability is
// 1. The device is connected to the home network
// 2. The device is connected to a foreign network and data
@ -400,7 +400,7 @@ GonkGPSGeolocationProvider::SetAGpsDataConn(nsAString& aApn)
#else
mAGpsInterface->data_conn_open(apn.get());
#endif
} else if (connectionState == nsINetworkInterface::NETWORK_STATE_DISCONNECTED) {
} else if (connectionState == nsINetworkInfo::NETWORK_STATE_DISCONNECTED) {
if (hasUpdateNetworkAvailability) {
mAGpsRilInterface->update_network_availability(false, apn.get());
}
@ -450,12 +450,12 @@ GonkGPSGeolocationProvider::RequestDataConnection()
return;
}
if (GetDataConnectionState() == nsINetworkInterface::NETWORK_STATE_CONNECTED) {
if (GetDataConnectionState() == nsINetworkInfo::NETWORK_STATE_CONNECTED) {
// Connection is already established, we don't need to setup again.
// We just get supl APN and make AGPS data connection state updated.
RequestSettingValue("ril.supl.apn");
} else {
mRadioInterface->SetupDataCallByType(nsINetworkInterface::NETWORK_TYPE_MOBILE_SUPL);
mRadioInterface->SetupDataCallByType(nsINetworkInfo::NETWORK_TYPE_MOBILE_SUPL);
}
}
@ -468,7 +468,7 @@ GonkGPSGeolocationProvider::ReleaseDataConnection()
return;
}
mRadioInterface->DeactivateDataCallByType(nsINetworkInterface::NETWORK_TYPE_MOBILE_SUPL);
mRadioInterface->DeactivateDataCallByType(nsINetworkInfo::NETWORK_TYPE_MOBILE_SUPL);
}
void
@ -1010,15 +1010,15 @@ int
ConvertToGpsNetworkType(int aNetworkInterfaceType)
{
switch (aNetworkInterfaceType) {
case nsINetworkInterface::NETWORK_TYPE_WIFI:
case nsINetworkInfo::NETWORK_TYPE_WIFI:
return AGPS_RIL_NETWORK_TYPE_WIFI;
case nsINetworkInterface::NETWORK_TYPE_MOBILE:
case nsINetworkInfo::NETWORK_TYPE_MOBILE:
return AGPS_RIL_NETWORK_TYPE_MOBILE;
case nsINetworkInterface::NETWORK_TYPE_MOBILE_MMS:
case nsINetworkInfo::NETWORK_TYPE_MOBILE_MMS:
return AGPS_RIL_NETWORK_TYPE_MOBILE_MMS;
case nsINetworkInterface::NETWORK_TYPE_MOBILE_SUPL:
case nsINetworkInfo::NETWORK_TYPE_MOBILE_SUPL:
return AGPS_RIL_NETWORK_TYPE_MOBILE_SUPL;
case nsINetworkInterface::NETWORK_TYPE_MOBILE_DUN:
case nsINetworkInfo::NETWORK_TYPE_MOBILE_DUN:
return AGPS_RIL_NETWORK_TTYPE_MOBILE_DUN;
default:
NS_WARNING(nsPrintfCString("Unknown network type mapping %d",
@ -1037,21 +1037,21 @@ GonkGPSGeolocationProvider::Observe(nsISupports* aSubject,
#ifdef MOZ_B2G_RIL
if (!strcmp(aTopic, kNetworkConnStateChangedTopic)) {
nsCOMPtr<nsINetworkInterface> iface = do_QueryInterface(aSubject);
if (!iface) {
nsCOMPtr<nsINetworkInfo> info = do_QueryInterface(aSubject);
if (!info) {
return NS_OK;
}
nsCOMPtr<nsIRilNetworkInterface> rilface = do_QueryInterface(aSubject);
nsCOMPtr<nsIRilNetworkInfo> rilInfo = do_QueryInterface(aSubject);
if (mAGpsRilInterface && mAGpsRilInterface->update_network_state) {
int32_t state;
int32_t type;
iface->GetState(&state);
iface->GetType(&type);
bool connected = (state == nsINetworkInterface::NETWORK_STATE_CONNECTED);
info->GetState(&state);
info->GetType(&type);
bool connected = (state == nsINetworkInfo::NETWORK_STATE_CONNECTED);
bool roaming = false;
int gpsNetworkType = ConvertToGpsNetworkType(type);
if (gpsNetworkType >= 0) {
if (rilface) {
if (rilInfo) {
do {
nsCOMPtr<nsIMobileConnectionService> service =
do_GetService(NS_MOBILE_CONNECTION_SERVICE_CONTRACTID);
@ -1080,7 +1080,7 @@ GonkGPSGeolocationProvider::Observe(nsISupports* aSubject,
}
}
// No data connection
if (!rilface) {
if (!rilInfo) {
return NS_OK;
}

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

@ -50,7 +50,7 @@ NetworkInterfaceListService.prototype = {
}
};
function FakeNetworkInterface(aAttributes) {
function FakeNetworkInfo(aAttributes) {
this.state = aAttributes.state;
this.type = aAttributes.type;
this.name = aAttributes.name;
@ -58,11 +58,9 @@ function FakeNetworkInterface(aAttributes) {
this.prefixLengths = aAttributes.prefixLengths;
this.gateways = aAttributes.gateways;
this.dnses = aAttributes.dnses;
this.httpProxyHost = aAttributes.httpProxyHost;
this.httpProxyPort = aAttributes.httpProxyPort;
}
FakeNetworkInterface.prototype = {
QueryInterface: XPCOMUtils.generateQI([Ci.nsINetworkInterface]),
FakeNetworkInfo.prototype = {
QueryInterface: XPCOMUtils.generateQI([Ci.nsINetworkInfo]),
getAddresses: function (ips, prefixLengths) {
ips.value = this.ips.slice();
@ -89,7 +87,7 @@ FakeNetworkInterface.prototype = {
function NetworkInterfaceList (aInterfaceLiterals) {
this._interfaces = [];
for (let entry of aInterfaceLiterals) {
this._interfaces.push(new FakeNetworkInterface(entry));
this._interfaces.push(new FakeNetworkInfo(entry));
}
}
@ -100,7 +98,7 @@ NetworkInterfaceList.prototype = {
return this._interfaces.length;
},
getInterface: function(index) {
getInterfaceInfo: function(index) {
if (!this._interfaces) {
return null;
}

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

@ -16,7 +16,7 @@ const NETWORKMANAGER_CONTRACTID = "@mozilla.org/network/manager;1";
const NETWORKMANAGER_CID =
Components.ID("{33901e46-33b8-11e1-9869-f46d04d25bcc}");
const DEFAULT_PREFERRED_NETWORK_TYPE = Ci.nsINetworkInterface.NETWORK_TYPE_WIFI;
const DEFAULT_PREFERRED_NETWORK_TYPE = Ci.nsINetworkInfo.NETWORK_TYPE_WIFI;
XPCOMUtils.defineLazyGetter(this, "ppmm", function() {
return Cc["@mozilla.org/parentprocessmessagemanager;1"]
@ -85,24 +85,22 @@ function defineLazyRegExp(obj, name, pattern) {
});
}
function NetworkInterface(aNetwork) {
function ExtraNetworkInfo(aNetwork) {
let ips = {};
let prefixLengths = {};
aNetwork.getAddresses(ips, prefixLengths);
aNetwork.info.getAddresses(ips, prefixLengths);
this.state = aNetwork.state;
this.type = aNetwork.type;
this.name = aNetwork.name;
this.state = aNetwork.info.state;
this.type = aNetwork.info.type;
this.name = aNetwork.info.name;
this.ips = ips.value;
this.prefixLengths = prefixLengths.value;
this.gateways = aNetwork.getGateways();
this.dnses = aNetwork.getDnses();
this.gateways = aNetwork.info.getGateways();
this.dnses = aNetwork.info.getDnses();
this.httpProxyHost = aNetwork.httpProxyHost;
this.httpProxyPort = aNetwork.httpProxyPort;
}
NetworkInterface.prototype = {
QueryInterface: XPCOMUtils.generateQI([Ci.nsINetworkInterface]),
ExtraNetworkInfo.prototype = {
getAddresses: function(aIps, aPrefixLengths) {
aIps.value = this.ips.slice();
aPrefixLengths.value = this.prefixLengths.slice();
@ -114,6 +112,7 @@ NetworkInterface.prototype = {
if (aCount) {
aCount.value = this.gateways.length;
}
return this.gateways.slice();
},
@ -121,6 +120,7 @@ NetworkInterface.prototype = {
if (aCount) {
aCount.value = this.dnses.length;
}
return this.dnses.slice();
}
};
@ -231,12 +231,13 @@ NetworkManager.prototype = {
let excludeFota = aMsg.json.excludeFota;
let interfaces = [];
for each (let i in this.networkInterfaces) {
if ((i.type == Ci.nsINetworkInterface.NETWORK_TYPE_MOBILE_MMS && excludeMms) ||
(i.type == Ci.nsINetworkInterface.NETWORK_TYPE_MOBILE_SUPL && excludeSupl) ||
(i.type == Ci.nsINetworkInterface.NETWORK_TYPE_MOBILE_IMS && excludeIms) ||
(i.type == Ci.nsINetworkInterface.NETWORK_TYPE_MOBILE_DUN && excludeDun) ||
(i.type == Ci.nsINetworkInterface.NETWORK_TYPE_MOBILE_FOTA && excludeFota)) {
for each (let network in this.networkInterfaces) {
let i = network.info;
if ((i.type == Ci.nsINetworkInfo.NETWORK_TYPE_MOBILE_MMS && excludeMms) ||
(i.type == Ci.nsINetworkInfo.NETWORK_TYPE_MOBILE_SUPL && excludeSupl) ||
(i.type == Ci.nsINetworkInfo.NETWORK_TYPE_MOBILE_IMS && excludeIms) ||
(i.type == Ci.nsINetworkInfo.NETWORK_TYPE_MOBILE_DUN && excludeDun) ||
(i.type == Ci.nsINetworkInfo.NETWORK_TYPE_MOBILE_FOTA && excludeFota)) {
continue;
}
@ -251,9 +252,7 @@ NetworkManager.prototype = {
ips: ips.value,
prefixLengths: prefixLengths.value,
gateways: i.getGateways(),
dnses: i.getDnses(),
httpProxyHost: i.httpProxyHost,
httpProxyPort: i.httpProxyPort
dnses: i.getDnses()
});
}
return interfaces;
@ -261,16 +260,16 @@ NetworkManager.prototype = {
}
},
getNetworkId: function(network) {
getNetworkId: function(aNetworkInfo) {
let id = "device";
try {
if (network instanceof Ci.nsIRilNetworkInterface) {
let rilNetwork = network.QueryInterface(Ci.nsIRilNetworkInterface);
id = "ril" + rilNetwork.serviceId;
if (aNetworkInfo instanceof Ci.nsIRilNetworkInfo) {
let rilInfo = aNetworkInfo.QueryInterface(Ci.nsIRilNetworkInfo);
id = "ril" + rilInfo.serviceId;
}
} catch (e) {}
return id + "-" + network.type;
return id + "-" + aNetworkInfo.type;
},
// nsINetworkManager
@ -280,7 +279,7 @@ NetworkManager.prototype = {
throw Components.Exception("Argument must be nsINetworkInterface.",
Cr.NS_ERROR_INVALID_ARG);
}
let networkId = this.getNetworkId(network);
let networkId = this.getNetworkId(network.info);
if (networkId in this.networkInterfaces) {
throw Components.Exception("Network with that type already registered!",
Cr.NS_ERROR_INVALID_ARG);
@ -288,7 +287,7 @@ NetworkManager.prototype = {
this.networkInterfaces[networkId] = network;
this.networkInterfaceLinks[networkId] = new NetworkInterfaceLinks();
Services.obs.notifyObservers(network, TOPIC_INTERFACE_REGISTERED, null);
Services.obs.notifyObservers(network.info, TOPIC_INTERFACE_REGISTERED, null);
debug("Network '" + networkId + "' registered.");
},
@ -316,65 +315,65 @@ NetworkManager.prototype = {
throw Components.Exception("Argument must be nsINetworkInterface.",
Cr.NS_ERROR_INVALID_ARG);
}
let networkId = this.getNetworkId(network);
let networkId = this.getNetworkId(network.info);
if (!(networkId in this.networkInterfaces)) {
throw Components.Exception("No network with that type registered.",
Cr.NS_ERROR_INVALID_ARG);
}
debug("Network " + network.type + "/" + network.name +
" changed state to " + network.state);
debug("Network " + network.info.type + "/" + network.info.name +
" changed state to " + network.info.state);
// Keep a copy of network in case it is modified while we are updating.
let networkInterface = new NetworkInterface(network);
let extNetworkInfo = new ExtraNetworkInfo(network);
// Note that since Lollipop we need to allocate and initialize
// something through netd, so we add createNetwork/destroyNetwork
// to deal with that explicitly.
switch (networkInterface.state) {
case Ci.nsINetworkInterface.NETWORK_STATE_CONNECTED:
switch (extNetworkInfo.state) {
case Ci.nsINetworkInfo.NETWORK_STATE_CONNECTED:
this._createNetwork(networkInterface.name)
this._createNetwork(extNetworkInfo.name)
// Remove pre-created default route and let setAndConfigureActive()
// to set default route only on preferred network
.then(() => this._removeDefaultRoute(networkInterface))
.then(() => this._removeDefaultRoute(extNetworkInfo))
// Set DNS server as early as possible to prevent from
// premature domain name lookup.
.then(() => this._setDNS(networkInterface))
.then(() => this._setDNS(extNetworkInfo))
.then(() => {
// Add host route for data calls
if (!this.isNetworkTypeMobile(networkInterface.type)) {
if (!this.isNetworkTypeMobile(extNetworkInfo.type)) {
return;
}
let currentInterfaceLinks = this.networkInterfaceLinks[networkId];
let newLinkRoutes = networkInterface.getDnses().concat(
networkInterface.httpProxyHost);
let newLinkRoutes = extNetworkInfo.getDnses().concat(
extNetworkInfo.httpProxyHost);
// If gateways have changed, remove all old routes first.
return this._handleGateways(networkId, networkInterface.getGateways())
return this._handleGateways(networkId, extNetworkInfo.getGateways())
.then(() => this._updateRoutes(currentInterfaceLinks.linkRoutes,
newLinkRoutes,
networkInterface.getGateways(),
networkInterface.name))
extNetworkInfo.getGateways(),
extNetworkInfo.name))
.then(() => currentInterfaceLinks.setLinks(newLinkRoutes,
networkInterface.getGateways(),
networkInterface.name));
extNetworkInfo.getGateways(),
extNetworkInfo.name));
})
.then(() => {
if (networkInterface.type !=
Ci.nsINetworkInterface.NETWORK_TYPE_MOBILE_DUN) {
if (extNetworkInfo.type !=
Ci.nsINetworkInfo.NETWORK_TYPE_MOBILE_DUN) {
return;
}
// Dun type is a special case where we add the default route to a
// secondary table.
return this.setSecondaryDefaultRoute(networkInterface);
return this.setSecondaryDefaultRoute(extNetworkInfo);
})
.then(() => this._addSubnetRoutes(networkInterface))
.then(() => this._addSubnetRoutes(extNetworkInfo))
.then(() => this.setAndConfigureActive())
.then(() => {
// Update data connection when Wifi connected/disconnected
if (networkInterface.type ==
Ci.nsINetworkInterface.NETWORK_TYPE_WIFI && this.mRil) {
if (extNetworkInfo.type ==
Ci.nsINetworkInfo.NETWORK_TYPE_WIFI && this.mRil) {
for (let i = 0; i < this.mRil.numRadioInterfaces; i++) {
this.mRil.getRadioInterface(i).updateRILNetworkInterface();
}
@ -382,70 +381,74 @@ NetworkManager.prototype = {
// Probing the public network accessibility after routing table is ready
CaptivePortalDetectionHelper
.notify(CaptivePortalDetectionHelper.EVENT_CONNECT, this.active);
.notify(CaptivePortalDetectionHelper.EVENT_CONNECT,
this.activeNetworkInfo);
})
.then(() => {
// Notify outer modules like MmsService to start the transaction after
// the configuration of the network interface is done.
Services.obs.notifyObservers(network, TOPIC_CONNECTION_STATE_CHANGED,
this.convertConnectionType(network));
Services.obs.notifyObservers(network.info,
TOPIC_CONNECTION_STATE_CHANGED,
this.convertConnectionType(network.info));
})
.catch(aError => {
debug("updateNetworkInterface error: " + aError);
});
break;
case Ci.nsINetworkInterface.NETWORK_STATE_DISCONNECTED:
case Ci.nsINetworkInfo.NETWORK_STATE_DISCONNECTED:
Promise.resolve()
.then(() => {
if (!this.isNetworkTypeMobile(networkInterface.type)) {
if (!this.isNetworkTypeMobile(extNetworkInfo.type)) {
return;
}
// Remove host route for data calls
return this._cleanupAllHostRoutes(networkId);
})
.then(() => {
if (networkInterface.type !=
Ci.nsINetworkInterface.NETWORK_TYPE_MOBILE_DUN) {
if (extNetworkInfo.type !=
Ci.nsINetworkInfo.NETWORK_TYPE_MOBILE_DUN) {
return;
}
// Remove secondary default route for dun.
return this.removeSecondaryDefaultRoute(networkInterface);
return this.removeSecondaryDefaultRoute(extNetworkInfo);
})
.then(() => {
if (networkInterface.type == Ci.nsINetworkInterface.NETWORK_TYPE_WIFI) {
if (extNetworkInfo.type == Ci.nsINetworkInfo.NETWORK_TYPE_WIFI) {
// Remove routing table in /proc/net/route
return this._resetRoutingTable(networkInterface.name);
return this._resetRoutingTable(extNetworkInfo.name);
}
if (networkInterface.type == Ci.nsINetworkInterface.NETWORK_TYPE_MOBILE) {
return this._removeDefaultRoute(networkInterface)
if (extNetworkInfo.type == Ci.nsINetworkInfo.NETWORK_TYPE_MOBILE) {
return this._removeDefaultRoute(extNetworkInfo)
}
})
.then(() => {
// Clear http proxy on active network.
if (this.active && networkInterface.type == this.active.type) {
if (this.activeNetworkInfo &&
extNetworkInfo.type == this.activeNetworkInfo.type) {
this.clearNetworkProxy();
}
// Abort ongoing captive portal detection on the wifi interface
CaptivePortalDetectionHelper
.notify(CaptivePortalDetectionHelper.EVENT_DISCONNECT, networkInterface);
.notify(CaptivePortalDetectionHelper.EVENT_DISCONNECT, extNetworkInfo);
})
.then(() => this.setAndConfigureActive())
.then(() => {
// Update data connection when Wifi connected/disconnected
if (networkInterface.type ==
Ci.nsINetworkInterface.NETWORK_TYPE_WIFI && this.mRil) {
if (extNetworkInfo.type ==
Ci.nsINetworkInfo.NETWORK_TYPE_WIFI && this.mRil) {
for (let i = 0; i < this.mRil.numRadioInterfaces; i++) {
this.mRil.getRadioInterface(i).updateRILNetworkInterface();
}
}
})
.then(() => this._destroyNetwork(networkInterface.name))
.then(() => this._destroyNetwork(extNetworkInfo.name))
.then(() => {
// Notify outer modules like MmsService to start the transaction after
// the configuration of the network interface is done.
Services.obs.notifyObservers(network, TOPIC_CONNECTION_STATE_CHANGED,
this.convertConnectionType(network));
Services.obs.notifyObservers(network.info,
TOPIC_CONNECTION_STATE_CHANGED,
this.convertConnectionType(network.info));
})
.catch(aError => {
debug("updateNetworkInterface error: " + aError);
@ -459,7 +462,7 @@ NetworkManager.prototype = {
throw Components.Exception("Argument must be nsINetworkInterface.",
Cr.NS_ERROR_INVALID_ARG);
}
let networkId = this.getNetworkId(network);
let networkId = this.getNetworkId(network.info);
if (!(networkId in this.networkInterfaces)) {
throw Components.Exception("No network with that type registered.",
Cr.NS_ERROR_INVALID_ARG);
@ -467,13 +470,13 @@ NetworkManager.prototype = {
// This is for in case a network gets unregistered without being
// DISCONNECTED.
if (this.isNetworkTypeMobile(network.type)) {
if (this.isNetworkTypeMobile(network.info.type)) {
this._cleanupAllHostRoutes(networkId);
}
delete this.networkInterfaces[networkId];
Services.obs.notifyObservers(network, TOPIC_INTERFACE_UNREGISTERED, null);
Services.obs.notifyObservers(network.info, TOPIC_INTERFACE_UNREGISTERED, null);
debug("Network '" + networkId + "' unregistered.");
},
@ -488,19 +491,25 @@ NetworkManager.prototype = {
return this._preferredNetworkType;
},
set preferredNetworkType(val) {
if ([Ci.nsINetworkInterface.NETWORK_TYPE_WIFI,
Ci.nsINetworkInterface.NETWORK_TYPE_MOBILE].indexOf(val) == -1) {
if ([Ci.nsINetworkInfo.NETWORK_TYPE_WIFI,
Ci.nsINetworkInfo.NETWORK_TYPE_MOBILE].indexOf(val) == -1) {
throw "Invalid network type";
}
this._preferredNetworkType = val;
},
active: null,
_activeNetwork: null,
get activeNetworkInfo() {
return this._activeNetwork && this._activeNetwork.info;
},
_overriddenActive: null,
overrideActive: function(network) {
if ([Ci.nsINetworkInterface.NETWORK_TYPE_WIFI,
Ci.nsINetworkInterface.NETWORK_TYPE_MOBILE].indexOf(val) == -1) {
let type = network.info.type;
if ([Ci.nsINetworkInfo.NETWORK_TYPE_WIFI,
Ci.nsINetworkInfo.NETWORK_TYPE_MOBILE].indexOf(type) == -1) {
throw "Invalid network type";
}
@ -548,10 +557,10 @@ NetworkManager.prototype = {
return Promise.all(promises);
},
isValidatedNetwork: function(network) {
isValidatedNetwork: function(aNetworkInfo) {
let isValid = false;
try {
isValid = (this.getNetworkId(network) in this.networkInterfaces);
isValid = (this.getNetworkId(aNetworkInfo) in this.networkInterfaces);
} catch (e) {
debug("Invalid network interface: " + e);
}
@ -559,19 +568,19 @@ NetworkManager.prototype = {
return isValid;
},
addHostRoute: function(network, host) {
if (!this.isValidatedNetwork(network)) {
return Promise.reject("Invalid network interface.");
addHostRoute: function(aNetworkInfo, aHost) {
if (!this.isValidatedNetwork(aNetworkInfo)) {
return Promise.reject("Invalid network info.");
}
return this.resolveHostname(network, host)
return this.resolveHostname(aNetworkInfo, aHost)
.then((ipAddresses) => {
let promises = [];
let networkId = this.getNetworkId(network);
let networkId = this.getNetworkId(aNetworkInfo);
ipAddresses.forEach((aIpAddress) => {
let promise =
this._setHostRoutes(true, [aIpAddress], network.name, network.getGateways())
this._setHostRoutes(true, [aIpAddress], aNetworkInfo.name, aNetworkInfo.getGateways())
.then(() => this.networkInterfaceLinks[networkId].extraRoutes.push(aIpAddress));
promises.push(promise);
@ -581,15 +590,15 @@ NetworkManager.prototype = {
});
},
removeHostRoute: function(network, host) {
if (!this.isValidatedNetwork(network)) {
return Promise.reject("Invalid network interface.");
removeHostRoute: function(aNetworkInfo, aHost) {
if (!this.isValidatedNetwork(aNetworkInfo)) {
return Promise.reject("Invalid network info.");
}
return this.resolveHostname(network, host)
return this.resolveHostname(aNetworkInfo, aHost)
.then((ipAddresses) => {
let promises = [];
let networkId = this.getNetworkId(network);
let networkId = this.getNetworkId(aNetworkInfo);
ipAddresses.forEach((aIpAddress) => {
let found = this.networkInterfaceLinks[networkId].extraRoutes.indexOf(aIpAddress);
@ -598,7 +607,7 @@ NetworkManager.prototype = {
}
let promise =
this._setHostRoutes(false, [aIpAddress], network.name, network.getGateways())
this._setHostRoutes(false, [aIpAddress], aNetworkInfo.name, aNetworkInfo.getGateways())
.then(() => {
this.networkInterfaceLinks[networkId].extraRoutes.splice(found, 1);
}, () => {
@ -613,15 +622,15 @@ NetworkManager.prototype = {
},
isNetworkTypeSecondaryMobile: function(type) {
return (type == Ci.nsINetworkInterface.NETWORK_TYPE_MOBILE_MMS ||
type == Ci.nsINetworkInterface.NETWORK_TYPE_MOBILE_SUPL ||
type == Ci.nsINetworkInterface.NETWORK_TYPE_MOBILE_IMS ||
type == Ci.nsINetworkInterface.NETWORK_TYPE_MOBILE_DUN ||
type == Ci.nsINetworkInterface.NETWORK_TYPE_MOBILE_FOTA);
return (type == Ci.nsINetworkInfo.NETWORK_TYPE_MOBILE_MMS ||
type == Ci.nsINetworkInfo.NETWORK_TYPE_MOBILE_SUPL ||
type == Ci.nsINetworkInfo.NETWORK_TYPE_MOBILE_IMS ||
type == Ci.nsINetworkInfo.NETWORK_TYPE_MOBILE_DUN ||
type == Ci.nsINetworkInfo.NETWORK_TYPE_MOBILE_FOTA);
},
isNetworkTypeMobile: function(type) {
return (type == Ci.nsINetworkInterface.NETWORK_TYPE_MOBILE ||
return (type == Ci.nsINetworkInfo.NETWORK_TYPE_MOBILE ||
this.isNetworkTypeSecondaryMobile(type));
},
@ -765,62 +774,64 @@ NetworkManager.prototype = {
*/
setAndConfigureActive: function() {
debug("Evaluating whether active network needs to be changed.");
let oldActive = this.active;
let oldActive = this._activeNetwork;
if (this._overriddenActive) {
debug("We have an override for the active network: " +
this._overriddenActive.name);
this._overriddenActive.info.name);
// The override was just set, so reconfigure the network.
if (this.active != this._overriddenActive) {
this.active = this._overriddenActive;
this._setDefaultRouteAndProxy(this.active, oldActive);
Services.obs.notifyObservers(this.active, TOPIC_ACTIVE_CHANGED, null);
if (this._activeNetwork != this._overriddenActive) {
this._activeNetwork = this._overriddenActive;
this._setDefaultRouteAndProxy(this._activeNetwork, oldActive);
Services.obs.notifyObservers(this.activeNetworkInfo,
TOPIC_ACTIVE_CHANGED, null);
}
return;
}
// The active network is already our preferred type.
if (this.active &&
this.active.state == Ci.nsINetworkInterface.NETWORK_STATE_CONNECTED &&
this.active.type == this._preferredNetworkType) {
if (this.activeNetworkInfo &&
this.activeNetworkInfo.state == Ci.nsINetworkInfo.NETWORK_STATE_CONNECTED &&
this.activeNetworkInfo.type == this._preferredNetworkType) {
debug("Active network is already our preferred type.");
return this._setDefaultRouteAndProxy(this.active, oldActive);
return this._setDefaultRouteAndProxy(this._activeNetwork, oldActive);
}
// Find a suitable network interface to activate.
this.active = null;
this._activeNetwork = null;
let anyConnected = false;
for each (let network in this.networkInterfaces) {
if (network.state != Ci.nsINetworkInterface.NETWORK_STATE_CONNECTED) {
if (network.info.state != Ci.nsINetworkInfo.NETWORK_STATE_CONNECTED) {
continue;
}
anyConnected = true;
// Set active only for default connections.
if (network.type != Ci.nsINetworkInterface.NETWORK_TYPE_WIFI &&
network.type != Ci.nsINetworkInterface.NETWORK_TYPE_MOBILE) {
if (network.info.type != Ci.nsINetworkInfo.NETWORK_TYPE_WIFI &&
network.info.type != Ci.nsINetworkInfo.NETWORK_TYPE_MOBILE) {
continue;
}
this.active = network;
if (network.type == this.preferredNetworkType) {
debug("Found our preferred type of network: " + network.name);
this._activeNetwork = network;
if (network.info.type == this.preferredNetworkType) {
debug("Found our preferred type of network: " + network.info.name);
break;
}
}
return Promise.resolve()
.then(() => {
if (!this.active) {
if (!this._activeNetwork) {
return Promise.resolve();
}
return this._setDefaultRouteAndProxy(this.active, oldActive);
return this._setDefaultRouteAndProxy(this._activeNetwork, oldActive);
})
.then(() => {
if (this.active != oldActive) {
Services.obs.notifyObservers(this.active, TOPIC_ACTIVE_CHANGED, null);
if (this._activeNetwork != oldActive) {
Services.obs.notifyObservers(this.activeNetworkInfo,
TOPIC_ACTIVE_CHANGED, null);
}
if (this._manageOfflineStatus) {
@ -829,15 +840,15 @@ NetworkManager.prototype = {
});
},
resolveHostname: function(network, hostname) {
resolveHostname: function(aNetworkInfo, aHostname) {
// Sanity check for null, undefined and empty string... etc.
if (!hostname) {
return Promise.reject(new Error("hostname is empty: " + hostname));
if (!aHostname) {
return Promise.reject(new Error("hostname is empty: " + aHostname));
}
if (hostname.match(this.REGEXP_IPV4) ||
hostname.match(this.REGEXP_IPV6)) {
return Promise.resolve([hostname]);
if (aHostname.match(this.REGEXP_IPV4) ||
aHostname.match(this.REGEXP_IPV6)) {
return Promise.resolve([aHostname]);
}
// Wrap gDNSService.asyncResolveExtended to a promise, which
@ -848,7 +859,7 @@ NetworkManager.prototype = {
// Callback for gDNSService.asyncResolveExtended.
let onLookupComplete = (aRequest, aRecord, aStatus) => {
if (!Components.isSuccessCode(aStatus)) {
aReject(new Error("Failed to resolve '" + hostname +
aReject(new Error("Failed to resolve '" + aHostname +
"', with status: " + aStatus));
return;
}
@ -863,14 +874,14 @@ NetworkManager.prototype = {
return;
}
debug("hostname is resolved: " + hostname);
debug("hostname is resolved: " + aHostname);
debug("Addresses: " + JSON.stringify(retval));
aResolve(retval);
};
debug('Calling gDNSService.asyncResolveExtended: ' + aNetId + ', ' + hostname);
gDNSService.asyncResolveExtended(hostname,
debug('Calling gDNSService.asyncResolveExtended: ' + aNetId + ', ' + aHostname);
gDNSService.asyncResolveExtended(aHostname,
0,
aNetId,
onLookupComplete,
@ -880,36 +891,36 @@ NetworkManager.prototype = {
// TODO: |getNetId| will be implemented as a sync call in nsINetworkManager
// once Bug 1141903 is landed.
return gNetworkService.getNetId(network.name)
return gNetworkService.getNetId(aNetworkInfo.name)
.then(aNetId => hostResolveWrapper(aNetId));
},
convertConnectionType: function(network) {
convertConnectionType: function(aNetworkInfo) {
// If there is internal interface change (e.g., MOBILE_MMS, MOBILE_SUPL),
// the function will return null so that it won't trigger type change event
// in NetworkInformation API.
if (network.type != Ci.nsINetworkInterface.NETWORK_TYPE_WIFI &&
network.type != Ci.nsINetworkInterface.NETWORK_TYPE_MOBILE) {
if (aNetworkInfo.type != Ci.nsINetworkInfo.NETWORK_TYPE_WIFI &&
aNetworkInfo.type != Ci.nsINetworkInfo.NETWORK_TYPE_MOBILE) {
return null;
}
if (network.state == Ci.nsINetworkInterface.NETWORK_STATE_DISCONNECTED) {
if (aNetworkInfo.state == Ci.nsINetworkInfo.NETWORK_STATE_DISCONNECTED) {
return CONNECTION_TYPE_NONE;
}
switch (network.type) {
case Ci.nsINetworkInterface.NETWORK_TYPE_WIFI:
switch (aNetworkInfo.type) {
case Ci.nsINetworkInfo.NETWORK_TYPE_WIFI:
return CONNECTION_TYPE_WIFI;
case Ci.nsINetworkInterface.NETWORK_TYPE_MOBILE:
case Ci.nsINetworkInfo.NETWORK_TYPE_MOBILE:
return CONNECTION_TYPE_CELLULAR;
}
},
_setDNS: function(aNetwork) {
_setDNS: function(aNetworkInfo) {
return new Promise((aResolve, aReject) => {
let dnses = aNetwork.getDnses();
let gateways = aNetwork.getGateways();
gNetworkService.setDNS(aNetwork.name, dnses.length, dnses,
let dnses = aNetworkInfo.getDnses();
let gateways = aNetworkInfo.getGateways();
gNetworkService.setDNS(aNetworkInfo.name, dnses.length, dnses,
gateways.length, gateways, (aError) => {
if (aError) {
aReject("setDNS failed");
@ -956,10 +967,10 @@ NetworkManager.prototype = {
});
},
_removeDefaultRoute: function(aNetwork) {
_removeDefaultRoute: function(aNetworkInfo) {
return new Promise((aResolve, aReject) => {
let gateways = aNetwork.getGateways();
gNetworkService.removeDefaultRoute(aNetwork.name, gateways.length,
let gateways = aNetworkInfo.getGateways();
gNetworkService.removeDefaultRoute(aNetworkInfo.name, gateways.length,
gateways, (aSuccess) => {
if (!aSuccess) {
debug("removeDefaultRoute failed");
@ -972,12 +983,13 @@ NetworkManager.prototype = {
_setDefaultRouteAndProxy: function(aNetwork, aOldInterface) {
return new Promise((aResolve, aReject) => {
let gateways = aNetwork.getGateways();
let oldInterfaceName = (aOldInterface ? aOldInterface.name : "");
gNetworkService.setDefaultRoute(aNetwork.name, gateways.length, gateways,
let networkInfo = aNetwork.info;
let gateways = networkInfo.getGateways();
let oldInterfaceName = (aOldInterface ? aOldInterface.info.name : "");
gNetworkService.setDefaultRoute(networkInfo.name, gateways.length, gateways,
oldInterfaceName, (aSuccess) => {
if (!aSuccess) {
gNetworkService.destroyNetwork(aNetwork, function() {
gNetworkService.destroyNetwork(networkInfo.name, function() {
aReject("setDefaultRoute failed");
});
return;
@ -988,23 +1000,23 @@ NetworkManager.prototype = {
});
},
setNetworkProxy: function(network) {
setNetworkProxy: function(aNetwork) {
try {
if (!network.httpProxyHost || network.httpProxyHost === "") {
if (!aNetwork.httpProxyHost || aNetwork.httpProxyHost === "") {
// Sets direct connection to internet.
this.clearNetworkProxy();
debug("No proxy support for " + network.name + " network interface.");
debug("No proxy support for " + aNetwork.info.name + " network interface.");
return;
}
debug("Going to set proxy settings for " + network.name + " network interface.");
debug("Going to set proxy settings for " + aNetwork.info.name + " network interface.");
// Do not use this proxy server for all protocols.
Services.prefs.setBoolPref("network.proxy.share_proxy_settings", false);
Services.prefs.setCharPref("network.proxy.http", network.httpProxyHost);
Services.prefs.setCharPref("network.proxy.ssl", network.httpProxyHost);
let port = network.httpProxyPort === 0 ? 8080 : network.httpProxyPort;
Services.prefs.setCharPref("network.proxy.http", aNetwork.httpProxyHost);
Services.prefs.setCharPref("network.proxy.ssl", aNetwork.httpProxyHost);
let port = aNetwork.httpProxyPort === 0 ? 8080 : aNetwork.httpProxyPort;
Services.prefs.setIntPref("network.proxy.http_port", port);
Services.prefs.setIntPref("network.proxy.ssl_port", port);
@ -1022,7 +1034,7 @@ NetworkManager.prototype = {
}
} catch(ex) {
debug("Exception " + ex + ". Unable to set proxy setting for " +
network.name + " network interface.");
aNetwork.info.name + " network interface.");
}
},
@ -1105,7 +1117,7 @@ let CaptivePortalDetectionHelper = (function() {
case EVENT_CONNECT:
// perform captive portal detection on wifi interface
if (_available && network &&
network.type == Ci.nsINetworkInterface.NETWORK_TYPE_WIFI) {
network.type == Ci.nsINetworkInfo.NETWORK_TYPE_WIFI) {
_performDetection(network.name, function() {
// TODO: bug 837600
// We can disconnect wifi in here if user abort the login procedure.
@ -1115,7 +1127,7 @@ let CaptivePortalDetectionHelper = (function() {
break;
case EVENT_DISCONNECT:
if (_available &&
network.type == Ci.nsINetworkInterface.NETWORK_TYPE_WIFI) {
network.type == Ci.nsINetworkInfo.NETWORK_TYPE_WIFI) {
_abort(network.name);
}
break;

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

@ -60,8 +60,8 @@ const kPrefRilDebuggingEnabled = "ril.debugging.enabled";
const RADIO_POWER_OFF_TIMEOUT = 30000;
const HW_DEFAULT_CLIENT_ID = 0;
const NETWORK_TYPE_WIFI = Ci.nsINetworkInterface.NETWORK_TYPE_WIFI;
const NETWORK_TYPE_MOBILE = Ci.nsINetworkInterface.NETWORK_TYPE_MOBILE;
const NETWORK_TYPE_WIFI = Ci.nsINetworkInfo.NETWORK_TYPE_WIFI;
const NETWORK_TYPE_MOBILE = Ci.nsINetworkInfo.NETWORK_TYPE_MOBILE;
// set to true in ril_consts.js to see debug messages
var DEBUG = RIL.DEBUG_RIL;
@ -1148,21 +1148,21 @@ RadioInterface.prototype = {
this._sntp.updateOffset(offset);
break;
case kNetworkConnStateChangedTopic:
let network = subject.QueryInterface(Ci.nsINetworkInterface);
if (network.state != Ci.nsINetworkInterface.NETWORK_STATE_CONNECTED) {
let networkInfo = subject.QueryInterface(Ci.nsINetworkInfo);
if (networkInfo.state != Ci.nsINetworkInfo.NETWORK_STATE_CONNECTED) {
return;
}
// SNTP can only update when we have mobile or Wifi connections.
if (network.type != NETWORK_TYPE_WIFI &&
network.type != NETWORK_TYPE_MOBILE) {
if (networkInfo.type != NETWORK_TYPE_WIFI &&
networkInfo.type != NETWORK_TYPE_MOBILE) {
return;
}
// If the network comes from RIL, make sure the RIL service is matched.
if (subject instanceof Ci.nsIRilNetworkInterface) {
network = subject.QueryInterface(Ci.nsIRilNetworkInterface);
if (network.serviceId != this.clientId) {
if (subject instanceof Ci.nsIRilNetworkInfo) {
networkInfo = subject.QueryInterface(Ci.nsIRilNetworkInfo);
if (networkInfo.serviceId != this.clientId) {
return;
}
}
@ -1242,8 +1242,9 @@ RadioInterface.prototype = {
// Set the latest cached NITZ time if it's available.
if (this._lastNitzMessage) {
this.setClockByNitz(this._lastNitzMessage);
} else if (gNetworkManager.active && gNetworkManager.active.state ==
Ci.nsINetworkInterface.NETWORK_STATE_CONNECTED) {
} else if (gNetworkManager.activeNetworkInfo &&
gNetworkManager.activeNetworkInfo.state ==
Ci.nsINetworkInfo.NETWORK_STATE_CONNECTED) {
// Set the latest cached SNTP time if it's available.
if (!this._sntp.isExpired()) {
this.setClockBySntp(this._sntp.getOffset());

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

@ -248,7 +248,7 @@ TetheringService.prototype = {
this.handle(aSubject.key, aSubject.value);
break;
case TOPIC_CONNECTION_STATE_CHANGED:
network = aSubject.QueryInterface(Ci.nsINetworkInterface);
network = aSubject.QueryInterface(Ci.nsINetworkInfo);
debug("Network " + network.type + "/" + network.name +
" changed state to " + network.state);
this.onConnectionChanged(network);
@ -338,18 +338,18 @@ TetheringService.prototype = {
libcutils.property_get("ro.tethering.dun_required") === "1";
},
getNetworkInterface: function(aType, aServiceId) {
for each (let network in gNetworkManager.networkInterfaces) {
if (network.type == aType) {
getNetworkInfo: function(aType, aServiceId) {
for each (let networkInfo in gNetworkManager.allNetworkInfo) {
if (networkInfo.type == aType) {
try {
if (network instanceof Ci.nsIRilNetworkInterface) {
let rilNetwork = network.QueryInterface(Ci.nsIRilNetworkInterface);
if (networkInfo instanceof Ci.nsIRilNetworkInfo) {
let rilNetwork = networkInfo.QueryInterface(Ci.nsIRilNetworkInfo);
if (rilNetwork.serviceId != aServiceId) {
continue;
}
}
} catch (e) {}
return network;
return networkInfo;
}
}
return null;
@ -405,7 +405,7 @@ TetheringService.prototype = {
let ril = gRil.getRadioInterface(this._dataDefaultServiceId);
this.dunRetryTimes = 0;
ril.setupDataCallByType(Ci.nsINetworkInterface.NETWORK_TYPE_MOBILE_DUN);
ril.setupDataCallByType(Ci.nsINetworkInfo.NETWORK_TYPE_MOBILE_DUN);
this.dunConnectTimer.cancel();
this.dunConnectTimer.
initWithCallback(this.onDunConnectTimerTimeout.bind(this),
@ -430,8 +430,8 @@ TetheringService.prototype = {
_dunActiveUsers: 0,
handleDunConnection: function(aEnable, aCallback) {
debug("handleDunConnection: " + aEnable);
let dun = this.getNetworkInterface(
Ci.nsINetworkInterface.NETWORK_TYPE_MOBILE_DUN, this._dataDefaultServiceId);
let dun = this.getNetworkInfo(
Ci.nsINetworkInfo.NETWORK_TYPE_MOBILE_DUN, this._dataDefaultServiceId);
if (!aEnable) {
this._dunActiveUsers--;
@ -445,15 +445,15 @@ TetheringService.prototype = {
this.dunConnectTimer.cancel();
this._pendingTetheringRequests = [];
if (dun && (dun.state == Ci.nsINetworkInterface.NETWORK_STATE_CONNECTED)) {
if (dun && (dun.state == Ci.nsINetworkInfo.NETWORK_STATE_CONNECTED)) {
gRil.getRadioInterface(this._dataDefaultServiceId)
.deactivateDataCallByType(Ci.nsINetworkInterface.NETWORK_TYPE_MOBILE_DUN);
.deactivateDataCallByType(Ci.nsINetworkInfo.NETWORK_TYPE_MOBILE_DUN);
}
return;
}
this._dunActiveUsers++;
if (!dun || (dun.state != Ci.nsINetworkInterface.NETWORK_STATE_CONNECTED)) {
if (!dun || (dun.state != Ci.nsINetworkInfo.NETWORK_STATE_CONNECTED)) {
debug("DUN data call inactive, setup dun data call!")
this._pendingTetheringRequests.push(aCallback);
this.dunRetryTimes = 0;
@ -495,23 +495,24 @@ TetheringService.prototype = {
this._usbTetheringAction = TETHERING_STATE_ONGOING;
if (this.tetheringSettings[SETTINGS_DUN_REQUIRED]) {
this.handleDunConnection(true, (aNetwork) => {
if (!aNetwork){
this.handleDunConnection(true, (aNetworkInfo) => {
if (!aNetworkInfo){
this.usbTetheringResultReport(aEnable, "Dun connection failed");
return;
}
this._tetheringInterface[TETHERING_TYPE_USB].externalInterface = aNetwork.name;
this._tetheringInterface[TETHERING_TYPE_USB].externalInterface =
aNetworkInfo.name;
gNetworkService.enableUsbRndis(true, this.enableUsbRndisResult.bind(this));
});
return;
}
if (gNetworkManager.active) {
if (gNetworkManager.activeNetworkInfo) {
this._tetheringInterface[TETHERING_TYPE_USB].externalInterface =
gNetworkManager.active.name;
gNetworkManager.activeNetworkInfo.name;
} else {
let mobile = this.getNetworkInterface(
Ci.nsINetworkInterface.NETWORK_TYPE_MOBILE, this._dataDefaultServiceId);
let mobile = this.getNetworkInfo(
Ci.nsINetworkInfo.NETWORK_TYPE_MOBILE, this._dataDefaultServiceId);
if (mobile && mobile.name) {
this._tetheringInterface[TETHERING_TYPE_USB].externalInterface = mobile.name;
}
@ -599,10 +600,10 @@ TetheringService.prototype = {
},
// Enable/disable WiFi tethering by sending commands to netd.
setWifiTethering: function(aEnable, aNetwork, aConfig, aCallback) {
setWifiTethering: function(aEnable, aInterfaceName, aConfig, aCallback) {
debug("setWifiTethering: " + aEnable);
if (!aNetwork) {
this.notifyError(true, aCallback, "invalid network information");
if (!aInterfaceName) {
this.notifyError(true, aCallback, "invalid network interface name");
return;
}
@ -630,22 +631,24 @@ TetheringService.prototype = {
return;
}
this._tetheringInterface[TETHERING_TYPE_WIFI].internalInterface = aNetwork.name;
this._tetheringInterface[TETHERING_TYPE_WIFI].internalInterface =
aInterfaceName;
if (this.tetheringSettings[SETTINGS_DUN_REQUIRED]) {
this.handleDunConnection(true, (aNetwork) => {
if (!aNetwork) {
this.handleDunConnection(true, (aNetworkInfo) => {
if (!aNetworkInfo) {
this.notifyError(true, aCallback, "Dun connection failed");
return;
}
this._tetheringInterface[TETHERING_TYPE_WIFI].externalInterface = aNetwork.name;
this._tetheringInterface[TETHERING_TYPE_WIFI].externalInterface =
aNetworkInfo.name;
this.enableWifiTethering(true, aConfig, aCallback);
});
return;
}
let mobile = this.getNetworkInterface(
Ci.nsINetworkInterface.NETWORK_TYPE_MOBILE, this._dataDefaultServiceId);
let mobile = this.getNetworkInfo(
Ci.nsINetworkInfo.NETWORK_TYPE_MOBILE, this._dataDefaultServiceId);
// Update the real interface name
if (mobile && mobile.name) {
this._tetheringInterface[TETHERING_TYPE_WIFI].externalInterface = mobile.name;
@ -745,20 +748,20 @@ TetheringService.prototype = {
}
},
onConnectionChanged: function(aNetwork) {
if (aNetwork.state != Ci.nsINetworkInterface.NETWORK_STATE_CONNECTED) {
onConnectionChanged: function(aNetworkInfo) {
if (aNetworkInfo.state != Ci.nsINetworkInfo.NETWORK_STATE_CONNECTED) {
debug("We are only interested in CONNECTED event");
return;
}
if (this.tetheringSettings[SETTINGS_DUN_REQUIRED] &&
aNetwork.type === Ci.nsINetworkInterface.NETWORK_TYPE_MOBILE_DUN) {
aNetworkInfo.type === Ci.nsINetworkInfo.NETWORK_TYPE_MOBILE_DUN) {
this.dunConnectTimer.cancel();
debug("DUN data call connected, process callbacks.");
while (this._pendingTetheringRequests.length > 0) {
let callback = this._pendingTetheringRequests.shift();
if (typeof callback === 'function') {
callback(aNetwork);
callback(aNetworkInfo);
}
}
return;
@ -770,15 +773,15 @@ TetheringService.prototype = {
}
if (this.tetheringSettings[SETTINGS_DUN_REQUIRED] &&
aNetwork.type === Ci.nsINetworkInterface.NETWORK_TYPE_MOBILE_DUN &&
aNetworkInfo.type === Ci.nsINetworkInfo.NETWORK_TYPE_MOBILE_DUN &&
this._tetheringInterface[TETHERING_TYPE_USB].externalInterface ===
aNetwork.name) {
aNetworkInfo.name) {
debug("Dun required and dun interface is the same");
return;
}
if (this._tetheringInterface[TETHERING_TYPE_USB].externalInterface ===
gNetworkManager.active.name) {
gNetworkManager.activeNetworkInfo.name) {
debug("The active interface is the same");
return;
}
@ -790,12 +793,12 @@ TetheringService.prototype = {
let current = {
internalIfname: this._tetheringInterface[TETHERING_TYPE_USB].internalInterface,
externalIfname: aNetwork.name
externalIfname: aNetworkInfo.name
};
let callback = (() => {
// Update external network interface.
debug("Update upstream interface to " + aNetwork.name);
debug("Update upstream interface to " + aNetworkInfo.name);
gNetworkService.updateUpStream(previous, current,
this.onConnectionChangedReport.bind(this));
});

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

@ -16,6 +16,7 @@
XPIDL_SOURCES += [
'nsIAudioManager.idl',
'nsINetworkInterface.idl',
'nsINetworkInterfaceListService.idl',
'nsINetworkManager.idl',
'nsINetworkService.idl',

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

@ -3,10 +3,10 @@
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#include "nsISupports.idl"
#include "nsINetworkManager.idl"
#include "nsINetworkInterface.idl"
[scriptable, uuid(b8ce8528-fce8-4b5e-9d0a-c3247296ccaf)]
interface nsIRilNetworkInterface : nsINetworkInterface
[scriptable, uuid(501b7041-0754-4ddb-9174-946e2c2ebd83)]
interface nsIRilNetworkInfo : nsINetworkInfo
{
readonly attribute unsigned long serviceId;
readonly attribute DOMString iccId;

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

@ -0,0 +1,100 @@
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
* You can obtain one at http://mozilla.org/MPL/2.0/. */
#include "nsISupports.idl"
[scriptable, uuid(f439ab5d-64bd-4a6c-8863-30235fa784d2)]
interface nsINetworkInfo : nsISupports
{
const long NETWORK_STATE_UNKNOWN = -1;
const long NETWORK_STATE_CONNECTING = 0;
const long NETWORK_STATE_CONNECTED = 1;
const long NETWORK_STATE_DISCONNECTING = 2;
const long NETWORK_STATE_DISCONNECTED = 3;
/**
* Current network state, one of the NETWORK_STATE_* constants.
*
* When this changes, network interface implementations notify with
* updateNetworkInterface() API.
*/
readonly attribute long state;
const long NETWORK_TYPE_UNKNOWN = -1;
const long NETWORK_TYPE_WIFI = 0;
const long NETWORK_TYPE_MOBILE = 1;
const long NETWORK_TYPE_MOBILE_MMS = 2;
const long NETWORK_TYPE_MOBILE_SUPL = 3;
const long NETWORK_TYPE_WIFI_P2P = 4;
const long NETWORK_TYPE_MOBILE_IMS = 5;
const long NETWORK_TYPE_MOBILE_DUN = 6;
const long NETWORK_TYPE_MOBILE_FOTA = 7;
/**
* Network type. One of the NETWORK_TYPE_* constants.
*/
readonly attribute long type;
/**
* Interface name of the network interface this network info belongs to.
*/
readonly attribute DOMString name;
/**
* Get the list of ip addresses and prefix lengths, ip address could be IPv4
* or IPv6, typically 1 IPv4 or 1 IPv6 or one of each.
*
* @param ips
* The list of ip addresses retrieved.
* @param prefixLengths
* The list of prefix lengths retrieved.
*
* @returns the length of the lists.
*/
void getAddresses([array, size_is(count)] out wstring ips,
[array, size_is(count)] out unsigned long prefixLengths,
[retval] out unsigned long count);
/**
* Get the list of gateways, could be IPv4 or IPv6, typically 1 IPv4 or 1
* IPv6 or one of each.
*
* @param count
* The length of the list of gateways
*
* @returns the list of gateways.
*/
void getGateways([optional] out unsigned long count,
[array, size_is(count), retval] out wstring gateways);
/**
* Get the list of dnses, could be IPv4 or IPv6.
*
* @param count
* The length of the list of dnses.
*
* @returns the list of dnses.
*/
void getDnses([optional] out unsigned long count,
[array, size_is(count), retval] out wstring dnses);
};
[scriptable, uuid(9a025351-8684-4ab5-a0c1-f21a9f83d405)]
interface nsINetworkInterface : nsISupports
{
/**
* The network information about this network interface.
*/
readonly attribute nsINetworkInfo info;
/**
* The host name of the http proxy server.
*/
readonly attribute DOMString httpProxyHost;
/*
* The port number of the http proxy server.
*/
readonly attribute long httpProxyPort;
};

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

@ -2,10 +2,11 @@
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
* You can obtain one at http://mozilla.org/MPL/2.0/. */
#include "nsINetworkManager.idl"
#include "nsISupports.idl"
[scriptable, uuid(b44d74db-c9d6-41dd-98ae-a56918d6e6ad)]
interface nsINetworkInfo;
[scriptable, uuid(55779d32-1e28-4f43-af87-09d04bc3cce9)]
interface nsINetworkInterfaceList : nsISupports
{
/**
@ -14,10 +15,10 @@ interface nsINetworkInterfaceList : nsISupports
long getNumberOfInterface();
/**
* Get the i-th interface from the list.
* Get the i-th interface info info from the list.
* @param interfaceIndex index of interface, from 0 to number of interface - 1.
*/
nsINetworkInterface getInterface(in long interfaceIndex);
nsINetworkInfo getInterfaceInfo(in long interfaceIndex);
};
[scriptable, uuid(21d7fc8b-28c4-4a4f-a15e-1f9defbc2cec)]

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

@ -4,99 +4,13 @@
#include "nsISupports.idl"
/**
* Information about networks that is exposed to network manager API consumers.
*/
[scriptable, uuid(12da2bfd-0801-40d9-9c2e-768868526065)]
interface nsINetworkInterface : nsISupports
{
const long NETWORK_STATE_UNKNOWN = -1;
const long NETWORK_STATE_CONNECTING = 0;
const long NETWORK_STATE_CONNECTED = 1;
const long NETWORK_STATE_DISCONNECTING = 2;
const long NETWORK_STATE_DISCONNECTED = 3;
/**
* Current network state, one of the NETWORK_STATE_* constants.
*
* When this changes, network interface implementations notify with
* updateNetworkInterface() API.
*/
readonly attribute long state;
const long NETWORK_TYPE_UNKNOWN = -1;
const long NETWORK_TYPE_WIFI = 0;
const long NETWORK_TYPE_MOBILE = 1;
const long NETWORK_TYPE_MOBILE_MMS = 2;
const long NETWORK_TYPE_MOBILE_SUPL = 3;
const long NETWORK_TYPE_WIFI_P2P = 4;
const long NETWORK_TYPE_MOBILE_IMS = 5;
const long NETWORK_TYPE_MOBILE_DUN = 6;
const long NETWORK_TYPE_MOBILE_FOTA = 7;
/**
* Network type. One of the NETWORK_TYPE_* constants.
*/
readonly attribute long type;
/**
* Name of the network interface. This identifier is unique.
*/
readonly attribute DOMString name;
/**
* The host name of the http proxy server.
*/
readonly attribute DOMString httpProxyHost;
/*
* The port number of the http proxy server.
*/
readonly attribute long httpProxyPort;
/**
* Get the list of ip addresses and prefix lengths, ip address could be IPv4
* or IPv6, typically 1 IPv4 or 1 IPv6 or one of each.
*
* @param ips
* The list of ip addresses retrieved.
* @param prefixLengths
* The list of prefix lengths retrieved.
*
* @returns the length of the lists.
*/
void getAddresses([array, size_is(count)] out wstring ips,
[array, size_is(count)] out unsigned long prefixLengths,
[retval] out unsigned long count);
/**
* Get the list of gateways, could be IPv4 or IPv6, typically 1 IPv4 or 1
* IPv6 or one of each.
*
* @param count
* The length of the list of gateways
*
* @returns the list of gateways.
*/
void getGateways([optional] out unsigned long count,
[array, size_is(count), retval] out wstring gateways);
/**
* Get the list of dnses, could be IPv4 or IPv6.
*
* @param count
* The length of the list of dnses.
*
* @returns the list of dnses.
*/
void getDnses([optional] out unsigned long count,
[array, size_is(count), retval] out wstring dnses);
};
interface nsINetworkInfo;
interface nsINetworkInterface;
/**
* Manage network interfaces.
*/
[scriptable, uuid(b0ab71bf-4b38-4796-8a3c-4141255f4259)]
[scriptable, uuid(e5ffe335-078e-4b25-87f1-02429bd2e458)]
interface nsINetworkManager : nsISupports
{
/**
@ -141,12 +55,12 @@ interface nsINetworkManager : nsISupports
void unregisterNetworkInterface(in nsINetworkInterface network);
/**
* Object containing all known network connections, keyed by their
* Object containing all known network information, keyed by their
* network id. Network id is composed of a sub-id + '-' + network
* type. For mobile network types, sub-id is 'ril' + service id; for
* non-mobile network types, sub-id is always 'device'.
*/
readonly attribute jsval networkInterfaces;
readonly attribute jsval allNetworkInfo;
/**
* The preferred network type. One of the
@ -159,12 +73,13 @@ interface nsINetworkManager : nsISupports
attribute long preferredNetworkType;
/**
* The network interface handling all data traffic.
* The network information of the network interface handling all network
* traffic.
*
* When this changes, the 'network-active-changed' observer
* notification is dispatched.
*/
readonly attribute nsINetworkInterface active;
readonly attribute nsINetworkInfo activeNetworkInfo;
/**
* Override the default behaviour for preferredNetworkType and route
@ -183,7 +98,7 @@ interface nsINetworkManager : nsISupports
* Add host route to the specified network into routing table.
*
* @param network
* The network interface where the host to be routed to.
* The network information for the host to be routed to.
* @param host
* The host to be added.
* The host will be resolved in advance if it's not an ip-address.
@ -191,14 +106,14 @@ interface nsINetworkManager : nsISupports
* @return a Promise
* resolved if added; rejected, otherwise.
*/
jsval addHostRoute(in nsINetworkInterface network,
jsval addHostRoute(in nsINetworkInfo network,
in DOMString host);
/**
* Remove host route to the specified network from routing table.
*
* @param network
* The network interface where the routing to be removed from.
* The network information for the routing to be removed from.
* @param host
* The host routed to the network.
* The host will be resolved in advance if it's not an ip-address.
@ -206,6 +121,6 @@ interface nsINetworkManager : nsISupports
* @return a Promise
* resolved if removed; rejected, otherwise.
*/
jsval removeHostRoute(in nsINetworkInterface network,
jsval removeHostRoute(in nsINetworkInfo network,
in DOMString host);
};

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

@ -7,7 +7,7 @@
interface nsINetworkInterface;
interface nsIWifiTetheringCallback;
[scriptable, uuid(80d65940-bd99-458f-8529-e438c7348087)]
[scriptable, uuid(993b79df-f10e-4697-a5dc-5981cf8ff7e6)]
interface nsITetheringService : nsISupports
{
/**
@ -16,15 +16,15 @@ interface nsITetheringService : nsISupports
* @param enabled
* Boolean that indicates whether tethering should be enabled (true) or
* disabled (false).
* @param networkInterface
* The Wifi network interface with at least name of network interface.
* @param interfaceName
* The Wifi network interface name for internal interface.
* @param config
* The Wifi Tethering configuration from settings db.
* @param callback
* Callback function used to report status to WifiManager.
*/
void setWifiTethering(in boolean enabled,
in nsINetworkInterface networkInterface,
in DOMString interfaceName,
in jsval config,
in nsIWifiTetheringCallback callback);
};

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

@ -9,18 +9,18 @@ const SETTINGS_KEY_DATA_APN_SETTINGS = "ril.data.apnSettings";
const TOPIC_CONNECTION_STATE_CHANGED = "network-connection-state-changed";
const TOPIC_NETWORK_ACTIVE_CHANGED = "network-active-changed";
const NETWORK_STATE_UNKNOWN = Ci.nsINetworkInterface.NETWORK_STATE_UNKNOWN;
const NETWORK_STATE_CONNECTING = Ci.nsINetworkInterface.NETWORK_STATE_CONNECTING;
const NETWORK_STATE_CONNECTED = Ci.nsINetworkInterface.NETWORK_STATE_CONNECTED;
const NETWORK_STATE_DISCONNECTING = Ci.nsINetworkInterface.NETWORK_STATE_DISCONNECTING;
const NETWORK_STATE_DISCONNECTED = Ci.nsINetworkInterface.NETWORK_STATE_DISCONNECTED;
const NETWORK_STATE_UNKNOWN = Ci.nsINetworkInfo.NETWORK_STATE_UNKNOWN;
const NETWORK_STATE_CONNECTING = Ci.nsINetworkInfo.NETWORK_STATE_CONNECTING;
const NETWORK_STATE_CONNECTED = Ci.nsINetworkInfo.NETWORK_STATE_CONNECTED;
const NETWORK_STATE_DISCONNECTING = Ci.nsINetworkInfo.NETWORK_STATE_DISCONNECTING;
const NETWORK_STATE_DISCONNECTED = Ci.nsINetworkInfo.NETWORK_STATE_DISCONNECTED;
const NETWORK_TYPE_MOBILE = Ci.nsINetworkInterface.NETWORK_TYPE_MOBILE;
const NETWORK_TYPE_MOBILE_MMS = Ci.nsINetworkInterface.NETWORK_TYPE_MOBILE_MMS;
const NETWORK_TYPE_MOBILE_SUPL = Ci.nsINetworkInterface.NETWORK_TYPE_MOBILE_SUPL;
const NETWORK_TYPE_MOBILE_IMS = Ci.nsINetworkInterface.NETWORK_TYPE_MOBILE_IMS;
const NETWORK_TYPE_MOBILE_DUN = Ci.nsINetworkInterface.NETWORK_TYPE_MOBILE_DUN;
const NETWORK_TYPE_MOBILE_FOTA = Ci.nsINetworkInterface.NETWORK_TYPE_MOBILE_FOTA;
const NETWORK_TYPE_MOBILE = Ci.nsINetworkInfo.NETWORK_TYPE_MOBILE;
const NETWORK_TYPE_MOBILE_MMS = Ci.nsINetworkInfo.NETWORK_TYPE_MOBILE_MMS;
const NETWORK_TYPE_MOBILE_SUPL = Ci.nsINetworkInfo.NETWORK_TYPE_MOBILE_SUPL;
const NETWORK_TYPE_MOBILE_IMS = Ci.nsINetworkInfo.NETWORK_TYPE_MOBILE_IMS;
const NETWORK_TYPE_MOBILE_DUN = Ci.nsINetworkInfo.NETWORK_TYPE_MOBILE_DUN;
const NETWORK_TYPE_MOBILE_FOTA = Ci.nsINetworkInfo.NETWORK_TYPE_MOBILE_FOTA;
const networkTypes = [
NETWORK_TYPE_MOBILE,
@ -144,13 +144,13 @@ function setDataEnabledAndWait(aEnabled) {
let promises = [];
promises.push(waitForObserverEvent(TOPIC_CONNECTION_STATE_CHANGED)
.then(function(aSubject) {
ok(aSubject instanceof Ci.nsIRilNetworkInterface,
"subject should be an instance of nsIRILNetworkInterface");
ok(aSubject instanceof Ci.nsIRilNetworkInfo,
"subject should be an instance of nsIRilNetworkInfo");
is(aSubject.type, NETWORK_TYPE_MOBILE,
"subject.type should be " + NETWORK_TYPE_MOBILE);
is(aSubject.state,
aEnabled ? Ci.nsINetworkInterface.NETWORK_STATE_CONNECTED
: Ci.nsINetworkInterface.NETWORK_STATE_DISCONNECTED,
aEnabled ? Ci.nsINetworkInfo.NETWORK_STATE_CONNECTED
: Ci.nsINetworkInfo.NETWORK_STATE_DISCONNECTED,
"subject.state should be " + aEnabled ? "CONNECTED" : "DISCONNECTED");
}));
promises.push(setSettings(SETTINGS_KEY_DATA_ENABLED, aEnabled));
@ -175,11 +175,11 @@ function setupDataCallAndWait(aNetworkType) {
let promises = [];
promises.push(waitForObserverEvent(TOPIC_CONNECTION_STATE_CHANGED)
.then(function(aSubject) {
ok(aSubject instanceof Ci.nsIRilNetworkInterface,
"subject should be an instance of nsIRILNetworkInterface");
ok(aSubject instanceof Ci.nsIRilNetworkInfo,
"subject should be an instance of nsIRilNetworkInfo");
is(aSubject.type, aNetworkType,
"subject.type should be " + aNetworkType);
is(aSubject.state, Ci.nsINetworkInterface.NETWORK_STATE_CONNECTED,
is(aSubject.state, Ci.nsINetworkInfo.NETWORK_STATE_CONNECTED,
"subject.state should be CONNECTED");
}));
promises.push(radioInterface.setupDataCallByType(aNetworkType));
@ -204,11 +204,11 @@ function deactivateDataCallAndWait(aNetworkType) {
let promises = [];
promises.push(waitForObserverEvent(TOPIC_CONNECTION_STATE_CHANGED)
.then(function(aSubject) {
ok(aSubject instanceof Ci.nsIRilNetworkInterface,
"subject should be an instance of nsIRILNetworkInterface");
ok(aSubject instanceof Ci.nsIRilNetworkInfo,
"subject should be an instance of nsIRilNetworkInfo");
is(aSubject.type, aNetworkType,
"subject.type should be " + aNetworkType);
is(aSubject.state, Ci.nsINetworkInterface.NETWORK_STATE_DISCONNECTED,
is(aSubject.state, Ci.nsINetworkInfo.NETWORK_STATE_DISCONNECTED,
"subject.state should be DISCONNECTED");
}));
promises.push(radioInterface.deactivateDataCallByType(aNetworkType));

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

@ -13,8 +13,8 @@ function testInitialState() {
return getSettings(SETTINGS_KEY_DATA_ENABLED)
.then((enabled) => {
is(enabled, false, "data should be off by default");
is(networkManager.active, null,
"networkManager.active should be null by default");
is(networkManager.activeNetworkInfo, null,
"networkManager.activeNetworkInfo should be null by default");
});
}
@ -29,16 +29,16 @@ function testActiveNetworkChangedBySwitchingDataCall(aDataCallEnabled) {
let subject = results[0];
if (aDataCallEnabled) {
ok(subject instanceof Ci.nsINetworkInterface,
"subject should be an instance of nsINetworkInterface");
ok(subject instanceof Ci.nsIRilNetworkInterface,
"subject should be an instance of nsIRILNetworkInterface");
ok(subject instanceof Ci.nsINetworkInfo,
"subject should be an instance of nsINetworkInfo");
ok(subject instanceof Ci.nsIRilNetworkInfo,
"subject should be an instance of nsIRilNetworkInfo");
is(subject.type, NETWORK_TYPE_MOBILE,
"subject.type should be NETWORK_TYPE_MOBILE");
}
is(subject, networkManager.active,
"subject should be equal with networkManager.active");
is(subject, networkManager.activeNetworkInfo,
"subject should be equal with networkManager.activeNetworkInfo");
});
}

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

@ -4,7 +4,7 @@
MARIONETTE_TIMEOUT = 60000;
MARIONETTE_HEAD_JS = "head.js";
function getNetworkInterface(aType) {
function getNetworkInfo(aType) {
let networkListService =
Cc["@mozilla.org/network/interface-list-service;1"].
getService(Ci.nsINetworkInterfaceListService);
@ -14,9 +14,9 @@ function getNetworkInterface(aType) {
// Try to get nsINetworkInterface for aType.
let numberOfInterface = networkList.getNumberOfInterface();
for (let i = 0; i < numberOfInterface; i++) {
let iface = networkList.getInterface(i);
if (iface.type === aType) {
return iface;
let info = networkList.getInterfaceInfo(i);
if (info.type === aType) {
return info;
}
}
@ -29,27 +29,27 @@ function testGetDataInterfaceList(aMobileDataEnabled) {
aMobileDataEnabled ? "enabled" : "disabled");
return setDataEnabledAndWait(aMobileDataEnabled)
.then(() => getNetworkInterface(NETWORK_TYPE_MOBILE))
.then((networkInterface) => {
if (!networkInterface) {
ok(false, "Should get an valid nsINetworkInterface for mobile");
.then(() => getNetworkInfo(NETWORK_TYPE_MOBILE))
.then((networkInfo) => {
if (!networkInfo) {
ok(false, "Should get an valid nsINetworkInfo for mobile");
return;
}
ok(networkInterface instanceof Ci.nsINetworkInterface,
"networkInterface should be an instance of nsINetworkInterface");
ok(networkInfo instanceof Ci.nsINetworkInfo,
"networkInfo should be an instance of nsINetworkInfo");
let ipAddresses = {};
let prefixs = {};
let numOfGateways = {};
let numOfDnses = {};
let numOfIpAddresses = networkInterface.getAddresses(ipAddresses, prefixs);
let gateways = networkInterface.getGateways(numOfGateways);
let dnses = networkInterface.getDnses(numOfDnses);
let numOfIpAddresses = networkInfo.getAddresses(ipAddresses, prefixs);
let gateways = networkInfo.getGateways(numOfGateways);
let dnses = networkInfo.getDnses(numOfDnses);
if (aMobileDataEnabled) {
// Mobile data is enabled.
is(networkInterface.state, NETWORK_STATE_CONNECTED, "check state");
is(networkInfo.state, NETWORK_STATE_CONNECTED, "check state");
ok(numOfIpAddresses > 0, "check number of ipAddresses");
ok(ipAddresses.value.length > 0, "check ipAddresses.length");
ok(prefixs.value.length > 0, "check prefixs.length");
@ -60,7 +60,7 @@ function testGetDataInterfaceList(aMobileDataEnabled) {
ok(dnses.length > 0, "check dnses.length");
} else {
// Mobile data is disabled.
is(networkInterface.state, NETWORK_STATE_DISCONNECTED, "check state");
is(networkInfo.state, NETWORK_STATE_DISCONNECTED, "check state");
is(numOfIpAddresses, 0, "check number of ipAddresses");
is(ipAddresses.value.length, 0, "check ipAddresses.length");
is(prefixs.value.length, 0, "check prefixs.length");

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

@ -490,39 +490,44 @@ function P2pStateMachine(aP2pCommand, aNetUtil) {
let _p2pNetworkInterface = {
QueryInterface: XPCOMUtils.generateQI([Ci.nsINetworkInterface]),
state: Ci.nsINetworkInterface.NETWORK_STATE_DISCONNECTED,
type: Ci.nsINetworkInterface.NETWORK_TYPE_WIFI_P2P,
name: P2P_INTERFACE_NAME,
ips: [],
prefixLengths: [],
dnses: [],
gateways: [],
info: {
QueryInterface: XPCOMUtils.generateQI([Ci.nsINetworkInfo]),
state: Ci.nsINetworkInfo.NETWORK_STATE_DISCONNECTED,
type: Ci.nsINetworkInfo.NETWORK_TYPE_WIFI_P2P,
name: P2P_INTERFACE_NAME,
ips: [],
prefixLengths: [],
dnses: [],
gateways: [],
getAddresses: function (ips, prefixLengths) {
ips.value = this.ips.slice();
prefixLengths.value = this.prefixLengths.slice();
return this.ips.length;
},
getGateways: function (count) {
if (count) {
count.value = this.gateways.length;
}
return this.gateways.slice();
},
getDnses: function (count) {
if (count) {
count.value = this.dnses.length;
}
return this.dnses.slice();
}
},
httpProxyHost: null,
httpProxyPort: null,
// help
registered: false,
getAddresses: function (ips, prefixLengths) {
ips.value = this.ips.slice();
prefixLengths.value = this.prefixLengths.slice();
return this.ips.length;
},
getGateways: function (count) {
if (count) {
count.value = this.gateways.length;
}
return this.gateways.slice();
},
getDnses: function (count) {
if (count) {
count.value = this.dnses.length;
}
return this.dnses.slice();
}
registered: false
};
//---------------------------------------------------------
@ -1419,10 +1424,10 @@ function P2pStateMachine(aP2pCommand, aNetUtil) {
}
// Update p2p network interface.
_p2pNetworkInterface.state = Ci.nsINetworkInterface.NETWORK_STATE_CONNECTED;
_p2pNetworkInterface.ips = [GO_NETWORK_INTERFACE.ip];
_p2pNetworkInterface.prefixLengths = [GO_NETWORK_INTERFACE.maskLength];
_p2pNetworkInterface.gateways = [GO_NETWORK_INTERFACE.ip];
_p2pNetworkInterface.info.state = Ci.nsINetworkInfo.NETWORK_STATE_CONNECTED;
_p2pNetworkInterface.info.ips = [GO_NETWORK_INTERFACE.ip];
_p2pNetworkInterface.info.prefixLengths = [GO_NETWORK_INTERFACE.maskLength];
_p2pNetworkInterface.info.gateways = [GO_NETWORK_INTERFACE.ip];
handleP2pNetworkInterfaceStateChanged();
_groupInfo.networkInterface = _p2pNetworkInterface;
@ -1454,18 +1459,18 @@ function P2pStateMachine(aP2pCommand, aNetUtil) {
if (!maskLength) {
maskLength = 32; // max prefix for IPv4.
}
_p2pNetworkInterface.state = Ci.nsINetworkInterface.NETWORK_STATE_CONNECTED;
_p2pNetworkInterface.ips = [dhcpData.info.ipaddr_str];
_p2pNetworkInterface.prefixLengths = [maskLength];
_p2pNetworkInterface.info.state = Ci.nsINetworkInfo.NETWORK_STATE_CONNECTED;
_p2pNetworkInterface.info.ips = [dhcpData.info.ipaddr_str];
_p2pNetworkInterface.info.prefixLengths = [maskLength];
if (typeof dhcpData.info.dns1_str == "string" &&
dhcpData.info.dns1_str.length) {
_p2pNetworkInterface.dnses.push(dhcpData.info.dns1_str);
_p2pNetworkInterface.info.dnses.push(dhcpData.info.dns1_str);
}
if (typeof dhcpData.info.dns2_str == "string" &&
dhcpData.info.dns2_str.length) {
_p2pNetworkInterface.dnses.push(dhcpData.info.dns2_str);
_p2pNetworkInterface.info.dnses.push(dhcpData.info.dns2_str);
}
_p2pNetworkInterface.gateways = [dhcpData.info.gateway_str];
_p2pNetworkInterface.info.gateways = [dhcpData.info.gateway_str];
handleP2pNetworkInterfaceStateChanged();
_groupInfo.networkInterface = _p2pNetworkInterface;
@ -1476,11 +1481,11 @@ function P2pStateMachine(aP2pCommand, aNetUtil) {
}
function resetP2pNetworkInterface() {
_p2pNetworkInterface.state = Ci.nsINetworkInterface.NETWORK_STATE_DISCONNECTED;
_p2pNetworkInterface.ips = [];
_p2pNetworkInterface.prefixLengths = [];
_p2pNetworkInterface.dnses = [];
_p2pNetworkInterface.gateways = [];
_p2pNetworkInterface.info.state = Ci.nsINetworkInfo.NETWORK_STATE_DISCONNECTED;
_p2pNetworkInterface.info.ips = [];
_p2pNetworkInterface.info.prefixLengths = [];
_p2pNetworkInterface.info.dnses = [];
_p2pNetworkInterface.info.gateways = [];
}
function registerP2pNetworkInteface() {
@ -1523,7 +1528,7 @@ function P2pStateMachine(aP2pCommand, aNetUtil) {
}
// Update p2p network interface.
_p2pNetworkInterface.state = Ci.nsINetworkInterface.NETWORK_STATE_DISCONNECTED;
_p2pNetworkInterface.info.state = Ci.nsINetworkInfo.NETWORK_STATE_DISCONNECTED;
handleP2pNetworkInterfaceStateChanged();
if (P2P_ROLE_GO === aInfo.role) {

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

@ -403,8 +403,8 @@ var WifiManager = (function() {
WifiNetworkInterface.httpProxyHost = network.httpProxyHost;
WifiNetworkInterface.httpProxyPort = network.httpProxyPort;
if (WifiNetworkInterface.state ==
Ci.nsINetworkInterface.NETWORK_STATE_CONNECTED) {
if (WifiNetworkInterface.info.state ==
Ci.nsINetworkInfo.NETWORK_STATE_CONNECTED) {
gNetworkManager.updateNetworkInterface(WifiNetworkInterface);
}
}
@ -1014,16 +1014,17 @@ var WifiManager = (function() {
if (enabled) {
manager.state = "INITIALIZING";
// Register as network interface.
WifiNetworkInterface.name = manager.ifname;
WifiNetworkInterface.info.name = manager.ifname;
if (!WifiNetworkInterface.registered) {
gNetworkManager.registerNetworkInterface(WifiNetworkInterface);
WifiNetworkInterface.registered = true;
}
WifiNetworkInterface.state = Ci.nsINetworkInterface.NETWORK_STATE_DISCONNECTED;
WifiNetworkInterface.ips = [];
WifiNetworkInterface.prefixLengths = [];
WifiNetworkInterface.gateways = [];
WifiNetworkInterface.dnses = [];
WifiNetworkInterface.info.state =
Ci.nsINetworkInfo.NETWORK_STATE_DISCONNECTED;
WifiNetworkInterface.info.ips = [];
WifiNetworkInterface.info.prefixLengths = [];
WifiNetworkInterface.info.gateways = [];
WifiNetworkInterface.info.dnses = [];
gNetworkManager.updateNetworkInterface(WifiNetworkInterface);
prepareForStartup(function() {
@ -1168,8 +1169,10 @@ var WifiManager = (function() {
function doStartWifiTethering() {
cancelWaitForDriverReadyTimer();
WifiNetworkInterface.name = libcutils.property_get("wifi.tethering.interface", manager.ifname);
gTetheringService.setWifiTethering(enabled, WifiNetworkInterface,
WifiNetworkInterface.info.name =
libcutils.property_get("wifi.tethering.interface", manager.ifname);
gTetheringService.setWifiTethering(enabled,
WifiNetworkInterface.info.name,
configuration, function(result) {
if (result) {
manager.tetheringState = "UNINITIALIZED";
@ -1783,55 +1786,59 @@ let WifiNetworkInterface = {
// nsINetworkInterface
NETWORK_STATE_UNKNOWN: Ci.nsINetworkInterface.NETWORK_STATE_UNKNOWN,
NETWORK_STATE_CONNECTING: Ci.nsINetworkInterface.CONNECTING,
NETWORK_STATE_CONNECTED: Ci.nsINetworkInterface.CONNECTED,
NETWORK_STATE_DISCONNECTING: Ci.nsINetworkInterface.DISCONNECTING,
NETWORK_STATE_DISCONNECTED: Ci.nsINetworkInterface.DISCONNECTED,
NETWORK_STATE_UNKNOWN: Ci.nsINetworkInfo.NETWORK_STATE_UNKNOWN,
NETWORK_STATE_CONNECTING: Ci.nsINetworkInfo.CONNECTING,
NETWORK_STATE_CONNECTED: Ci.nsINetworkInfo.CONNECTED,
NETWORK_STATE_DISCONNECTING: Ci.nsINetworkInfo.DISCONNECTING,
NETWORK_STATE_DISCONNECTED: Ci.nsINetworkInfo.DISCONNECTED,
state: Ci.nsINetworkInterface.NETWORK_STATE_UNKNOWN,
NETWORK_TYPE_WIFI: Ci.nsINetworkInfo.NETWORK_TYPE_WIFI,
NETWORK_TYPE_MOBILE: Ci.nsINetworkInfo.NETWORK_TYPE_MOBILE,
NETWORK_TYPE_MOBILE_MMS: Ci.nsINetworkInfo.NETWORK_TYPE_MOBILE_MMS,
NETWORK_TYPE_MOBILE_SUPL: Ci.nsINetworkInfo.NETWORK_TYPE_MOBILE_SUPL,
NETWORK_TYPE_WIFI: Ci.nsINetworkInterface.NETWORK_TYPE_WIFI,
NETWORK_TYPE_MOBILE: Ci.nsINetworkInterface.NETWORK_TYPE_MOBILE,
NETWORK_TYPE_MOBILE_MMS: Ci.nsINetworkInterface.NETWORK_TYPE_MOBILE_MMS,
NETWORK_TYPE_MOBILE_SUPL: Ci.nsINetworkInterface.NETWORK_TYPE_MOBILE_SUPL,
info: {
QueryInterface: XPCOMUtils.generateQI([Ci.nsINetworkInfo]),
type: Ci.nsINetworkInterface.NETWORK_TYPE_WIFI,
state: Ci.nsINetworkInfo.NETWORK_STATE_UNKNOWN,
name: null,
type: Ci.nsINetworkInfo.NETWORK_TYPE_WIFI,
ips: [],
name: null,
prefixLengths: [],
ips: [],
dnses: [],
prefixLengths: [],
gateways: [],
dnses: [],
gateways: [],
getAddresses: function (ips, prefixLengths) {
ips.value = this.ips.slice();
prefixLengths.value = this.prefixLengths.slice();
return this.ips.length;
},
getGateways: function (count) {
if (count) {
count.value = this.gateways.length;
}
return this.gateways.slice();
},
getDnses: function (count) {
if (count) {
count.value = this.dnses.length;
}
return this.dnses.slice();
}
},
httpProxyHost: null,
httpProxyPort: null,
getAddresses: function (ips, prefixLengths) {
ips.value = this.ips.slice();
prefixLengths.value = this.prefixLengths.slice();
return this.ips.length;
},
getGateways: function (count) {
if (count) {
count.value = this.gateways.length;
}
return this.gateways.slice();
},
getDnses: function (count) {
if (count) {
count.value = this.dnses.length;
}
return this.dnses.slice();
}
httpProxyPort: null
};
function WifiScanResult() {}
@ -2252,8 +2259,8 @@ function WifiWorker() {
case "DISCONNECTED":
// wpa_supplicant may give us a "DISCONNECTED" event even if
// we are already in "DISCONNECTED" state.
if ((WifiNetworkInterface.state ===
Ci.nsINetworkInterface.NETWORK_STATE_DISCONNECTED) &&
if ((WifiNetworkInterface.info.state ===
Ci.nsINetworkInfo.NETWORK_STATE_DISCONNECTED) &&
(this.prevState === "INITIALIZING" ||
this.prevState === "DISCONNECTED" ||
this.prevState === "INTERFACE_DISABLED" ||
@ -2285,13 +2292,16 @@ function WifiWorker() {
}
});
WifiNetworkInterface.state =
Ci.nsINetworkInterface.NETWORK_STATE_DISCONNECTED;
WifiNetworkInterface.ips = [];
WifiNetworkInterface.prefixLengths = [];
WifiNetworkInterface.gateways = [];
WifiNetworkInterface.dnses = [];
WifiNetworkInterface.info.state =
Ci.nsINetworkInfo.NETWORK_STATE_DISCONNECTED;
// Update network infterface first then clear properties.
gNetworkManager.updateNetworkInterface(WifiNetworkInterface);
WifiNetworkInterface.info.ips = [];
WifiNetworkInterface.info.prefixLengths = [];
WifiNetworkInterface.info.gateways = [];
WifiNetworkInterface.info.dnses = [];
break;
case "WPS_TIMEOUT":
@ -2333,18 +2343,18 @@ function WifiWorker() {
WifiNetworkInterface.httpProxyPort = netConnect.httpProxyPort;
}
WifiNetworkInterface.state =
Ci.nsINetworkInterface.NETWORK_STATE_CONNECTED;
WifiNetworkInterface.ips = [this.info.ipaddr_str];
WifiNetworkInterface.prefixLengths = [maskLength];
WifiNetworkInterface.gateways = [this.info.gateway_str];
WifiNetworkInterface.info.state =
Ci.nsINetworkInfo.NETWORK_STATE_CONNECTED;
WifiNetworkInterface.info.ips = [this.info.ipaddr_str];
WifiNetworkInterface.info.prefixLengths = [maskLength];
WifiNetworkInterface.info.gateways = [this.info.gateway_str];
if (typeof this.info.dns1_str == "string" &&
this.info.dns1_str.length) {
WifiNetworkInterface.dnses.push(this.info.dns1_str);
WifiNetworkInterface.info.dnses.push(this.info.dns1_str);
}
if (typeof this.info.dns2_str == "string" &&
this.info.dns2_str.length) {
WifiNetworkInterface.dnses.push(this.info.dns2_str);
WifiNetworkInterface.info.dnses.push(this.info.dns2_str);
}
gNetworkManager.updateNetworkInterface(WifiNetworkInterface);

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

@ -12,7 +12,7 @@ extern "C" {
#include <vector>
#include <string>
#include "nsINetworkManager.h"
#include "nsINetworkInterface.h"
#include "nsINetworkInterfaceListService.h"
#include "runnable_utils.h"
#include "nsCOMPtr.h"
@ -58,8 +58,8 @@ GetInterfaces(std::vector<NetworkInterface>* aInterfaces)
aInterfaces->clear();
for (int32_t i = 0; i < listLength; i++) {
nsCOMPtr<nsINetworkInterface> iface;
if (NS_FAILED(networkList->GetInterface(i, getter_AddRefs(iface)))) {
nsCOMPtr<nsINetworkInfo> info;
if (NS_FAILED(networkList->GetInterfaceInfo(i, getter_AddRefs(info)))) {
continue;
}
@ -71,7 +71,7 @@ GetInterfaces(std::vector<NetworkInterface>* aInterfaces)
memset(&(interface.addr), 0, sizeof(interface.addr));
interface.addr.sin_family = AF_INET;
if (NS_FAILED(iface->GetAddresses(&ips, &prefixs, &count))) {
if (NS_FAILED(info->GetAddresses(&ips, &prefixs, &count))) {
continue;
}
@ -94,20 +94,20 @@ GetInterfaces(std::vector<NetworkInterface>* aInterfaces)
}
nsAutoString ifaceName;
if (NS_FAILED(iface->GetName(ifaceName))) {
if (NS_FAILED(info->GetName(ifaceName))) {
continue;
}
interface.name = NS_ConvertUTF16toUTF8(ifaceName).get();
int32_t type;
if (NS_FAILED(iface->GetType(&type))) {
if (NS_FAILED(info->GetType(&type))) {
continue;
}
switch (type) {
case nsINetworkInterface::NETWORK_TYPE_WIFI:
case nsINetworkInfo::NETWORK_TYPE_WIFI:
interface.type = NR_INTERFACE_TYPE_WIFI;
break;
case nsINetworkInterface::NETWORK_TYPE_MOBILE:
case nsINetworkInfo::NETWORK_TYPE_MOBILE:
interface.type = NR_INTERFACE_TYPE_MOBILE;
break;
}

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

@ -11,6 +11,7 @@
#include "nsCOMPtr.h"
#include "nsError.h"
#include "nsINetworkInterface.h"
#include "nsINetworkManager.h"
#include "nsINetworkStatsServiceProxy.h"
#include "nsThreadUtils.h"
@ -24,7 +25,7 @@ const static uint64_t NETWORK_STATS_THRESHOLD = 65536;
const static char NETWORK_STATS_NO_SERVICE_TYPE[] = "";
inline nsresult
GetActiveNetworkInterface(nsCOMPtr<nsINetworkInterface> &aNetworkInterface)
GetActiveNetworkInfo(nsCOMPtr<nsINetworkInfo> &aNetworkInfo)
{
MOZ_ASSERT(NS_IsMainThread());
@ -33,11 +34,11 @@ GetActiveNetworkInterface(nsCOMPtr<nsINetworkInterface> &aNetworkInterface)
do_GetService("@mozilla.org/network/manager;1", &rv);
if (NS_FAILED(rv) || !networkManager) {
aNetworkInterface = nullptr;
aNetworkInfo = nullptr;
return rv;
}
networkManager->GetActive(getter_AddRefs(aNetworkInterface));
networkManager->GetActiveNetworkInfo(getter_AddRefs(aNetworkInfo));
return NS_OK;
}
@ -46,19 +47,19 @@ class SaveNetworkStatsEvent : public nsRunnable {
public:
SaveNetworkStatsEvent(uint32_t aAppId,
bool aIsInBrowser,
nsMainThreadPtrHandle<nsINetworkInterface> &aActiveNetwork,
nsMainThreadPtrHandle<nsINetworkInfo> &aActiveNetworkInfo,
uint64_t aCountRecv,
uint64_t aCountSent,
bool aIsAccumulative)
: mAppId(aAppId),
mIsInBrowser(aIsInBrowser),
mActiveNetwork(aActiveNetwork),
mActiveNetworkInfo(aActiveNetworkInfo),
mCountRecv(aCountRecv),
mCountSent(aCountSent),
mIsAccumulative(aIsAccumulative)
{
MOZ_ASSERT(mAppId != NECKO_NO_APP_ID);
MOZ_ASSERT(mActiveNetwork);
MOZ_ASSERT(mActiveNetworkInfo);
}
NS_IMETHOD Run()
@ -75,7 +76,7 @@ public:
// save the network stats through NetworkStatsServiceProxy
mNetworkStatsServiceProxy->SaveAppStats(mAppId,
mIsInBrowser,
mActiveNetwork,
mActiveNetworkInfo,
PR_Now() / 1000,
mCountRecv,
mCountSent,
@ -87,7 +88,7 @@ public:
private:
uint32_t mAppId;
bool mIsInBrowser;
nsMainThreadPtrHandle<nsINetworkInterface> mActiveNetwork;
nsMainThreadPtrHandle<nsINetworkInfo> mActiveNetworkInfo;
uint64_t mCountRecv;
uint64_t mCountSent;
bool mIsAccumulative;

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

@ -49,6 +49,7 @@
#ifdef MOZ_WIDGET_GONK
#include "nsINetworkManager.h"
#include "nsINetworkInterface.h"
#endif
#if defined(XP_WIN)
@ -1321,18 +1322,18 @@ IsWifiActive()
if (!networkManager) {
return false;
}
nsCOMPtr<nsINetworkInterface> active;
networkManager->GetActive(getter_AddRefs(active));
if (!active) {
nsCOMPtr<nsINetworkInfo> activeNetworkInfo;
networkManager->GetActiveNetworkInfo(getter_AddRefs(activeNetworkInfo));
if (!activeNetworkInfo) {
return false;
}
int32_t type;
if (NS_FAILED(active->GetType(&type))) {
if (NS_FAILED(activeNetworkInfo->GetType(&type))) {
return false;
}
switch (type) {
case nsINetworkInterface::NETWORK_TYPE_WIFI:
case nsINetworkInterface::NETWORK_TYPE_WIFI_P2P:
case nsINetworkInfo::NETWORK_TYPE_WIFI:
case nsINetworkInfo::NETWORK_TYPE_WIFI_P2P:
return true;
default:
return false;
@ -1433,7 +1434,7 @@ nsIOService::Observe(nsISupports *subject,
if (IsNeckoChild()) {
return NS_OK;
}
nsCOMPtr<nsINetworkInterface> interface = do_QueryInterface(subject);
nsCOMPtr<nsINetworkInfo> interface = do_QueryInterface(subject);
if (!interface) {
return NS_ERROR_FAILURE;
}
@ -1444,8 +1445,8 @@ nsIOService::Observe(nsISupports *subject,
bool wifiActive = IsWifiActive();
int32_t newWifiState = wifiActive ?
nsINetworkInterface::NETWORK_TYPE_WIFI :
nsINetworkInterface::NETWORK_TYPE_MOBILE;
nsINetworkInfo::NETWORK_TYPE_WIFI :
nsINetworkInfo::NETWORK_TYPE_MOBILE;
if (mPreviousWifiState != newWifiState) {
// Notify wifi-only apps of their new status
int32_t status = wifiActive ?

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

@ -811,10 +811,10 @@ nsUDPSocket::InitWithAddress(const NetAddr *aAddr, nsIPrincipal *aPrincipal,
#ifdef MOZ_WIDGET_GONK
if (mAppId != NECKO_UNKNOWN_APP_ID) {
nsCOMPtr<nsINetworkInterface> activeNetwork;
GetActiveNetworkInterface(activeNetwork);
mActiveNetwork =
new nsMainThreadPtrHolder<nsINetworkInterface>(activeNetwork);
nsCOMPtr<nsINetworkInfo> activeNetworkInfo;
GetActiveNetworkInfo(activeNetworkInfo);
mActiveNetworkInfo =
new nsMainThreadPtrHolder<nsINetworkInfo>(activeNetworkInfo);
}
#endif
@ -918,7 +918,7 @@ void
nsUDPSocket::SaveNetworkStats(bool aEnforce)
{
#ifdef MOZ_WIDGET_GONK
if (!mActiveNetwork || mAppId == NECKO_UNKNOWN_APP_ID) {
if (!mActiveNetworkInfo || mAppId == NECKO_UNKNOWN_APP_ID) {
return;
}
@ -931,7 +931,7 @@ nsUDPSocket::SaveNetworkStats(bool aEnforce)
// Create the event to save the network statistics.
// the event is then dispathed to the main thread.
nsRefPtr<nsRunnable> event =
new SaveNetworkStatsEvent(mAppId, mIsInBrowserElement, mActiveNetwork,
new SaveNetworkStatsEvent(mAppId, mIsInBrowserElement, mActiveNetworkInfo,
mByteReadCount, mByteWriteCount, false);
NS_DispatchToMainThread(event);

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

@ -13,7 +13,7 @@
#include "nsCycleCollectionParticipant.h"
#ifdef MOZ_WIDGET_GONK
#include "nsINetworkManager.h"
#include "nsINetworkInterface.h"
#include "nsProxyRelease.h"
#endif
@ -72,7 +72,7 @@ private:
uint64_t mByteReadCount;
uint64_t mByteWriteCount;
#ifdef MOZ_WIDGET_GONK
nsMainThreadPtrHandle<nsINetworkInterface> mActiveNetwork;
nsMainThreadPtrHandle<nsINetworkInfo> mActiveNetworkInfo;
#endif
};

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

@ -1617,10 +1617,10 @@ nsFtpState::Init(nsFtpChannel *channel)
mCountRecv = 0;
#ifdef MOZ_WIDGET_GONK
nsCOMPtr<nsINetworkInterface> activeNetwork;
GetActiveNetworkInterface(activeNetwork);
mActiveNetwork =
new nsMainThreadPtrHolder<nsINetworkInterface>(activeNetwork);
nsCOMPtr<nsINetworkInfo> activeNetworkInfo;
GetActiveNetworkInfo(activeNetworkInfo);
mActiveNetworkInfo =
new nsMainThreadPtrHolder<nsINetworkInfo>(activeNetworkInfo);
#endif
mKeepRunning = true;
@ -2105,7 +2105,7 @@ nsFtpState::SaveNetworkStats(bool enforce)
NS_GetAppInfo(mChannel, &appId, &isInBrowser);
// Check if active network and appid are valid.
if (!mActiveNetwork || appId == NECKO_NO_APP_ID) {
if (!mActiveNetworkInfo || appId == NECKO_NO_APP_ID) {
return NS_OK;
}
@ -2124,7 +2124,7 @@ nsFtpState::SaveNetworkStats(bool enforce)
// Create the event to save the network statistics.
// the event is then dispathed to the main thread.
nsRefPtr<nsRunnable> event =
new SaveNetworkStatsEvent(appId, isInBrowser, mActiveNetwork,
new SaveNetworkStatsEvent(appId, isInBrowser, mActiveNetworkInfo,
mCountRecv, 0, false);
NS_DispatchToMainThread(event);

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

@ -18,7 +18,7 @@
#include "nsIProtocolProxyCallback.h"
#ifdef MOZ_WIDGET_GONK
#include "nsINetworkManager.h"
#include "nsINetworkInterface.h"
#include "nsProxyRelease.h"
#endif
@ -218,7 +218,7 @@ private:
// Currently, they are only available on gonk.
uint64_t mCountRecv;
#ifdef MOZ_WIDGET_GONK
nsMainThreadPtrHandle<nsINetworkInterface> mActiveNetwork;
nsMainThreadPtrHandle<nsINetworkInfo> mActiveNetworkInfo;
#endif
nsresult SaveNetworkStats(bool);
void CountRecvBytes(uint64_t recvBytes)

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

@ -252,10 +252,10 @@ nsHttpTransaction::Init(uint32_t caps,
#ifdef MOZ_WIDGET_GONK
if (mAppId != NECKO_NO_APP_ID) {
nsCOMPtr<nsINetworkInterface> activeNetwork;
GetActiveNetworkInterface(activeNetwork);
mActiveNetwork =
new nsMainThreadPtrHolder<nsINetworkInterface>(activeNetwork);
nsCOMPtr<nsINetworkInfo> activeNetworkInfo;
GetActiveNetworkInfo(activeNetworkInfo);
mActiveNetworkInfo =
new nsMainThreadPtrHolder<nsINetworkInfo>(activeNetworkInfo);
}
#endif
@ -823,7 +823,7 @@ nsHttpTransaction::SaveNetworkStats(bool enforce)
{
#ifdef MOZ_WIDGET_GONK
// Check if active network and appid are valid.
if (!mActiveNetwork || mAppId == NECKO_NO_APP_ID) {
if (!mActiveNetworkInfo || mAppId == NECKO_NO_APP_ID) {
return NS_OK;
}
@ -843,7 +843,7 @@ nsHttpTransaction::SaveNetworkStats(bool enforce)
// Create the event to save the network statistics.
// the event is then dispathed to the main thread.
nsRefPtr<nsRunnable> event =
new SaveNetworkStatsEvent(mAppId, mIsInBrowser, mActiveNetwork,
new SaveNetworkStatsEvent(mAppId, mIsInBrowser, mActiveNetworkInfo,
mCountRecv, mCountSent, false);
NS_DispatchToMainThread(event);

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

@ -19,7 +19,7 @@
#include "mozilla/net/DNS.h"
#ifdef MOZ_WIDGET_GONK
#include "nsINetworkManager.h"
#include "nsINetworkInterface.h"
#include "nsProxyRelease.h"
#endif
@ -408,7 +408,7 @@ private:
uint32_t mAppId;
bool mIsInBrowser;
#ifdef MOZ_WIDGET_GONK
nsMainThreadPtrHandle<nsINetworkInterface> mActiveNetwork;
nsMainThreadPtrHandle<nsINetworkInfo> mActiveNetworkInfo;
#endif
nsresult SaveNetworkStats(bool);
void CountRecvBytes(uint64_t recvBytes)

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

@ -1376,10 +1376,10 @@ WebSocketChannel::BeginOpenInternal()
#ifdef MOZ_WIDGET_GONK
if (mAppId != NECKO_NO_APP_ID) {
nsCOMPtr<nsINetworkInterface> activeNetwork;
GetActiveNetworkInterface(activeNetwork);
mActiveNetwork =
new nsMainThreadPtrHolder<nsINetworkInterface>(activeNetwork);
nsCOMPtr<nsINetworkInfo> activeNetworkInfo;
GetActiveNetworkInfo(activeNetworkInfo);
mActiveNetworkInfo =
new nsMainThreadPtrHolder<nsINetworkInfo>(activeNetworkInfo);
}
#endif
@ -3709,7 +3709,7 @@ WebSocketChannel::SaveNetworkStats(bool enforce)
{
#ifdef MOZ_WIDGET_GONK
// Check if the active network and app id are valid.
if(!mActiveNetwork || mAppId == NECKO_NO_APP_ID) {
if(!mActiveNetworkInfo || mAppId == NECKO_NO_APP_ID) {
return NS_OK;
}
@ -3735,7 +3735,7 @@ WebSocketChannel::SaveNetworkStats(bool enforce)
// Create the event to save the network statistics.
// the event is then dispathed to the main thread.
nsRefPtr<nsRunnable> event =
new SaveNetworkStatsEvent(mAppId, mIsInBrowser, mActiveNetwork,
new SaveNetworkStatsEvent(mAppId, mIsInBrowser, mActiveNetworkInfo,
countRecv, countSent, false);
NS_DispatchToMainThread(event);

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

@ -22,7 +22,7 @@
#include "BaseWebSocketChannel.h"
#ifdef MOZ_WIDGET_GONK
#include "nsINetworkManager.h"
#include "nsINetworkInterface.h"
#include "nsProxyRelease.h"
#endif
@ -291,7 +291,7 @@ private:
uint32_t mAppId;
bool mIsInBrowser;
#ifdef MOZ_WIDGET_GONK
nsMainThreadPtrHandle<nsINetworkInterface> mActiveNetwork;
nsMainThreadPtrHandle<nsINetworkInfo> mActiveNetworkInfo;
#endif
nsresult SaveNetworkStats(bool);
void CountRecvBytes(uint64_t recvBytes)

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

@ -1,4 +1,4 @@
{
"repo": "https://hg.mozilla.org/build/mozharness",
"revision": "672af8a8da3e"
"revision": "d72df953784c"
}

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

@ -48,6 +48,7 @@ class GaiaIntegrationTest(GaiaTest):
if os.path.exists(gaia_runner_service):
self.install_module('gaia-runner-service', gaia_runner_service)
env['VIRTUALENV_PATH'] = self.query_virtualenv_path()
env['HOST_LOG'] = os.path.join(dirs['abs_log_dir'], 'gecko_output.log')
cmd = [
'make',

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

@ -385,16 +385,16 @@ Discovery.prototype = {
if (topic !== "network-active-changed") {
return;
}
let activeNetwork = subject;
if (!activeNetwork) {
log("No active network");
let activeNetworkInfo = subject;
if (!activeNetworkInfo) {
log("No active network info");
return;
}
activeNetwork = activeNetwork.QueryInterface(Ci.nsINetworkInterface);
log("Active network changed to: " + activeNetwork.type);
activeNetworkInfo = activeNetworkInfo.QueryInterface(Ci.nsINetworkInfo);
log("Active network changed to: " + activeNetworkInfo.type);
// UDP sockets go down when the device goes offline, so we'll restart them
// when the active network goes back to WiFi.
if (activeNetwork.type === Ci.nsINetworkInterface.NETWORK_TYPE_WIFI) {
if (activeNetworkInfo.type === Ci.nsINetworkInfo.NETWORK_TYPE_WIFI) {
this._restartListening();
}
},