Closed Bug 835729 Opened 11 years ago Closed 11 years ago

B2G RIL: we shall update operator's mcc/mnc first then longName/shortName

Categories

(Firefox OS Graveyard :: General, defect)

ARM
Gonk (Firefox OS)
defect
Not set
normal

Tracking

(Not tracked)

RESOLVED FIXED

People

(Reporter: edgar, Assigned: edgar)

References

Details

Attachments

(3 files, 7 obsolete files)

The flow of updating operator's mcc/mnc/longName/shortName seems wrong. We shall update operator's mcc/mnc first then name. But in current flow [1], we update operator's name first then mcc/mnc, so we may use the old mcc/mnc to get operator's name.

[1] http://hg.mozilla.org/mozilla-central/file/0c45e6378f1f/dom/system/gonk/ril_worker.js#l3057
Assignee: nobody → echen
Correct the sequence of updating operator's info.
Attachment #707521 - Flags: review?(allstars.chh)
Attached patch Part 2: xpcshell tests, v2 (obsolete) — Splinter Review
xpcshell tests
Attachment #707522 - Flags: review?(allstars.chh)
Comment on attachment 707521 [details] [diff] [review]
Part 1: Fix updating operator's info, v1

Review of attachment 707521 [details] [diff] [review]:
-----------------------------------------------------------------

