Bug 736706 - Part 1: Save message class information, r=philikon
authorVicamo Yang <vyang@mozilla.com>
Wed, 26 Sep 2012 14:56:08 +0800
changeset 108113 37ef7ce25b9ccbee3d2e646604c1ac5e614bfb77
parent 108102 f0a48031d4d12eef304afc7225837b8e7761f827
child 108114 73d41a3aa7d980061a1bacd6ac481ede0b775b1b
push id23539
push userryanvm@gmail.com
push dateWed, 26 Sep 2012 22:55:55 +0000
treeherderautoland@ec079fd92224 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersphilikon
bugs736706
milestone18.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 736706 - Part 1: Save message class information, r=philikon
dom/system/gonk/ril_consts.js
dom/system/gonk/ril_worker.js
--- a/dom/system/gonk/ril_consts.js
+++ b/dom/system/gonk/ril_consts.js
@@ -897,23 +897,23 @@ const PDU_PID_ANSI_136_R_DATA           
 const PDU_PID_ME_DATA_DOWNLOAD             = 0x7D;
 const PDU_PID_ME_DEPERSONALIZATION         = 0x7E;
 const PDU_PID_USIM_DATA_DOWNLOAD           = 0x7F;
 
 // DCS - Data Coding Scheme
 const PDU_DCS_MSG_CODING_7BITS_ALPHABET  = 0x00;
 const PDU_DCS_MSG_CODING_8BITS_ALPHABET  = 0x04;
 const PDU_DCS_MSG_CODING_16BITS_ALPHABET = 0x08;
-const PDU_DCS_MSG_CLASS_ME_SPECIFIC      = 0xF1;
-const PDU_DCS_MSG_CLASS_SIM_SPECIFIC     = 0xF2;
-const PDU_DCS_MSG_CLASS_TE_SPECIFIC      = 0xF3;
+const PDU_DCS_MSG_CLASS_UNKNOWN          = 0xFF;
+const PDU_DCS_MSG_CLASS_0                = 0x00;
+const PDU_DCS_MSG_CLASS_ME_SPECIFIC      = 0x01;
+const PDU_DCS_MSG_CLASS_SIM_SPECIFIC     = 0x02;
+const PDU_DCS_MSG_CLASS_TE_SPECIFIC      = 0x03;
 const PDU_DCS_CODING_GROUP_BITS          = 0xF0;
-const PDU_DCS_CODING_GROUP_7BITS_DISCARD = 0xC0;
-const PDU_DCS_CODING_GROUP_7BITS_STORE   = 0xD0;
-const PDU_DCS_CODING_GROUP_16BITS_STORE  = 0xE0;
+const PDU_DCS_MSG_CLASS_BITS             = 0x03;
 const PDU_DCS_MWI_ACTIVE_BITS            = 0x08;
 const PDU_DCS_MWI_ACTIVE_VALUE           = 0x08;
 const PDU_DCS_MWI_TYPE_BITS              = 0x03;
 const PDU_DCS_MWI_TYPE_VOICEMAIL         = 0x00;
 const PDU_DCS_MWI_TYPE_FAX               = 0x01;
 const PDU_DCS_MWI_TYPE_EMAIL             = 0x02;
 const PDU_DCS_MWI_TYPE_OTHER             = 0x03;
 
