Bug 833711 - Part 2: Revise handleoperatorchange in RadioInterfaceLayer and updateInfo in RILContentHelper. r=vicamo
authorYoshi Huang <allstars.chh@mozilla.com>
Mon, 28 Jan 2013 11:41:34 +0800
changeset 130608 6d4a334a99bc4df83c0141c0243ebeb491aafca2
parent 130607 a4c130560ea6d40ea478aa91e028c2a94280aae3
child 130609 da1f103142bdcf020925630d7cf9213110d277e7
push id2323
push userbbajaj@mozilla.com
push dateMon, 01 Apr 2013 19:47:02 +0000
treeherdermozilla-beta@7712be144d91 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersvicamo
bugs833711
milestone21.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 833711 - Part 2: Revise handleoperatorchange in RadioInterfaceLayer and updateInfo in RILContentHelper. r=vicamo
dom/system/gonk/RILContentHelper.js
dom/system/gonk/RadioInterfaceLayer.js
--- a/dom/system/gonk/RILContentHelper.js
+++ b/dom/system/gonk/RILContentHelper.js
@@ -338,17 +338,18 @@ RILContentHelper.prototype = {
                                          Ci.nsIRILContentHelper,
                                          Ci.nsIObserver]),
   classID:   RILCONTENTHELPER_CID,
   classInfo: XPCOMUtils.generateCI({classID: RILCONTENTHELPER_CID,
                                     classDescription: "RILContentHelper",
                                     interfaces: [Ci.nsIMobileConnectionProvider,
                                                  Ci.nsIRILContentHelper]}),
 
