Bug 1111990 - Support access EF_FDN only if FDN service is available. r=echen
authorJohn Dai <jdai@mozilla.com>
Sun, 04 Jan 2015 17:54:00 +0800
changeset 222112 355429828a63a801ff2bbd7d209798bcc1f1d041
parent 222111 ab9fb3092d9f89d87766229fa81d94a23d7c0a1f
child 222113 644bd5f5f444fa7a71930b5e935172f05a83a9f3
push id13029
push userechen@mozilla.com
push dateTue, 06 Jan 2015 02:17:53 +0000
treeherderb2g-inbound@355429828a63 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersechen
bugs1111990
milestone37.0a1
Bug 1111990 - Support access EF_FDN only if FDN service is available. r=echen
dom/system/gonk/ril_consts.js
dom/system/gonk/ril_worker.js
dom/system/gonk/tests/test_ril_worker_icc_ICCContactHelper.js
--- a/dom/system/gonk/ril_consts.js
+++ b/dom/system/gonk/ril_consts.js
@@ -1311,16 +1311,17 @@ this.GECKO_ICC_SERVICES = {
     PNN: 45,
     OPL: 46,
     MDN: 47,
     MWIS: 48,
     SPDI: 51
   },
   // @see 3GPP2 C.S0023-D 3.4.18 (RUIM).
   ruim: {
+    FDN: 3,
     ENHANCED_PHONEBOOK: 6,
     SPN: 17,
     SDN: 18
   },
   // @see B.3.1.1 CPHS Information in CPHS Phase 2:
   // Indicates which of the CPHS 'optional' data-fields are present in the SIM card:
   //   EF_CPHS_CSP, EF_CPHS_SST, EF_CPHS_MBN, EF_CPHS_ONSF, EF_CPHS_INFO_NUM
   // Note: Mandatory EFs are: (B.3.1 Enhanced SIM Requirements)
