Bug 819560 - RIL: remember the last mcc code. r=sicking, a=blocking-basecamp
authorGregor Wagner <anygregor@gmail.com>
Wed, 12 Dec 2012 16:57:11 -0800
changeset 118876 5d10c266fa868749b43224f977edcf5dfdc7b006
parent 118875 4dba9c208e9aa5f57b894708f0f562807bcdee38
child 118877 2af0ee41e9daf77de9530ff195567d05a152f236
push idunknown
push userunknown
push dateunknown
reviewerssicking, blocking-basecamp
bugs819560
milestone19.0a2
Bug 819560 - RIL: remember the last mcc code. r=sicking, a=blocking-basecamp
b2g/app/b2g.js
dom/network/interfaces/nsIDOMMobileConnection.idl
dom/system/gonk/RILContentHelper.js
--- a/b2g/app/b2g.js
+++ b/b2g/app/b2g.js
@@ -397,16 +397,17 @@ pref("dom.sms.strict7BitEncoding", false
 pref("dom.mozContacts.enabled", true);
 
 // WebAlarms
 pref("dom.mozAlarms.enabled", true);
 
 // NetworkStats
 #ifdef MOZ_B2G_RIL
 pref("dom.mozNetworkStats.enabled", true);
+pref("ril.lastKnownMcc", 724);
 #endif
 
 // WebSettings
 pref("dom.mozSettings.enabled", true);
 pref("dom.mozPermissionSettings.enabled", true);
 
 // controls if we want camera support
 pref("device.camera.enabled", true);
--- a/dom/network/interfaces/nsIDOMMobileConnection.idl
+++ b/dom/network/interfaces/nsIDOMMobileConnection.idl
@@ -411,30 +411,35 @@ interface nsIDOMMozMobileCellInfo: nsISu
   readonly attribute unsigned short gsmLocationAreaCode;
 
   /**
    * Mobile Cell ID for GSM/WCDMA networks.
    */
   readonly attribute unsigned long gsmCellId;
 };
 
-[scriptable, uuid(352e7f1a-c09f-44ed-8fde-a138b09a0ea9)]
+[scriptable, uuid(1fb27dc0-427e-11e2-a25f-0800200c9a66)]
 interface nsIDOMMozMobileICCInfo : nsISupports
 {
    /**
    * Integrated Circuit Card Identifier.
    */
   readonly attribute DOMString iccid;
 
   /**
    * Mobile Country Code (MCC) of the subscriber's home network.
    */
   readonly attribute unsigned short mcc;
 
   /**
+   * Mobile Country Code (MCC) of previous subscriber's home network.
+   */
+  readonly attribute unsigned short lastKnownMcc;
+
+  /**
    * Mobile Network Code (MNC) of the subscriber's home network.
    */
   readonly attribute unsigned short mnc;
 
   /**
    * Service Provider Name (SPN) of the subscriber's home network.
    */
   readonly attribute DOMString spn;
--- a/dom/system/gonk/RILContentHelper.js
+++ b/dom/system/gonk/RILContentHelper.js
@@ -106,31 +106,36 @@ function MobileICCCardLockResult(options
 };
 MobileICCCardLockResult.prototype = {
   __exposedProps__ : {lockType: 'r',
                       enabled: 'r',
                       retryCount: 'r',
                       success: 'r'}
 };
 
-function MobileICCInfo() {}
+function MobileICCInfo() {
+  try {
+    this.lastKnownMcc = Services.prefs.getIntPref("ril.lastKnownMcc");
+  } catch (e) {}
+};
 MobileICCInfo.prototype = {
   QueryInterface: XPCOMUtils.generateQI([Ci.nsIDOMMozMobileICCInfo]),
   classID:        MOBILEICCINFO_CID,
   classInfo:      XPCOMUtils.generateCI({
     classID:          MOBILEICCINFO_CID,
     classDescription: "MobileICCInfo",
     flags:            Ci.nsIClassInfo.DOM_OBJECT,
     interfaces:       [Ci.nsIDOMMozMobileICCInfo]
   }),
 
   // nsIDOMMozMobileICCInfo
 
   iccid: null,
   mcc: 0,
+  lastKnownMcc: 0,
   mnc: 0,
   spn: null,
   msisdn: null
 };
 
 function MobileVoicemailInfo() {}
 MobileVoicemailInfo.prototype = {
   number: null,
@@ -350,16 +355,19 @@ RILContentHelper.prototype = {
     for (let key in srcInfo) {
       destInfo[key] = srcInfo[key];
     }
   },
 
   updateICCInfo: function updateICCInfo(srcInfo, destInfo) {
     for (let key in srcInfo) {
       destInfo[key] = srcInfo[key];
+      if (key === 'mcc') {
+        destInfo['lastKnownMcc'] = srcInfo[key];
+      }
     }
   },
 
   updateConnectionInfo: function updateConnectionInfo(srcInfo, destInfo) {
     for (let key in srcInfo) {
       if ((key != "network") && (key != "cell")) {
         destInfo[key] = srcInfo[key];
       }
@@ -848,16 +856,19 @@ RILContentHelper.prototype = {
       case "RIL:CardStateChanged":
         if (this.cardState != msg.json.cardState) {
           this.cardState = msg.json.cardState;
           Services.obs.notifyObservers(null, kCardStateChangedTopic, null);
         }
         break;
       case "RIL:IccInfoChanged":
         this.updateICCInfo(msg.json, this.iccInfo);
+        if (this.iccInfo.mcc) {
+          Services.prefs.setIntPref("ril.lastKnownMcc", this.iccInfo.mcc);
+        }
         Services.obs.notifyObservers(null, kIccInfoChangedTopic, null);
         break;
       case "RIL:VoiceInfoChanged":
         this.updateConnectionInfo(msg.json, this.voiceConnectionInfo);
         Services.obs.notifyObservers(null, kVoiceChangedTopic, null);
         break;
       case "RIL:DataInfoChanged":
         this.updateConnectionInfo(msg.json, this.dataConnectionInfo);