I think your patch did fixed the problem,
but I think the problem is the function 'updateNetworkName' is way too complicated,
The function name seems not very well expressed,
it reads so many global data,
and some code seems confusing, for example 
...
    if (iccInfoPriv.OPL) {
      for (let i in iccInfoPriv.OPL) {
...

I leave you to decide whether we could fix it in the bug or file another for it.
Attachment #707521 - Flags: review?(allstars.chh) → review+
Comment on attachment 707522 [details] [diff] [review]
Part 2: xpcshell tests, v2

Review of attachment 707522 [details] [diff] [review]:
-----------------------------------------------------------------

I think we should still keep the unit test for single function, for example, updateNetworkName.
Your test looks more like a huge test for _processOperator, which should test several functions.

I propose to make your test simpler and easier.

::: dom/system/gonk/tests/test_ril_worker_icc.js
@@ +1090,5 @@
>      }
>    }).RIL;
>  
> +  function testNetworkName(operatorData, expectedMCC, expectedMNC,
> +                                         expectedLongName, expectedShortName) {

I think the parameters should be
(operatorData, expectedData), that makes this function more simple.
Attachment #707522 - Flags: review?(allstars.chh)
(In reply to Yoshi Huang[:yoshi][:allstars.chh] from comment #4)
> Comment on attachment 707521 [details] [diff] [review]
> Part 1: Fix updating operator's info, v1
> 
> Review of attachment 707521 [details] [diff] [review]:
> -----------------------------------------------------------------
> 
> I think your patch did fixed the problem,
> but I think the problem is the function 'updateNetworkName' is way too
> complicated,
> The function name seems not very well expressed,
> it reads so many global data,
> and some code seems confusing, for example 
> ...
>     if (iccInfoPriv.OPL) {
>       for (let i in iccInfoPriv.OPL) {
> ...
> 
> I leave you to decide whether we could fix it in the bug or file another for
> it.

Can't agree more. I will try to refactor it in this bug.
Thanks.
Depends on: 838096
Refactor updateNetworkName() and _processOperator()
Attachment #707522 - Attachment is obsolete: true
1). Rebase. (Based on bug 838096)
2). Correct debug logging.
Attachment #707521 - Attachment is obsolete: true
Rebase. (Based on bug 838096)
Attachment #710476 - Attachment is obsolete: true
Update comment
Attachment #711148 - Attachment is obsolete: true
Attached patch Part 3: xpcshell tests, v2 (obsolete) — Splinter Review
Attachment #711147 - Flags: review?(allstars.chh)
Attachment #711161 - Flags: review?(allstars.chh)
Attachment #711163 - Flags: review?(allstars.chh)
Comment on attachment 711147 [details] [diff] [review]
Part 1: Fix updating operator's info, v2

Review of attachment 711147 [details] [diff] [review]:
-----------------------------------------------------------------

::: dom/system/gonk/ril_worker.js
@@ +3087,5 @@
> +      } else {
> +        // According to ril.h, the operator fields will be NULL when the operator
> +        // is not currently registered. We can avoid trying to parse the numeric
> +        // tuple in that case.
> +        if (DEBUG) {

In the original code there's a check for !longName
Can you explain why it's removed?
Attachment #711147 - Flags: review?(allstars.chh)
Comment on attachment 711161 [details] [diff] [review]
Part 2: Refactor updateNetworkName and _processOperator, v3

Review of attachment 711161 [details] [diff] [review]:
-----------------------------------------------------------------

::: dom/system/gonk/ril_worker.js
@@ +1282,5 @@
>      Buf.sendParcel();
>    },
>  
>    /**
> +   * Get network names using EF_OPL and EF_PNN

by using

@@ +1291,5 @@
> +   * @param mcc   The mobile country code of the network.
> +   * @param mnc   The mobile network code of the network.
> +   * @param lac   The location area code of the network.
> +   */
> +  getNetworkName: function getNetworkName(mcc, mnc, lac) {

Although it's called get*Network*Name, but actually the name is from SIM card, with information from OPL and PNN.

To avoid confusion, can you use a better name for this?
Also, can we move this function to ICCUtilsHelper ?
In that case, you also need to rename some data below, for example, this.iccInfo -> RIL.iccInfo.

@@ +1301,5 @@
>        return null;
>      }
>  
> +    // We won't get network name if there is no PNN file.
> +    if (!iccInfoPriv.PNN) {

Can we also add a check for OPL here?
so we won't need to 
if (iccInfoPriv.OPL) below.
Attachment #711161 - Flags: review?(allstars.chh)
Comment on attachment 711163 [details] [diff] [review]
Part 3: xpcshell tests, v2

Review of attachment 711163 [details] [diff] [review]:
-----------------------------------------------------------------

This looks okay to me,
but I'd like to review this again when you update Part 2.

::: dom/system/gonk/tests/test_ril_worker_icc.js
@@ +1150,5 @@
>        // Do nothing
>      },
>      postMessage: function fakePostMessage(message) {
>        // Do nothing
>      }

Can you also remove these two dummy methods?
The original newWorker has done this.
Attachment #711163 - Flags: review?(allstars.chh)
(In reply to Yoshi Huang(Happy Chinese New Year 2.9~2.17)[:yoshi][:allstars.chh] from comment #12)
> Comment on attachment 711147 [details] [diff] [review]
> Part 1: Fix updating operator's info, v2
> 
> Review of attachment 711147 [details] [diff] [review]:
> -----------------------------------------------------------------
> 
> ::: dom/system/gonk/ril_worker.js
> @@ +3087,5 @@
> > +      } else {
> > +        // According to ril.h, the operator fields will be NULL when the operator
> > +        // is not currently registered. We can avoid trying to parse the numeric
> > +        // tuple in that case.
> > +        if (DEBUG) {
> 
> In the original code there's a check for !longName
> Can you explain why it's removed?


The check for longName is used for printing debug log when the network is unregistered.
And if unregistered, the networkTuple will be *null* as well (Same behavior as longName).

Because the check for longName there is a little bit weird to me, so I use networkTuple to make it more clear. How do you think? :)
Comment on attachment 711147 [details] [diff] [review]
Part 1: Fix updating operator's info, v2

Review of attachment 711147 [details] [diff] [review]:
-----------------------------------------------------------------

okay to me.
Attachment #711147 - Flags: review+
(In reply to Yoshi Huang[:allstars.chh] from comment #13)
> Comment on attachment 711161 [details] [diff] [review]
> Part 2: Refactor updateNetworkName and _processOperator, v3
> 
> Review of attachment 711161 [details] [diff] [review]:
> -----------------------------------------------------------------
> 
> ::: dom/system/gonk/ril_worker.js
> @@ +1301,5 @@
> >        return null;
> >      }
> >  
> > +    // We won't get network name if there is no PNN file.
> > +    if (!iccInfoPriv.PNN) {
> 
> Can we also add a check for OPL here?
> so we won't need to 
> if (iccInfoPriv.OPL) below.

Because OPL and PNN are depended on different service, we may need to check them separately.
PNN -> Service 45: PLMN Network Name
OPL -> Service 46: Operator PLMN List
1). Rename updateNetworkName() as getNetworkNameFromICC().
2). Move getNetworkNameFromICC() to ICCUtilsHelper.
Attachment #711161 - Attachment is obsolete: true
Attachment #711163 - Attachment is obsolete: true
Attachment #715031 - Flags: review?(allstars.chh)
Attachment #715035 - Flags: review?(allstars.chh)
Comment on attachment 715031 [details] [diff] [review]
Part 2: Refactor updateNetworkName and _processOperator, v4

Review of attachment 715031 [details] [diff] [review]:
-----------------------------------------------------------------

::: dom/system/gonk/ril_worker.js
@@ +9600,5 @@
> +    // the ME shall use this EF_OPL in association with the EF_PNN in place
> +    // of any network name stored within the ME's internal list and any network
> +    // name received when registered to the PLMN.
> +    if (iccInfoPriv.OPL) {
> +      for (let i = 0; i < iccInfoPriv.OPL.length; i++) {

Using two levels of indents seems ugly to me.

Can we use 

let length = iccInfoPriv.OPL ? iccInfoPriv.OPL.length: 0;
for (let i = 0; i < length; i++) {
...
}

@@ +9631,5 @@
> +    // value to it.
> +    if (!pnnEntry && mcc == iccInfo.mcc && mnc == iccInfo.mnc) {
> +      pnnEntry = iccInfoPriv.PNN[0]
> +    }
> +

Seems we don't need 'ret' below.


if (!pnnEntry) {
  return null;
}

return {fullName: pnnEntry.fullName || "",
        shortName: pnnEntry.shortName || ""};
Attachment #715031 - Flags: review?(allstars.chh) → review+
Attachment #715035 - Flags: review?(allstars.chh) → review+
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: