Philipp von Weitershausen [:philikon] <
phi...@weitershausen.de> has asked
Jonas Sicking (:sicking) <
jo...@sicking.cc> for superreview:
Bug 744344: B2G RIL: Allow network to be selected manually
https://bugzilla.mozilla.org/show_bug.cgi?id=744344
Attachment 625655: Initial patch for implementation of
mozMobileConnection.getNetworks()
https://bugzilla.mozilla.org/attachment.cgi?id=625655&action=edit
------- Additional Comments from Philipp von Weitershausen [:philikon]
<
phi...@weitershausen.de>
Review of attachment 625655:
-----------------------------------------------------------------
Great start! Just a few suggestions/nits beliow.
Note that this is also only one half of the feature. We would still need to
allow a user to manually choose the operator. Perhaps we should do that in a
follow-up though, since we might want to bikeshed^W debate the exact mechanism
(settings API and if so, which value? setting `operator`? ...)
::: dom/network/interfaces/nsIDOMMobileConnection.idl
@@ +31,5 @@
>
> /**
> * Search for available networks.
> *
> + * If successful, the request result will be an array of
nsIDOMMozMobileOperatorInfo.
I'm generally in favour of this plan. Should we also make
nsIDOMMozMobileConnectionInfo::operator an nsIDOMMozMobileOperatorInfo?
In any case, asking sicking for superreview on the interface.
@@ +119,5 @@
> +
> + /**
> + * Numeric id of the network operator (in the form of a String)
> + */
> + readonly attribute DOMString numeric;
Can you find out if we can make this a `long`?
@@ +124,5 @@
> +
> + /**
> + * State of this network operator.
> + *
> + * Possible values: 'unknown', 'available', 'connected', 'forbidden'
In other APIs we've used `null` instead of the string 'unknown'
::: dom/system/gonk/RILContentHelper.js
@@ +121,5 @@
>
> cardState: RIL.GECKO_CARDSTATE_UNAVAILABLE,
> voiceConnectionInfo: null,
> dataConnectionInfo: null,
> + _domRequests: null,
Please rebase your patch on top of bug 731786 where this has already been
implemented.
::: dom/system/gonk/ril_worker.js
@@ +1098,5 @@
>
> /**
> + * Get the available networks (GSM only?)
> + */
> + getAvailableNetworks: function getAvailableNetworks(message) {
For no good reason, our convention is to call the parameter `options` here. (I
would not be opposed to a file-global renaming, but we should keep it
consistent for now.)
@@ +1100,5 @@
> + * Get the available networks (GSM only?)
> + */
> + getAvailableNetworks: function getAvailableNetworks(message) {
> + if (DEBUG) debug("Getting available networks");
> + Buf.newParcel(REQUEST_QUERY_AVAILABLE_NETWORKS, { requestId:
message.requestId });
Just pass the message object. No need to create objects unnecessarily.
@@ +2591,5 @@
> };
> RIL[REQUEST_SET_NETWORK_SELECTION_AUTOMATIC] = null;
> RIL[REQUEST_SET_NETWORK_SELECTION_MANUAL] = null;
> +RIL[REQUEST_QUERY_AVAILABLE_NETWORKS] = function
REQUEST_QUERY_AVAILABLE_NETWORKS(length, options) {
> + let message = {type: "getAvailableNetworks", requestId:
options.requestId};
If you pass the message object in `getAvailableNetworks`, the `options`
parameter will contain exactly this information already.
@@ +2595,5 @@
> + let message = {type: "getAvailableNetworks", requestId:
options.requestId};
> +
> + if (options.rilRequestError) {
> + message.error = options.rilRequestError;
> + this.sendDOMMessage(message);
Again, you can just morph `options` into the object you want to throw over the
wall to the main thread.
@@ +2596,5 @@
> +
> + if (options.rilRequestError) {
> + message.error = options.rilRequestError;
> + this.sendDOMMessage(message);
> + return;
Also, you want to notify a different message name, e.g.
"RIL:GetAvailableNetworks:KO", to indicate the error. See bug 731786 for some
good examples.
@@ +2607,5 @@
> + networks.push({
> + longName: strings[i],
> + shortName: strings[i+1],
> + numeric: strings[i+2],
> + state: strings[i+3]
Indent by two spaces, please.
@@ +2612,5 @@
> + });
> + }
> +
> + message.networks = networks;
> + this.sendDOMMessage(message);
See above re: reusing `options`