Bug 796277 - 0001.Save voicemail info in RIL. r=hsinyi
authorChuck Lee <chulee@mozilla.com>
Fri, 23 Nov 2012 12:09:01 +0800
changeset 114107 a355e0709bc2f232e6c78783523cc915766ba88d
parent 114106 c0c9d5933dcd236c946b43a8261877a4aaeaf9b4
child 114108 c3918ed8d7bee70c120a791c09e4b48d7fca59f6
push id23904
push useremorley@mozilla.com
push dateMon, 26 Nov 2012 11:00:15 +0000
treeherdermozilla-central@541ccce39563 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewershsinyi
bugs796277
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 796277 - 0001.Save voicemail info in RIL. r=hsinyi
dom/system/gonk/RILContentHelper.js
dom/system/gonk/RadioInterfaceLayer.js
--- a/dom/system/gonk/RILContentHelper.js
+++ b/dom/system/gonk/RILContentHelper.js
@@ -55,17 +55,17 @@ const RIL_IPC_MSG_NAMES = [
   "RIL:DataInfoChanged",
   "RIL:EnumerateCalls",
   "RIL:GetAvailableNetworks",
   "RIL:NetworkSelectionModeChanged",
   "RIL:SelectNetwork",
   "RIL:SelectNetworkAuto",
   "RIL:CallStateChanged",
   "RIL:VoicemailNotification",
-  "RIL:VoicemailNumberChanged",
+  "RIL:VoicemailInfoChanged",
   "RIL:CallError",
   "RIL:CardLockResult",
   "RIL:USSDReceived",
   "RIL:SendMMI:Return:OK",
   "RIL:SendMMI:Return:KO",
   "RIL:CancelMMI:Return:OK",
   "RIL:CancelMMI:Return:KO",
   "RIL:StkCommand",
@@ -118,17 +118,23 @@ MobileICCInfo.prototype = {
   }),
 
   // nsIDOMMozMobileICCInfo
 
   iccid: null,
   mcc: 0,
   mnc: 0,
   spn: null,
