Bug 882985 - 0001. Receive CDMA information record and send system message. r=vicamo
authorChuck Lee <chulee@mozilla.com>
Wed, 11 Sep 2013 00:48:19 +0800
changeset 159523 cccdb7f084a40ce98d927e40a2560569378148ff
parent 159522 564f0718eefe0f22949bcb28df74eec588a6eb9a
child 159524 3e66d6106662dc93fa4230441c2877c96c1957ee
push id2961
push userlsblakk@mozilla.com
push dateMon, 28 Oct 2013 21:59:28 +0000
treeherdermozilla-beta@73ef4f13486f [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersvicamo
bugs882985
milestone26.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 882985 - 0001. Receive CDMA information record and send system message. r=vicamo
dom/messages/SystemMessagePermissionsChecker.jsm
dom/system/gonk/RadioInterfaceLayer.js
dom/system/gonk/ril_consts.js
dom/system/gonk/ril_worker.js
--- a/dom/messages/SystemMessagePermissionsChecker.jsm
+++ b/dom/messages/SystemMessagePermissionsChecker.jsm
@@ -94,16 +94,19 @@ this.SystemMessagePermissionsTable = {
     "telephony": []
   },
   "ussd-received": {
     "mobileconnection": []
   },
   "wappush-received": {
     "wappush": []
   },
+  "cdma-info-rec-received": {
+    "mobileconnection": []
+  },
 };
 
 this.SystemMessagePermissionsChecker = {
   /**
    * Return all the needed permission names for the given system message.
    * @param string aSysMsgName
    *        The system messsage name.
    * @returns object
--- a/dom/system/gonk/RadioInterfaceLayer.js
+++ b/dom/system/gonk/RadioInterfaceLayer.js
@@ -997,16 +997,20 @@ RadioInterface.prototype = {
         break;
       case "setRadioEnabled":
         let lock = gSettingsService.createLock();
         lock.set("ril.radio.disabled", !message.on, null, null);
         break;
       case "exitEmergencyCbMode":
         this.handleExitEmergencyCbMode(message);
         break;
+      case "cdma-info-rec-received":
+        if (DEBUG) this.debug("cdma-info-rec-received: " + JSON.stringify(message));
+        gSystemMessenger.broadcastMessage("cdma-info-rec-received", message);
+        break;
       default:
         throw new Error("Don't know about this message type: " +
                         message.rilMessageType);
     }
   },
 
   getMsisdn: function getMsisdn() {
     let iccInfo = this.rilContext.iccInfo;
--- a/dom/system/gonk/ril_consts.js
+++ b/dom/system/gonk/ril_consts.js
@@ -2770,16 +2770,60 @@ this.GECKO_CDMA_ROAMING_PREFERENCE_AFFIL
 this.GECKO_CDMA_ROAMING_PREFERENCE_ANY = "any";
 
 this.CDMA_ROAMING_PREFERENCE_TO_GECKO = [
   GECKO_CDMA_ROAMING_PREFERENCE_HOME,       // CDMA_ROAMING_PREFERENCE_HOME
   GECKO_CDMA_ROAMING_PREFERENCE_AFFILIATED, // CDMA_ROAMING_PREFERENCE_AFFILIATED
   GECKO_CDMA_ROAMING_PREFERENCE_ANY         // CDMA_ROAMING_PREFERENCE_ANY
 ];
 
+// Information Record Type, reference from ril.h
+this.PDU_CDMA_INFO_REC_TYPE_DISPLAY = 0;
+this.PDU_CDMA_INFO_REC_TYPE_CALLED_PARTY_NUMBER = 1;
+this.PDU_CDMA_INFO_REC_TYPE_CALLING_PARTY_NUMBER = 2;
+this.PDU_CDMA_INFO_REC_TYPE_CONNECTED_NUMBER =3;
+this.PDU_CDMA_INFO_REC_TYPE_SIGNAL = 4;
+this.PDU_CDMA_INFO_REC_TYPE_REDIRECTING_NUMBER = 5;
+this.PDU_CDMA_INFO_REC_TYPE_LINE_CONTROL = 6;
+this.PDU_CDMA_INFO_REC_TYPE_EXTENDED_DISPLAY = 7;
+this.PDU_CDMA_INFO_REC_TYPE_T53_CLIR = 8;
+this.PDU_CDMA_INFO_REC_TYPE_T53_RELEASE = 9;
+this.PDU_CDMA_INFO_REC_TYPE_T53_AUDIO_CONTROL = 10;
+
+// Display type of extended display of information record,
+// as defined in C.S0005-F v1.0, Table 3.7.5.16-2
+this.INFO_REC_EXTENDED_DISPLAY_BLANK = 0x80;
+this.INFO_REC_EXTENDED_DISPLAY_SKIP = 0x81;
+this.INFO_REC_EXTENDED_DISPLAY_CONTINATION = 0x82;
+this.INFO_REC_EXTENDED_DISPLAY_CALLED_ADDRESS = 0x83;
+this.INFO_REC_EXTENDED_DISPLAY_CAUSE = 0x84;
+this.INFO_REC_EXTENDED_DISPLAY_PROGRESS_INDICATOR = 0x85;
+this.INFO_REC_EXTENDED_DISPLAY_NOTIFICATION_INDICATOR = 0x86;
+this.INFO_REC_EXTENDED_DISPLAY_PROMPT = 0x87;
+this.INFO_REC_EXTENDED_DISPLAY_ACCUMULATED_DIGITS = 0x88;
+this.INFO_REC_EXTENDED_DISPLAY_STATUS = 0x89;
+this.INFO_REC_EXTENDED_DISPLAY_INBAND = 0x8A;
+this.INFO_REC_EXTENDED_DISPLAY_CALLING_ADDRESS = 0x8B;
+this.INFO_REC_EXTENDED_DISPLAY_REASON = 0x8C;
+this.INFO_REC_EXTENDED_DISPLAY_CALLING_PARTY_NAME = 0x8D;
+this.INFO_REC_EXTENDED_DISPLAY_CALLED_PARTY_NAME = 0x8E;
+this.INFO_REC_EXTENDED_DISPLAY_ORIGINAL_CALLED_NAME = 0x8F;
+this.INFO_REC_EXTENDED_DISPLAY_REDIRECT_NAME = 0x90;
+this.INFO_REC_EXTENDED_DISPLAY_CONNECTED_NAME = 0x91;
+this.INFO_REC_EXTENDED_DISPLAY_ORIGINATING_RESTRICTIONS = 0x92;
+this.INFO_REC_EXTENDED_DISPLAY_DATE_TIME_OF_DAY = 0x93;
+this.INFO_REC_EXTENDED_DISPLAY_CALL_APPEARANCE_ID = 0x94;
+this.INFO_REC_EXTENDED_DISPLAY_FEATURE_ADDRESS = 0x95;
+this.INFO_REC_EXTENDED_DISPLAY_REDIRECTION_NAME = 0x96;
+this.INFO_REC_EXTENDED_DISPLAY_REDIRECTION_NUMBER = 0x97;
+this.INFO_REC_EXTENDED_DISPLAY_REDIRECTING_NUMBER = 0x98;
+this.INFO_REC_EXTENDED_DISPLAY_ORIGINAL_CALLED_NUMBER = 0x99;
+this.INFO_REC_EXTENDED_DISPLAY_CONNECTED_NUMBER = 0x9A;
+this.INFO_REC_EXTENDED_DISPLAY_TEXT = 0x9B;
+
 /**
  * The table for MCC which the length of MNC is 3
  *
  * This table is built from below links.
  * - http://www.itu.int/pub/T-SP-E.212B-2013
  * - http://en.wikipedia.org/wiki/Mobile_Network_Code
  */
 this.MCC_TABLE_FOR_MNC_LENGTH_IS_3 = [
--- a/dom/system/gonk/ril_worker.js
+++ b/dom/system/gonk/ril_worker.js
@@ -6144,17 +6144,21 @@ RIL[UNSOLICITED_CDMA_CALL_WAITING] = fun
   this.sendChromeMessage({rilMessageType: "cdmaCallWaiting",
                           number: call.number});
 };
 RIL[UNSOLICITED_CDMA_OTA_PROVISION_STATUS] = function UNSOLICITED_CDMA_OTA_PROVISION_STATUS() {
   let status = Buf.readUint32List()[0];
   this.sendChromeMessage({rilMessageType: "otastatuschange",
                           status: status});
 };
-RIL[UNSOLICITED_CDMA_INFO_REC] = null;
+RIL[UNSOLICITED_CDMA_INFO_REC] = function UNSOLICITED_CDMA_INFO_REC(length) {
+  let record = CdmaPDUHelper.decodeInformationRecord();
+  record.rilMessageType = "cdma-info-rec-received";
+  this.sendChromeMessage(record);
+};
 RIL[UNSOLICITED_OEM_HOOK_RAW] = null;
 RIL[UNSOLICITED_RINGBACK_TONE] = null;
 RIL[UNSOLICITED_RESEND_INCALL_MUTE] = null;
 RIL[UNSOLICITED_EXIT_EMERGENCY_CALLBACK_MODE] = function UNSOLICITED_EXIT_EMERGENCY_CALLBACK_MODE() {
   this._handleChangedEmergencyCbMode(false);
 };
 RIL[UNSOLICITED_RIL_CONNECTED] = function UNSOLICITED_RIL_CONNECTED(length) {
   // Prevent response id collision between UNSOLICITED_RIL_CONNECTED and
@@ -9249,16 +9253,128 @@ let CdmaPDUHelper = {
         result += this.dtmfChars.charAt(addrDigit);
       } else {
         let addrDigit = BitBufferHelper.readBits(8);
         result += String.fromCharCode(addrDigit);
       }
     }
 
     return result;
+  },
+
+  /**
+   * Decode information record parcel.
+   */
+  decodeInformationRecord: function cdma_decodeInformationRecord() {
+    let record = {};
+    let numOfRecords = Buf.readUint32();
+
+    let type;
+    for (let i = 0; i < numOfRecords; i++) {
+      type = Buf.readUint32();
+
+      switch (type) {
+        /*
+         * Every type is encaped by ril, except extended display
+         */
+        case PDU_CDMA_INFO_REC_TYPE_DISPLAY:
+          record.display = Buf.readString();
+          break;
+        case PDU_CDMA_INFO_REC_TYPE_CALLED_PARTY_NUMBER:
+          record.calledNumber = {};
+          record.calledNumber.number = Buf.readString();
+          record.calledNumber.type = Buf.readUint32();
+          record.calledNumber.plan = Buf.readUint32();
+          record.calledNumber.pi = Buf.readUint32();
+          record.calledNumber.si = Buf.readUint32();
+          break;
+        case PDU_CDMA_INFO_REC_TYPE_CALLING_PARTY_NUMBER:
+          record.callingNumber = {};
+          record.callingNumber.number = Buf.readString();
+          record.callingNumber.type = Buf.readUint32();
+          record.callingNumber.plan = Buf.readUint32();
+          record.callingNumber.pi = Buf.readUint32();
+          record.callingNumber.si = Buf.readUint32();
+          break;
+        case PDU_CDMA_INFO_REC_TYPE_CONNECTED_NUMBER:
+          record.connectedNumber = {};
+          record.connectedNumber.number = Buf.readString();
+          record.connectedNumber.type = Buf.readUint32();
+          record.connectedNumber.plan = Buf.readUint32();
+          record.connectedNumber.pi = Buf.readUint32();
+          record.connectedNumber.si = Buf.readUint32();
+          break;
+        case PDU_CDMA_INFO_REC_TYPE_SIGNAL:
+          record.signal = {};
+          record.signal.present = Buf.readUint32();
+          record.signal.type = Buf.readUint32();
+          record.signal.alertPitch = Buf.readUint32();
+          record.signal.signal = Buf.readUint32();
+          break;
+        case PDU_CDMA_INFO_REC_TYPE_REDIRECTING_NUMBER:
+          record.redirect = {};
+          record.redirect.number = Buf.readString();
+          record.redirect.type = Buf.readUint32();
+          record.redirect.plan = Buf.readUint32();
+          record.redirect.pi = Buf.readUint32();
+          record.redirect.si = Buf.readUint32();
+          record.redirect.reason = Buf.readUint32();
+          break;
+        case PDU_CDMA_INFO_REC_TYPE_LINE_CONTROL:
+          record.lineControl = {};
+          record.lineControl.polarityIncluded = Buf.readUint32();
+          record.lineControl.toggle = Buf.readUint32();
+          record.lineControl.recerse = Buf.readUint32();
+          record.lineControl.powerDenial = Buf.readUint32();
+          break;
+        case PDU_CDMA_INFO_REC_TYPE_EXTENDED_DISPLAY:
+          let length = Buf.readUint32();
+          /*
+           * Extended display is still in format defined in
+           * C.S0005-F v1.0, 3.7.5.16
+           */
+          record.extendedDisplay = {};
+
+          let headerByte = Buf.readUint32();
+          length--;
+          // Based on spec, headerByte must be 0x80 now
+          record.extendedDisplay.indicator = (headerByte >> 7);
+          record.extendedDisplay.type = (headerByte & 0x7F);
+          record.extendedDisplay.records = [];
+
+          while (length > 0) {
+            let display = {};
+
+            display.tag = Buf.readUint32();
+            length--;
+            if (display.tag !== INFO_REC_EXTENDED_DISPLAY_BLANK &&
+                display.tag !== INFO_REC_EXTENDED_DISPLAY_SKIP) {
+              display.content = Buf.readString();
+              length -= (display.content.length + 1);
+            }
+
+            record.extendedDisplay.records.push(display);
+          }
+          break;
+        case PDU_CDMA_INFO_REC_TYPE_T53_CLIR:
+          record.cause = Buf.readUint32();
+          break;
+        case PDU_CDMA_INFO_REC_TYPE_T53_AUDIO_CONTROL:
+          record.audioControl = {};
+          record.audioControl.upLink = Buf.readUint32();
+          record.audioControl.downLink = Buf.readUint32();
+          break;
+        case PDU_CDMA_INFO_REC_TYPE_T53_RELEASE:
+          // Fall through
+        default:
+          throw new Error("UNSOLICITED_CDMA_INFO_REC(), Unsupported information record type " + record.type + "\n");
+      }
+    }
+
+    return record;
   }
 };
 
 let StkCommandParamsFactory = {
   createParam: function createParam(cmdDetails, ctlvs) {
     let method = StkCommandParamsFactory[cmdDetails.typeOfCommand];
     if (typeof method != "function") {
       if (DEBUG) {