diff --git a/dom/system/gonk/ril_consts.js b/dom/system/gonk/ril_consts.js index df5740dfeae8..ad3677c5b085 100644 --- a/dom/system/gonk/ril_consts.js +++ b/dom/system/gonk/ril_consts.js @@ -667,13 +667,6 @@ this.USIM_TAG_NAME[ICC_USIM_EFUID_TAG] = "uid"; this.USIM_TAG_NAME[ICC_USIM_EFEMAIL_TAG] = "email"; this.USIM_TAG_NAME[ICC_USIM_EFCCP1_TAG] = "ccp1"; -// Error message for ICC contact. -this.CONTACT_ERR_REQUEST_NOT_SUPPORTED = GECKO_ERROR_REQUEST_NOT_SUPPORTED; -this.CONTACT_ERR_CONTACT_TYPE_NOT_SUPPORTED = "ContactTypeNotSupported"; -this.CONTACT_ERR_FIELD_NOT_SUPPORTED = "FieldNotSupported"; -this.CONTACT_ERR_NO_FREE_RECORD_FOUND = "NoFreeRecordFound"; -this.CONTACT_ERR_CANNOT_ACCESS_PHONEBOOK = "CannotAccessPhoneBook"; - // CDMA IMSI_M's byte const. // 3GPP2 C.S0065 Sec. 5.2.2 this.CSIM_IMSI_M_MIN2_BYTE = 1; diff --git a/dom/system/gonk/ril_worker.js b/dom/system/gonk/ril_worker.js index bb039a9e7b7d..b48364d95103 100644 --- a/dom/system/gonk/ril_worker.js +++ b/dom/system/gonk/ril_worker.js @@ -851,7 +851,7 @@ let RIL = { */ readICCContacts: function readICCContacts(options) { if (!this.appType) { - options.errorMsg = CONTACT_ERR_REQUEST_NOT_SUPPORTED; + options.errorMsg = GECKO_ERROR_REQUEST_NOT_SUPPORTED; this.sendChromeMessage(options); return; } @@ -899,7 +899,7 @@ let RIL = { }.bind(this); if (!this.appType || !options.contact) { - onerror(CONTACT_ERR_REQUEST_NOT_SUPPORTED ); + onerror(GECKO_ERROR_REQUEST_NOT_SUPPORTED); return; } @@ -11162,20 +11162,19 @@ let ICCIOHelper = { * Process ICC IO error. */ processICCIOError: function processICCIOError(options) { - let requestError = RIL_ERROR_TO_GECKO_ERROR[options.rilRequestError]; - if (DEBUG) { - // See GSM11.11, TS 51.011 clause 9.4, and ISO 7816-4 for the error - // description. - let errorMsg = "ICC I/O Error code " + requestError + - " EF id = " + options.fileId.toString(16) + - " command = " + options.command.toString(16); - if (options.sw1 && options.sw2) { - errorMsg += "(" + options.sw1.toString(16) + - "/" + options.sw2.toString(16) + ")"; - } - debug(errorMsg); + let error = options.onerror || debug; + + // See GSM11.11, TS 51.011 clause 9.4, and ISO 7816-4 for the error + // description. + let errorMsg = "ICC I/O Error code " + + RIL_ERROR_TO_GECKO_ERROR[options.rilRequestError] + + " EF id = " + options.fileId.toString(16) + + " command = " + options.command.toString(16); + if (options.sw1 && options.sw2) { + errorMsg += "(" + options.sw1.toString(16) + + "/" + options.sw2.toString(16) + ")"; } - onerror(requestError); + error(errorMsg); }, }; ICCIOHelper[ICC_COMMAND_SEEK] = null; @@ -12156,10 +12155,8 @@ let ICCRecordHelper = { ICCIOHelper.loadNextRecord(options); } else { // No free record found. - if (DEBUG) { - debug(CONTACT_ERR_NO_FREE_RECORD_FOUND); - } - onerror(CONTACT_ERR_NO_FREE_RECORD_FOUND); + let error = onerror || debug; + error("No free record found."); } } @@ -12660,10 +12657,8 @@ let ICCContactHelper = { ICCRecordHelper.readADNLike(ICC_EF_FDN, onsuccess, onerror); break; default: - if (DEBUG) { - debug("Unsupported contactType :" + contactType); - } - onerror(CONTACT_ERR_CONTACT_TYPE_NOT_SUPPORTED); + let error = onerror || debug; + error(GECKO_ERROR_REQUEST_NOT_SUPPORTED); break; } }, @@ -12693,10 +12688,8 @@ let ICCContactHelper = { ICCRecordHelper.findFreeRecordId(ICC_EF_FDN, onsuccess.bind(null, 0), onerror); break; default: - if (DEBUG) { - debug("Unsupported contactType :" + contactType); - } - onerror(CONTACT_ERR_CONTACT_TYPE_NOT_SUPPORTED); + let error = onerror || debug; + error(GECKO_ERROR_REQUEST_NOT_SUPPORTED); break; } }, @@ -12711,10 +12704,8 @@ let ICCContactHelper = { findUSimFreeADNRecordId: function findUSimFreeADNRecordId(pbrs, onsuccess, onerror) { (function findFreeRecordId(pbrIndex) { if (pbrIndex >= pbrs.length) { - if (DEBUG) { - debug(CONTACT_ERR_NO_FREE_RECORD_FOUND); - } - onerror(CONTACT_ERR_NO_FREE_RECORD_FOUND); + let error = onerror || debug; + error("No free record found."); return; } @@ -12758,6 +12749,7 @@ let ICCContactHelper = { * @param onerror Callback to be called when error. */ updateICCContact: function updateICCContact(appType, contactType, contact, pin2, onsuccess, onerror) { + let error = onerror || debug; switch (contactType) { case "adn": if (!this.hasDfPhoneBook(appType)) { @@ -12768,16 +12760,13 @@ let ICCContactHelper = { break; case "fdn": if (!pin2) { - onerror(GECKO_ERROR_SIM_PIN2); + error("pin2 is empty"); return; } ICCRecordHelper.updateADNLike(ICC_EF_FDN, contact, pin2, onsuccess, onerror); break; default: - if (DEBUG) { - debug("Unsupported contactType :" + contactType); - } - onerror(CONTACT_ERR_CONTACT_TYPE_NOT_SUPPORTED); + error(GECKO_ERROR_REQUEST_NOT_SUPPORTED); break; } }, @@ -12948,10 +12937,8 @@ let ICCContactHelper = { ICCRecordHelper.readANR(fileId, fileType, recordId, gotFieldCb, onerror); break; default: - if (DEBUG) { - debug("Unsupported field :" + field); - } - onerror(CONTACT_ERR_FIELD_NOT_SUPPORTED); + let error = onerror || debug; + error("Unknown field " + field); break; } }.bind(this); @@ -12991,10 +12978,8 @@ let ICCContactHelper = { ICCRecordHelper.readIAP(pbr.iap.fileId, contact.recordId, gotIapCb, onerror); } else { - if (DEBUG) { - debug("USIM PBR files in Type 3 format are not supported."); - } - onerror(CONTACT_ERR_REQUEST_NOT_SUPPORTED); + let error = onerror | debug; + error("USIM PBR files in Type 3 format are not supported."); } }, @@ -13009,10 +12994,8 @@ let ICCContactHelper = { let gotPbrCb = function gotPbrCb(pbrs) { let pbr = pbrs[contact.pbrIndex]; if (!pbr) { - if (DEBUG) { - debug(CONTACT_ERR_CANNOT_ACCESS_PHONEBOOK); - } - onerror(CONTACT_ERR_CANNOT_ACCESS_PHONEBOOK); + let error = onerror || debug; + error("Cannot access Phonebook."); return; } this.updatePhonebookSet(pbr, contact, onsuccess, onerror); @@ -13089,11 +13072,6 @@ let ICCContactHelper = { this.updateContactFieldType1(pbr, contact, field, onsuccess, onerror); } else if (pbr[field].fileType === ICC_USIM_TYPE2_TAG) { this.updateContactFieldType2(pbr, contact, field, onsuccess, onerror); - } else { - if (DEBUG) { - debug("USIM PBR files in Type 3 format are not supported."); - } - onerror(CONTACT_ERR_REQUEST_NOT_SUPPORTED); } }, @@ -13111,11 +13089,6 @@ let ICCContactHelper = { ICCRecordHelper.updateEmail(pbr, contact.recordId, contact.email, null, onsuccess, onerror); } else if (field === USIM_PBR_ANR0) { ICCRecordHelper.updateANR(pbr, contact.recordId, contact.anr[0], null, onsuccess, onerror); - } else { - if (DEBUG) { - debug("Unsupported field :" + field); - } - onerror(CONTACT_ERR_FIELD_NOT_SUPPORTED); } }, @@ -13150,13 +13123,7 @@ let ICCContactHelper = { ICCRecordHelper.updateEmail(pbr, recordId, contact.email, contact.recordId, onsuccess, onerror); } else if (field === USIM_PBR_ANR0) { ICCRecordHelper.updateANR(pbr, recordId, contact.anr[0], contact.recordId, onsuccess, onerror); - } else { - if (DEBUG) { - debug("Unsupported field :" + field); - } - onerror(CONTACT_ERR_FIELD_NOT_SUPPORTED); } - }.bind(this); ICCRecordHelper.readIAP(pbr.iap.fileId, contact.recordId, gotIapCb, onerror); @@ -13185,10 +13152,8 @@ let ICCContactHelper = { }.bind(this); let errorCb = function errorCb(errorMsg) { - if (DEBUG) { - debug(errorMsg + " USIM field " + field); - } - onerror(errorMsg); + let error = onerror || debug; + error(errorMsg + " USIM field " + field); }.bind(this); ICCRecordHelper.findFreeRecordId(pbr[field].fileId, successCb, errorCb);