Bug 822528 - PhonenumberJS: Start using previous MCC. r=sicking
authorGregor Wagner <anygregor@gmail.com>
Wed, 19 Dec 2012 23:17:37 -0800
changeset 125714 6bec2e9a2371184340a27ce405a1288da282d865
parent 125713 c94c3ad9317dcfd21357463835d07395da5ba2e2
child 125715 ebad7aef8c52ef6ea023a6dbab9dfb3a62ef77ab
push id2151
push userlsblakk@mozilla.com
push dateTue, 19 Feb 2013 18:06:57 +0000
treeherdermozilla-beta@4952e88741ec [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerssicking
bugs822528
milestone20.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 822528 - PhonenumberJS: Start using previous MCC. r=sicking
dom/phonenumberutils/PhoneNumberUtils.jsm
--- a/dom/phonenumberutils/PhoneNumberUtils.jsm
+++ b/dom/phonenumberutils/PhoneNumberUtils.jsm
@@ -30,46 +30,58 @@ this.PhoneNumberUtils = {
   // mcc for Brasil
   _mcc: '724',
 
   _getCountryName: function() {
     let mcc;
     let countryName;
 
 #ifdef MOZ_B2G_RIL
-    // Get network mcc.
-    if (ril.voiceConnectionInfo && ril.voiceConnectionInfo.network)
+    // Get network mcc
+    if (ril.voiceConnectionInfo && ril.voiceConnectionInfo.network) {
       mcc = ril.voiceConnectionInfo.network.mcc;
+    }
+
+    // Get SIM mcc
+    if (!mcc) {
+      mcc = ril.iccInfo.mcc;
+    }
 
-    // Get SIM mcc or set it to mcc for Brasil
-    if (!mcc)
-      mcc = ril.iccInfo.mcc || this._mcc;
+    // Get previous mcc
+    if (!mcc && ril.voiceConnectionInfo && ril.voiceConnectionInfo.network) {
+      mcc = ril.voiceConnectionInfo.network.previousMcc;
+    }
+
+    // Set to default mcc
+    if (!mcc) {
+      mcc = this._mcc;
+    }
 #else
     mcc = this._mcc;
 #endif
 
     countryName = MCC_ISO3166_TABLE[mcc];
-    debug("MCC: " + mcc + "countryName: " + countryName);
+    if (DEBUG) debug("MCC: " + mcc + "countryName: " + countryName);
     return countryName;
   },
 
   parse: function(aNumber) {
-    debug("call parse: " + aNumber);
+    if (DEBUG) debug("call parse: " + aNumber);
     let result = PhoneNumber.Parse(aNumber, this._getCountryName());
     if (DEBUG) {
       if (result) {
         debug("InternationalFormat: " + result.internationalFormat);
         debug("InternationalNumber: " + result.internationalNumber);
         debug("NationalNumber: " + result.nationalNumber);
         debug("NationalFormat: " + result.nationalFormat);
       } else {
         debug("No result!\n");
       }
     }
     return result;
   },
 
   parseWithMCC: function(aNumber, aMCC) {
     let countryName = MCC_ISO3166_TABLE[aMCC];
-    debug("found country name: " + countryName);
+    if (DEBUG) debug("found country name: " + countryName);
     return PhoneNumber.Parse(aNumber, countryName);
   }
 };