--- a/dom/system/gonk/ril_worker.js
+++ b/dom/system/gonk/ril_worker.js
@@ -5125,99 +5125,99 @@ let GsmPDUHelper = {
    *        message object for output.
    *
    * @see 3GPP TS 23.040 9.2.3.10, 3GPP TS 23.038 4.
    */
   readDataCodingScheme: function readDataCodingScheme(msg) {
     let dcs = this.readHexOctet();
     if (DEBUG) debug("PDU: read dcs: " + dcs);
 
-    // Level 2 of message waiting indication
-    this.readMessageWaitingFromDCS(msg, dcs);
-
+    // No message class by default.
+    let messageClass = PDU_DCS_MSG_CLASS_UNKNOWN;
     // 7 bit is the default fallback encoding.
     let encoding = PDU_DCS_MSG_CODING_7BITS_ALPHABET;
-    switch (dcs & 0xC0) {
-      case 0x0:
-        // bits 7..4 = 00xx
+    switch (dcs & PDU_DCS_CODING_GROUP_BITS) {
+      case 0x40: // bits 7..4 = 01xx
+      case 0x50:
+      case 0x60:
+      case 0x70:
+        // Bit 5..0 are coded exactly the same as Group 00xx
+      case 0x00: // bits 7..4 = 00xx
+      case 0x10:
+      case 0x20:
+      case 0x30:
+        if (dcs & 0x10) {
+          messageClass = dcs & PDU_DCS_MSG_CLASS_BITS;
+        }
         switch (dcs & 0x0C) {
           case 0x4:
             encoding = PDU_DCS_MSG_CODING_8BITS_ALPHABET;
             break;
           case 0x8:
             encoding = PDU_DCS_MSG_CODING_16BITS_ALPHABET;
             break;
         }
         break;
-      case 0xC0:
-        // bits 7..4 = 11xx
-        switch (dcs & 0x30) {
-          case 0x20:
-            encoding = PDU_DCS_MSG_CODING_16BITS_ALPHABET;
+
+      case 0xE0: // bits 7..4 = 1110
+        encoding = PDU_DCS_MSG_CODING_16BITS_ALPHABET;
+        // Bit 3..0 are coded exactly the same as Message Waiting Indication
+        // Group 1101.
+      case 0xC0: // bits 7..4 = 1100
+      case 0xD0: // bits 7..4 = 1101
+        // Indiciates voicemail indicator set or clear
+        let active = (dcs & PDU_DCS_MWI_ACTIVE_BITS) == PDU_DCS_MWI_ACTIVE_VALUE;
+
+        // If TP-UDH is present, these values will be overwritten
+        switch (dcs & PDU_DCS_MWI_TYPE_BITS) {
+          case PDU_DCS_MWI_TYPE_VOICEMAIL:
+            let mwi = msg.mwi;
+            if (!mwi) {
+              mwi = msg.mwi = {};
+            }
+
+            mwi.active = active;
+            mwi.discard = (dcs & PDU_DCS_CODING_GROUP_BITS) == 0xC0;
+            mwi.msgCount = active ? GECKO_VOICEMAIL_MESSAGE_COUNT_UNKNOWN : 0;
+
+            if (DEBUG) {
+              debug("MWI in DCS received for voicemail: " + JSON.stringify(mwi));
+            }
             break;
-          case 0x30:
-            if (dcs & 0x04) {
-              encoding = PDU_DCS_MSG_CODING_8BITS_ALPHABET;
-            }
+          case PDU_DCS_MWI_TYPE_FAX:
+            if (DEBUG) debug("MWI in DCS received for fax");
+            break;
+          case PDU_DCS_MWI_TYPE_EMAIL:
+            if (DEBUG) debug("MWI in DCS received for email");
+            break;
+          default:
+            if (DEBUG) debug("MWI in DCS received for \"other\"");
             break;
         }
         break;
+
+      case 0xF0: // bits 7..4 = 1111
+        if (dcs & 0x04) {
+          encoding = PDU_DCS_MSG_CODING_8BITS_ALPHABET;
+        }
+        messageClass = dcs & PDU_DCS_MSG_CLASS_BITS;
+        break;
+
       default:
         // Falling back to default encoding.
         break;
     }
 
     msg.dcs = dcs;
     msg.encoding = encoding;
+    msg.messageClass = messageClass;
 
     if (DEBUG) debug("PDU: message encoding is " + encoding + " bit.");
   },
 
-  readMessageWaitingFromDCS: function readMessageWaitingFromDCS(msg, dcs) {
-    // 0xC0 == 7 bit, don't store
-    // 0xD0 == 7 bit, store
-    // 0xE0 == UCS-2, store
-    let codingGroup = dcs & PDU_DCS_CODING_GROUP_BITS;
-
-    if (codingGroup == PDU_DCS_CODING_GROUP_7BITS_DISCARD ||
-        codingGroup == PDU_DCS_CODING_GROUP_7BITS_STORE ||
-        codingGroup == PDU_DCS_CODING_GROUP_16BITS_STORE) {
-
-      // Indiciates voicemail indicator set or clear
-      let active = (dcs & PDU_DCS_MWI_ACTIVE_BITS) == PDU_DCS_MWI_ACTIVE_VALUE;
-
-      // If TP-UDH is present, these values will be overwritten
-      switch (dcs & PDU_DCS_MWI_TYPE_BITS) {
-        case PDU_DCS_MWI_TYPE_VOICEMAIL:
-          let mwi = msg.mwi;
-          if (!mwi) {
-            mwi = msg.mwi = {};
-          }
-
-          mwi.active = active;
-          mwi.discard = codingGroup == PDU_DCS_CODING_GROUP_7BITS_DISCARD;
-          mwi.msgCount = active ? GECKO_VOICEMAIL_MESSAGE_COUNT_UNKNOWN : 0;
-
-          if (DEBUG) {
-            debug("MWI in DCS received for voicemail: " + JSON.stringify(mwi));
-          }
-          break;
-        case PDU_DCS_MWI_TYPE_FAX:
-          if (DEBUG) debug("MWI in DCS received for fax");
-          break;
-        case PDU_DCS_MWI_TYPE_EMAIL:
-          if (DEBUG) debug("MWI in DCS received for email");
-          break;
-        default:
-          if (DEBUG) debug("MWI in DCS received for \"other\"");
-          break;
-      }
-    }
-  },
-
   /**
    * Read GSM TP-Service-Centre-Time-Stamp(TP-SCTS).
    *
    * @see 3GPP TS 23.040 9.2.3.11
    */
   readTimestamp: function readTimestamp() {
     let year   = this.readSwappedNibbleBcdNum(1) + PDU_TIMESTAMP_YEAR_OFFSET;
     let month  = this.readSwappedNibbleBcdNum(1) - 1;