-  updateVoicemailInfo: function updateVoicemailInfo(srcInfo, destInfo) {
+  // An utility function to copy objects.
+  updateInfo: function updateInfo(srcInfo, destInfo) {
     for (let key in srcInfo) {
       destInfo[key] = srcInfo[key];
     }
   },
 
   updateICCInfo: function updateICCInfo(srcInfo, destInfo) {
     for (let key in srcInfo) {
       destInfo[key] = srcInfo[key];
@@ -384,21 +385,18 @@ RILContentHelper.prototype = {
       return;
     }
 
     let network = destInfo.network;
     if (!network) {
       network = destInfo.network = new MobileNetworkInfo();
     }
 
-    network.longName = srcNetwork.longName;
-    network.shortName = srcNetwork.shortName;
-    network.mnc = srcNetwork.mnc;
-    network.mcc = srcNetwork.mcc;
-  },
+    this.updateInfo(srcNetwork, network);
+ },
 
   // nsIRILContentHelper
 
   networkSelectionMode: RIL.GECKO_NETWORK_SELECTION_UNKNOWN,
 
   rilContext: null,
 
   getRilContext: function getRilContext() {
@@ -682,17 +680,17 @@ RILContentHelper.prototype = {
   getVoicemailInfo: function getVoicemailInfo() {
     // Get voicemail infomation by IPC only on first time.
     this.getVoicemailInfo = function getVoicemailInfo() {
       return this.voicemailInfo;
     };
 
     let voicemailInfo = cpmm.sendSyncMessage("RIL:GetVoicemailInfo")[0];
     if (voicemailInfo) {
-      this.updateVoicemailInfo(voicemailInfo, this.voicemailInfo);
+      this.updateInfo(voicemailInfo, this.voicemailInfo);
     }
 
     return this.voicemailInfo;
   },
   get voicemailNumber() {
     return this.getVoicemailInfo().number;
   },
   get voicemailDisplayName() {
@@ -962,17 +960,17 @@ RILContentHelper.prototype = {
                               "notifyError",
                               [msg.json.callIndex,
                                msg.json.error]);
         break;
       case "RIL:VoicemailNotification":
         this.handleVoicemailNotification(msg.json);
         break;
       case "RIL:VoicemailInfoChanged":
-        this.updateVoicemailInfo(msg.json, this.voicemailInfo);
+        this.updateInfo(msg.json, this.voicemailInfo);
         break;
       case "RIL:CardLockResult":
         if (msg.json.success) {
           let result = new MobileICCCardLockResult(msg.json);
           this.fireRequestSuccess(msg.json.requestId, result);
         } else {
           if (msg.json.rilMessageType == "iccSetCardLock" ||
               msg.json.rilMessageType == "iccUnlockCardLock") {
@@ -1071,21 +1069,17 @@ RILContentHelper.prototype = {
       Services.DOMRequest.fireError(request, message.error);
       return;
     }
 
     let networks = message.networks;
     for (let i = 0; i < networks.length; i++) {
       let network = networks[i];
       let info = new MobileNetworkInfo();
-
-      for (let key in network) {
-        info[key] = network[key];
-      }
-
+      this.updateInfo(network, info);
       networks[i] = info;
     }
 
     Services.DOMRequest.fireSuccess(request, networks);
   },
 
   handleSelectNetwork: function handleSelectNetwork(message, mode) {
     this._selectingNetwork = null;
@@ -1130,21 +1124,17 @@ RILContentHelper.prototype = {
                             [this.voicemailStatus]);
     }
   },
 
   _cfRulesToMobileCfInfo: function _cfRulesToMobileCfInfo(rules) {
     for (let i = 0; i < rules.length; i++) {
       let rule = rules[i];
       let info = new MobileCFInfo();
-
-      for (let key in rule) {
-        info[key] = rule[key];
-      }
-
+      this.updateInfo(rule, info);
       rules[i] = info;
     }
   },
 
   handleGetCallForwardingOption: function handleGetCallForwardingOption(message) {
     let requestId = message.requestId;
     let request = this.takeRequest(requestId);
     if (!request) {
--- a/dom/system/gonk/RadioInterfaceLayer.js
+++ b/dom/system/gonk/RadioInterfaceLayer.js
@@ -782,32 +782,28 @@ RadioInterfaceLayer.prototype = {
     let selectionMessage = message[RIL.NETWORK_INFO_NETWORK_SELECTION_MODE];
 
     // Batch the *InfoChanged messages together
     if (voiceMessage) {
       voiceMessage.batch = true;
       this.updateVoiceConnection(voiceMessage);
     }
 
-    let dataInfoChanged = false;
     if (dataMessage) {
       dataMessage.batch = true;
       this.updateDataConnection(dataMessage);
     }
 
+    if (operatorMessage) {
+      operatorMessage.batch = true;
+      this.handleOperatorChange(operatorMessage);
+    }
+
     let voice = this.rilContext.voice;
     let data = this.rilContext.data;
-    if (operatorMessage) {
-      if (this.networkChanged(operatorMessage, voice.network)) {
-        voice.network = operatorMessage;
-      }
-      if (this.networkChanged(operatorMessage, data.network)) {
-        data.network = operatorMessage;
-      }
-    }
 
     this.checkRoamingBetweenOperators(voice);
     this.checkRoamingBetweenOperators(data);
 
     if (voiceMessage || operatorMessage) {
       this._sendTargetMessage("mobileconnection", "RIL:VoiceInfoChanged", voice);
     }
     if (dataMessage || operatorMessage) {
@@ -1008,22 +1004,26 @@ RadioInterfaceLayer.prototype = {
   },
 
   handleOperatorChange: function handleOperatorChange(message) {
     let voice = this.rilContext.voice;
     let data = this.rilContext.data;
 
     if (this.networkChanged(message, voice.network)) {
       voice.network = message;
-      this._sendTargetMessage("mobileconnection", "RIL:VoiceInfoChanged", voice);
+      if (!message.batch) {
+        this._sendTargetMessage("mobileconnection", "RIL:VoiceInfoChanged", voice);
+      }
     }
 
     if (this.networkChanged(message, data.network)) {
       data.network = message;
-      this._sendTargetMessage("mobileconnection", "RIL:DataInfoChanged", data);
+      if (!message.batch) {
+        this._sendTargetMessage("mobileconnection", "RIL:DataInfoChanged", data);
+      }
     }
   },
 
   handleRadioStateChange: function handleRadioStateChange(message) {
     this._changingRadioPower = false;
 
     let newState = message.radioState;
     if (this.rilContext.radioState == newState) {