Bug 920551 - 2.h/2: fix dom/system/gonk/*. r=hsinyi,khuey

This commit is contained in:
Vicamo Yang 2013-10-29 16:12:45 +08:00
parent f5509134f6
commit 3eb62fc290
22 changed files with 336 additions and 266 deletions

View File

@ -430,7 +430,7 @@ pref("services.push.requestTimeout", 10000);
pref("services.push.udp.wakeupEnabled", true); pref("services.push.udp.wakeupEnabled", true);
// NetworkStats // NetworkStats
#ifdef MOZ_B2G_RIL #ifdef MOZ_WIDGET_GONK
pref("dom.mozNetworkStats.enabled", true); pref("dom.mozNetworkStats.enabled", true);
pref("dom.webapps.firstRunWithSIM", true); pref("dom.webapps.firstRunWithSIM", true);
#endif #endif

View File

@ -18,7 +18,7 @@ Cu.import("resource://gre/modules/AppsUtils.jsm");
Cu.import('resource://gre/modules/UserAgentOverrides.jsm'); Cu.import('resource://gre/modules/UserAgentOverrides.jsm');
Cu.import('resource://gre/modules/Keyboard.jsm'); Cu.import('resource://gre/modules/Keyboard.jsm');
Cu.import('resource://gre/modules/ErrorPage.jsm'); Cu.import('resource://gre/modules/ErrorPage.jsm');
#ifdef MOZ_B2G_RIL #ifdef MOZ_WIDGET_GONK
Cu.import('resource://gre/modules/NetworkStatsService.jsm'); Cu.import('resource://gre/modules/NetworkStatsService.jsm');
#endif #endif
@ -611,7 +611,7 @@ var shell = {
this.sendEvent(window, 'ContentStart'); this.sendEvent(window, 'ContentStart');
#ifdef MOZ_B2G_RIL #ifdef MOZ_WIDGET_GONK
Cu.import('resource://gre/modules/OperatorApps.jsm'); Cu.import('resource://gre/modules/OperatorApps.jsm');
#endif #endif

View File

@ -164,10 +164,12 @@
@BINPATH@/components/dom_audiochannel.xpt @BINPATH@/components/dom_audiochannel.xpt
@BINPATH@/components/dom_base.xpt @BINPATH@/components/dom_base.xpt
@BINPATH@/components/dom_system.xpt @BINPATH@/components/dom_system.xpt
#ifdef MOZ_B2G_RIL #ifdef MOZ_WIDGET_GONK
@BINPATH@/components/dom_voicemail.xpt
@BINPATH@/components/dom_wifi.xpt @BINPATH@/components/dom_wifi.xpt
@BINPATH@/components/dom_system_gonk.xpt @BINPATH@/components/dom_system_gonk.xpt
#endif
#ifdef MOZ_B2G_RIL
@BINPATH@/components/dom_voicemail.xpt
@BINPATH@/components/dom_icc.xpt @BINPATH@/components/dom_icc.xpt
@BINPATH@/components/dom_cellbroadcast.xpt @BINPATH@/components/dom_cellbroadcast.xpt
@BINPATH@/components/dom_wappush.xpt @BINPATH@/components/dom_wappush.xpt
@ -400,11 +402,31 @@
@BINPATH@/components/nsSidebar.manifest @BINPATH@/components/nsSidebar.manifest
@BINPATH@/components/nsSidebar.js @BINPATH@/components/nsSidebar.js
; WiFi, NetworkManager, NetworkStats
#ifdef MOZ_WIDGET_GONK
@BINPATH@/components/DOMWifiManager.js
@BINPATH@/components/DOMWifiManager.manifest
@BINPATH@/components/NetworkInterfaceListService.js
@BINPATH@/components/NetworkInterfaceListService.manifest
@BINPATH@/components/NetworkManager.js
@BINPATH@/components/NetworkManager.manifest
@BINPATH@/components/NetworkStatsManager.js
@BINPATH@/components/NetworkStatsManager.manifest
@BINPATH@/components/NetworkStatsServiceProxy.js
@BINPATH@/components/NetworkStatsServiceProxy.manifest
@BINPATH@/components/WifiWorker.js
@BINPATH@/components/WifiWorker.manifest
#endif // MOZ_WIDGET_GONK
; RIL
#if defined(MOZ_WIDGET_GONK) && defined(MOZ_B2G_RIL) #if defined(MOZ_WIDGET_GONK) && defined(MOZ_B2G_RIL)
@BINPATH@/components/MmsService.js @BINPATH@/components/MmsService.js
@BINPATH@/components/MmsService.manifest @BINPATH@/components/MmsService.manifest
@BINPATH@/components/MobileMessageDatabaseService.js @BINPATH@/components/MobileMessageDatabaseService.js
@BINPATH@/components/MobileMessageDatabaseService.manifest @BINPATH@/components/MobileMessageDatabaseService.manifest
@BINPATH@/components/RadioInterfaceLayer.js
@BINPATH@/components/RadioInterfaceLayer.manifest
@BINPATH@/components/RILContentHelper.js
@BINPATH@/components/TelephonyProvider.js @BINPATH@/components/TelephonyProvider.js
@BINPATH@/components/TelephonyProvider.manifest @BINPATH@/components/TelephonyProvider.manifest
#endif // MOZ_WIDGET_GONK && MOZ_B2G_RIL #endif // MOZ_WIDGET_GONK && MOZ_B2G_RIL
@ -474,23 +496,6 @@
@BINPATH@/components/webvtt.xpt @BINPATH@/components/webvtt.xpt
@BINPATH@/components/WebVTT.manifest @BINPATH@/components/WebVTT.manifest
@BINPATH@/components/WebVTTParserWrapper.js @BINPATH@/components/WebVTTParserWrapper.js
#ifdef MOZ_B2G_RIL
@BINPATH@/components/NetworkManager.manifest
@BINPATH@/components/NetworkManager.js
@BINPATH@/components/RadioInterfaceLayer.manifest
@BINPATH@/components/RadioInterfaceLayer.js
@BINPATH@/components/RILContentHelper.js
@BINPATH@/components/WifiWorker.js
@BINPATH@/components/WifiWorker.manifest
@BINPATH@/components/DOMWifiManager.js
@BINPATH@/components/DOMWifiManager.manifest
@BINPATH@/components/NetworkStatsManager.js
@BINPATH@/components/NetworkStatsManager.manifest
@BINPATH@/components/NetworkInterfaceListService.manifest
@BINPATH@/components/NetworkInterfaceListService.js
@BINPATH@/components/NetworkStatsServiceProxy.manifest
@BINPATH@/components/NetworkStatsServiceProxy.js
#endif
#ifdef MOZ_ENABLE_DBUS #ifdef MOZ_ENABLE_DBUS
@BINPATH@/components/@DLL_PREFIX@dbusservice@DLL_SUFFIX@ @BINPATH@/components/@DLL_PREFIX@dbusservice@DLL_SUFFIX@
#endif #endif

View File

@ -18,7 +18,7 @@ LOCAL_INCLUDES += \
-I$(srcdir)/../../../layout/xul/tree/ \ -I$(srcdir)/../../../layout/xul/tree/ \
$(NULL) $(NULL)
ifdef MOZ_B2G_RIL ifeq (gonk,$(MOZ_WIDGET_TOOLKIT))
LOCAL_INCLUDES += \ LOCAL_INCLUDES += \
-I$(srcdir)/../../../dom/wifi \ -I$(srcdir)/../../../dom/wifi \
$(NULL) $(NULL)

View File

@ -143,7 +143,7 @@ LOCAL_INCLUDES += [
'/layout/xul/base/src', '/layout/xul/base/src',
] ]
if CONFIG['MOZ_B2G_RIL']: if CONFIG['MOZ_WIDGET_TOOLKIT'] == 'gonk':
LOCAL_INCLUDES += [ LOCAL_INCLUDES += [
'../fmradio', '../fmradio',
'../system/gonk', '../system/gonk',

View File

@ -80,9 +80,11 @@ PARALLEL_DIRS += [
if CONFIG['OS_ARCH'] == 'WINNT': if CONFIG['OS_ARCH'] == 'WINNT':
PARALLEL_DIRS += ['plugins/ipc/hangui'] PARALLEL_DIRS += ['plugins/ipc/hangui']
if CONFIG['MOZ_WIDGET_TOOLKIT'] == 'gonk':
PARALLEL_DIRS += ['wifi']
if CONFIG['MOZ_B2G_RIL']: if CONFIG['MOZ_B2G_RIL']:
PARALLEL_DIRS += [ PARALLEL_DIRS += [
'wifi',
'icc', 'icc',
'cellbroadcast', 'cellbroadcast',
'voicemail', 'voicemail',

View File

@ -22,10 +22,14 @@ if CONFIG['MOZ_B2G_RIL']:
'nsIDOMMobileConnection.idl', 'nsIDOMMobileConnection.idl',
'nsIDOMMozEmergencyCbModeEvent.idl', 'nsIDOMMozEmergencyCbModeEvent.idl',
'nsIDOMMozOtaStatusEvent.idl', 'nsIDOMMozOtaStatusEvent.idl',
'nsIDOMNetworkStats.idl',
'nsIDOMNetworkStatsManager.idl',
'nsIDOMUSSDReceivedEvent.idl', 'nsIDOMUSSDReceivedEvent.idl',
'nsIMobileConnectionProvider.idl', 'nsIMobileConnectionProvider.idl',
]
if CONFIG['MOZ_WIDGET_TOOLKIT'] == 'gonk':
XPIDL_SOURCES += [
'nsIDOMNetworkStats.idl',
'nsIDOMNetworkStatsManager.idl',
'nsINetworkStatsServiceProxy.idl', 'nsINetworkStatsServiceProxy.idl',
] ]

View File

@ -28,6 +28,8 @@ if CONFIG['MOZ_B2G_RIL']:
SOURCES += [ SOURCES += [
'MobileConnection.cpp', 'MobileConnection.cpp',
] ]
if CONFIG['MOZ_WIDGET_TOOLKIT'] == 'gonk':
EXTRA_JS_MODULES = [ EXTRA_JS_MODULES = [
'NetworkStatsDB.jsm', 'NetworkStatsDB.jsm',
'NetworkStatsService.jsm', 'NetworkStatsService.jsm',
@ -43,7 +45,7 @@ EXTRA_PP_COMPONENTS += [
'TCPSocket.js', 'TCPSocket.js',
] ]
if CONFIG['MOZ_B2G_RIL']: if CONFIG['MOZ_WIDGET_TOOLKIT'] == 'gonk':
EXTRA_COMPONENTS += [ EXTRA_COMPONENTS += [
'NetworkStatsManager.js', 'NetworkStatsManager.js',
'NetworkStatsManager.manifest', 'NetworkStatsManager.manifest',

View File

@ -9,7 +9,7 @@ MOCHITEST_FILES = \
test_tcpsocket_enabled_with_perm.html \ test_tcpsocket_enabled_with_perm.html \
$(NULL) $(NULL)
ifdef MOZ_B2G_RIL ifeq (gonk,$(MOZ_WIDGET_TOOLKIT))
MOCHITEST_FILES = \ MOCHITEST_FILES = \
test_networkstats_basics.html \ test_networkstats_basics.html \
test_networkstats_disabled.html \ test_networkstats_disabled.html \

View File

@ -133,8 +133,10 @@ function defineLazyRegExp(obj, name, pattern) {
function NetworkManager() { function NetworkManager() {
this.networkInterfaces = {}; this.networkInterfaces = {};
Services.obs.addObserver(this, TOPIC_INTERFACE_STATE_CHANGED, true); Services.obs.addObserver(this, TOPIC_INTERFACE_STATE_CHANGED, true);
#ifdef MOZ_B2G_RIL
Services.obs.addObserver(this, TOPIC_INTERFACE_REGISTERED, true); Services.obs.addObserver(this, TOPIC_INTERFACE_REGISTERED, true);
Services.obs.addObserver(this, TOPIC_INTERFACE_UNREGISTERED, true); Services.obs.addObserver(this, TOPIC_INTERFACE_UNREGISTERED, true);
#endif
Services.obs.addObserver(this, TOPIC_XPCOM_SHUTDOWN, false); Services.obs.addObserver(this, TOPIC_XPCOM_SHUTDOWN, false);
Services.obs.addObserver(this, TOPIC_MOZSETTINGS_CHANGED, false); Services.obs.addObserver(this, TOPIC_MOZSETTINGS_CHANGED, false);
@ -229,6 +231,7 @@ NetworkManager.prototype = {
debug("Network " + network.name + " changed state to " + network.state); debug("Network " + network.name + " changed state to " + network.state);
switch (network.state) { switch (network.state) {
case Ci.nsINetworkInterface.NETWORK_STATE_CONNECTED: case Ci.nsINetworkInterface.NETWORK_STATE_CONNECTED:
#ifdef MOZ_B2G_RIL
// Add host route for data calls // Add host route for data calls
if (network.type == Ci.nsINetworkInterface.NETWORK_TYPE_MOBILE || if (network.type == Ci.nsINetworkInterface.NETWORK_TYPE_MOBILE ||
network.type == Ci.nsINetworkInterface.NETWORK_TYPE_MOBILE_MMS || network.type == Ci.nsINetworkInterface.NETWORK_TYPE_MOBILE_MMS ||
@ -238,16 +241,19 @@ NetworkManager.prototype = {
} }
// Add extra host route. For example, mms proxy or mmsc. // Add extra host route. For example, mms proxy or mmsc.
this.setExtraHostRoute(network); this.setExtraHostRoute(network);
#endif
// Remove pre-created default route and let setAndConfigureActive() // Remove pre-created default route and let setAndConfigureActive()
// to set default route only on preferred network // to set default route only on preferred network
this.removeDefaultRoute(network.name); this.removeDefaultRoute(network.name);
this.setAndConfigureActive(); this.setAndConfigureActive();
#ifdef MOZ_B2G_RIL
// Update data connection when Wifi connected/disconnected // Update data connection when Wifi connected/disconnected
if (network.type == Ci.nsINetworkInterface.NETWORK_TYPE_WIFI) { if (network.type == Ci.nsINetworkInterface.NETWORK_TYPE_WIFI) {
for (let i = 0; i < this.mRIL.numRadioInterfaces; i++) { for (let i = 0; i < this.mRIL.numRadioInterfaces; i++) {
this.mRIL.getRadioInterface(i).updateRILNetworkInterface(); this.mRIL.getRadioInterface(i).updateRILNetworkInterface();
} }
} }
#endif
this.onConnectionChanged(network); this.onConnectionChanged(network);
@ -255,6 +261,7 @@ NetworkManager.prototype = {
CaptivePortalDetectionHelper.notify(CaptivePortalDetectionHelper.EVENT_CONNECT, this.active); CaptivePortalDetectionHelper.notify(CaptivePortalDetectionHelper.EVENT_CONNECT, this.active);
break; break;
case Ci.nsINetworkInterface.NETWORK_STATE_DISCONNECTED: case Ci.nsINetworkInterface.NETWORK_STATE_DISCONNECTED:
#ifdef MOZ_B2G_RIL
// Remove host route for data calls // Remove host route for data calls
if (network.type == Ci.nsINetworkInterface.NETWORK_TYPE_MOBILE || if (network.type == Ci.nsINetworkInterface.NETWORK_TYPE_MOBILE ||
network.type == Ci.nsINetworkInterface.NETWORK_TYPE_MOBILE_MMS || network.type == Ci.nsINetworkInterface.NETWORK_TYPE_MOBILE_MMS ||
@ -263,24 +270,30 @@ NetworkManager.prototype = {
} }
// Remove extra host route. For example, mms proxy or mmsc. // Remove extra host route. For example, mms proxy or mmsc.
this.removeExtraHostRoute(network); this.removeExtraHostRoute(network);
#endif
// Remove routing table in /proc/net/route // Remove routing table in /proc/net/route
if (network.type == Ci.nsINetworkInterface.NETWORK_TYPE_WIFI) { if (network.type == Ci.nsINetworkInterface.NETWORK_TYPE_WIFI) {
this.resetRoutingTable(network); this.resetRoutingTable(network);
#ifdef MOZ_B2G_RIL
} else if (network.type == Ci.nsINetworkInterface.NETWORK_TYPE_MOBILE) { } else if (network.type == Ci.nsINetworkInterface.NETWORK_TYPE_MOBILE) {
this.removeDefaultRoute(network.name); this.removeDefaultRoute(network.name);
#endif
} }
// Abort ongoing captive portal detection on the wifi interface // Abort ongoing captive portal detection on the wifi interface
CaptivePortalDetectionHelper.notify(CaptivePortalDetectionHelper.EVENT_DISCONNECT, network); CaptivePortalDetectionHelper.notify(CaptivePortalDetectionHelper.EVENT_DISCONNECT, network);
this.setAndConfigureActive(); this.setAndConfigureActive();
#ifdef MOZ_B2G_RIL
// Update data connection when Wifi connected/disconnected // Update data connection when Wifi connected/disconnected
if (network.type == Ci.nsINetworkInterface.NETWORK_TYPE_WIFI) { if (network.type == Ci.nsINetworkInterface.NETWORK_TYPE_WIFI) {
for (let i = 0; i < this.mRIL.numRadioInterfaces; i++) { for (let i = 0; i < this.mRIL.numRadioInterfaces; i++) {
this.mRIL.getRadioInterface(i).updateRILNetworkInterface(); this.mRIL.getRadioInterface(i).updateRILNetworkInterface();
} }
} }
#endif
break; break;
} }
break; break;
#ifdef MOZ_B2G_RIL
case TOPIC_INTERFACE_REGISTERED: case TOPIC_INTERFACE_REGISTERED:
let regNetwork = subject.QueryInterface(Ci.nsINetworkInterface); let regNetwork = subject.QueryInterface(Ci.nsINetworkInterface);
// Add extra host route. For example, mms proxy or mmsc. // Add extra host route. For example, mms proxy or mmsc.
@ -291,6 +304,7 @@ NetworkManager.prototype = {
// Remove extra host route. For example, mms proxy or mmsc. // Remove extra host route. For example, mms proxy or mmsc.
this.removeExtraHostRoute(unregNetwork); this.removeExtraHostRoute(unregNetwork);
break; break;
#endif
case TOPIC_MOZSETTINGS_CHANGED: case TOPIC_MOZSETTINGS_CHANGED:
let setting = JSON.parse(data); let setting = JSON.parse(data);
this.handle(setting.key, setting.value); this.handle(setting.key, setting.value);
@ -303,8 +317,10 @@ NetworkManager.prototype = {
case TOPIC_XPCOM_SHUTDOWN: case TOPIC_XPCOM_SHUTDOWN:
Services.obs.removeObserver(this, TOPIC_XPCOM_SHUTDOWN); Services.obs.removeObserver(this, TOPIC_XPCOM_SHUTDOWN);
Services.obs.removeObserver(this, TOPIC_MOZSETTINGS_CHANGED); Services.obs.removeObserver(this, TOPIC_MOZSETTINGS_CHANGED);
#ifdef MOZ_B2G_RIL
Services.obs.removeObserver(this, TOPIC_INTERFACE_REGISTERED); Services.obs.removeObserver(this, TOPIC_INTERFACE_REGISTERED);
Services.obs.removeObserver(this, TOPIC_INTERFACE_UNREGISTERED); Services.obs.removeObserver(this, TOPIC_INTERFACE_UNREGISTERED);
#endif
Services.obs.removeObserver(this, TOPIC_INTERFACE_STATE_CHANGED); Services.obs.removeObserver(this, TOPIC_INTERFACE_STATE_CHANGED);
break; break;
} }
@ -313,15 +329,19 @@ NetworkManager.prototype = {
receiveMessage: function receiveMessage(aMsg) { receiveMessage: function receiveMessage(aMsg) {
switch (aMsg.name) { switch (aMsg.name) {
case "NetworkInterfaceList:ListInterface": { case "NetworkInterfaceList:ListInterface": {
#ifdef MOZ_B2G_RIL
let excludeMms = aMsg.json.exculdeMms; let excludeMms = aMsg.json.exculdeMms;
let excludeSupl = aMsg.json.exculdeSupl; let excludeSupl = aMsg.json.exculdeSupl;
#endif
let interfaces = []; let interfaces = [];
for each (let i in this.networkInterfaces) { for each (let i in this.networkInterfaces) {
#ifdef MOZ_B2G_RIL
if ((i.type == Ci.nsINetworkInterface.NETWORK_TYPE_MOBILE_MMS && excludeMms) || 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_SUPL && excludeSupl)) {
continue; continue;
} }
#endif
interfaces.push({ interfaces.push({
state: i.state, state: i.state,
type: i.type, type: i.type,
@ -353,12 +373,14 @@ NetworkManager.prototype = {
Cr.NS_ERROR_INVALID_ARG); Cr.NS_ERROR_INVALID_ARG);
} }
this.networkInterfaces[network.name] = network; this.networkInterfaces[network.name] = network;
#ifdef MOZ_B2G_RIL
// Add host route for data calls // Add host route for data calls
if (network.type == Ci.nsINetworkInterface.NETWORK_TYPE_MOBILE || if (network.type == Ci.nsINetworkInterface.NETWORK_TYPE_MOBILE ||
network.type == Ci.nsINetworkInterface.NETWORK_TYPE_MOBILE_MMS || network.type == Ci.nsINetworkInterface.NETWORK_TYPE_MOBILE_MMS ||
network.type == Ci.nsINetworkInterface.NETWORK_TYPE_MOBILE_SUPL) { network.type == Ci.nsINetworkInterface.NETWORK_TYPE_MOBILE_SUPL) {
this.addHostRoute(network); this.addHostRoute(network);
} }
#endif
// Remove pre-created default route and let setAndConfigureActive() // Remove pre-created default route and let setAndConfigureActive()
// to set default route only on preferred network // to set default route only on preferred network
this.removeDefaultRoute(network.name); this.removeDefaultRoute(network.name);
@ -377,12 +399,14 @@ NetworkManager.prototype = {
Cr.NS_ERROR_INVALID_ARG); Cr.NS_ERROR_INVALID_ARG);
} }
delete this.networkInterfaces[network.name]; delete this.networkInterfaces[network.name];
#ifdef MOZ_B2G_RIL
// Remove host route for data calls // Remove host route for data calls
if (network.type == Ci.nsINetworkInterface.NETWORK_TYPE_MOBILE || if (network.type == Ci.nsINetworkInterface.NETWORK_TYPE_MOBILE ||
network.type == Ci.nsINetworkInterface.NETWORK_TYPE_MOBILE_MMS || network.type == Ci.nsINetworkInterface.NETWORK_TYPE_MOBILE_MMS ||
network.type == Ci.nsINetworkInterface.NETWORK_TYPE_MOBILE_SUPL) { network.type == Ci.nsINetworkInterface.NETWORK_TYPE_MOBILE_SUPL) {
this.removeHostRoute(network); this.removeHostRoute(network);
} }
#endif
this.setAndConfigureActive(); this.setAndConfigureActive();
Services.obs.notifyObservers(network, TOPIC_INTERFACE_UNREGISTERED, null); Services.obs.notifyObservers(network, TOPIC_INTERFACE_UNREGISTERED, null);
debug("Network '" + network.name + "' unregistered."); debug("Network '" + network.name + "' unregistered.");
@ -397,8 +421,12 @@ NetworkManager.prototype = {
return this._preferredNetworkType; return this._preferredNetworkType;
}, },
set preferredNetworkType(val) { set preferredNetworkType(val) {
#ifdef MOZ_B2G_RIL
if ([Ci.nsINetworkInterface.NETWORK_TYPE_WIFI, if ([Ci.nsINetworkInterface.NETWORK_TYPE_WIFI,
Ci.nsINetworkInterface.NETWORK_TYPE_MOBILE].indexOf(val) == -1) { Ci.nsINetworkInterface.NETWORK_TYPE_MOBILE].indexOf(val) == -1) {
#else
if (val != Ci.nsINetworkInterface.NETWORK_TYPE_WIFI) {
#endif
throw "Invalid network type"; throw "Invalid network type";
} }
this._preferredNetworkType = val; this._preferredNetworkType = val;
@ -411,10 +439,12 @@ NetworkManager.prototype = {
_activeInfo: null, _activeInfo: null,
overrideActive: function overrideActive(network) { overrideActive: function overrideActive(network) {
#ifdef MOZ_B2G_RIL
if (network.type == Ci.nsINetworkInterface.NETWORK_TYPE_MOBILE_MMS || if (network.type == Ci.nsINetworkInterface.NETWORK_TYPE_MOBILE_MMS ||
network.type == Ci.nsINetworkInterface.NETWORK_TYPE_MOBILE_SUPL) { network.type == Ci.nsINetworkInterface.NETWORK_TYPE_MOBILE_SUPL) {
throw "Invalid network type"; throw "Invalid network type";
} }
#endif
this._overriddenActive = network; this._overriddenActive = network;
this.setAndConfigureActive(); this.setAndConfigureActive();
}, },
@ -486,6 +516,7 @@ NetworkManager.prototype = {
} }
}, },
#ifdef MOZ_B2G_RIL
setExtraHostRoute: function setExtraHostRoute(network) { setExtraHostRoute: function setExtraHostRoute(network) {
if (network.type == Ci.nsINetworkInterface.NETWORK_TYPE_MOBILE_MMS) { if (network.type == Ci.nsINetworkInterface.NETWORK_TYPE_MOBILE_MMS) {
debug("Network '" + network.name + "' registered, adding mmsproxy and/or mmsc route"); debug("Network '" + network.name + "' registered, adding mmsproxy and/or mmsc route");
@ -505,6 +536,7 @@ NetworkManager.prototype = {
this.removeHostRouteWithResolve(network, mmsHosts); this.removeHostRouteWithResolve(network, mmsHosts);
} }
}, },
#endif // MOZ_B2G_RIL
/** /**
* Determine the active interface and configure it. * Determine the active interface and configure it.
@ -512,7 +544,6 @@ NetworkManager.prototype = {
setAndConfigureActive: function setAndConfigureActive() { setAndConfigureActive: function setAndConfigureActive() {
debug("Evaluating whether active network needs to be changed."); debug("Evaluating whether active network needs to be changed.");
let oldActive = this.active; let oldActive = this.active;
let defaultDataNetwork;
if (this._overriddenActive) { if (this._overriddenActive) {
debug("We have an override for the active network: " + debug("We have an override for the active network: " +
@ -538,13 +569,18 @@ NetworkManager.prototype = {
// Find a suitable network interface to activate. // Find a suitable network interface to activate.
this.active = null; this.active = null;
this._activeInfo = Object.create(null); this._activeInfo = Object.create(null);
#ifdef MOZ_B2G_RIL
let defaultDataNetwork;
#endif
for each (let network in this.networkInterfaces) { for each (let network in this.networkInterfaces) {
if (network.state != Ci.nsINetworkInterface.NETWORK_STATE_CONNECTED) { if (network.state != Ci.nsINetworkInterface.NETWORK_STATE_CONNECTED) {
continue; continue;
} }
#ifdef MOZ_B2G_RIL
if (network.type == Ci.nsINetworkInterface.NETWORK_TYPE_MOBILE) { if (network.type == Ci.nsINetworkInterface.NETWORK_TYPE_MOBILE) {
defaultDataNetwork = network; defaultDataNetwork = network;
} }
#endif
this.active = network; this.active = network;
this._activeInfo = {name:network.name, ip:network.ip, netmask:network.netmask}; this._activeInfo = {name:network.name, ip:network.ip, netmask:network.netmask};
if (network.type == this.preferredNetworkType) { if (network.type == this.preferredNetworkType) {
@ -553,6 +589,7 @@ NetworkManager.prototype = {
} }
} }
if (this.active) { if (this.active) {
#ifdef MOZ_B2G_RIL
// Give higher priority to default data APN than seconary APN. // Give higher priority to default data APN than seconary APN.
// If default data APN is not connected, we still set default route // If default data APN is not connected, we still set default route
// and DNS on seconary APN. // and DNS on seconary APN.
@ -567,8 +604,11 @@ NetworkManager.prototype = {
this.active.type == Ci.nsINetworkInterface.NETWORK_TYPE_MOBILE_SUPL) { this.active.type == Ci.nsINetworkInterface.NETWORK_TYPE_MOBILE_SUPL) {
this.setDNS(this.active); this.setDNS(this.active);
} else { } else {
#endif // MOZ_B2G_RIL
this.setDefaultRouteAndDNS(oldActive); this.setDefaultRouteAndDNS(oldActive);
#ifdef MOZ_B2G_RIL
} }
#endif
if (this.active != oldActive) { if (this.active != oldActive) {
Services.obs.notifyObservers(this.active, TOPIC_ACTIVE_CHANGED, null); Services.obs.notifyObservers(this.active, TOPIC_ACTIVE_CHANGED, null);
} }
@ -593,6 +633,7 @@ NetworkManager.prototype = {
this.worker.postMessage(options); this.worker.postMessage(options);
}, },
#ifdef MOZ_B2G_RIL
setDNS: function setDNS(networkInterface) { setDNS: function setDNS(networkInterface) {
debug("Going DNS to " + networkInterface.name); debug("Going DNS to " + networkInterface.name);
let options = { let options = {
@ -603,6 +644,7 @@ NetworkManager.prototype = {
}; };
this.worker.postMessage(options); this.worker.postMessage(options);
}, },
#endif
setDefaultRouteAndDNS: function setDefaultRouteAndDNS(oldInterface) { setDefaultRouteAndDNS: function setDefaultRouteAndDNS(oldInterface) {
debug("Going to change route and DNS to " + this.active.name); debug("Going to change route and DNS to " + this.active.name);
@ -627,6 +669,7 @@ NetworkManager.prototype = {
this.worker.postMessage(options); this.worker.postMessage(options);
}, },
#ifdef MOZ_B2G_RIL
addHostRoute: function addHostRoute(network) { addHostRoute: function addHostRoute(network) {
debug("Going to add host route on " + network.name); debug("Going to add host route on " + network.name);
let options = { let options = {
@ -706,6 +749,7 @@ NetworkManager.prototype = {
}; };
this.worker.postMessage(options); this.worker.postMessage(options);
}, },
#endif // MOZ_B2G_RIL
setNetworkProxy: function setNetworkProxy(network) { setNetworkProxy: function setNetworkProxy(network) {
try { try {
@ -1224,9 +1268,11 @@ let CaptivePortalDetectionHelper = (function() {
}; };
}()); }());
#ifdef MOZ_B2G_RIL
XPCOMUtils.defineLazyServiceGetter(NetworkManager.prototype, "mRIL", XPCOMUtils.defineLazyServiceGetter(NetworkManager.prototype, "mRIL",
"@mozilla.org/ril;1", "@mozilla.org/ril;1",
"nsIRadioInterfaceLayer"); "nsIRadioInterfaceLayer");
#endif
this.NSGetFactory = XPCOMUtils.generateNSGetFactory([NetworkManager]); this.NSGetFactory = XPCOMUtils.generateNSGetFactory([NetworkManager]);

View File

@ -24,13 +24,13 @@
#include "jsfriendapi.h" #include "jsfriendapi.h"
#include "mozilla/dom/workers/Workers.h" #include "mozilla/dom/workers/Workers.h"
#ifdef MOZ_WIDGET_GONK
#include "mozilla/ipc/Netd.h" #include "mozilla/ipc/Netd.h"
#include "AutoMounter.h" #include "AutoMounter.h"
#include "TimeZoneSettingObserver.h" #include "TimeZoneSettingObserver.h"
#include "AudioManager.h" #include "AudioManager.h"
#endif #ifdef MOZ_B2G_RIL
#include "mozilla/ipc/Ril.h" #include "mozilla/ipc/Ril.h"
#endif
#include "mozilla/ipc/KeyStore.h" #include "mozilla/ipc/KeyStore.h"
#include "nsIObserverService.h" #include "nsIObserverService.h"
#include "nsCxPusher.h" #include "nsCxPusher.h"
@ -44,9 +44,7 @@ USING_WORKERS_NAMESPACE
using namespace mozilla::dom::gonk; using namespace mozilla::dom::gonk;
using namespace mozilla::ipc; using namespace mozilla::ipc;
#ifdef MOZ_WIDGET_GONK
using namespace mozilla::system; using namespace mozilla::system;
#endif
#define NS_NETWORKMANAGER_CID \ #define NS_NETWORKMANAGER_CID \
{ 0x33901e46, 0x33b8, 0x11e1, \ { 0x33901e46, 0x33b8, 0x11e1, \
@ -60,107 +58,6 @@ NS_DEFINE_CID(kNetworkManagerCID, NS_NETWORKMANAGER_CID);
// Doesn't carry a reference, we're owned by services. // Doesn't carry a reference, we're owned by services.
SystemWorkerManager *gInstance = nullptr; SystemWorkerManager *gInstance = nullptr;
class ConnectWorkerToRIL : public WorkerTask
{
public:
ConnectWorkerToRIL()
{ }
virtual bool RunTask(JSContext *aCx);
};
class SendRilSocketDataTask : public nsRunnable
{
public:
SendRilSocketDataTask(unsigned long aClientId,
UnixSocketRawData *aRawData)
: mRawData(aRawData)
, mClientId(aClientId)
{ }
NS_IMETHOD Run()
{
MOZ_ASSERT(NS_IsMainThread());
SystemWorkerManager::SendRilRawData(mClientId, mRawData);
return NS_OK;
}
private:
UnixSocketRawData *mRawData;
unsigned long mClientId;
};
bool
PostToRIL(JSContext *cx, unsigned argc, JS::Value *vp)
{
NS_ASSERTION(!NS_IsMainThread(), "Expecting to be on the worker thread");
if (argc != 2) {
JS_ReportError(cx, "Expecting two arguments with the RIL message");
return false;
}
JS::Value cv = JS_ARGV(cx, vp)[0];
int clientId = cv.toInt32();
JS::Value v = JS_ARGV(cx, vp)[1];
JSAutoByteString abs;
void *data;
size_t size;
if (JSVAL_IS_STRING(v)) {
JSString *str = JSVAL_TO_STRING(v);
if (!abs.encodeUtf8(cx, str)) {
return false;
}
data = abs.ptr();
size = abs.length();
} else if (!JSVAL_IS_PRIMITIVE(v)) {
JSObject *obj = JSVAL_TO_OBJECT(v);
if (!JS_IsTypedArrayObject(obj)) {
JS_ReportError(cx, "Object passed in wasn't a typed array");
return false;
}
uint32_t type = JS_GetArrayBufferViewType(obj);
if (type != js::ArrayBufferView::TYPE_INT8 &&
type != js::ArrayBufferView::TYPE_UINT8 &&
type != js::ArrayBufferView::TYPE_UINT8_CLAMPED) {
JS_ReportError(cx, "Typed array data is not octets");
return false;
}
size = JS_GetTypedArrayByteLength(obj);
data = JS_GetArrayBufferViewData(obj);
} else {
JS_ReportError(cx,
"Incorrect argument. Expecting a string or a typed array");
return false;
}
UnixSocketRawData* raw = new UnixSocketRawData(data, size);
nsRefPtr<SendRilSocketDataTask> task = new SendRilSocketDataTask(clientId, raw);
NS_DispatchToMainThread(task);
return true;
}
bool
ConnectWorkerToRIL::RunTask(JSContext *aCx)
{
// Set up the postRILMessage on the function for worker -> RIL thread
// communication.
NS_ASSERTION(!NS_IsMainThread(), "Expecting to be on the worker thread");
NS_ASSERTION(!JS_IsRunning(aCx), "Are we being called somehow?");
JSObject *workerGlobal = JS::CurrentGlobalOrNull(aCx);
return !!JS_DefineFunction(aCx, workerGlobal, "postRILMessage", PostToRIL, 1,
0);
}
#ifdef MOZ_WIDGET_GONK
bool bool
DoNetdCommand(JSContext *cx, unsigned argc, JS::Value *vp) DoNetdCommand(JSContext *cx, unsigned argc, JS::Value *vp)
{ {
@ -306,8 +203,6 @@ NetdReceiver::DispatchNetdEvent::RunTask(JSContext *aCx)
argv, argv); argv, argv);
} }
#endif // MOZ_WIDGET_GONK
} // anonymous namespace } // anonymous namespace
SystemWorkerManager::SystemWorkerManager() SystemWorkerManager::SystemWorkerManager()
@ -345,14 +240,12 @@ SystemWorkerManager::Init()
InitKeyStore(cx); InitKeyStore(cx);
#ifdef MOZ_WIDGET_GONK
InitAutoMounter(); InitAutoMounter();
InitializeTimeZoneSettingObserver(); InitializeTimeZoneSettingObserver();
rv = InitNetd(cx); rv = InitNetd(cx);
NS_ENSURE_SUCCESS(rv, rv); NS_ENSURE_SUCCESS(rv, rv);
nsCOMPtr<nsIAudioManager> audioManager = nsCOMPtr<nsIAudioManager> audioManager =
do_GetService(NS_AUDIOMANAGER_CONTRACTID); do_GetService(NS_AUDIOMANAGER_CONTRACTID);
#endif
nsCOMPtr<nsIObserverService> obs = mozilla::services::GetObserverService(); nsCOMPtr<nsIObserverService> obs = mozilla::services::GetObserverService();
if (!obs) { if (!obs) {
@ -376,21 +269,14 @@ SystemWorkerManager::Shutdown()
mShutdown = true; mShutdown = true;
#ifdef MOZ_WIDGET_GONK
ShutdownAutoMounter(); ShutdownAutoMounter();
#ifdef MOZ_B2G_RIL
RilConsumer::Shutdown();
#endif #endif
for (unsigned long i = 0; i < mRilConsumers.Length(); i++) {
if (mRilConsumers[i]) {
mRilConsumers[i]->Shutdown();
mRilConsumers[i] = nullptr;
}
}
#ifdef MOZ_WIDGET_GONK
StopNetd(); StopNetd();
mNetdWorker = nullptr; mNetdWorker = nullptr;
#endif
nsCOMPtr<nsIWifi> wifi(do_QueryInterface(mWifiWorker)); nsCOMPtr<nsIWifi> wifi(do_QueryInterface(mWifiWorker));
if (wifi) { if (wifi) {
@ -433,20 +319,6 @@ SystemWorkerManager::GetInterfaceRequestor()
return gInstance; return gInstance;
} }
bool
SystemWorkerManager::SendRilRawData(unsigned long aClientId,
UnixSocketRawData* aRaw)
{
if ((gInstance->mRilConsumers.Length() <= aClientId) ||
!gInstance->mRilConsumers[aClientId] ||
gInstance->mRilConsumers[aClientId]->GetConnectionStatus() != SOCKET_CONNECTED) {
// Probably shuting down.
delete aRaw;
return true;
}
return gInstance->mRilConsumers[aClientId]->SendSocketData(aRaw);
}
NS_IMETHODIMP NS_IMETHODIMP
SystemWorkerManager::GetInterface(const nsIID &aIID, void **aResult) SystemWorkerManager::GetInterface(const nsIID &aIID, void **aResult)
{ {
@ -457,12 +329,10 @@ SystemWorkerManager::GetInterface(const nsIID &aIID, void **aResult)
reinterpret_cast<nsIWifi**>(aResult)); reinterpret_cast<nsIWifi**>(aResult));
} }
#ifdef MOZ_WIDGET_GONK
if (aIID.Equals(NS_GET_IID(nsINetworkManager))) { if (aIID.Equals(NS_GET_IID(nsINetworkManager))) {
return CallQueryInterface(mNetdWorker, return CallQueryInterface(mNetdWorker,
reinterpret_cast<nsINetworkManager**>(aResult)); reinterpret_cast<nsINetworkManager**>(aResult));
} }
#endif
NS_WARNING("Got nothing for the requested IID!"); NS_WARNING("Got nothing for the requested IID!");
return NS_ERROR_NO_INTERFACE; return NS_ERROR_NO_INTERFACE;
@ -473,15 +343,11 @@ SystemWorkerManager::RegisterRilWorker(unsigned int aClientId,
const JS::Value& aWorker, const JS::Value& aWorker,
JSContext *aCx) JSContext *aCx)
{ {
#ifndef MOZ_B2G_RIL
return NS_ERROR_NOT_IMPLEMENTED;
#else
NS_ENSURE_TRUE(!JSVAL_IS_PRIMITIVE(aWorker), NS_ERROR_UNEXPECTED); NS_ENSURE_TRUE(!JSVAL_IS_PRIMITIVE(aWorker), NS_ERROR_UNEXPECTED);
mRilConsumers.EnsureLengthAtLeast(aClientId + 1);
if (mRilConsumers[aClientId]) {
NS_WARNING("RilConsumer already registered");
return NS_ERROR_FAILURE;
}
JSAutoCompartment ac(aCx, JSVAL_TO_OBJECT(aWorker)); JSAutoCompartment ac(aCx, JSVAL_TO_OBJECT(aWorker));
WorkerCrossThreadDispatcher *wctd = WorkerCrossThreadDispatcher *wctd =
@ -491,18 +357,10 @@ SystemWorkerManager::RegisterRilWorker(unsigned int aClientId,
return NS_ERROR_FAILURE; return NS_ERROR_FAILURE;
} }
nsRefPtr<ConnectWorkerToRIL> connection = new ConnectWorkerToRIL(); return RilConsumer::Register(aClientId, wctd);
if (!wctd->PostTask(connection)) { #endif // MOZ_B2G_RIL
NS_WARNING("Failed to connect worker to ril");
return NS_ERROR_UNEXPECTED;
}
// Now that we're set up, connect ourselves to the RIL thread.
mRilConsumers[aClientId] = new RilConsumer(aClientId, wctd);
return NS_OK;
} }
#ifdef MOZ_WIDGET_GONK
nsresult nsresult
SystemWorkerManager::InitNetd(JSContext *cx) SystemWorkerManager::InitNetd(JSContext *cx)
{ {
@ -535,7 +393,6 @@ SystemWorkerManager::InitNetd(JSContext *cx)
mNetdWorker = worker; mNetdWorker = worker;
return NS_OK; return NS_OK;
} }
#endif
nsresult nsresult
SystemWorkerManager::InitWifi(JSContext *cx) SystemWorkerManager::InitWifi(JSContext *cx)

View File

@ -23,18 +23,13 @@
#include "nsIObserver.h" #include "nsIObserver.h"
#include "nsAutoPtr.h" #include "nsAutoPtr.h"
#include "nsCOMPtr.h" #include "nsCOMPtr.h"
#include "nsDebug.h" #include "nsXULAppAPI.h" // For XRE_GetProcessType
#include "nsDOMEventTargetHelper.h"
#include "nsString.h"
#include "nsTArray.h"
class nsIWorkerHolder; class nsIWorkerHolder;
namespace mozilla { namespace mozilla {
namespace ipc { namespace ipc {
class RilConsumer;
class UnixSocketRawData;
class KeyStore; class KeyStore;
} }
@ -60,25 +55,17 @@ public:
static nsIInterfaceRequestor* static nsIInterfaceRequestor*
GetInterfaceRequestor(); GetInterfaceRequestor();
static bool SendRilRawData(unsigned long aClientId,
ipc::UnixSocketRawData* aRaw);
private: private:
SystemWorkerManager(); SystemWorkerManager();
~SystemWorkerManager(); ~SystemWorkerManager();
#ifdef MOZ_WIDGET_GONK
nsresult InitNetd(JSContext *cx); nsresult InitNetd(JSContext *cx);
#endif
nsresult InitWifi(JSContext *cx); nsresult InitWifi(JSContext *cx);
nsresult InitKeyStore(JSContext *cx); nsresult InitKeyStore(JSContext *cx);
#ifdef MOZ_WIDGET_GONK
nsCOMPtr<nsIWorkerHolder> mNetdWorker; nsCOMPtr<nsIWorkerHolder> mNetdWorker;
#endif
nsCOMPtr<nsIWorkerHolder> mWifiWorker; nsCOMPtr<nsIWorkerHolder> mWifiWorker;
nsTArray<nsRefPtr<ipc::RilConsumer> > mRilConsumers;
nsRefPtr<ipc::KeyStore> mKeyStore; nsRefPtr<ipc::KeyStore> mKeyStore;
bool mShutdown; bool mShutdown;

View File

@ -18,7 +18,6 @@ XPIDL_SOURCES += [
'nsIAudioManager.idl', 'nsIAudioManager.idl',
'nsINetworkInterfaceListService.idl', 'nsINetworkInterfaceListService.idl',
'nsINetworkManager.idl', 'nsINetworkManager.idl',
'nsIRadioInterfaceLayer.idl',
'nsISystemWorkerManager.idl', 'nsISystemWorkerManager.idl',
'nsIVolume.idl', 'nsIVolume.idl',
'nsIVolumeMountLock.idl', 'nsIVolumeMountLock.idl',
@ -31,55 +30,61 @@ XPIDL_MODULE = 'dom_system_gonk'
MODULE = 'dom' MODULE = 'dom'
if CONFIG['MOZ_WIDGET_TOOLKIT'] == 'gonk': EXPORTS += [
EXPORTS += [ 'GonkGPSGeolocationProvider.h',
'GonkGPSGeolocationProvider.h', 'nsVolume.h',
'nsVolume.h', 'nsVolumeService.h',
'nsVolumeService.h', ]
] SOURCES += [
SOURCES += [ 'AudioChannelManager.cpp',
'AudioChannelManager.cpp', 'AudioManager.cpp',
'AudioManager.cpp', 'AutoMounter.cpp',
'AutoMounter.cpp', 'AutoMounterSetting.cpp',
'AutoMounterSetting.cpp', 'GonkGPSGeolocationProvider.cpp',
'GonkGPSGeolocationProvider.cpp', 'nsVolume.cpp',
'nsVolume.cpp', 'nsVolumeMountLock.cpp',
'nsVolumeMountLock.cpp', 'nsVolumeService.cpp',
'nsVolumeService.cpp', 'nsVolumeStat.cpp',
'nsVolumeStat.cpp', 'OpenFileFinder.cpp',
'OpenFileFinder.cpp', 'SystemWorkerManager.cpp',
'TimeZoneSettingObserver.cpp', 'TimeZoneSettingObserver.cpp',
'Volume.cpp', 'Volume.cpp',
'VolumeCommand.cpp', 'VolumeCommand.cpp',
'VolumeManager.cpp', 'VolumeManager.cpp',
'VolumeServiceIOThread.cpp', 'VolumeServiceIOThread.cpp',
'VolumeServiceTest.cpp', 'VolumeServiceTest.cpp',
] ]
if CONFIG['ENABLE_TESTS']: if CONFIG['ENABLE_TESTS']:
XPCSHELL_TESTS_MANIFESTS += ['tests/xpcshell.ini'] XPCSHELL_TESTS_MANIFESTS += ['tests/xpcshell.ini']
SOURCES += [
'SystemWorkerManager.cpp',
]
EXTRA_COMPONENTS += [ EXTRA_COMPONENTS += [
'NetworkInterfaceListService.js', 'NetworkInterfaceListService.js',
'NetworkInterfaceListService.manifest', 'NetworkInterfaceListService.manifest',
'NetworkManager.js',
'NetworkManager.manifest', 'NetworkManager.manifest',
'RadioInterfaceLayer.js',
'RadioInterfaceLayer.manifest',
'RILContentHelper.js',
] ]
EXTRA_PP_COMPONENTS += [
'NetworkManager.js',
]
EXTRA_JS_MODULES += [ EXTRA_JS_MODULES += [
'net_worker.js', 'net_worker.js',
'ril_consts.js',
'ril_worker.js',
'systemlibs.js', 'systemlibs.js',
] ]
if CONFIG['MOZ_B2G_RIL']:
XPIDL_SOURCES += [
'nsIRadioInterfaceLayer.idl',
]
EXTRA_COMPONENTS += [
'RadioInterfaceLayer.js',
'RadioInterfaceLayer.manifest',
'RILContentHelper.js',
]
EXTRA_JS_MODULES += [
'ril_consts.js',
'ril_worker.js',
]
FAIL_ON_WARNINGS = True FAIL_ON_WARNINGS = True
LIBXUL_LIBRARY = True LIBXUL_LIBRARY = True

View File

@ -14,8 +14,7 @@ elif toolkit == 'cocoa':
DIRS += ['mac'] DIRS += ['mac']
elif toolkit == 'android': elif toolkit == 'android':
DIRS += ['android'] DIRS += ['android']
elif toolkit == 'gonk':
if CONFIG['MOZ_B2G_RIL']:
DIRS += ['gonk'] DIRS += ['gonk']
TEST_DIRS += ['tests'] TEST_DIRS += ['tests']

View File

@ -514,9 +514,13 @@ if CONFIG['MOZ_B2G_RIL']:
'MozStkCommandEvent.webidl', 'MozStkCommandEvent.webidl',
'MozVoicemail.webidl', 'MozVoicemail.webidl',
'MozVoicemailEvent.webidl', 'MozVoicemailEvent.webidl',
'USSDReceivedEvent.webidl',
]
if CONFIG['MOZ_WIDGET_TOOLKIT'] == 'gonk':
WEBIDL_FILES += [
'MozWifiConnectionInfoEvent.webidl', 'MozWifiConnectionInfoEvent.webidl',
'MozWifiStatusChangeEvent.webidl', 'MozWifiStatusChangeEvent.webidl',
'USSDReceivedEvent.webidl',
] ]
if CONFIG['MOZ_WEBSPEECH']: if CONFIG['MOZ_WEBSPEECH']:

View File

@ -17,10 +17,10 @@ if CONFIG['MOZ_B2G_RIL']:
if CONFIG['MOZ_B2G_BT_BLUEZ']: if CONFIG['MOZ_B2G_BT_BLUEZ']:
DIRS += ['dbus'] DIRS += ['dbus']
if CONFIG['MOZ_B2G_RIL'] or CONFIG['MOZ_B2G_BT']: if CONFIG['MOZ_B2G_RIL'] or CONFIG['MOZ_B2G_BT'] or CONFIG['MOZ_WIDGET_TOOLKIT'] == 'gonk':
DIRS += ['unixsocket', 'keystore'] DIRS += ['unixsocket']
if CONFIG['MOZ_WIDGET_TOOLKIT'] == 'gonk': if CONFIG['MOZ_WIDGET_TOOLKIT'] == 'gonk':
DIRS += ['netd'] DIRS += ['netd', 'keystore']
TOOL_DIRS += ['app'] TOOL_DIRS += ['app']

View File

@ -4,6 +4,8 @@
* License, v. 2.0. If a copy of the MPL was not distributed with this * 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/. */ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#include "mozilla/ipc/Ril.h"
#include <fcntl.h> #include <fcntl.h>
#include <sys/socket.h> #include <sys/socket.h>
#include <sys/un.h> #include <sys/un.h>
@ -18,8 +20,8 @@
#endif #endif
#include "jsfriendapi.h" #include "jsfriendapi.h"
#include "nsTArray.h"
#include "nsThreadUtils.h" // For NS_IsMainThread. #include "nsThreadUtils.h" // For NS_IsMainThread.
#include "Ril.h"
USING_WORKERS_NAMESPACE USING_WORKERS_NAMESPACE
using namespace mozilla::ipc; using namespace mozilla::ipc;
@ -32,17 +34,130 @@ const char* RIL_SOCKET_NAME = "/dev/socket/rilproxy";
// desktop development. // desktop development.
const uint32_t RIL_TEST_PORT = 6200; const uint32_t RIL_TEST_PORT = 6200;
class DispatchRILEvent : public WorkerTask nsTArray<nsRefPtr<mozilla::ipc::RilConsumer> > sRilConsumers;
class ConnectWorkerToRIL : public WorkerTask
{ {
public: public:
DispatchRILEvent(UnixSocketRawData* aMessage) ConnectWorkerToRIL()
: mMessage(aMessage)
{ } { }
virtual bool RunTask(JSContext *aCx); virtual bool RunTask(JSContext *aCx);
};
class SendRilSocketDataTask : public nsRunnable
{
public:
SendRilSocketDataTask(unsigned long aClientId,
UnixSocketRawData *aRawData)
: mRawData(aRawData)
, mClientId(aClientId)
{ }
NS_IMETHOD Run()
{
MOZ_ASSERT(NS_IsMainThread());
if (sRilConsumers.Length() <= mClientId ||
!sRilConsumers[mClientId] ||
sRilConsumers[mClientId]->GetConnectionStatus() != SOCKET_CONNECTED) {
// Probably shuting down.
delete mRawData;
return NS_OK;
}
sRilConsumers[mClientId]->SendSocketData(mRawData);
return NS_OK;
}
private: private:
nsAutoPtr<UnixSocketRawData> mMessage; UnixSocketRawData *mRawData;
unsigned long mClientId;
};
bool
PostToRIL(JSContext *aCx,
unsigned aArgc,
JS::Value *aArgv)
{
NS_ASSERTION(!NS_IsMainThread(), "Expecting to be on the worker thread");
if (aArgc != 2) {
JS_ReportError(aCx, "Expecting two arguments with the RIL message");
return false;
}
JS::Value cv = JS_ARGV(aCx, aArgv)[0];
int clientId = cv.toInt32();
JS::Value v = JS_ARGV(aCx, aArgv)[1];
JSAutoByteString abs;
void *data;
size_t size;
if (JSVAL_IS_STRING(v)) {
JSString *str = JSVAL_TO_STRING(v);
if (!abs.encodeUtf8(aCx, str)) {
return false;
}
data = abs.ptr();
size = abs.length();
} else if (!JSVAL_IS_PRIMITIVE(v)) {
JSObject *obj = JSVAL_TO_OBJECT(v);
if (!JS_IsTypedArrayObject(obj)) {
JS_ReportError(aCx, "Object passed in wasn't a typed array");
return false;
}
uint32_t type = JS_GetArrayBufferViewType(obj);
if (type != js::ArrayBufferView::TYPE_INT8 &&
type != js::ArrayBufferView::TYPE_UINT8 &&
type != js::ArrayBufferView::TYPE_UINT8_CLAMPED) {
JS_ReportError(aCx, "Typed array data is not octets");
return false;
}
size = JS_GetTypedArrayByteLength(obj);
data = JS_GetArrayBufferViewData(obj);
} else {
JS_ReportError(aCx,
"Incorrect argument. Expecting a string or a typed array");
return false;
}
UnixSocketRawData* raw = new UnixSocketRawData(data, size);
nsRefPtr<SendRilSocketDataTask> task =
new SendRilSocketDataTask(clientId, raw);
NS_DispatchToMainThread(task);
return true;
}
bool
ConnectWorkerToRIL::RunTask(JSContext *aCx)
{
// Set up the postRILMessage on the function for worker -> RIL thread
// communication.
NS_ASSERTION(!NS_IsMainThread(), "Expecting to be on the worker thread");
NS_ASSERTION(!JS_IsRunning(aCx), "Are we being called somehow?");
JSObject *workerGlobal = JS::CurrentGlobalOrNull(aCx);
return !!JS_DefineFunction(aCx, workerGlobal,
"postRILMessage", PostToRIL, 1, 0);
}
class DispatchRILEvent : public WorkerTask
{
public:
DispatchRILEvent(UnixSocketRawData* aMessage)
: mMessage(aMessage)
{ }
virtual bool RunTask(JSContext *aCx);
private:
nsAutoPtr<UnixSocketRawData> mMessage;
}; };
bool bool
@ -192,11 +307,45 @@ RilConsumer::RilConsumer(unsigned long aClientId,
ConnectSocket(new RilConnector(mClientId), mAddress.get()); ConnectSocket(new RilConnector(mClientId), mAddress.get());
} }
nsresult
RilConsumer::Register(unsigned int aClientId,
WorkerCrossThreadDispatcher* aDispatcher)
{
MOZ_ASSERT(NS_IsMainThread());
sRilConsumers.EnsureLengthAtLeast(aClientId + 1);
if (sRilConsumers[aClientId]) {
NS_WARNING("RilConsumer already registered");
return NS_ERROR_FAILURE;
}
nsRefPtr<ConnectWorkerToRIL> connection = new ConnectWorkerToRIL();
if (!aDispatcher->PostTask(connection)) {
NS_WARNING("Failed to connect worker to ril");
return NS_ERROR_UNEXPECTED;
}
// Now that we're set up, connect ourselves to the RIL thread.
sRilConsumers[aClientId] = new RilConsumer(aClientId, aDispatcher);
return NS_OK;
}
void void
RilConsumer::Shutdown() RilConsumer::Shutdown()
{ {
mShutdown = true; MOZ_ASSERT(NS_IsMainThread());
CloseSocket();
for (unsigned long i = 0; i < sRilConsumers.Length(); i++) {
nsRefPtr<RilConsumer>& instance = sRilConsumers[i];
if (!instance) {
continue;
}
instance->mShutdown = true;
instance->CloseSocket();
instance = nullptr;
}
} }
void void
@ -212,20 +361,20 @@ void
RilConsumer::OnConnectSuccess() RilConsumer::OnConnectSuccess()
{ {
// Nothing to do here. // Nothing to do here.
LOG("RIL[%u]: %s\n", mClientId, __FUNCTION__); LOG("RIL[%lu]: %s\n", mClientId, __FUNCTION__);
} }
void void
RilConsumer::OnConnectError() RilConsumer::OnConnectError()
{ {
LOG("RIL[%u]: %s\n", mClientId, __FUNCTION__); LOG("RIL[%lu]: %s\n", mClientId, __FUNCTION__);
CloseSocket(); CloseSocket();
} }
void void
RilConsumer::OnDisconnect() RilConsumer::OnDisconnect()
{ {
LOG("RIL[%u]: %s\n", mClientId, __FUNCTION__); LOG("RIL[%lu]: %s\n", mClientId, __FUNCTION__);
if (!mShutdown) { if (!mShutdown) {
ConnectSocket(new RilConnector(mClientId), mAddress.get(), 1000); ConnectSocket(new RilConnector(mClientId), mAddress.get(), 1000);
} }

View File

@ -16,13 +16,16 @@ namespace ipc {
class RilConsumer : public mozilla::ipc::UnixSocketConsumer class RilConsumer : public mozilla::ipc::UnixSocketConsumer
{ {
public: public:
RilConsumer(unsigned long aClientId,
mozilla::dom::workers::WorkerCrossThreadDispatcher* aDispatcher);
virtual ~RilConsumer() { } virtual ~RilConsumer() { }
void Shutdown(); static nsresult Register(unsigned int aClientId,
mozilla::dom::workers::WorkerCrossThreadDispatcher* aDispatcher);
static void Shutdown();
private: private:
RilConsumer(unsigned long aClientId,
mozilla::dom::workers::WorkerCrossThreadDispatcher* aDispatcher);
virtual void ReceiveSocketData(nsAutoPtr<UnixSocketRawData>& aMessage); virtual void ReceiveSocketData(nsAutoPtr<UnixSocketRawData>& aMessage);
virtual void OnConnectSuccess(); virtual void OnConnectSuccess();

View File

@ -23,6 +23,10 @@ simple_events = [
'StyleRuleChangeEvent', 'StyleRuleChangeEvent',
'StyleSheetChangeEvent', 'StyleSheetChangeEvent',
'StyleSheetApplicableStateChangeEvent', 'StyleSheetApplicableStateChangeEvent',
#ifdef MOZ_WIDGET_GONK
'MozWifiStatusChangeEvent',
'MozWifiConnectionInfoEvent',
#endif
#ifdef MOZ_B2G_BT #ifdef MOZ_B2G_BT
'BluetoothDeviceEvent', 'BluetoothDeviceEvent',
'BluetoothStatusChangedEvent', 'BluetoothStatusChangedEvent',
@ -32,8 +36,6 @@ simple_events = [
'DataErrorEvent', 'DataErrorEvent',
'MozEmergencyCbModeEvent', 'MozEmergencyCbModeEvent',
'MozOtaStatusEvent', 'MozOtaStatusEvent',
'MozWifiStatusChangeEvent',
'MozWifiConnectionInfoEvent',
'MozCellBroadcastEvent', 'MozCellBroadcastEvent',
'MozVoicemailEvent', 'MozVoicemailEvent',
'USSDReceivedEvent', 'USSDReceivedEvent',

View File

@ -127,9 +127,14 @@ endif #}
SHARED_LIBRARY_LIBS += $(DEPTH)/dom/camera/$(LIB_PREFIX)domcamera_s.$(LIB_SUFFIX) SHARED_LIBRARY_LIBS += $(DEPTH)/dom/camera/$(LIB_PREFIX)domcamera_s.$(LIB_SUFFIX)
ifdef MOZ_B2G_RIL #{ ifeq (gonk,$(MOZ_WIDGET_TOOLKIT))
SHARED_LIBRARY_LIBS += \ SHARED_LIBRARY_LIBS += \
$(DEPTH)/dom/system/gonk/$(LIB_PREFIX)domsystemgonk_s.$(LIB_SUFFIX) \ $(DEPTH)/dom/system/gonk/$(LIB_PREFIX)domsystemgonk_s.$(LIB_SUFFIX) \
$(NULL)
endif #}
ifdef MOZ_B2G_RIL #{
SHARED_LIBRARY_LIBS += \
$(DEPTH)/dom/icc/src/$(LIB_PREFIX)dom_icc_s.$(LIB_SUFFIX) \ $(DEPTH)/dom/icc/src/$(LIB_PREFIX)dom_icc_s.$(LIB_SUFFIX) \
$(DEPTH)/dom/cellbroadcast/src/$(LIB_PREFIX)dom_cellbroadcast_s.$(LIB_SUFFIX) \ $(DEPTH)/dom/cellbroadcast/src/$(LIB_PREFIX)dom_cellbroadcast_s.$(LIB_SUFFIX) \
$(DEPTH)/dom/voicemail/$(LIB_PREFIX)domvoicemail_s.$(LIB_SUFFIX) \ $(DEPTH)/dom/voicemail/$(LIB_PREFIX)domvoicemail_s.$(LIB_SUFFIX) \
@ -326,7 +331,7 @@ ifdef MOZ_GSTREAMER
LOCAL_INCLUDES += $(GSTREAMER_CFLAGS) LOCAL_INCLUDES += $(GSTREAMER_CFLAGS)
endif endif
ifdef MOZ_B2G_RIL #{ ifeq (gonk,$(MOZ_WIDGET_TOOLKIT))
LOCAL_INCLUDES += -I$(topsrcdir)/dom/system/gonk LOCAL_INCLUDES += -I$(topsrcdir)/dom/system/gonk
endif #} endif #}

View File

@ -101,7 +101,7 @@
#include "mozilla/dom/nsSynthVoiceRegistry.h" #include "mozilla/dom/nsSynthVoiceRegistry.h"
#endif #endif
#ifdef MOZ_B2G_RIL #ifdef MOZ_WIDGET_GONK
#include "SystemWorkerManager.h" #include "SystemWorkerManager.h"
using mozilla::dom::gonk::SystemWorkerManager; using mozilla::dom::gonk::SystemWorkerManager;
#define SYSTEMWORKERMANAGER_CID \ #define SYSTEMWORKERMANAGER_CID \
@ -288,7 +288,7 @@ NS_GENERIC_FACTORY_SINGLETON_CONSTRUCTOR(DOMRequestService,
DOMRequestService::FactoryCreate) DOMRequestService::FactoryCreate)
NS_GENERIC_FACTORY_SINGLETON_CONSTRUCTOR(QuotaManager, NS_GENERIC_FACTORY_SINGLETON_CONSTRUCTOR(QuotaManager,
QuotaManager::FactoryCreate) QuotaManager::FactoryCreate)
#ifdef MOZ_B2G_RIL #ifdef MOZ_WIDGET_GONK
NS_GENERIC_FACTORY_SINGLETON_CONSTRUCTOR(SystemWorkerManager, NS_GENERIC_FACTORY_SINGLETON_CONSTRUCTOR(SystemWorkerManager,
SystemWorkerManager::FactoryCreate) SystemWorkerManager::FactoryCreate)
#endif #endif
@ -754,7 +754,7 @@ NS_DEFINE_NAMED_CID(NS_TEXTEDITOR_CID);
NS_DEFINE_NAMED_CID(INDEXEDDB_MANAGER_CID); NS_DEFINE_NAMED_CID(INDEXEDDB_MANAGER_CID);
NS_DEFINE_NAMED_CID(DOMREQUEST_SERVICE_CID); NS_DEFINE_NAMED_CID(DOMREQUEST_SERVICE_CID);
NS_DEFINE_NAMED_CID(QUOTA_MANAGER_CID); NS_DEFINE_NAMED_CID(QUOTA_MANAGER_CID);
#ifdef MOZ_B2G_RIL #ifdef MOZ_WIDGET_GONK
NS_DEFINE_NAMED_CID(SYSTEMWORKERMANAGER_CID); NS_DEFINE_NAMED_CID(SYSTEMWORKERMANAGER_CID);
#endif #endif
#ifdef MOZ_B2G_BT #ifdef MOZ_B2G_BT
@ -1043,7 +1043,7 @@ static const mozilla::Module::CIDEntry kLayoutCIDs[] = {
{ &kINDEXEDDB_MANAGER_CID, false, nullptr, IndexedDatabaseManagerConstructor }, { &kINDEXEDDB_MANAGER_CID, false, nullptr, IndexedDatabaseManagerConstructor },
{ &kDOMREQUEST_SERVICE_CID, false, nullptr, DOMRequestServiceConstructor }, { &kDOMREQUEST_SERVICE_CID, false, nullptr, DOMRequestServiceConstructor },
{ &kQUOTA_MANAGER_CID, false, nullptr, QuotaManagerConstructor }, { &kQUOTA_MANAGER_CID, false, nullptr, QuotaManagerConstructor },
#ifdef MOZ_B2G_RIL #ifdef MOZ_WIDGET_GONK
{ &kSYSTEMWORKERMANAGER_CID, true, nullptr, SystemWorkerManagerConstructor }, { &kSYSTEMWORKERMANAGER_CID, true, nullptr, SystemWorkerManagerConstructor },
#endif #endif
#ifdef MOZ_B2G_BT #ifdef MOZ_B2G_BT
@ -1201,7 +1201,7 @@ static const mozilla::Module::ContractIDEntry kLayoutContracts[] = {
{ INDEXEDDB_MANAGER_CONTRACTID, &kINDEXEDDB_MANAGER_CID }, { INDEXEDDB_MANAGER_CONTRACTID, &kINDEXEDDB_MANAGER_CID },
{ DOMREQUEST_SERVICE_CONTRACTID, &kDOMREQUEST_SERVICE_CID }, { DOMREQUEST_SERVICE_CONTRACTID, &kDOMREQUEST_SERVICE_CID },
{ QUOTA_MANAGER_CONTRACTID, &kQUOTA_MANAGER_CID }, { QUOTA_MANAGER_CONTRACTID, &kQUOTA_MANAGER_CID },
#ifdef MOZ_B2G_RIL #ifdef MOZ_WIDGET_GONK
{ SYSTEMWORKERMANAGER_CONTRACTID, &kSYSTEMWORKERMANAGER_CID }, { SYSTEMWORKERMANAGER_CONTRACTID, &kSYSTEMWORKERMANAGER_CID },
#endif #endif
#ifdef MOZ_B2G_BT #ifdef MOZ_B2G_BT
@ -1286,8 +1286,8 @@ static const mozilla::Module::CategoryEntry kLayoutCategories[] = {
{ "app-startup", "Volume Service", "service," NS_VOLUMESERVICE_CONTRACTID }, { "app-startup", "Volume Service", "service," NS_VOLUMESERVICE_CONTRACTID },
#endif #endif
CONTENTDLF_CATEGORIES CONTENTDLF_CATEGORIES
#ifdef MOZ_B2G_RIL #ifdef MOZ_WIDGET_GONK
{ "profile-after-change", "Telephony System Worker Manager", SYSTEMWORKERMANAGER_CONTRACTID }, { "profile-after-change", "Gonk System Worker Manager", SYSTEMWORKERMANAGER_CONTRACTID },
#endif #endif
#ifdef MOZ_B2G_BT #ifdef MOZ_B2G_BT
{ "profile-after-change", "Bluetooth Service", BLUETOOTHSERVICE_CONTRACTID }, { "profile-after-change", "Bluetooth Service", BLUETOOTHSERVICE_CONTRACTID },

View File

@ -96,12 +96,12 @@ OS_LIBS += -ldbus
endif endif
endif #} endif #}
ifneq ($(strip $(MOZ_B2G_RIL)$(MOZ_B2G_BT)),) #{ ifneq ($(strip $(MOZ_B2G_RIL)$(MOZ_B2G_BT)$(filter gonk,$(MOZ_WIDGET_TOOLKIT))),) #{
STATIC_LIBS += mozipcunixsocket_s mozkeystore_s STATIC_LIBS += mozipcunixsocket_s
endif #} endif #}
ifeq (gonk,$(MOZ_WIDGET_TOOLKIT)) ifeq (gonk,$(MOZ_WIDGET_TOOLKIT))
STATIC_LIBS += moznetd_s STATIC_LIBS += moznetd_s mozkeystore_s
endif endif
ifdef MOZ_B2G_CAMERA #{ ifdef MOZ_B2G_CAMERA #{