-  msisdn: null,
+  msisdn: null
+};
+
+function MobileVoicemailInfo() {}
+MobileVoicemailInfo.prototype = {
+  number: null,
+  displayName: null
 };
 
 function MobileConnectionInfo() {}
 MobileConnectionInfo.prototype = {
   QueryInterface: XPCOMUtils.generateQI([Ci.nsIDOMMozMobileConnectionInfo]),
   classID:        MOBILECONNECTIONINFO_CID,
   classInfo:      XPCOMUtils.generateCI({
     classID:          MOBILECONNECTIONINFO_CID,
@@ -236,46 +242,54 @@ MobileCFInfo.prototype = {
   number: null,
   timeSeconds: 0
 };
 
 function RILContentHelper() {
   this.iccInfo = new MobileICCInfo();
   this.voiceConnectionInfo = new MobileConnectionInfo();
   this.dataConnectionInfo = new MobileConnectionInfo();
+  this.voicemailInfo = new MobileVoicemailInfo();
 
   this.initRequests();
   this.initMessageListener(RIL_IPC_MSG_NAMES);
   Services.obs.addObserver(this, "xpcom-shutdown", false);
 
   // Request initial context.
   let rilContext = cpmm.sendSyncMessage("RIL:GetRilContext")[0];
 
   if (!rilContext) {
     debug("Received null rilContext from chrome process.");
     return;
   }
   this.cardState = rilContext.cardState;
   this.updateICCInfo(rilContext.icc, this.iccInfo);
   this.updateConnectionInfo(rilContext.voice, this.voiceConnectionInfo);
   this.updateConnectionInfo(rilContext.data, this.dataConnectionInfo);
+  this.updateVoicemailInfo(rilContext.voicemail, this.voicemailInfo);
 }
 
 RILContentHelper.prototype = {
   __proto__: DOMRequestIpcHelper.prototype,
 
   QueryInterface: XPCOMUtils.generateQI([Ci.nsIMobileConnectionProvider,
                                          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) {
+    for (let key in srcInfo) {
+      destInfo[key] = srcInfo[key];
+    }
+  },
+
   updateICCInfo: function updateICCInfo(srcInfo, destInfo) {
     for (let key in srcInfo) {
       destInfo[key] = srcInfo[key];
     }
   },
 
   updateConnectionInfo: function updateConnectionInfo(srcInfo, destInfo) {
     for (let key in srcInfo) {
@@ -548,18 +562,22 @@ RILContentHelper.prototype = {
     return request;
   },
 
   _telephonyCallbacks: null,
   _voicemailCallbacks: null,
   _enumerateTelephonyCallbacks: null,
 
   voicemailStatus: null,
-  voicemailNumber: null,
-  voicemailDisplayName: null,
+  get voicemailNumber() {
+    return this.voicemailInfo.number;
+  },
+  get voicemailDisplayName() {
+    return this.voicemailInfo.displayName;
+  },
 
   registerCallback: function registerCallback(callbackType, callback) {
     let callbacks = this[callbackType];
     if (!callbacks) {
       callbacks = this[callbackType] = [];
     }
 
     if (callbacks.indexOf(callback) != -1) {
@@ -792,19 +810,18 @@ RILContentHelper.prototype = {
         this._deliverCallback("_telephonyCallbacks",
                               "notifyError",
                               [msg.json.callIndex,
                                msg.json.error]);
         break;
       case "RIL:VoicemailNotification":
         this.handleVoicemailNotification(msg.json);
         break;
-      case "RIL:VoicemailNumberChanged":
-        this.voicemailNumber = msg.json.number;
-        this.voicemailDisplayName = msg.json.alphaId;
+      case "RIL:VoicemailInfoChanged":
+        this.updateVoicemailInfo(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") {
--- a/dom/system/gonk/RadioInterfaceLayer.js
+++ b/dom/system/gonk/RadioInterfaceLayer.js
@@ -189,16 +189,18 @@ function RadioInterfaceLayer() {
   this.worker = new ChromeWorker("resource://gre/modules/ril_worker.js");
   this.worker.onerror = this.onerror.bind(this);
   this.worker.onmessage = this.onmessage.bind(this);
 
   this.rilContext = {
     radioState:     RIL.GECKO_RADIOSTATE_UNAVAILABLE,
     cardState:      RIL.GECKO_CARDSTATE_UNAVAILABLE,
     icc:            null,
+    voicemail:      {number: null,
+                     displayName: null},
 
     // These objects implement the nsIDOMMozMobileConnectionInfo interface,
     // although the actual implementation lives in the content process. So are
     // the child attributes `network` and `cell`, which implement
     // nsIDOMMozMobileNetworkInfo and nsIDOMMozMobileCellInfo respectively.
     voice:          {connected: false,
                      emergencyCallsOnly: false,
                      roaming: false,
@@ -563,17 +565,17 @@ RadioInterfaceLayer.prototype = {
         if (callback) {
           delete this._contactsCallbacks[message.requestId];
           callback.receiveContactsList(message.errorMsg,
                                        message.contactType,
                                        message.contacts);
         }
         break;
       case "iccmbdn":
-        this._sendTargetMessage("voicemail", "RIL:VoicemailNumberChanged", message);
+        this.handleICCMbdn(message);
         break;
       case "USSDReceived":
         debug("USSDReceived " + JSON.stringify(message));
         this.handleUSSDReceived(message);
         break;
       case "sendMMI":
       case "sendUSSD":
         this.handleSendMMI(message);
@@ -1472,16 +1474,25 @@ RadioInterfaceLayer.prototype = {
     this._lastNitzMessage = message;
 
     // Set the received NITZ time if the setting is enabled.
     if (this._nitzAutomaticUpdateEnabled) {
       this.setNitzTime(message);
     }
   },
 
+  handleICCMbdn: function handleICCMbdn(message) {
+    let voicemail = this.rilContext.voicemail;
+
+    voicemail.number = message.number;
+    voicemail.displayName = message.alphaId;
+
+    this._sendTargetMessage("voicemail", "RIL:VoicemailInfoChanged", voicemail);
+  },
+
   handleICCInfoChange: function handleICCInfoChange(message) {
     let oldIcc = this.rilContext.icc;
     this.rilContext.icc = message;
    
     let iccInfoChanged = !oldIcc ||
                          oldIcc.iccid != message.iccid ||
                          oldIcc.mcc != message.mcc || 
                          oldIcc.mnc != message.mnc ||