canmove, Confirmed users
725
edits
(→Gecko: DOM APIs: fix links) |
|||
| Line 261: | Line 261: | ||
** <code>ril_worker.js</code>: worker thread that talks to <code>rild</code> (via <code>rilproxy</code>) and implements the radio state machine. | ** <code>ril_worker.js</code>: worker thread that talks to <code>rild</code> (via <code>rilproxy</code>) and implements the radio state machine. | ||
** <code>nsIRadioInterfaceLayer</code>: main thread XPCOM service that mostly acts as a message exchange between the <code>ril_worker.js</code> thread and various other Gecko components, including the Gecko content processes. | ** <code>nsIRadioInterfaceLayer</code>: main thread XPCOM service that mostly acts as a message exchange between the <code>ril_worker.js</code> thread and various other Gecko components, including the Gecko content processes. | ||
* Gecko content process | * Gecko <em>content process</em> | ||
** <code>nsIRILContentHelper</code>: XPCOM service that let's DOM implementations such as Telephony, SMS, etc. talk to <code>nsIRadioInterfaceLayer</code> in the chrome process. | |||
=== Example === | |||
Let's start with an example that demonstrates the lower-level parts of the system. When the modem receives an incoming call, it notifies the <code>rild</code> using a proprietary mechanism. The rild then prepares a message for its client according to the "open" protocol [https://github.com/mozilla-b2g/android-hardware-ril/blob/master/include/telephony/ril.h here]. In this case, an incoming call generates the [https://github.com/mozilla-b2g/android-hardware-ril/blob/master/include/telephony/ril.h#L3290 RIL_UNSOL_RESPONSE_CALL_STATE_CHANGED] message. This message is sent by rild to its client and received by rilproxy [https://github.com/mozilla-b2g/rilproxy/blob/master/src/rilproxy.c#L214 here] | Let's start with an example that demonstrates the lower-level parts of the system. When the modem receives an incoming call, it notifies the <code>rild</code> using a proprietary mechanism. The rild then prepares a message for its client according to the "open" protocol [https://github.com/mozilla-b2g/android-hardware-ril/blob/master/include/telephony/ril.h here]. In this case, an incoming call generates the [https://github.com/mozilla-b2g/android-hardware-ril/blob/master/include/telephony/ril.h#L3290 RIL_UNSOL_RESPONSE_CALL_STATE_CHANGED] message. This message is sent by rild to its client and received by rilproxy [https://github.com/mozilla-b2g/rilproxy/blob/master/src/rilproxy.c#L214 here] | ||
| Line 270: | Line 273: | ||
} | } | ||
</pre> | </pre> | ||
where it's forwarded along to Gecko, on the socket connecting rilproxy and Gecko. Gecko receives these forwarded bytes [https:// | where it's forwarded along to Gecko, on the socket connecting rilproxy and Gecko. Gecko receives these forwarded bytes [https://mxr.mozilla.org/mozilla-central/source/ipc/ril/Ril.cpp#231 on the IPC thread] like so: | ||
<pre> | <pre> | ||
int ret = read(fd, mIncoming->mData, 1024); | int ret = read(fd, mIncoming->mData, 1024); | ||
| Line 277: | Line 280: | ||
sConsumer->MessageReceived(mIncoming.forget()); | sConsumer->MessageReceived(mIncoming.forget()); | ||
</pre> | </pre> | ||
The consumer is [https:// | The consumer is [https://mxr.mozilla.org/mozilla-central/source/dom/system/gonk/SystemWorkerManager.cpp#160 SystemWorkerManager] which repackages the message and dispatches it to the <code>ril_worker.js</code> thread that implements the RIL state machine: | ||
<pre> | <pre> | ||
virtual void MessageReceived(RilRawData *aMessage) { | virtual void MessageReceived(RilRawData *aMessage) { | ||
| Line 284: | Line 287: | ||
} | } | ||
</pre> | </pre> | ||
The task posted to that thread | The task posted to that thread [https://mxr.mozilla.org/mozilla-central/source/dom/system/gonk/SystemWorkerManager.cpp#181 calls a function] <code>onRILMessage()</code> in the JS code on the RIL worker: | ||
<pre> | <pre> | ||
return JS_CallFunctionName(aCx, obj, "onRILMessage", NS_ARRAY_LENGTH(argv), | return JS_CallFunctionName(aCx, obj, "onRILMessage", NS_ARRAY_LENGTH(argv), | ||
argv, argv); | argv, argv); | ||
</pre> | </pre> | ||
That function is [https://mxr.mozilla.org/mozilla-central/source/dom/system/gonk/ril_worker.js#4482 defined in <code>ril_worker.js</code>]. The message bytes are processed a bit, until finally we dispatch the message [https://github.com/cgjones/mozilla-central/blob/master/dom/system/b2g/ril_worker.js#L888 here] | |||
<pre> | <pre> | ||
handleParcel: function handleParcel(request_type, length) { | handleParcel: function handleParcel(request_type, length) { | ||