Bug 952371 - Part 3: ril implementation - [DSDS] mozMobileconnection.lastKnownNetwork and .lastKnownHomeNetwork aren't working. r=hsinyi
authorJessica Jong <jjong@mozilla.com>
Wed, 08 Jan 2014 18:54:34 +0800
changeset 162527 50101ad17ae757a8e2387de9b90b466f5cc14428
parent 162526 3fd3861f9778cab04752cf8cc2593430619d4f03
child 162528 3b867c474f453f66c036ad87d3bcb88333918434
push id25958
push userryanvm@gmail.com
push dateWed, 08 Jan 2014 20:22:21 +0000
treeherdermozilla-central@8988416e489d [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewershsinyi
bugs952371
milestone29.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 952371 - Part 3: ril implementation - [DSDS] mozMobileconnection.lastKnownNetwork and .lastKnownHomeNetwork aren't working. r=hsinyi
dom/system/gonk/RILContentHelper.js
dom/system/gonk/RadioInterfaceLayer.js
--- a/dom/system/gonk/RILContentHelper.js
+++ b/dom/system/gonk/RILContentHelper.js
@@ -638,16 +638,28 @@ RILContentHelper.prototype = {
     let context = this.getRilContext(clientId);
     return context && context.cardState;
   },
 
   /**
    * nsIMobileConnectionProvider
    */
 
+  getLastKnownNetwork: function getLastKnownNetwork(clientId) {
+    return cpmm.sendSyncMessage("RIL:GetLastKnownNetwork", {
+      clientId: clientId
+    })[0];
+  },
+
+  getLastKnownHomeNetwork: function getLastKnownHomeNetwork(clientId) {
+    return cpmm.sendSyncMessage("RIL:GetLastKnownHomeNetwork", {
+      clientId: clientId
+    })[0];
+  },
+
   getVoiceConnectionInfo: function getVoiceConnectionInfo(clientId) {
     let context = this.getRilContext(clientId);
     return context && context.voiceConnectionInfo;
   },
 
   getDataConnectionInfo: function getDataConnectionInfo(clientId) {
     let context = this.getRilContext(clientId);
     return context && context.dataConnectionInfo;
--- a/dom/system/gonk/RadioInterfaceLayer.js
+++ b/dom/system/gonk/RadioInterfaceLayer.js
@@ -113,16 +113,21 @@ const RIL_IPC_MOBILECONNECTION_MSG_NAMES
   "RIL:SetRoamingPreference",
   "RIL:GetRoamingPreference",
   "RIL:ExitEmergencyCbMode",
   "RIL:SetRadioEnabled",
   "RIL:SetVoicePrivacyMode",
   "RIL:GetVoicePrivacyMode"
 ];
 
+const RIL_IPC_MOBILENETWORK_MSG_NAMES = [
+  "RIL:GetLastKnownNetwork",
+  "RIL:GetLastKnownHomeNetwork"
+];
+
 const RIL_IPC_ICCMANAGER_MSG_NAMES = [
   "RIL:SendStkResponse",
   "RIL:SendStkMenuSelection",
   "RIL:SendStkTimerExpiration",
   "RIL:SendStkEventDownload",
   "RIL:GetCardLockState",
   "RIL:UnlockCardLock",
   "RIL:SetCardLock",
@@ -230,32 +235,38 @@ XPCOMUtils.defineLazyGetter(this, "gMess
       this._unregisterMessageListeners();
     },
 
     _registerMessageListeners: function _registerMessageListeners() {
       ppmm.addMessageListener("child-process-shutdown", this);
       for (let msgname of RIL_IPC_MOBILECONNECTION_MSG_NAMES) {
         ppmm.addMessageListener(msgname, this);
       }
+      for (let msgname of RIL_IPC_MOBILENETWORK_MSG_NAMES) {
+        ppmm.addMessageListener(msgname, this);
+      }
       for (let msgName of RIL_IPC_ICCMANAGER_MSG_NAMES) {
         ppmm.addMessageListener(msgName, this);
       }
       for (let msgname of RIL_IPC_VOICEMAIL_MSG_NAMES) {
         ppmm.addMessageListener(msgname, this);
       }
       for (let msgname of RIL_IPC_CELLBROADCAST_MSG_NAMES) {
         ppmm.addMessageListener(msgname, this);
       }
     },
 
     _unregisterMessageListeners: function _unregisterMessageListeners() {
       ppmm.removeMessageListener("child-process-shutdown", this);
       for (let msgname of RIL_IPC_MOBILECONNECTION_MSG_NAMES) {
         ppmm.removeMessageListener(msgname, this);
       }
+      for (let msgname of RIL_IPC_MOBILENETWORK_MSG_NAMES) {
+        ppmm.removeMessageListener(msgname, this);
+      }
       for (let msgName of RIL_IPC_ICCMANAGER_MSG_NAMES) {
         ppmm.removeMessageListener(msgName, this);
       }
       for (let msgname of RIL_IPC_VOICEMAIL_MSG_NAMES) {
         ppmm.removeMessageListener(msgname, this);
       }
       for (let msgname of RIL_IPC_CELLBROADCAST_MSG_NAMES) {
         ppmm.removeMessageListener(msgname, this);
@@ -370,16 +381,24 @@ XPCOMUtils.defineLazyGetter(this, "gMess
       if (RIL_IPC_MOBILECONNECTION_MSG_NAMES.indexOf(msg.name) != -1) {
         if (!msg.target.assertPermission("mobileconnection")) {
           if (DEBUG) {
             debug("MobileConnection message " + msg.name +
                   " from a content process with no 'mobileconnection' privileges.");
           }
           return null;
         }
+      } else if (RIL_IPC_MOBILENETWORK_MSG_NAMES.indexOf(msg.name) != -1) {
+        if (!msg.target.assertPermission("mobilenetwork")) {
+          if (DEBUG) {
+            debug("MobileNetwork message " + msg.name +
+                  " from a content process with no 'mobilenetwork' privileges.");
+          }
+          return null;
+        }
       } else if (RIL_IPC_ICCMANAGER_MSG_NAMES.indexOf(msg.name) != -1) {
         if (!msg.target.assertPermission("mobileconnection")) {
           if (DEBUG) {
             debug("IccManager message " + msg.name +
                   " from a content process with no 'mobileconnection' privileges.");
           }
           return null;
         }
@@ -1212,16 +1231,22 @@ RadioInterface.prototype = {
   /**
    * Process a message from the content process.
    */
   receiveMessage: function receiveMessage(msg) {
     switch (msg.name) {
       case "RIL:GetRilContext":
         // This message is sync.
         return this.rilContext;
+      case "RIL:GetLastKnownNetwork":
+        // This message is sync.
+        return this._lastKnownNetwork;
+      case "RIL:GetLastKnownHomeNetwork":
+        // This message is sync.
+        return this._lastKnownHomeNetwork;
       case "RIL:GetAvailableNetworks":
         this.workerMessenger.sendWithIPCMessage(msg, "getAvailableNetworks");
         break;
       case "RIL:SelectNetwork":
         this.workerMessenger.sendWithIPCMessage(msg, "selectNetwork");
         break;
       case "RIL:SelectNetworkAuto":
         this.workerMessenger.sendWithIPCMessage(msg, "selectNetworkAuto");
@@ -1819,20 +1844,18 @@ RadioInterface.prototype = {
     let voice = this.rilContext.voice;
     let data = this.rilContext.data;
 
     if (this.isInfoChanged(message, operatorInfo)) {
       this.updateInfo(message, operatorInfo);
 
       // Update lastKnownNetwork
       if (message.mcc && message.mnc) {
-        try {
-          Services.prefs.setCharPref("ril.lastKnownNetwork",
-                                     message.mcc + "-" + message.mnc);
-        } catch (e) {}
+        this._lastKnownNetwork = message.mcc + "-" + message.mnc;
+        if (DEBUG) this.debug("_lastKnownNetwork: " + this._lastKnownNetwork);
       }
 
       // If the voice is unregistered, no need to send RIL:VoiceInfoChanged.
       if (voice.network && !batch) {
         gMessageManager.sendMobileConnectionMessage("RIL:VoiceInfoChanged",
                                                     this.clientId, voice);
       }
 
@@ -2524,20 +2547,18 @@ RadioInterface.prototype = {
       try {
         Services.prefs.setCharPref("ril.lastKnownSimMcc",
                                    message.mcc.toString());
       } catch (e) {}
     }
 
     // Update lastKnownHomeNetwork.
     if (message.mcc && message.mnc) {
-      try {
-        Services.prefs.setCharPref("ril.lastKnownHomeNetwork",
-                                   message.mcc + "-" + message.mnc);
-      } catch (e) {}
+      this._lastKnownHomeNetwork = message.mcc + "-" + message.mnc;
+      this.debug("_lastKnownHomeNetwork: " + this._lastKnownHomeNetwork);
     }
 
     // If spn becomes available, we should check roaming again.
     if (!oldSpn && message.spn) {
       let voice = this.rilContext.voice;
       let data = this.rilContext.data;
       let voiceRoaming = voice.roaming;
       let dataRoaming = data.roaming;
@@ -2655,16 +2676,22 @@ RadioInterface.prototype = {
   _lastNitzMessage: null,
 
   // Object that handles SNTP.
   _sntp: null,
 
   // Cell Broadcast settings values.
   _cellBroadcastSearchListStr: null,
 
+  // Operator's mcc-mnc.
+  _lastKnownNetwork: null,
+
+  // ICC's mcc-mnc.
+  _lastKnownHomeNetwork: null,
+
   handleSettingsChange: function handleSettingsChange(aName, aResult, aMessage) {
     // Don't allow any content processes to modify the setting
     // "time.clock.automatic-update.available" except for the chrome process.
     if (aName === kSettingsClockAutoUpdateAvailable &&
         aMessage !== "fromInternalSetting") {
       let isClockAutoUpdateAvailable = this._lastNitzMessage !== null ||
                                        this._sntp.isAvailable();
       if (aResult !== isClockAutoUpdateAvailable) {