--- a/dom/system/gonk/ril_worker.js
+++ b/dom/system/gonk/ril_worker.js
@@ -15266,30 +15266,34 @@ ICCContactHelperObject.prototype = {
    *
    * @param appType       One of CARD_APPTYPE_*.
    * @param contactType   One of GECKO_CARDCONTACT_TYPE_*.
    * @param onsuccess     Callback to be called when success.
    * @param onerror       Callback to be called when error.
    */
   readICCContacts: function(appType, contactType, onsuccess, onerror) {
     let ICCRecordHelper = this.context.ICCRecordHelper;
+    let ICCUtilsHelper = this.context.ICCUtilsHelper;
 
     switch (contactType) {
       case GECKO_CARDCONTACT_TYPE_ADN:
         if (!this.hasDfPhoneBook(appType)) {
           ICCRecordHelper.readADNLike(ICC_EF_ADN, onsuccess, onerror);
         } else {
           this.readUSimContacts(onsuccess, onerror);
         }
         break;
       case GECKO_CARDCONTACT_TYPE_FDN:
+        if (!ICCUtilsHelper.isICCServiceAvailable("FDN")) {
+          onerror(CONTACT_ERR_CONTACT_TYPE_NOT_SUPPORTED);
+          break;
+        }
         ICCRecordHelper.readADNLike(ICC_EF_FDN, onsuccess, onerror);
         break;
       case GECKO_CARDCONTACT_TYPE_SDN:
-        let ICCUtilsHelper = this.context.ICCUtilsHelper;
         if (!ICCUtilsHelper.isICCServiceAvailable("SDN")) {
           onerror(CONTACT_ERR_CONTACT_TYPE_NOT_SUPPORTED);
           break;
         }
 
         ICCRecordHelper.readADNLike(ICC_EF_SDN, onsuccess, onerror);
         break;
       default:
@@ -15406,30 +15410,35 @@ ICCContactHelperObject.prototype = {
    * @param contactType   One of GECKO_CARDCONTACT_TYPE_*.
    * @param contact       The contact will be updated.
    * @param pin2          PIN2 is required for FDN.
    * @param onsuccess     Callback to be called when success.
    * @param onerror       Callback to be called when error.
    */
   updateICCContact: function(appType, contactType, contact, pin2, onsuccess, onerror) {
     let ICCRecordHelper = this.context.ICCRecordHelper;
+    let ICCUtilsHelper = this.context.ICCUtilsHelper;
 
     switch (contactType) {
       case GECKO_CARDCONTACT_TYPE_ADN:
         if (!this.hasDfPhoneBook(appType)) {
           ICCRecordHelper.updateADNLike(ICC_EF_ADN, contact, null, onsuccess, onerror);
         } else {
           this.updateUSimContact(contact, onsuccess, onerror);
         }
         break;
       case GECKO_CARDCONTACT_TYPE_FDN:
         if (!pin2) {
           onerror(GECKO_ERROR_SIM_PIN2);
           return;
         }
+        if (!ICCUtilsHelper.isICCServiceAvailable("FDN")) {
+          onerror(CONTACT_ERR_CONTACT_TYPE_NOT_SUPPORTED);
+          break;
+        }
         ICCRecordHelper.updateADNLike(ICC_EF_FDN, contact, pin2, onsuccess, onerror);
         break;
       default:
         if (DEBUG) {
           this.context.debug("Unsupported contactType :" + contactType);
         }
         onerror(CONTACT_ERR_CONTACT_TYPE_NOT_SUPPORTED);
         break;
--- a/dom/system/gonk/tests/test_ril_worker_icc_ICCContactHelper.js
+++ b/dom/system/gonk/tests/test_ril_worker_icc_ICCContactHelper.js
@@ -125,18 +125,22 @@ add_test(function test_read_icc_contacts
   let record = context.ICCRecordHelper;
   let contactHelper = context.ICCContactHelper;
   let ril = context.RIL;
 
   function do_test(aSimType, aContactType, aExpectedContact, aEnhancedPhoneBook) {
     ril.appType = aSimType;
     ril._isCdma = (aSimType === CARD_APPTYPE_RUIM);
     ril.iccInfoPrivate.cst = (aEnhancedPhoneBook) ?
-                                    [0x0, 0x0C, 0x0, 0x0, 0x0]:
-                                    [0x0, 0x00, 0x0, 0x0, 0x0];
+                                    [0x20, 0x0C, 0x0, 0x0, 0x0]:
+                                    [0x20, 0x00, 0x0, 0x0, 0x0];
+
+    ril.iccInfoPrivate.sst = (aSimType === CARD_APPTYPE_SIM)?
+                                    [0x20, 0x0, 0x0, 0x0, 0x0]:
+                                    [0x2, 0x0, 0x0, 0x0, 0x0];
 
     // Override some functions to test.
     contactHelper.getContactFieldRecordId = function(pbr, contact, field, onsuccess, onerror) {
       onsuccess(1);
     };
 
     record.readPBR = function readPBR(onsuccess, onerror) {
       onsuccess([{adn:{fileId: 0x6f3a}, email: {}, anr0: {}}]);
@@ -237,18 +241,21 @@ add_test(function test_update_icc_contac
   let context = worker.ContextPool._contexts[0];
   let recordHelper = context.ICCRecordHelper;
   let contactHelper = context.ICCContactHelper;
   let ril = context.RIL;
 
   function do_test(aSimType, aContactType, aContact, aPin2, aFileType, aHaveIapIndex, aEnhancedPhoneBook) {
     ril.appType = aSimType;
     ril._isCdma = (aSimType === CARD_APPTYPE_RUIM);
-    ril.iccInfoPrivate.cst = (aEnhancedPhoneBook) ? [0x0, 0x0C, 0x0, 0x0, 0x0]
-                                                  : [0x0, 0x00, 0x0, 0x0, 0x0];
+    ril.iccInfoPrivate.cst = (aEnhancedPhoneBook) ? [0x20, 0x0C, 0x0, 0x0, 0x0]
+                                                  : [0x20, 0x00, 0x0, 0x0, 0x0];
+    ril.iccInfoPrivate.sst = (aSimType === CARD_APPTYPE_SIM)?
+                                    [0x20, 0x0, 0x0, 0x0, 0x0]:
+                                    [0x2, 0x0, 0x0, 0x0, 0x0];
 
     recordHelper.readPBR = function(onsuccess, onerror) {
       if (aFileType === ICC_USIM_TYPE1_TAG) {
         onsuccess([{
           adn:   {fileId: ICC_EF_ADN},
           email: {fileId: EMAIL_FILE_ID,
                   fileType: ICC_USIM_TYPE1_TAG},
           anr0:  {fileId: ANR0_FILE_ID,