mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 920551 - 2.h/2: fix dom/system/gonk/*. r=hsinyi,khuey
This commit is contained in:
parent
4796c5c220
commit
4732a65627
@ -430,7 +430,7 @@ pref("services.push.requestTimeout", 10000);
|
||||
pref("services.push.udp.wakeupEnabled", true);
|
||||
|
||||
// NetworkStats
|
||||
#ifdef MOZ_B2G_RIL
|
||||
#ifdef MOZ_WIDGET_GONK
|
||||
pref("dom.mozNetworkStats.enabled", true);
|
||||
pref("dom.webapps.firstRunWithSIM", true);
|
||||
#endif
|
||||
|
@ -18,7 +18,7 @@ Cu.import("resource://gre/modules/AppsUtils.jsm");
|
||||
Cu.import('resource://gre/modules/UserAgentOverrides.jsm');
|
||||
Cu.import('resource://gre/modules/Keyboard.jsm');
|
||||
Cu.import('resource://gre/modules/ErrorPage.jsm');
|
||||
#ifdef MOZ_B2G_RIL
|
||||
#ifdef MOZ_WIDGET_GONK
|
||||
Cu.import('resource://gre/modules/NetworkStatsService.jsm');
|
||||
#endif
|
||||
|
||||
@ -611,7 +611,7 @@ var shell = {
|
||||
|
||||
this.sendEvent(window, 'ContentStart');
|
||||
|
||||
#ifdef MOZ_B2G_RIL
|
||||
#ifdef MOZ_WIDGET_GONK
|
||||
Cu.import('resource://gre/modules/OperatorApps.jsm');
|
||||
#endif
|
||||
|
||||
|
@ -164,10 +164,12 @@
|
||||
@BINPATH@/components/dom_audiochannel.xpt
|
||||
@BINPATH@/components/dom_base.xpt
|
||||
@BINPATH@/components/dom_system.xpt
|
||||
#ifdef MOZ_B2G_RIL
|
||||
@BINPATH@/components/dom_voicemail.xpt
|
||||
#ifdef MOZ_WIDGET_GONK
|
||||
@BINPATH@/components/dom_wifi.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_cellbroadcast.xpt
|
||||
@BINPATH@/components/dom_wappush.xpt
|
||||
@ -400,11 +402,31 @@
|
||||
@BINPATH@/components/nsSidebar.manifest
|
||||
@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)
|
||||
@BINPATH@/components/MmsService.js
|
||||
@BINPATH@/components/MmsService.manifest
|
||||
@BINPATH@/components/MobileMessageDatabaseService.js
|
||||
@BINPATH@/components/MobileMessageDatabaseService.manifest
|
||||
@BINPATH@/components/RadioInterfaceLayer.js
|
||||
@BINPATH@/components/RadioInterfaceLayer.manifest
|
||||
@BINPATH@/components/RILContentHelper.js
|
||||
@BINPATH@/components/TelephonyProvider.js
|
||||
@BINPATH@/components/TelephonyProvider.manifest
|
||||
#endif // MOZ_WIDGET_GONK && MOZ_B2G_RIL
|
||||
@ -474,23 +496,6 @@
|
||||
@BINPATH@/components/webvtt.xpt
|
||||
@BINPATH@/components/WebVTT.manifest
|
||||
@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
|
||||
@BINPATH@/components/@DLL_PREFIX@dbusservice@DLL_SUFFIX@
|
||||
#endif
|
||||
|
@ -19,7 +19,7 @@ LOCAL_INCLUDES += \
|
||||
-I$(srcdir)/../../../layout/xul/tree/ \
|
||||
$(NULL)
|
||||
|
||||
ifdef MOZ_B2G_RIL
|
||||
ifeq (gonk,$(MOZ_WIDGET_TOOLKIT))
|
||||
LOCAL_INCLUDES += \
|
||||
-I$(srcdir)/../../../dom/wifi \
|
||||
$(NULL)
|
||||
|
@ -37,7 +37,7 @@ DOM_SRCDIRS = \
|
||||
dom/camera \
|
||||
$(NULL)
|
||||
|
||||
ifdef MOZ_B2G_RIL
|
||||
ifeq (gonk,$(MOZ_WIDGET_TOOLKIT))
|
||||
DOM_SRCDIRS += \
|
||||
dom/system/gonk \
|
||||
dom/wifi \
|
||||
|
@ -80,9 +80,11 @@ PARALLEL_DIRS += [
|
||||
if CONFIG['OS_ARCH'] == 'WINNT':
|
||||
PARALLEL_DIRS += ['plugins/ipc/hangui']
|
||||
|
||||
if CONFIG['MOZ_WIDGET_TOOLKIT'] == 'gonk':
|
||||
PARALLEL_DIRS += ['wifi']
|
||||
|
||||
if CONFIG['MOZ_B2G_RIL']:
|
||||
PARALLEL_DIRS += [
|
||||
'wifi',
|
||||
'icc',
|
||||
'cellbroadcast',
|
||||
'voicemail',
|
||||
|
@ -22,10 +22,14 @@ if CONFIG['MOZ_B2G_RIL']:
|
||||
'nsIDOMMobileConnection.idl',
|
||||
'nsIDOMMozEmergencyCbModeEvent.idl',
|
||||
'nsIDOMMozOtaStatusEvent.idl',
|
||||
'nsIDOMNetworkStats.idl',
|
||||
'nsIDOMNetworkStatsManager.idl',
|
||||
'nsIDOMUSSDReceivedEvent.idl',
|
||||
'nsIMobileConnectionProvider.idl',
|
||||
]
|
||||
|
||||
if CONFIG['MOZ_WIDGET_TOOLKIT'] == 'gonk':
|
||||
XPIDL_SOURCES += [
|
||||
'nsIDOMNetworkStats.idl',
|
||||
'nsIDOMNetworkStatsManager.idl',
|
||||
'nsINetworkStatsServiceProxy.idl',
|
||||
]
|
||||
|
||||
|
@ -28,6 +28,8 @@ if CONFIG['MOZ_B2G_RIL']:
|
||||
CPP_SOURCES += [
|
||||
'MobileConnection.cpp',
|
||||
]
|
||||
|
||||
if CONFIG['MOZ_WIDGET_TOOLKIT'] == 'gonk':
|
||||
EXTRA_JS_MODULES = [
|
||||
'NetworkStatsDB.jsm',
|
||||
'NetworkStatsService.jsm',
|
||||
@ -43,7 +45,7 @@ EXTRA_PP_COMPONENTS += [
|
||||
'TCPSocket.js',
|
||||
]
|
||||
|
||||
if CONFIG['MOZ_B2G_RIL']:
|
||||
if CONFIG['MOZ_WIDGET_TOOLKIT'] == 'gonk':
|
||||
EXTRA_COMPONENTS += [
|
||||
'NetworkStatsManager.js',
|
||||
'NetworkStatsManager.manifest',
|
||||
|
@ -9,7 +9,7 @@ MOCHITEST_FILES = \
|
||||
test_tcpsocket_enabled_with_perm.html \
|
||||
$(NULL)
|
||||
|
||||
ifdef MOZ_B2G_RIL
|
||||
ifeq (gonk,$(MOZ_WIDGET_TOOLKIT))
|
||||
MOCHITEST_FILES = \
|
||||
test_networkstats_basics.html \
|
||||
test_networkstats_disabled.html \
|
||||
|
@ -133,8 +133,10 @@ function defineLazyRegExp(obj, name, pattern) {
|
||||
function NetworkManager() {
|
||||
this.networkInterfaces = {};
|
||||
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_UNREGISTERED, true);
|
||||
#endif
|
||||
Services.obs.addObserver(this, TOPIC_XPCOM_SHUTDOWN, false);
|
||||
Services.obs.addObserver(this, TOPIC_MOZSETTINGS_CHANGED, false);
|
||||
|
||||
@ -229,6 +231,7 @@ NetworkManager.prototype = {
|
||||
debug("Network " + network.name + " changed state to " + network.state);
|
||||
switch (network.state) {
|
||||
case Ci.nsINetworkInterface.NETWORK_STATE_CONNECTED:
|
||||
#ifdef MOZ_B2G_RIL
|
||||
// Add host route for data calls
|
||||
if (network.type == Ci.nsINetworkInterface.NETWORK_TYPE_MOBILE ||
|
||||
network.type == Ci.nsINetworkInterface.NETWORK_TYPE_MOBILE_MMS ||
|
||||
@ -238,14 +241,17 @@ NetworkManager.prototype = {
|
||||
}
|
||||
// Add extra host route. For example, mms proxy or mmsc.
|
||||
this.setExtraHostRoute(network);
|
||||
#endif
|
||||
// Remove pre-created default route and let setAndConfigureActive()
|
||||
// to set default route only on preferred network
|
||||
this.removeDefaultRoute(network.name);
|
||||
this.setAndConfigureActive();
|
||||
#ifdef MOZ_B2G_RIL
|
||||
// Update data connection when Wifi connected/disconnected
|
||||
if (network.type == Ci.nsINetworkInterface.NETWORK_TYPE_WIFI) {
|
||||
this.mRIL.getRadioInterface(0).updateRILNetworkInterface();
|
||||
}
|
||||
#endif
|
||||
|
||||
this.onConnectionChanged(network);
|
||||
|
||||
@ -253,6 +259,7 @@ NetworkManager.prototype = {
|
||||
CaptivePortalDetectionHelper.notify(CaptivePortalDetectionHelper.EVENT_CONNECT, this.active);
|
||||
break;
|
||||
case Ci.nsINetworkInterface.NETWORK_STATE_DISCONNECTED:
|
||||
#ifdef MOZ_B2G_RIL
|
||||
// Remove host route for data calls
|
||||
if (network.type == Ci.nsINetworkInterface.NETWORK_TYPE_MOBILE ||
|
||||
network.type == Ci.nsINetworkInterface.NETWORK_TYPE_MOBILE_MMS ||
|
||||
@ -261,22 +268,28 @@ NetworkManager.prototype = {
|
||||
}
|
||||
// Remove extra host route. For example, mms proxy or mmsc.
|
||||
this.removeExtraHostRoute(network);
|
||||
#endif
|
||||
// Remove routing table in /proc/net/route
|
||||
if (network.type == Ci.nsINetworkInterface.NETWORK_TYPE_WIFI) {
|
||||
this.resetRoutingTable(network);
|
||||
#ifdef MOZ_B2G_RIL
|
||||
} else if (network.type == Ci.nsINetworkInterface.NETWORK_TYPE_MOBILE) {
|
||||
this.removeDefaultRoute(network.name);
|
||||
#endif
|
||||
}
|
||||
// Abort ongoing captive portal detection on the wifi interface
|
||||
CaptivePortalDetectionHelper.notify(CaptivePortalDetectionHelper.EVENT_DISCONNECT, network);
|
||||
this.setAndConfigureActive();
|
||||
#ifdef MOZ_B2G_RIL
|
||||
// Update data connection when Wifi connected/disconnected
|
||||
if (network.type == Ci.nsINetworkInterface.NETWORK_TYPE_WIFI) {
|
||||
this.mRIL.getRadioInterface(0).updateRILNetworkInterface();
|
||||
}
|
||||
#endif
|
||||
break;
|
||||
}
|
||||
break;
|
||||
#ifdef MOZ_B2G_RIL
|
||||
case TOPIC_INTERFACE_REGISTERED:
|
||||
let regNetwork = subject.QueryInterface(Ci.nsINetworkInterface);
|
||||
// Add extra host route. For example, mms proxy or mmsc.
|
||||
@ -287,6 +300,7 @@ NetworkManager.prototype = {
|
||||
// Remove extra host route. For example, mms proxy or mmsc.
|
||||
this.removeExtraHostRoute(unregNetwork);
|
||||
break;
|
||||
#endif
|
||||
case TOPIC_MOZSETTINGS_CHANGED:
|
||||
let setting = JSON.parse(data);
|
||||
this.handle(setting.key, setting.value);
|
||||
@ -299,8 +313,10 @@ NetworkManager.prototype = {
|
||||
case TOPIC_XPCOM_SHUTDOWN:
|
||||
Services.obs.removeObserver(this, TOPIC_XPCOM_SHUTDOWN);
|
||||
Services.obs.removeObserver(this, TOPIC_MOZSETTINGS_CHANGED);
|
||||
#ifdef MOZ_B2G_RIL
|
||||
Services.obs.removeObserver(this, TOPIC_INTERFACE_REGISTERED);
|
||||
Services.obs.removeObserver(this, TOPIC_INTERFACE_UNREGISTERED);
|
||||
#endif
|
||||
Services.obs.removeObserver(this, TOPIC_INTERFACE_STATE_CHANGED);
|
||||
break;
|
||||
}
|
||||
@ -309,15 +325,19 @@ NetworkManager.prototype = {
|
||||
receiveMessage: function receiveMessage(aMsg) {
|
||||
switch (aMsg.name) {
|
||||
case "NetworkInterfaceList:ListInterface": {
|
||||
#ifdef MOZ_B2G_RIL
|
||||
let excludeMms = aMsg.json.exculdeMms;
|
||||
let excludeSupl = aMsg.json.exculdeSupl;
|
||||
#endif
|
||||
let interfaces = [];
|
||||
|
||||
for each (let i in this.networkInterfaces) {
|
||||
#ifdef MOZ_B2G_RIL
|
||||
if ((i.type == Ci.nsINetworkInterface.NETWORK_TYPE_MOBILE_MMS && excludeMms) ||
|
||||
(i.type == Ci.nsINetworkInterface.NETWORK_TYPE_MOBILE_SUPL && excludeSupl)) {
|
||||
continue;
|
||||
}
|
||||
#endif
|
||||
interfaces.push({
|
||||
state: i.state,
|
||||
type: i.type,
|
||||
@ -349,12 +369,14 @@ NetworkManager.prototype = {
|
||||
Cr.NS_ERROR_INVALID_ARG);
|
||||
}
|
||||
this.networkInterfaces[network.name] = network;
|
||||
#ifdef MOZ_B2G_RIL
|
||||
// Add host route for data calls
|
||||
if (network.type == Ci.nsINetworkInterface.NETWORK_TYPE_MOBILE ||
|
||||
network.type == Ci.nsINetworkInterface.NETWORK_TYPE_MOBILE_MMS ||
|
||||
network.type == Ci.nsINetworkInterface.NETWORK_TYPE_MOBILE_SUPL) {
|
||||
this.addHostRoute(network);
|
||||
}
|
||||
#endif
|
||||
// Remove pre-created default route and let setAndConfigureActive()
|
||||
// to set default route only on preferred network
|
||||
this.removeDefaultRoute(network.name);
|
||||
@ -373,12 +395,14 @@ NetworkManager.prototype = {
|
||||
Cr.NS_ERROR_INVALID_ARG);
|
||||
}
|
||||
delete this.networkInterfaces[network.name];
|
||||
#ifdef MOZ_B2G_RIL
|
||||
// Remove host route for data calls
|
||||
if (network.type == Ci.nsINetworkInterface.NETWORK_TYPE_MOBILE ||
|
||||
network.type == Ci.nsINetworkInterface.NETWORK_TYPE_MOBILE_MMS ||
|
||||
network.type == Ci.nsINetworkInterface.NETWORK_TYPE_MOBILE_SUPL) {
|
||||
this.removeHostRoute(network);
|
||||
}
|
||||
#endif
|
||||
this.setAndConfigureActive();
|
||||
Services.obs.notifyObservers(network, TOPIC_INTERFACE_UNREGISTERED, null);
|
||||
debug("Network '" + network.name + "' unregistered.");
|
||||
@ -393,8 +417,12 @@ NetworkManager.prototype = {
|
||||
return this._preferredNetworkType;
|
||||
},
|
||||
set preferredNetworkType(val) {
|
||||
#ifdef MOZ_B2G_RIL
|
||||
if ([Ci.nsINetworkInterface.NETWORK_TYPE_WIFI,
|
||||
Ci.nsINetworkInterface.NETWORK_TYPE_MOBILE].indexOf(val) == -1) {
|
||||
#else
|
||||
if (val != Ci.nsINetworkInterface.NETWORK_TYPE_WIFI) {
|
||||
#endif
|
||||
throw "Invalid network type";
|
||||
}
|
||||
this._preferredNetworkType = val;
|
||||
@ -407,10 +435,12 @@ NetworkManager.prototype = {
|
||||
_activeInfo: null,
|
||||
|
||||
overrideActive: function overrideActive(network) {
|
||||
#ifdef MOZ_B2G_RIL
|
||||
if (network.type == Ci.nsINetworkInterface.NETWORK_TYPE_MOBILE_MMS ||
|
||||
network.type == Ci.nsINetworkInterface.NETWORK_TYPE_MOBILE_SUPL) {
|
||||
throw "Invalid network type";
|
||||
}
|
||||
#endif
|
||||
this._overriddenActive = network;
|
||||
this.setAndConfigureActive();
|
||||
},
|
||||
@ -482,6 +512,7 @@ NetworkManager.prototype = {
|
||||
}
|
||||
},
|
||||
|
||||
#ifdef MOZ_B2G_RIL
|
||||
setExtraHostRoute: function setExtraHostRoute(network) {
|
||||
if (network.type == Ci.nsINetworkInterface.NETWORK_TYPE_MOBILE_MMS) {
|
||||
debug("Network '" + network.name + "' registered, adding mmsproxy and/or mmsc route");
|
||||
@ -501,6 +532,7 @@ NetworkManager.prototype = {
|
||||
this.removeHostRouteWithResolve(network, mmsHosts);
|
||||
}
|
||||
},
|
||||
#endif // MOZ_B2G_RIL
|
||||
|
||||
/**
|
||||
* Determine the active interface and configure it.
|
||||
@ -508,7 +540,6 @@ NetworkManager.prototype = {
|
||||
setAndConfigureActive: function setAndConfigureActive() {
|
||||
debug("Evaluating whether active network needs to be changed.");
|
||||
let oldActive = this.active;
|
||||
let defaultDataNetwork;
|
||||
|
||||
if (this._overriddenActive) {
|
||||
debug("We have an override for the active network: " +
|
||||
@ -534,13 +565,18 @@ NetworkManager.prototype = {
|
||||
// Find a suitable network interface to activate.
|
||||
this.active = null;
|
||||
this._activeInfo = Object.create(null);
|
||||
#ifdef MOZ_B2G_RIL
|
||||
let defaultDataNetwork;
|
||||
#endif
|
||||
for each (let network in this.networkInterfaces) {
|
||||
if (network.state != Ci.nsINetworkInterface.NETWORK_STATE_CONNECTED) {
|
||||
continue;
|
||||
}
|
||||
#ifdef MOZ_B2G_RIL
|
||||
if (network.type == Ci.nsINetworkInterface.NETWORK_TYPE_MOBILE) {
|
||||
defaultDataNetwork = network;
|
||||
}
|
||||
#endif
|
||||
this.active = network;
|
||||
this._activeInfo = {name:network.name, ip:network.ip, netmask:network.netmask};
|
||||
if (network.type == this.preferredNetworkType) {
|
||||
@ -549,6 +585,7 @@ NetworkManager.prototype = {
|
||||
}
|
||||
}
|
||||
if (this.active) {
|
||||
#ifdef MOZ_B2G_RIL
|
||||
// Give higher priority to default data APN than seconary APN.
|
||||
// If default data APN is not connected, we still set default route
|
||||
// and DNS on seconary APN.
|
||||
@ -563,8 +600,11 @@ NetworkManager.prototype = {
|
||||
this.active.type == Ci.nsINetworkInterface.NETWORK_TYPE_MOBILE_SUPL) {
|
||||
this.setDNS(this.active);
|
||||
} else {
|
||||
#endif // MOZ_B2G_RIL
|
||||
this.setDefaultRouteAndDNS(oldActive);
|
||||
#ifdef MOZ_B2G_RIL
|
||||
}
|
||||
#endif
|
||||
if (this.active != oldActive) {
|
||||
Services.obs.notifyObservers(this.active, TOPIC_ACTIVE_CHANGED, null);
|
||||
}
|
||||
@ -589,6 +629,7 @@ NetworkManager.prototype = {
|
||||
this.worker.postMessage(options);
|
||||
},
|
||||
|
||||
#ifdef MOZ_B2G_RIL
|
||||
setDNS: function setDNS(networkInterface) {
|
||||
debug("Going DNS to " + networkInterface.name);
|
||||
let options = {
|
||||
@ -599,6 +640,7 @@ NetworkManager.prototype = {
|
||||
};
|
||||
this.worker.postMessage(options);
|
||||
},
|
||||
#endif
|
||||
|
||||
setDefaultRouteAndDNS: function setDefaultRouteAndDNS(oldInterface) {
|
||||
debug("Going to change route and DNS to " + this.active.name);
|
||||
@ -623,6 +665,7 @@ NetworkManager.prototype = {
|
||||
this.worker.postMessage(options);
|
||||
},
|
||||
|
||||
#ifdef MOZ_B2G_RIL
|
||||
addHostRoute: function addHostRoute(network) {
|
||||
debug("Going to add host route on " + network.name);
|
||||
let options = {
|
||||
@ -702,6 +745,7 @@ NetworkManager.prototype = {
|
||||
};
|
||||
this.worker.postMessage(options);
|
||||
},
|
||||
#endif // MOZ_B2G_RIL
|
||||
|
||||
setNetworkProxy: function setNetworkProxy(network) {
|
||||
try {
|
||||
@ -1220,9 +1264,11 @@ let CaptivePortalDetectionHelper = (function() {
|
||||
};
|
||||
}());
|
||||
|
||||
#ifdef MOZ_B2G_RIL
|
||||
XPCOMUtils.defineLazyServiceGetter(NetworkManager.prototype, "mRIL",
|
||||
"@mozilla.org/ril;1",
|
||||
"nsIRadioInterfaceLayer");
|
||||
#endif
|
||||
|
||||
this.NSGetFactory = XPCOMUtils.generateNSGetFactory([NetworkManager]);
|
||||
|
||||
|
@ -24,13 +24,13 @@
|
||||
|
||||
#include "jsfriendapi.h"
|
||||
#include "mozilla/dom/workers/Workers.h"
|
||||
#ifdef MOZ_WIDGET_GONK
|
||||
#include "mozilla/ipc/Netd.h"
|
||||
#include "AutoMounter.h"
|
||||
#include "TimeZoneSettingObserver.h"
|
||||
#include "AudioManager.h"
|
||||
#endif
|
||||
#ifdef MOZ_B2G_RIL
|
||||
#include "mozilla/ipc/Ril.h"
|
||||
#endif
|
||||
#include "mozilla/ipc/KeyStore.h"
|
||||
#include "nsIObserverService.h"
|
||||
#include "nsCxPusher.h"
|
||||
@ -44,9 +44,7 @@ USING_WORKERS_NAMESPACE
|
||||
|
||||
using namespace mozilla::dom::gonk;
|
||||
using namespace mozilla::ipc;
|
||||
#ifdef MOZ_WIDGET_GONK
|
||||
using namespace mozilla::system;
|
||||
#endif
|
||||
|
||||
#define NS_NETWORKMANAGER_CID \
|
||||
{ 0x33901e46, 0x33b8, 0x11e1, \
|
||||
@ -60,107 +58,6 @@ NS_DEFINE_CID(kNetworkManagerCID, NS_NETWORKMANAGER_CID);
|
||||
// Doesn't carry a reference, we're owned by services.
|
||||
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
|
||||
DoNetdCommand(JSContext *cx, unsigned argc, JS::Value *vp)
|
||||
{
|
||||
@ -306,8 +203,6 @@ NetdReceiver::DispatchNetdEvent::RunTask(JSContext *aCx)
|
||||
argv, argv);
|
||||
}
|
||||
|
||||
#endif // MOZ_WIDGET_GONK
|
||||
|
||||
} // anonymous namespace
|
||||
|
||||
SystemWorkerManager::SystemWorkerManager()
|
||||
@ -345,14 +240,12 @@ SystemWorkerManager::Init()
|
||||
|
||||
InitKeyStore(cx);
|
||||
|
||||
#ifdef MOZ_WIDGET_GONK
|
||||
InitAutoMounter();
|
||||
InitializeTimeZoneSettingObserver();
|
||||
rv = InitNetd(cx);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
nsCOMPtr<nsIAudioManager> audioManager =
|
||||
do_GetService(NS_AUDIOMANAGER_CONTRACTID);
|
||||
#endif
|
||||
|
||||
nsCOMPtr<nsIObserverService> obs = mozilla::services::GetObserverService();
|
||||
if (!obs) {
|
||||
@ -376,21 +269,14 @@ SystemWorkerManager::Shutdown()
|
||||
|
||||
mShutdown = true;
|
||||
|
||||
#ifdef MOZ_WIDGET_GONK
|
||||
ShutdownAutoMounter();
|
||||
|
||||
#ifdef MOZ_B2G_RIL
|
||||
RilConsumer::Shutdown();
|
||||
#endif
|
||||
|
||||
for (unsigned long i = 0; i < mRilConsumers.Length(); i++) {
|
||||
if (mRilConsumers[i]) {
|
||||
mRilConsumers[i]->Shutdown();
|
||||
mRilConsumers[i] = nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef MOZ_WIDGET_GONK
|
||||
StopNetd();
|
||||
mNetdWorker = nullptr;
|
||||
#endif
|
||||
|
||||
nsCOMPtr<nsIWifi> wifi(do_QueryInterface(mWifiWorker));
|
||||
if (wifi) {
|
||||
@ -433,20 +319,6 @@ SystemWorkerManager::GetInterfaceRequestor()
|
||||
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
|
||||
SystemWorkerManager::GetInterface(const nsIID &aIID, void **aResult)
|
||||
{
|
||||
@ -457,12 +329,10 @@ SystemWorkerManager::GetInterface(const nsIID &aIID, void **aResult)
|
||||
reinterpret_cast<nsIWifi**>(aResult));
|
||||
}
|
||||
|
||||
#ifdef MOZ_WIDGET_GONK
|
||||
if (aIID.Equals(NS_GET_IID(nsINetworkManager))) {
|
||||
return CallQueryInterface(mNetdWorker,
|
||||
reinterpret_cast<nsINetworkManager**>(aResult));
|
||||
}
|
||||
#endif
|
||||
|
||||
NS_WARNING("Got nothing for the requested IID!");
|
||||
return NS_ERROR_NO_INTERFACE;
|
||||
@ -473,15 +343,11 @@ SystemWorkerManager::RegisterRilWorker(unsigned int aClientId,
|
||||
const JS::Value& aWorker,
|
||||
JSContext *aCx)
|
||||
{
|
||||
#ifndef MOZ_B2G_RIL
|
||||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
#else
|
||||
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));
|
||||
|
||||
WorkerCrossThreadDispatcher *wctd =
|
||||
@ -491,18 +357,10 @@ SystemWorkerManager::RegisterRilWorker(unsigned int aClientId,
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
nsRefPtr<ConnectWorkerToRIL> connection = new ConnectWorkerToRIL();
|
||||
if (!wctd->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.
|
||||
mRilConsumers[aClientId] = new RilConsumer(aClientId, wctd);
|
||||
return NS_OK;
|
||||
return RilConsumer::Register(aClientId, wctd);
|
||||
#endif // MOZ_B2G_RIL
|
||||
}
|
||||
|
||||
#ifdef MOZ_WIDGET_GONK
|
||||
nsresult
|
||||
SystemWorkerManager::InitNetd(JSContext *cx)
|
||||
{
|
||||
@ -535,7 +393,6 @@ SystemWorkerManager::InitNetd(JSContext *cx)
|
||||
mNetdWorker = worker;
|
||||
return NS_OK;
|
||||
}
|
||||
#endif
|
||||
|
||||
nsresult
|
||||
SystemWorkerManager::InitWifi(JSContext *cx)
|
||||
|
@ -23,18 +23,13 @@
|
||||
#include "nsIObserver.h"
|
||||
#include "nsAutoPtr.h"
|
||||
#include "nsCOMPtr.h"
|
||||
#include "nsDebug.h"
|
||||
#include "nsDOMEventTargetHelper.h"
|
||||
#include "nsString.h"
|
||||
#include "nsTArray.h"
|
||||
#include "nsXULAppAPI.h" // For XRE_GetProcessType
|
||||
|
||||
class nsIWorkerHolder;
|
||||
|
||||
namespace mozilla {
|
||||
|
||||
namespace ipc {
|
||||
class RilConsumer;
|
||||
class UnixSocketRawData;
|
||||
class KeyStore;
|
||||
}
|
||||
|
||||
@ -60,25 +55,17 @@ public:
|
||||
static nsIInterfaceRequestor*
|
||||
GetInterfaceRequestor();
|
||||
|
||||
static bool SendRilRawData(unsigned long aClientId,
|
||||
ipc::UnixSocketRawData* aRaw);
|
||||
|
||||
private:
|
||||
SystemWorkerManager();
|
||||
~SystemWorkerManager();
|
||||
|
||||
#ifdef MOZ_WIDGET_GONK
|
||||
nsresult InitNetd(JSContext *cx);
|
||||
#endif
|
||||
nsresult InitWifi(JSContext *cx);
|
||||
nsresult InitKeyStore(JSContext *cx);
|
||||
|
||||
#ifdef MOZ_WIDGET_GONK
|
||||
nsCOMPtr<nsIWorkerHolder> mNetdWorker;
|
||||
#endif
|
||||
nsCOMPtr<nsIWorkerHolder> mWifiWorker;
|
||||
|
||||
nsTArray<nsRefPtr<ipc::RilConsumer> > mRilConsumers;
|
||||
nsRefPtr<ipc::KeyStore> mKeyStore;
|
||||
|
||||
bool mShutdown;
|
||||
|
@ -18,7 +18,6 @@ XPIDL_SOURCES += [
|
||||
'nsIAudioManager.idl',
|
||||
'nsINetworkInterfaceListService.idl',
|
||||
'nsINetworkManager.idl',
|
||||
'nsIRadioInterfaceLayer.idl',
|
||||
'nsISystemWorkerManager.idl',
|
||||
'nsIVolume.idl',
|
||||
'nsIVolumeMountLock.idl',
|
||||
@ -31,55 +30,61 @@ XPIDL_MODULE = 'dom_system_gonk'
|
||||
|
||||
MODULE = 'dom'
|
||||
|
||||
if CONFIG['MOZ_WIDGET_TOOLKIT'] == 'gonk':
|
||||
EXPORTS += [
|
||||
'GonkGPSGeolocationProvider.h',
|
||||
'nsVolume.h',
|
||||
'nsVolumeService.h',
|
||||
]
|
||||
CPP_SOURCES += [
|
||||
'AudioChannelManager.cpp',
|
||||
'AudioManager.cpp',
|
||||
'AutoMounter.cpp',
|
||||
'AutoMounterSetting.cpp',
|
||||
'GonkGPSGeolocationProvider.cpp',
|
||||
'nsVolume.cpp',
|
||||
'nsVolumeMountLock.cpp',
|
||||
'nsVolumeService.cpp',
|
||||
'nsVolumeStat.cpp',
|
||||
'OpenFileFinder.cpp',
|
||||
'TimeZoneSettingObserver.cpp',
|
||||
'Volume.cpp',
|
||||
'VolumeCommand.cpp',
|
||||
'VolumeManager.cpp',
|
||||
'VolumeServiceIOThread.cpp',
|
||||
'VolumeServiceTest.cpp',
|
||||
]
|
||||
EXPORTS += [
|
||||
'GonkGPSGeolocationProvider.h',
|
||||
'nsVolume.h',
|
||||
'nsVolumeService.h',
|
||||
]
|
||||
CPP_SOURCES += [
|
||||
'AudioChannelManager.cpp',
|
||||
'AudioManager.cpp',
|
||||
'AutoMounter.cpp',
|
||||
'AutoMounterSetting.cpp',
|
||||
'GonkGPSGeolocationProvider.cpp',
|
||||
'nsVolume.cpp',
|
||||
'nsVolumeMountLock.cpp',
|
||||
'nsVolumeService.cpp',
|
||||
'nsVolumeStat.cpp',
|
||||
'OpenFileFinder.cpp',
|
||||
'SystemWorkerManager.cpp',
|
||||
'TimeZoneSettingObserver.cpp',
|
||||
'Volume.cpp',
|
||||
'VolumeCommand.cpp',
|
||||
'VolumeManager.cpp',
|
||||
'VolumeServiceIOThread.cpp',
|
||||
'VolumeServiceTest.cpp',
|
||||
]
|
||||
|
||||
if CONFIG['ENABLE_TESTS']:
|
||||
XPCSHELL_TESTS_MANIFESTS += ['tests/xpcshell.ini']
|
||||
|
||||
CPP_SOURCES += [
|
||||
'SystemWorkerManager.cpp',
|
||||
]
|
||||
|
||||
EXTRA_COMPONENTS += [
|
||||
'NetworkInterfaceListService.js',
|
||||
'NetworkInterfaceListService.manifest',
|
||||
'NetworkManager.js',
|
||||
'NetworkManager.manifest',
|
||||
'RadioInterfaceLayer.js',
|
||||
'RadioInterfaceLayer.manifest',
|
||||
'RILContentHelper.js',
|
||||
]
|
||||
|
||||
EXTRA_PP_COMPONENTS += [
|
||||
'NetworkManager.js',
|
||||
]
|
||||
EXTRA_JS_MODULES += [
|
||||
'net_worker.js',
|
||||
'ril_consts.js',
|
||||
'ril_worker.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
|
||||
|
||||
LIBXUL_LIBRARY = True
|
||||
|
@ -14,8 +14,7 @@ elif toolkit == 'cocoa':
|
||||
DIRS += ['mac']
|
||||
elif toolkit == 'android':
|
||||
DIRS += ['android']
|
||||
|
||||
if CONFIG['MOZ_B2G_RIL']:
|
||||
elif toolkit == 'gonk':
|
||||
DIRS += ['gonk']
|
||||
|
||||
TEST_DIRS += ['tests']
|
||||
|
@ -513,9 +513,13 @@ if CONFIG['MOZ_B2G_RIL']:
|
||||
'MozStkCommandEvent.webidl',
|
||||
'MozVoicemail.webidl',
|
||||
'MozVoicemailEvent.webidl',
|
||||
'USSDReceivedEvent.webidl',
|
||||
]
|
||||
|
||||
if CONFIG['MOZ_WIDGET_TOOLKIT'] == 'gonk':
|
||||
WEBIDL_FILES += [
|
||||
'MozWifiConnectionInfoEvent.webidl',
|
||||
'MozWifiStatusChangeEvent.webidl',
|
||||
'USSDReceivedEvent.webidl',
|
||||
]
|
||||
|
||||
if CONFIG['MOZ_WEBSPEECH']:
|
||||
|
@ -17,10 +17,10 @@ if CONFIG['MOZ_B2G_RIL']:
|
||||
if CONFIG['MOZ_B2G_BT_BLUEZ']:
|
||||
DIRS += ['dbus']
|
||||
|
||||
if CONFIG['MOZ_B2G_RIL'] or CONFIG['MOZ_B2G_BT']:
|
||||
DIRS += ['unixsocket', 'keystore']
|
||||
if CONFIG['MOZ_B2G_RIL'] or CONFIG['MOZ_B2G_BT'] or CONFIG['MOZ_WIDGET_TOOLKIT'] == 'gonk':
|
||||
DIRS += ['unixsocket']
|
||||
|
||||
if CONFIG['MOZ_WIDGET_TOOLKIT'] == 'gonk':
|
||||
DIRS += ['netd']
|
||||
DIRS += ['netd', 'keystore']
|
||||
|
||||
TOOL_DIRS += ['app']
|
||||
|
169
ipc/ril/Ril.cpp
169
ipc/ril/Ril.cpp
@ -4,6 +4,8 @@
|
||||
* 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 "mozilla/ipc/Ril.h"
|
||||
|
||||
#include <fcntl.h>
|
||||
#include <sys/socket.h>
|
||||
#include <sys/un.h>
|
||||
@ -18,8 +20,8 @@
|
||||
#endif
|
||||
|
||||
#include "jsfriendapi.h"
|
||||
#include "nsTArray.h"
|
||||
#include "nsThreadUtils.h" // For NS_IsMainThread.
|
||||
#include "Ril.h"
|
||||
|
||||
USING_WORKERS_NAMESPACE
|
||||
using namespace mozilla::ipc;
|
||||
@ -32,17 +34,130 @@ const char* RIL_SOCKET_NAME = "/dev/socket/rilproxy";
|
||||
// desktop development.
|
||||
const uint32_t RIL_TEST_PORT = 6200;
|
||||
|
||||
class DispatchRILEvent : public WorkerTask
|
||||
nsTArray<nsRefPtr<mozilla::ipc::RilConsumer> > sRilConsumers;
|
||||
|
||||
class ConnectWorkerToRIL : public WorkerTask
|
||||
{
|
||||
public:
|
||||
DispatchRILEvent(UnixSocketRawData* aMessage)
|
||||
: mMessage(aMessage)
|
||||
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());
|
||||
|
||||
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:
|
||||
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
|
||||
@ -184,11 +299,45 @@ RilConsumer::RilConsumer(unsigned long aClientId,
|
||||
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
|
||||
RilConsumer::Shutdown()
|
||||
{
|
||||
mShutdown = true;
|
||||
CloseSocket();
|
||||
MOZ_ASSERT(NS_IsMainThread());
|
||||
|
||||
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
|
||||
@ -204,20 +353,20 @@ void
|
||||
RilConsumer::OnConnectSuccess()
|
||||
{
|
||||
// Nothing to do here.
|
||||
LOG("RIL[%u]: %s\n", mClientId, __FUNCTION__);
|
||||
LOG("RIL[%lu]: %s\n", mClientId, __FUNCTION__);
|
||||
}
|
||||
|
||||
void
|
||||
RilConsumer::OnConnectError()
|
||||
{
|
||||
LOG("RIL[%u]: %s\n", mClientId, __FUNCTION__);
|
||||
LOG("RIL[%lu]: %s\n", mClientId, __FUNCTION__);
|
||||
CloseSocket();
|
||||
}
|
||||
|
||||
void
|
||||
RilConsumer::OnDisconnect()
|
||||
{
|
||||
LOG("RIL[%u]: %s\n", mClientId, __FUNCTION__);
|
||||
LOG("RIL[%lu]: %s\n", mClientId, __FUNCTION__);
|
||||
if (!mShutdown) {
|
||||
ConnectSocket(new RilConnector(mClientId), mAddress.get(), 1000);
|
||||
}
|
||||
|
@ -16,13 +16,16 @@ namespace ipc {
|
||||
class RilConsumer : public mozilla::ipc::UnixSocketConsumer
|
||||
{
|
||||
public:
|
||||
RilConsumer(unsigned long aClientId,
|
||||
mozilla::dom::workers::WorkerCrossThreadDispatcher* aDispatcher);
|
||||
virtual ~RilConsumer() { }
|
||||
|
||||
void Shutdown();
|
||||
static nsresult Register(unsigned int aClientId,
|
||||
mozilla::dom::workers::WorkerCrossThreadDispatcher* aDispatcher);
|
||||
static void Shutdown();
|
||||
|
||||
private:
|
||||
RilConsumer(unsigned long aClientId,
|
||||
mozilla::dom::workers::WorkerCrossThreadDispatcher* aDispatcher);
|
||||
|
||||
virtual void ReceiveSocketData(nsAutoPtr<UnixSocketRawData>& aMessage);
|
||||
|
||||
virtual void OnConnectSuccess();
|
||||
|
@ -23,6 +23,10 @@ simple_events = [
|
||||
'StyleRuleChangeEvent',
|
||||
'StyleSheetChangeEvent',
|
||||
'StyleSheetApplicableStateChangeEvent',
|
||||
#ifdef MOZ_WIDGET_GONK
|
||||
'MozWifiStatusChangeEvent',
|
||||
'MozWifiConnectionInfoEvent',
|
||||
#endif
|
||||
#ifdef MOZ_B2G_BT
|
||||
'BluetoothDeviceEvent',
|
||||
'BluetoothStatusChangedEvent',
|
||||
@ -32,8 +36,6 @@ simple_events = [
|
||||
'DataErrorEvent',
|
||||
'MozEmergencyCbModeEvent',
|
||||
'MozOtaStatusEvent',
|
||||
'MozWifiStatusChangeEvent',
|
||||
'MozWifiConnectionInfoEvent',
|
||||
'MozCellBroadcastEvent',
|
||||
'MozVoicemailEvent',
|
||||
'USSDReceivedEvent',
|
||||
|
@ -127,9 +127,14 @@ endif #}
|
||||
|
||||
SHARED_LIBRARY_LIBS += $(DEPTH)/dom/camera/$(LIB_PREFIX)domcamera_s.$(LIB_SUFFIX)
|
||||
|
||||
ifdef MOZ_B2G_RIL #{
|
||||
ifeq (gonk,$(MOZ_WIDGET_TOOLKIT))
|
||||
SHARED_LIBRARY_LIBS += \
|
||||
$(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/cellbroadcast/src/$(LIB_PREFIX)dom_cellbroadcast_s.$(LIB_SUFFIX) \
|
||||
$(DEPTH)/dom/voicemail/$(LIB_PREFIX)domvoicemail_s.$(LIB_SUFFIX) \
|
||||
@ -327,7 +332,7 @@ ifdef MOZ_GSTREAMER
|
||||
LOCAL_INCLUDES += $(GSTREAMER_CFLAGS)
|
||||
endif
|
||||
|
||||
ifdef MOZ_B2G_RIL #{
|
||||
ifeq (gonk,$(MOZ_WIDGET_TOOLKIT))
|
||||
LOCAL_INCLUDES += -I$(topsrcdir)/dom/system/gonk
|
||||
endif #}
|
||||
|
||||
|
@ -101,7 +101,7 @@
|
||||
#include "mozilla/dom/nsSynthVoiceRegistry.h"
|
||||
#endif
|
||||
|
||||
#ifdef MOZ_B2G_RIL
|
||||
#ifdef MOZ_WIDGET_GONK
|
||||
#include "SystemWorkerManager.h"
|
||||
using mozilla::dom::gonk::SystemWorkerManager;
|
||||
#define SYSTEMWORKERMANAGER_CID \
|
||||
@ -288,7 +288,7 @@ NS_GENERIC_FACTORY_SINGLETON_CONSTRUCTOR(DOMRequestService,
|
||||
DOMRequestService::FactoryCreate)
|
||||
NS_GENERIC_FACTORY_SINGLETON_CONSTRUCTOR(QuotaManager,
|
||||
QuotaManager::FactoryCreate)
|
||||
#ifdef MOZ_B2G_RIL
|
||||
#ifdef MOZ_WIDGET_GONK
|
||||
NS_GENERIC_FACTORY_SINGLETON_CONSTRUCTOR(SystemWorkerManager,
|
||||
SystemWorkerManager::FactoryCreate)
|
||||
#endif
|
||||
@ -754,7 +754,7 @@ NS_DEFINE_NAMED_CID(NS_TEXTEDITOR_CID);
|
||||
NS_DEFINE_NAMED_CID(INDEXEDDB_MANAGER_CID);
|
||||
NS_DEFINE_NAMED_CID(DOMREQUEST_SERVICE_CID);
|
||||
NS_DEFINE_NAMED_CID(QUOTA_MANAGER_CID);
|
||||
#ifdef MOZ_B2G_RIL
|
||||
#ifdef MOZ_WIDGET_GONK
|
||||
NS_DEFINE_NAMED_CID(SYSTEMWORKERMANAGER_CID);
|
||||
#endif
|
||||
#ifdef MOZ_B2G_BT
|
||||
@ -1043,7 +1043,7 @@ static const mozilla::Module::CIDEntry kLayoutCIDs[] = {
|
||||
{ &kINDEXEDDB_MANAGER_CID, false, nullptr, IndexedDatabaseManagerConstructor },
|
||||
{ &kDOMREQUEST_SERVICE_CID, false, nullptr, DOMRequestServiceConstructor },
|
||||
{ &kQUOTA_MANAGER_CID, false, nullptr, QuotaManagerConstructor },
|
||||
#ifdef MOZ_B2G_RIL
|
||||
#ifdef MOZ_WIDGET_GONK
|
||||
{ &kSYSTEMWORKERMANAGER_CID, true, nullptr, SystemWorkerManagerConstructor },
|
||||
#endif
|
||||
#ifdef MOZ_B2G_BT
|
||||
@ -1201,7 +1201,7 @@ static const mozilla::Module::ContractIDEntry kLayoutContracts[] = {
|
||||
{ INDEXEDDB_MANAGER_CONTRACTID, &kINDEXEDDB_MANAGER_CID },
|
||||
{ DOMREQUEST_SERVICE_CONTRACTID, &kDOMREQUEST_SERVICE_CID },
|
||||
{ QUOTA_MANAGER_CONTRACTID, &kQUOTA_MANAGER_CID },
|
||||
#ifdef MOZ_B2G_RIL
|
||||
#ifdef MOZ_WIDGET_GONK
|
||||
{ SYSTEMWORKERMANAGER_CONTRACTID, &kSYSTEMWORKERMANAGER_CID },
|
||||
#endif
|
||||
#ifdef MOZ_B2G_BT
|
||||
@ -1286,8 +1286,8 @@ static const mozilla::Module::CategoryEntry kLayoutCategories[] = {
|
||||
{ "app-startup", "Volume Service", "service," NS_VOLUMESERVICE_CONTRACTID },
|
||||
#endif
|
||||
CONTENTDLF_CATEGORIES
|
||||
#ifdef MOZ_B2G_RIL
|
||||
{ "profile-after-change", "Telephony System Worker Manager", SYSTEMWORKERMANAGER_CONTRACTID },
|
||||
#ifdef MOZ_WIDGET_GONK
|
||||
{ "profile-after-change", "Gonk System Worker Manager", SYSTEMWORKERMANAGER_CONTRACTID },
|
||||
#endif
|
||||
#ifdef MOZ_B2G_BT
|
||||
{ "profile-after-change", "Bluetooth Service", BLUETOOTHSERVICE_CONTRACTID },
|
||||
|
@ -96,12 +96,12 @@ OS_LIBS += -ldbus
|
||||
endif
|
||||
endif #}
|
||||
|
||||
ifneq ($(strip $(MOZ_B2G_RIL)$(MOZ_B2G_BT)),) #{
|
||||
STATIC_LIBS += mozipcunixsocket_s mozkeystore_s
|
||||
ifneq ($(strip $(MOZ_B2G_RIL)$(MOZ_B2G_BT)$(filter gonk,$(MOZ_WIDGET_TOOLKIT))),) #{
|
||||
STATIC_LIBS += mozipcunixsocket_s
|
||||
endif #}
|
||||
|
||||
ifeq (gonk,$(MOZ_WIDGET_TOOLKIT))
|
||||
STATIC_LIBS += moznetd_s
|
||||
STATIC_LIBS += moznetd_s mozkeystore_s
|
||||
endif
|
||||
|
||||
ifdef MOZ_B2G_CAMERA #{
|
||||
|
Loading…
Reference in New Issue
Block a user