Bug 786701 : B2G RIL : refactor reading MSISDN. r=vicamo
authorYoshi Huang <allstars.chh@mozilla.com>
Tue, 28 Aug 2012 13:08:05 -0300
changeset 103808 c71057cd9300944ca573e49ff252f84ebf05d51a
parent 103807 f8d3febc5f64733f76eaa546a8c30c58a11e105d
child 103809 503884273a3a5d703a00dacc7a5b3b4b52ec835d
push id1
push userroot
push dateMon, 20 Oct 2014 17:29:22 +0000
reviewersvicamo
bugs786701
milestone18.0a1
Bug 786701 : B2G RIL : refactor reading MSISDN. r=vicamo
dom/system/gonk/ril_worker.js
--- a/dom/system/gonk/ril_worker.js
+++ b/dom/system/gonk/ril_worker.js
@@ -1069,37 +1069,26 @@ let RIL = {
     Buf.writeString(aid ? aid : this.aid);
     Buf.sendParcel();
   },
 
   /**
    * Read the MSISDN from the ICC.
    */
   getMSISDN: function getMSISDN() {
-    function callback() {
-      let length = Buf.readUint32();
-      // Each octet is encoded into two chars.
-      let recordLength = length / 2;
-      // Skip prefixed alpha identifier
-      Buf.seekIncoming((recordLength - MSISDN_FOOTER_SIZE_BYTES) *
-                        PDU_HEX_OCTET_SIZE);
-
-      // Dialling Number/SSC String
-      let len = GsmPDUHelper.readHexOctet();
-      if (len > MSISDN_MAX_NUMBER_SIZE_BYTES) {
-        debug("ICC_EF_MSISDN: invalid length of BCD number/SSC contents - " + len);
-        return;
-      }
-      this.iccInfo.msisdn = GsmPDUHelper.readDiallingNumber(len);
-      Buf.readStringDelimiter(length);
-
-      if (DEBUG) debug("MSISDN: " + this.iccInfo.msisdn);
-      if (this.iccInfo.msisdn) {
+    function callback(options) {
+      let parseCallback = function parseCallback(msisdn) {
+        if (this.iccInfo.msisdn === msisdn.number) {
+          return;
+        }
+        this.iccInfo.msisdn = msisdn.number;
+        if (DEBUG) debug("MSISDN: " + this.iccInfo.msisdn);
         this._handleICCInfoChange();
       }
+      this.parseDiallingNumber(options, parseCallback);
     }
 
     this.iccIO({
       command:   ICC_COMMAND_GET_RESPONSE,
       fileId:    ICC_EF_MSISDN,
       pathId:    this._getPathIdForICCRecord(ICC_EF_MSISDN),
       p1:        0, // For GET_RESPONSE, p1 = 0
       p2:        0, // For GET_RESPONSE, p2 = 0