Bug 773068 - Part 3: RIL implementation of SIM EF_MBDN. r=vicamo
authorMarshall Culpepper <marshall@mozilla.com>
Fri, 20 Jul 2012 20:19:38 -0400
changeset 103112 e0f6dcb1eeca84d902e49021485171060da14675
parent 103111 1a829406e669f9c8377b886fff877fe5743cb31c
child 103113 a5daaa4e1657cda5f2614bbbd0a3ae97fe4e18de
push id1989
push userakeybl@mozilla.com
push dateTue, 28 Aug 2012 00:20:43 +0000
treeherdermozilla-aurora@a8e95ae10ea7 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersvicamo
bugs773068
milestone17.0a1
Bug 773068 - Part 3: RIL implementation of SIM EF_MBDN. r=vicamo
dom/system/gonk/RILContentHelper.js
dom/system/gonk/RadioInterfaceLayer.js
dom/system/gonk/nsIRadioInterfaceLayer.idl
dom/system/gonk/ril_worker.js
--- a/dom/system/gonk/RILContentHelper.js
+++ b/dom/system/gonk/RILContentHelper.js
@@ -42,16 +42,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:CallError",
   "RIL:GetCardLock:Return:OK",
   "RIL:GetCardLock:Return:KO",
   "RIL:SetCardLock:Return:OK",
   "RIL:SetCardLock:Return:KO",
   "RIL:UnlockCardLock:Return:OK",
   "RIL:UnlockCardLock:Return:KO",
   "RIL:UssdReceived",
@@ -344,16 +345,18 @@ RILContentHelper.prototype = {
     return request;
   },
 
   _telephonyCallbacks: null,
   _voicemailCallbacks: null,
   _enumerateTelephonyCallbacks: null,
 
   voicemailStatus: null,
+  voicemailNumber: null,
+  voicemailDisplayName: null,
 
   registerCallback: function registerCallback(callbackType, callback) {
     let callbacks = this[callbackType];
     if (!callbacks) {
       callbacks = this[callbackType] = [];
     }
 
     if (callbacks.indexOf(callback) != -1) {
@@ -552,16 +555,20 @@ 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;
+        break;
       case "RIL:GetCardLock:Return:OK":
       case "RIL:SetCardLock:Return:OK":
       case "RIL:UnlockCardLock:Return:OK":
         this.fireRequestSuccess(msg.json.requestId, msg.json);
         break;
       case "RIL:GetCardLock:Return:KO":
       case "RIL:SetCardLock:Return:KO":
       case "RIL:UnlockCardLock:Return:KO":
--- a/dom/system/gonk/RadioInterfaceLayer.js
+++ b/dom/system/gonk/RadioInterfaceLayer.js
@@ -392,16 +392,19 @@ RadioInterfaceLayer.prototype = {
           return;
         }
         let callback = this._contactsCallbacks[message.requestId];
         if (callback) {
           delete this._contactsCallbacks[message.requestId];
           callback.receiveContactsList(message.contactType, message.contacts);
         }
         break;
+      case "iccmbdn":
+        ppmm.sendAsyncMessage("RIL:VoicemailNumberChanged", message);
+        break;
       case "celllocationchanged":
         this.rilContext.cell = message;
         break;
       case "ussdreceived":
         debug("ussdreceived " + JSON.stringify(message));
         this.handleUSSDReceived(message);
         break;
       case "sendussd":
--- a/dom/system/gonk/nsIRadioInterfaceLayer.idl
+++ b/dom/system/gonk/nsIRadioInterfaceLayer.idl
@@ -58,17 +58,17 @@ interface nsIRILTelephonyCallback : nsIS
    *        Call identifier assigned by the RIL. -1 if no connection
    * @param error
    *        Error from RIL.
    */
   void notifyError(in long callIndex,
                    in AString error);
 };
 
-[scriptable, uuid(3ac98987-a63c-4ebe-adbd-ff7a0348d804)]
+[scriptable, uuid(521cfe4a-bf79-4134-a9fc-e2242164d657)]
 interface nsIRILVoicemailCallback : nsISupports
 {
   /**
    * Called when a voicemail notification has been received by the network.
    *
    * @param status
    *        The new voicemail status
    */
@@ -158,16 +158,18 @@ interface nsIRILContentHelper : nsIMobil
   void rejectCall(in unsigned long callIndex);
   void holdCall(in unsigned long callIndex);
   void resumeCall(in unsigned long callIndex);
 
   attribute bool microphoneMuted;
   attribute bool speakerEnabled;
 
   readonly attribute nsIDOMMozVoicemailStatus voicemailStatus;
+  readonly attribute DOMString voicemailNumber;
+  readonly attribute DOMString voicemailDisplayName;
 };
 
 [scriptable, uuid(fd9e8b38-b839-4d56-8482-3bf1f5c8f2ee)]
 interface nsIICCRecords : nsISupports
 {
   /**
    * Mobile Subscriber ISDN Number
    */
--- a/dom/system/gonk/ril_worker.js
+++ b/dom/system/gonk/ril_worker.js
@@ -987,16 +987,17 @@ let RIL = {
   /**
    * Fetch ICC records.
    */
   fetchICCRecords: function fetchICCRecords() {
     this.getIMSI();
     this.getMSISDN();
     this.getAD();
     this.getUST();
+    this.getMBDN();
   },
 
   /**
    * Update the ICC information to RadioInterfaceLayer.
    */
   _handleICCInfoChange: function _handleICCInfoChange() {
     this.iccInfo.type = "iccinfochange";
     this.sendDOMMessage(this.iccInfo);
@@ -1289,16 +1290,51 @@ let RIL = {
       pin2:      null,
       type:      EF_TYPE_LINEAR_FIXED,
       callback:  callback,
       loadAll:   true,
       requestId: options.requestId
     });
   },
 
+   /**
+   * Get ICC MBDN. (Mailbox Dialling Number)
+   *
+   * @see TS 131.102, clause 4.2.60
+   */
+  getMBDN: function getMBDN() {
+    function callback(options) {
+      let parseCallback = function parseCallback(contact) {
+        if (DEBUG) {
+          debug("MBDN, alphaId="+contact.alphaId+" number="+contact.number);
+        }
+        if (this.iccInfo.mbdn != contact.number) {
+          this.iccInfo.mbdn = contact.number;
+          contact.type = "iccmbdn";
+          this.sendDOMMessage(contact);
+        }
+      };
+
+      this.parseDiallingNumber(options, parseCallback);
+    }
+
+    this.iccIO({
+      command:   ICC_COMMAND_GET_RESPONSE,
+      fileId:    ICC_EF_MBDN,
+      pathId:    EF_PATH_MF_SIM + EF_PATH_DF_GSM,
+      p1:        0, // For GET_RESPONSE, p1 = 0
+      p2:        0, // For GET_RESPONSE, p2 = 0
+      p3:        GET_RESPONSE_EF_SIZE_BYTES,
+      data:      null,
+      pin2:      null,
+      type:      EF_TYPE_LINEAR_FIXED,
+      callback:  callback,
+    });
+  },
+
   decodeSimTlvs: function decodeSimTlvs(tlvsLen) {
     let index = 0;
     let tlvs = [];
     while (index < tlvsLen) {
       let simTlv = {
         tag : GsmPDUHelper.readHexOctet(),
         length : GsmPDUHelper.readHexOctet(),
       };