Bug 816893 - Part 3: ICCUtils Helper. r=hsinyi
authorYoshi Huang <allstars.chh@mozilla.com>
Thu, 06 Dec 2012 19:48:28 +0800
changeset 126417 4804e200cc5a18c716ad41b124c70cdd16aad47f
parent 126416 58615c1dbc7fe015fc2412ff399d6d6f2c16874d
child 126418 8e186f3b8f258b74216ee1b61ef2f4f308f1da50
push id2151
push userlsblakk@mozilla.com
push dateTue, 19 Feb 2013 18:06:57 +0000
treeherdermozilla-beta@4952e88741ec [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewershsinyi
bugs816893
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 816893 - Part 3: ICCUtils Helper. r=hsinyi
dom/system/gonk/ril_worker.js
dom/system/gonk/tests/test_ril_worker_icc.js
--- a/dom/system/gonk/ril_worker.js
+++ b/dom/system/gonk/ril_worker.js
@@ -1209,103 +1209,16 @@ let RIL = {
     Buf.writeString(options.pin2 || null);
     if (!RILQUIRKS_V5_LEGACY) {
       Buf.writeString(options.aid || this.aid);
     }
     Buf.sendParcel();
   },
 
   /**
-   * This will compute the spnDisplay field of the network.
-   * See TS 22.101 Annex A and TS 51.011 10.3.11 for details.
-   *
-   * @return True if some of iccInfo is changed in by this function.
-   */
-  updateDisplayCondition: function updateDisplayCondition() {
-    // If EFspn isn't existed in SIM or it haven't been read yet, we should
-    // just set isDisplayNetworkNameRequired = true and
-    // isDisplaySpnRequired = false
-    let iccInfo = this.iccInfo;
-    let iccInfoPriv = this.iccInfoPrivate;
-    let iccSpn = iccInfoPriv.SPN;
-    let origIsDisplayNetworkNameRequired = iccInfo.isDisplayNetworkNameRequired;
-    let origIsDisplaySPNRequired = iccInfo.isDisplaySpnRequired;
-
-    if (!iccSpn) {
-      iccInfo.isDisplayNetworkNameRequired = true;
-      iccInfo.isDisplaySpnRequired = false;
-    } else {
-      let operatorMnc = this.operator.mnc;
-      let operatorMcc = this.operator.mcc;
-
-      // First detect if we are on HPLMN or one of the PLMN
-      // specified by the SIM card.
-      let isOnMatchingPlmn = false;
-
-      // If the current network is the one defined as mcc/mnc
-      // in SIM card, it's okay.
-      if (iccInfo.mcc == operatorMcc && iccInfo.mnc == operatorMnc) {
-        isOnMatchingPlmn = true;
-      }
-
-      // Test to see if operator's mcc/mnc match mcc/mnc of PLMN.
-      if (!isOnMatchingPlmn && iccInfoPriv.SPDI) {
-        let iccSpdi = iccInfoPriv.SPDI; // PLMN list
-        for (let plmn in iccSpdi) {
-          let plmnMcc = iccSpdi[plmn].mcc;
-          let plmnMnc = iccSpdi[plmn].mnc;
-          isOnMatchingPlmn = (plmnMcc == operatorMcc) && (plmnMnc == operatorMnc);
-          if (isOnMatchingPlmn) {
-            break;
-          }
-        }
-      }
-
-      if (isOnMatchingPlmn) {
-        // The first bit of display condition tells us if we should display
-        // registered PLMN.
-        if (DEBUG) debug("updateDisplayCondition: PLMN is HPLMN or PLMN is in PLMN list");
-
-        // TS 31.102 Sec. 4.2.66 and TS 51.011 Sec. 10.3.50
-        // EF_SPDI contains a list of PLMNs in which the Service Provider Name
-        // shall be displayed.
-        iccInfo.isDisplaySpnRequired = true;
-        if (iccSpn.spnDisplayCondition & 0x01) {
-          iccInfo.isDisplayNetworkNameRequired = true;
-        } else {
-          iccInfo.isDisplayNetworkNameRequired = false;
-        }
-      } else {
-        // The second bit of display condition tells us if we should display
-        // registered PLMN.
-        if (DEBUG) debug("updateICCDisplayName: PLMN isn't HPLMN and PLMN isn't in PLMN list");
-
-        // We didn't found the requirement of displaying network name if
-        // current PLMN isn't HPLMN nor one of PLMN in SPDI. So we keep
-        // isDisplayNetworkNameRequired false.
-        if (iccSpn.spnDisplayCondition & 0x02) {
-          iccInfo.isDisplayNetworkNameRequired = false;
-          iccInfo.isDisplaySpnRequired = false;
-        } else {
-          iccInfo.isDisplayNetworkNameRequired = false;
-          iccInfo.isDisplaySpnRequired = true;
-        }
-      }
-    }
-
-    if (DEBUG) {
-      debug("updateDisplayCondition: isDisplayNetworkNameRequired = " + iccInfo.isDisplayNetworkNameRequired);
-      debug("updateDisplayCondition: isDisplaySpnRequired = " + iccInfo.isDisplaySpnRequired);
-    }
-
-    return ((origIsDisplayNetworkNameRequired !== iccInfo.isDisplayNetworkNameRequired) ||
-            (origIsDisplaySPNRequired !== iccInfo.isDisplaySpnRequired));
-  },
-
-  /**
    * Get IMSI.
    *
    * @param [optional] aid
    *        AID value.
    */
   getIMSI: function getIMSI(aid) {
     if (RILQUIRKS_V5_LEGACY) {
       Buf.simpleRequest(REQUEST_GET_IMSI);
@@ -1313,78 +1226,16 @@ let RIL = {
     }
     let token = Buf.newParcel(REQUEST_GET_IMSI);
     Buf.writeUint32(1);
     Buf.writeString(aid || this.aid);
     Buf.sendParcel();
   },
 
   /**
-   * Get whether specificed (U)SIM service is available.
-   *
-   * @param geckoService
-   *        Service name like "ADN", "BDN", etc.
-   *
-   * @return true if the service is enabled, false otherwise.
-   */
-  isICCServiceAvailable: function isICCServiceAvailable(geckoService) {
-    let serviceTable = this.iccInfo.sst;
-    let index, bitmask;
-    if (this.appType == CARD_APPTYPE_SIM) {
-      /**
-       * Service id is valid in 1..N, and 2 bits are used to code each service.
-       *
-       * +----+--  --+----+----+
-       * | b8 | ...  | b2 | b1 |
-       * +----+--  --+----+----+
-       *
-       * b1 = 0, service not allocated.
-       *      1, service allocated.
-       * b2 = 0, service not activatd.
-       *      1, service allocated.
-       *
-       * @see 3GPP TS 51.011 10.3.7.
-       */
-      let simService = GECKO_ICC_SERVICES.sim[geckoService];
-      if (!simService) {
-        return false;
-      }
-      simService -= 1;
-      index = Math.floor(simService / 4);
-      bitmask = 2 << ((simService % 4) << 1);
-    } else {
-      /**
-       * Service id is valid in 1..N, and 1 bit is used to code each service.
-       *
-       * +----+--  --+----+----+
-       * | b8 | ...  | b2 | b1 |
-       * +----+--  --+----+----+
-       *
-       * b1 = 0, service not avaiable.
-       *      1, service available.
-       * b2 = 0, service not avaiable.
-       *      1, service available.
-       *
-       * @see 3GPP TS 31.102 4.2.8.
-       */
-      let usimService = GECKO_ICC_SERVICES.usim[geckoService];
-      if (!usimService) {
-        return false;
-      }
-      usimService -= 1;
-      index = Math.floor(usimService / 8);
-      bitmask = 1 << ((usimService % 8) << 0);
-    }
-
-    return (serviceTable &&
-           (index < serviceTable.length) &&
-           (serviceTable[index] & bitmask)) != 0;
-  },
-
-  /**
    * Choose network names using EF_OPL and EF_PNN
    * See 3GPP TS 31.102 sec. 4.2.58 and sec. 4.2.59 for USIM,
    *     3GPP TS 51.011 sec. 10.3.41 and sec. 10.3.42 for SIM.
    */
   updateNetworkName: function updateNetworkName() {
     let iccInfoPriv = this.iccInfoPrivate;
     let iccInfo = this.iccInfo;
 
@@ -3140,18 +2991,18 @@ let RIL = {
 
       if (networkTuple) {
         try {
           this._processNetworkTuple(networkTuple, this.operator);
         } catch (e) {
           debug("Error processing operator tuple: " + e);
         }
       }
-      if (this.updateDisplayCondition()) {
-        ICCRecordHelper.handleICCInfoChange();
+      if (ICCUtilsHelper.updateDisplayCondition()) {
+        ICCUtilsHelper.handleICCInfoChange();
       }
       this._sendNetworkInfoMessage(NETWORK_INFO_OPERATOR, this.operator);
     }
   },
 
   /**
    * Helpers for processing call state and handle the active call.
    */
@@ -3627,17 +3478,17 @@ let RIL = {
       // 9.2.3.9
       return PDU_FCS_OK;
     }
 
     if (message.messageClass == GECKO_SMS_MESSAGE_CLASSES[PDU_DCS_MSG_CLASS_2]) {
       switch (message.epid) {
         case PDU_PID_ANSI_136_R_DATA:
         case PDU_PID_USIM_DATA_DOWNLOAD:
-          if (this.isICCServiceAvailable("DATA_DOWNLOAD_SMS_PP")) {
+          if (ICCUtilsHelper.isICCServiceAvailable("DATA_DOWNLOAD_SMS_PP")) {
             // `If the service "data download via SMS Point-to-Point" is
             // allocated and activated in the (U)SIM Service Table, ... then the
             // ME shall pass the message transparently to the UICC using the
             // ENVELOPE (SMS-PP DOWNLOAD).` ~ 3GPP TS 31.111 7.1.1.1
             this.dataDownloadViaSMSPP(message);
 
             // `the ME shall not display the message, or alert the user of a
             // short message waiting.` ~ 3GPP TS 31.111 7.1.1.1
@@ -8577,17 +8428,17 @@ let ICCRecordHelper = {
   getICCID: function getICCID() {
     function callback() {
       let length = Buf.readUint32();
       RIL.iccInfo.iccid = GsmPDUHelper.readSwappedNibbleBcdString(length / 2);
       Buf.readStringDelimiter(length);
 
       if (DEBUG) debug("ICCID: " + RIL.iccInfo.iccid);
       if (RIL.iccInfo.iccid) {
-        this.handleICCInfoChange();
+        ICCUtilsHelper.handleICCInfoChange();
       }
     }
 
     ICCIOHelper.loadTransparentEF({fileId: ICC_EF_ICCID,
                                    callback: callback.bind(this)});
   },
 
   /**
@@ -8596,17 +8447,17 @@ let ICCRecordHelper = {
   getMSISDN: function getMSISDN() {
     function callback(options) {
       let contact = GsmPDUHelper.readAlphaIdDiallingNumber(options);
       if (!contact || RIL.iccInfo.msisdn === contact.number) {
         return;
       }
       RIL.iccInfo.msisdn = contact.number;
       if (DEBUG) debug("MSISDN: " + RIL.iccInfo.msisdn);
-      this.handleICCInfoChange();
+      ICCUtilsHelper.handleICCInfoChange();
     }
 
     ICCIOHelper.loadLinearFixedEF({fileId: ICC_EF_MSISDN,
                                    callback: callback.bind(this)});
   },
 
   /**
    * Read the AD (Administrative Data) from the ICC.
@@ -8628,17 +8479,17 @@ let ICCRecordHelper = {
       }
 
       if (RIL.iccInfo.imsi) {
         // MCC is the first 3 digits of IMSI.
         RIL.iccInfo.mcc = parseInt(RIL.iccInfo.imsi.substr(0,3));
         // The 4th byte of the response is the length of MNC.
         RIL.iccInfo.mnc = parseInt(RIL.iccInfo.imsi.substr(3, RIL.iccInfo.ad[3]));
         if (DEBUG) debug("MCC: " + RIL.iccInfo.mcc + " MNC: " + RIL.iccInfo.mnc);
-        this.handleICCInfoChange();
+        ICCUtilsHelper.handleICCInfoChange();
       }
     }
 
     ICCIOHelper.loadTransparentEF({fileId: ICC_EF_AD,
                                    callback: callback.bind(this)});
   },
 
   /**
@@ -8659,18 +8510,18 @@ let ICCRecordHelper = {
               ", spnDisplayCondition = " + spnDisplayCondition);
       }
 
       RIL.iccInfoPrivate.SPN = {
         spn : spn,
         spnDisplayCondition : spnDisplayCondition,
       };
       RIL.iccInfo.spn = spn;
-      RIL.updateDisplayCondition();
-      this.handleICCInfoChange();
+      ICCUtilsHelper.updateDisplayCondition();
+      ICCUtilsHelper.handleICCInfoChange();
     }
 
     ICCIOHelper.loadTransparentEF({fileId: ICC_EF_SPN,
                                    callback: callback.bind(this)});
   },
 
   /**
    * Read the (U)SIM Service Table from the ICC.
@@ -8687,50 +8538,50 @@ let ICCRecordHelper = {
         let str = "";
         for (let i = 0; i < RIL.iccInfo.sst.length; i++) {
           str += RIL.iccInfo.sst[i] + ", ";
         }
         debug("SST: " + str);
       }
 
       // Fetch SPN and PLMN list, if some of them are available.
-      if (RIL.isICCServiceAvailable("SPN")) {
+      if (ICCUtilsHelper.isICCServiceAvailable("SPN")) {
         if (DEBUG) debug("SPN: SPN is available");
         this.getSPN();
       } else {
         if (DEBUG) debug("SPN: SPN service is not available");
       }
 
-      if (RIL.isICCServiceAvailable("SPDI")) {
+      if (ICCUtilsHelper.isICCServiceAvailable("SPDI")) {
         if (DEBUG) debug("SPDI: SPDI available.");
         this.getSPDI();
       } else {
         if (DEBUG) debug("SPDI: SPDI service is not available");
       }
 
-      if (RIL.isICCServiceAvailable("PNN")) {
+      if (ICCUtilsHelper.isICCServiceAvailable("PNN")) {
         if (DEBUG) debug("PNN: PNN is available");
         this.getPNN();
       } else {
         if (DEBUG) debug("PNN: PNN is not available");
       }
 
-      if (RIL.isICCServiceAvailable("OPL")) {
+      if (ICCUtilsHelper.isICCServiceAvailable("OPL")) {
         if (DEBUG) debug("OPL: OPL is available");
         this.getOPL();
       } else {
         if (DEBUG) debug("OPL: OPL is not available");
       }
 
-      if (RIL.isICCServiceAvailable("CBMI")) {
+      if (ICCUtilsHelper.isICCServiceAvailable("CBMI")) {
         this.getCBMI();
       } else {
         RIL.cellBroadcastConfigs.CBMI = null;
       }
-      if (RIL.isICCServiceAvailable("CBMIR")) {
+      if (ICCUtilsHelper.isICCServiceAvailable("CBMIR")) {
         this.getCBMIR();
       } else {
         RIL.cellBroadcastConfigs.CBMIR = null;
       }
       RIL._mergeAllCellBroadcastConfigs();
     }
 
     // ICC_EF_UST has the same value with ICC_EF_SST.
@@ -8854,19 +8705,19 @@ let ICCRecordHelper = {
    *         Request id from RadioInterfaceLayer.
    */
   getPBR: function getPBR(options) {
     function callback(options) {
       let bufLen = Buf.readUint32();
 
       let tag = GsmPDUHelper.readHexOctet();
       let length = GsmPDUHelper.readHexOctet();
-      let value = this.decodeSimTlvs(length);
-
-      let adn = this.searchForIccUsimTag(value, ICC_USIM_EFADN_TAG);
+      let value = ICCUtilsHelper.decodeSimTlvs(length);
+
+      let adn = ICCUtilsHelper.searchForIccUsimTag(value, ICC_USIM_EFADN_TAG);
       options.fileId = (adn.value[0] << 8) | adn.value[1];
       Buf.readStringDelimiter(bufLen);
 
       this.getADN(options);
     }
 
     function error(options) {
       delete options.callback;
@@ -8940,18 +8791,18 @@ let ICCRecordHelper = {
         }
       }
 
       // Consume unread octets.
       Buf.seekIncoming((length / 2 - readLen) * PDU_HEX_OCTET_SIZE);
       Buf.readStringDelimiter(length);
 
       if (DEBUG) debug("SPDI: " + JSON.stringify(RIL.iccInfoPrivate.SPDI));
-      if (RIL.updateDisplayCondition()) {
-        this.handleICCInfoChange();
+      if (ICCUtilsHelper.updateDisplayCondition()) {
+        ICCUtilsHelper.handleICCInfoChange();
       }
     }
 
     // PLMN List is Servive 51 in USIM, EF_SPDI
     ICCIOHelper.loadTransparentEF({fileId: ICC_EF_SPDI,
                                    callback: callback.bind(this)});
   },
 
@@ -9223,23 +9074,107 @@ let ICCRecordHelper = {
       } catch (e) {
         if (DEBUG) debug("readPLMNEntries: PLMN entry " + index + " is invalid.");
         break;
       }
       index ++;
     }
     return plmnList;
   },
-
-  /**
-   * Update the ICC information to RadioInterfaceLayer.
-   */
-  handleICCInfoChange: function handleICCInfoChange() {
-    RIL.iccInfo.rilMessageType = "iccinfochange";
-    RIL.sendDOMMessage(RIL.iccInfo);
+};
+
+/**
+ * Helper functions for ICC utilities.
+ */
+let ICCUtilsHelper = {
+  /**
+   * This will compute the spnDisplay field of the network.
+   * See TS 22.101 Annex A and TS 51.011 10.3.11 for details.
+   *
+   * @return True if some of iccInfo is changed in by this function.
+   */
+  updateDisplayCondition: function updateDisplayCondition() {
+    // If EFspn isn't existed in SIM or it haven't been read yet, we should
+    // just set isDisplayNetworkNameRequired = true and
+    // isDisplaySpnRequired = false
+    let iccInfo = RIL.iccInfo;
+    let iccInfoPriv = RIL.iccInfoPrivate;
+    let iccSpn = iccInfoPriv.SPN;
+    let origIsDisplayNetworkNameRequired = iccInfo.isDisplayNetworkNameRequired;
+    let origIsDisplaySPNRequired = iccInfo.isDisplaySpnRequired;
+
+    if (!iccSpn) {
+      iccInfo.isDisplayNetworkNameRequired = true;
+      iccInfo.isDisplaySpnRequired = false;
+    } else {
+      let operatorMnc = RIL.operator.mnc;
+      let operatorMcc = RIL.operator.mcc;
+
+      // First detect if we are on HPLMN or one of the PLMN
+      // specified by the SIM card.
+      let isOnMatchingPlmn = false;
+
+      // If the current network is the one defined as mcc/mnc
+      // in SIM card, it's okay.
+      if (iccInfo.mcc == operatorMcc && iccInfo.mnc == operatorMnc) {
+        isOnMatchingPlmn = true;
+      }
+
+      // Test to see if operator's mcc/mnc match mcc/mnc of PLMN.
+      if (!isOnMatchingPlmn && iccInfoPriv.SPDI) {
+        let iccSpdi = iccInfoPriv.SPDI; // PLMN list
+        for (let plmn in iccSpdi) {
+          let plmnMcc = iccSpdi[plmn].mcc;
+          let plmnMnc = iccSpdi[plmn].mnc;
+          isOnMatchingPlmn = (plmnMcc == operatorMcc) && (plmnMnc == operatorMnc);
+          if (isOnMatchingPlmn) {
+            break;
+          }
+        }
+      }
+
+      if (isOnMatchingPlmn) {
+        // The first bit of display condition tells us if we should display
+        // registered PLMN.
+        if (DEBUG) debug("updateDisplayCondition: PLMN is HPLMN or PLMN is in PLMN list");
+
+        // TS 31.102 Sec. 4.2.66 and TS 51.011 Sec. 10.3.50
+        // EF_SPDI contains a list of PLMNs in which the Service Provider Name
+        // shall be displayed.
+        iccInfo.isDisplaySpnRequired = true;
+        if (iccSpn.spnDisplayCondition & 0x01) {
+          iccInfo.isDisplayNetworkNameRequired = true;
+        } else {
+          iccInfo.isDisplayNetworkNameRequired = false;
+        }
+      } else {
+        // The second bit of display condition tells us if we should display
+        // registered PLMN.
+        if (DEBUG) debug("updateICCDisplayName: PLMN isn't HPLMN and PLMN isn't in PLMN list");
+
+        // We didn't found the requirement of displaying network name if
+        // current PLMN isn't HPLMN nor one of PLMN in SPDI. So we keep
+        // isDisplayNetworkNameRequired false.
+        if (iccSpn.spnDisplayCondition & 0x02) {
+          iccInfo.isDisplayNetworkNameRequired = false;
+          iccInfo.isDisplaySpnRequired = false;
+        } else {
+          iccInfo.isDisplayNetworkNameRequired = false;
+          iccInfo.isDisplaySpnRequired = true;
+        }
+      }
+    }
+
+    if (DEBUG) {
+      debug("updateDisplayCondition: isDisplayNetworkNameRequired = " + iccInfo.isDisplayNetworkNameRequired);
+      debug("updateDisplayCondition: isDisplaySpnRequired = " + iccInfo.isDisplaySpnRequired);
+    }
+
+    return ((origIsDisplayNetworkNameRequired !== iccInfo.isDisplayNetworkNameRequired) ||
+            (origIsDisplaySPNRequired !== iccInfo.isDisplaySpnRequired));
   },
 
   decodeSimTlvs: function decodeSimTlvs(tlvsLen) {
     let index = 0;
     let tlvs = [];
     while (index < tlvsLen) {
       let simTlv = {
         tag : GsmPDUHelper.readHexOctet(),
@@ -9255,16 +9190,86 @@ let ICCRecordHelper = {
   searchForIccUsimTag: function searchForIccUsimTag(tlvs, tag) {
     for (let i = 0; i < tlvs.length; i++) {
       if (tlvs[i].tag == tag) {
         return tlvs[i];
       }
     }
     return null;
   },
+
+  /**
+   * Update the ICC information to RadioInterfaceLayer.
+   */
+  handleICCInfoChange: function handleICCInfoChange() {
+    RIL.iccInfo.rilMessageType = "iccinfochange";
+    RIL.sendDOMMessage(RIL.iccInfo);
+  },
+
+  /**
+   * Get whether specificed (U)SIM service is available.
+   *
+   * @param geckoService
+   *        Service name like "ADN", "BDN", etc.
+   *
+   * @return true if the service is enabled, false otherwise.
+   */
+  isICCServiceAvailable: function isICCServiceAvailable(geckoService) {
+    let serviceTable = RIL.iccInfo.sst;
+    let index, bitmask;
+    if (RIL.appType == CARD_APPTYPE_SIM) {
+      /**
+       * Service id is valid in 1..N, and 2 bits are used to code each service.
+       *
+       * +----+--  --+----+----+
+       * | b8 | ...  | b2 | b1 |
+       * +----+--  --+----+----+
+       *
+       * b1 = 0, service not allocated.
+       *      1, service allocated.
+       * b2 = 0, service not activatd.
+       *      1, service allocated.
+       *
+       * @see 3GPP TS 51.011 10.3.7.
+       */
+      let simService = GECKO_ICC_SERVICES.sim[geckoService];
+      if (!simService) {
+        return false;
+      }
+      simService -= 1;
+      index = Math.floor(simService / 4);
+      bitmask = 2 << ((simService % 4) << 1);
+    } else {
+      /**
+       * Service id is valid in 1..N, and 1 bit is used to code each service.
+       *
+       * +----+--  --+----+----+
+       * | b8 | ...  | b2 | b1 |
+       * +----+--  --+----+----+
+       *
+       * b1 = 0, service not avaiable.
+       *      1, service available.
+       * b2 = 0, service not avaiable.
+       *      1, service available.
+       *
+       * @see 3GPP TS 31.102 4.2.8.
+       */
+      let usimService = GECKO_ICC_SERVICES.usim[geckoService];
+      if (!usimService) {
+        return false;
+      }
+      usimService -= 1;
+      index = Math.floor(usimService / 8);
+      bitmask = 1 << ((usimService % 8) << 0);
+    }
+
+    return (serviceTable &&
+           (index < serviceTable.length) &&
+           (serviceTable[index] & bitmask)) != 0;
+  },
 };
 
 /**
  * Global stuff.
  */
 
 if (!this.debug) {
   // Debugging stub that goes nowhere.
--- a/dom/system/gonk/tests/test_ril_worker_icc.js
+++ b/dom/system/gonk/tests/test_ril_worker_icc.js
@@ -186,27 +186,28 @@ add_test(function test_octect_BCD() {
   octet = 0x56;
   number = helper.octetToBCD(octet);
   do_check_eq(helper.BCDToOctet(number), octet);
 
   run_next_test();
 });
 
 /**
- * Verify RIL.isICCServiceAvailable.
+ * Verify ICCUtilsHelper.isICCServiceAvailable.
  */
 add_test(function test_is_icc_service_available() {
   let worker = newUint8Worker();
+  let ICCUtilsHelper = worker.ICCUtilsHelper;
 
   function test_table(sst, geckoService, simEnabled, usimEnabled) {
     worker.RIL.iccInfo.sst = sst;
     worker.RIL.appType = CARD_APPTYPE_SIM;
-    do_check_eq(worker.RIL.isICCServiceAvailable(geckoService), simEnabled);
+    do_check_eq(ICCUtilsHelper.isICCServiceAvailable(geckoService), simEnabled);
     worker.RIL.appType = CARD_APPTYPE_USIM;
-    do_check_eq(worker.RIL.isICCServiceAvailable(geckoService), usimEnabled);
+    do_check_eq(ICCUtilsHelper.isICCServiceAvailable(geckoService), usimEnabled);
   }
 
   test_table([0x08], "ADN", true, false);
   test_table([0x08], "FDN", false, false);
   test_table([0x08], "SDN", false, true);
 
   run_next_test();
 });
@@ -565,27 +566,29 @@ add_test(function test_stk_proactive_com
   for (let i = 0; i < tlv.value.eventList.length; i++) {
     do_check_eq(tlv.value.eventList[i], i);
   }
 
   run_next_test();
 });
 
 add_test(function test_spn_display_condition() {
-  let RIL = newWorker({
+  let worker = newWorker({
     postRILMessage: function fakePostRILMessage(data) {
       // Do nothing
     },
     postMessage: function fakePostMessage(message) {
       // Do nothing
     }
-  }).RIL;
+  });
+  let RIL = worker.RIL;
+  let ICCUtilsHelper = worker.ICCUtilsHelper;
 
   // Test updateDisplayCondition runs before any of SIM file is ready.
-  do_check_eq(RIL.updateDisplayCondition(), true);
+  do_check_eq(ICCUtilsHelper.updateDisplayCondition(), true);
   do_check_eq(RIL.iccInfo.isDisplayNetworkNameRequired, true);
   do_check_eq(RIL.iccInfo.isDisplaySpnRequired, false);
 
   // Test with value.
   function testDisplayCondition(iccDisplayCondition,
                                 iccMcc, iccMnc, plmnMcc, plmnMnc,
                                 expectedIsDisplayNetworkNameRequired,
                                 expectedIsDisplaySPNRequired,
@@ -597,17 +600,17 @@ add_test(function test_spn_display_condi
       mcc: iccMcc,
       mnc: iccMnc
     };
     RIL.operator = {
       mcc: plmnMcc,
       mnc: plmnMnc
     };
 
-    do_check_eq(RIL.updateDisplayCondition(), true);
+    do_check_eq(ICCUtilsHelper.updateDisplayCondition(), true);
     do_check_eq(RIL.iccInfo.isDisplayNetworkNameRequired, expectedIsDisplayNetworkNameRequired);
     do_check_eq(RIL.iccInfo.isDisplaySpnRequired, expectedIsDisplaySPNRequired);
     do_timeout(0, callback);
   };
 
   function testDisplayConditions(func, caseArray, oncomplete) {
     (function do_call(index) {
       let next = index < (caseArray.length - 1) ? do_call.bind(null, index + 1) : oncomplete;
@@ -896,41 +899,42 @@ add_test(function test_stk_proactive_com
   do_check_eq(tlv.value.commandNumber, 0x01);
   do_check_eq(tlv.value.typeOfCommand, STK_CMD_PROVIDE_LOCAL_INFO);
   do_check_eq(tlv.value.commandQualifier, STK_LOCAL_INFO_DATE_TIME_ZONE);
 
   run_next_test();
 });
 
 add_test(function test_path_id_for_spid_and_spn() {
-  let RIL = newWorker({
+  let worker = newWorker({
     postRILMessage: function fakePostRILMessage(data) {
       // Do nothing
     },
     postMessage: function fakePostMessage(message) {
       // Do nothing
-    }
-  }).RIL;
+    }});
+  let RIL = worker.RIL;
+  let ICCFileHelper = worker.ICCFileHelper;
 
   // Test SIM
   RIL.iccStatus = {
     gsmUmtsSubscriptionAppIndex: 0,
     apps: [
       {
         app_type: CARD_APPTYPE_SIM
       }, {
         app_type: CARD_APPTYPE_USIM
       }
     ]
   }
-  do_check_eq(RIL._getPathIdForICCRecord(ICC_EF_SPDI),
+  do_check_eq(ICCFileHelper.getEFPath(ICC_EF_SPDI),
               EF_PATH_MF_SIM + EF_PATH_DF_GSM);
-  do_check_eq(RIL._getPathIdForICCRecord(ICC_EF_SPN),
+  do_check_eq(ICCFileHelper.getEFPath(ICC_EF_SPN),
               EF_PATH_MF_SIM + EF_PATH_DF_GSM);
 
   // Test USIM
   RIL.iccStatus.gsmUmtsSubscriptionAppIndex = 1;
-  do_check_eq(RIL._getPathIdForICCRecord(ICC_EF_SPDI),
+  do_check_eq(ICCFileHelper.getEFPath(ICC_EF_SPDI),
               EF_PATH_MF_SIM + EF_PATH_ADF_USIM);
-  do_check_eq(RIL._getPathIdForICCRecord(ICC_EF_SPDI),
+  do_check_eq(ICCFileHelper.getEFPath(ICC_EF_SPDI),
               EF_PATH_MF_SIM + EF_PATH_ADF_USIM);
   run_next_test();
-});
\ No newline at end of file
+});