diff --git a/dom/system/gonk/ril_worker.js b/dom/system/gonk/ril_worker.js index efeb53fc0941..604207f61f1b 100644 --- a/dom/system/gonk/ril_worker.js +++ b/dom/system/gonk/ril_worker.js @@ -9149,6 +9149,82 @@ let ICCRecordHelper = { onerror: onerror}); }, + /** + * Read ICC EF_IAP. (Index Administration Phonebook) + * + * @see TS 131.102, clause 4.4.2.2 + * + * @param fileId EF id of the IAP. + * @param recordNumber The number of the record shall be loaded. + * @param onsuccess Callback to be called when success. + * @param onerror Callback to be called when error. + */ + readIAP: function readIAP(fileId, recordNumber, onsuccess, onerror) { + function callback(options) { + let strLen = Buf.readUint32(); + let octetLen = strLen / 2; + + let iap = GsmPDUHelper.readHexOctetArray(octetLen); + Buf.readStringDelimiter(strLen); + + if (onsuccess) { + onsuccess(iap); + } + } + + ICCIOHelper.loadLinearFixedEF({fileId: fileId, + recordNumber: recordNumber, + callback: callback.bind(this), + onerror: onerror}); + }, + + /** + * Read USIM Phonebook EF_EMAIL. + * + * @see TS 131.102, clause 4.4.2.13 + * + * @param fileId EF id of the EMAIL. + * @param fileType The type of the EMAIL, one of the ICC_USIM_TYPE* constants. + * @param recordNumber The number of the record shall be loaded. + * @param onsuccess Callback to be called when success. + * @param onerror Callback to be called when error. + */ + readEmail: function readEmail(fileId, fileType, recordNumber, onsuccess, onerror) { + function callback(optoins) { + let strLen = Buf.readUint32(); + let octetLen = strLen / 2; + let email = null; + + // Read contact's email + // + // | Byte | Description | Length | M/O + // | 1 ~ X | E-mail Address | X | M + // | X+1 | ADN file SFI | 1 | C + // | X+2 | ADN file Record Identifier | 1 | C + // Note: The fields marked as C above are mandatort if the file + // is not type 1 (as specified in EF_PBR) + if (fileType == ICC_USIM_TYPE1_TAG) { + email = GsmPDUHelper.read8BitUnpackedToString(octetLen); + } else { + email = GsmPDUHelper.read8BitUnpackedToString(octetLen - 2); + + // Consumes the remaining buffer + Buf.seekIncoming(2 * PDU_HEX_OCTET_SIZE); // For ADN SFI and Record Identifier + } + + Buf.readStringDelimiter(strLen); + + if (onsuccess) { + onsuccess(email); + } + } + + ICCIOHelper.loadLinearFixedEF({fileId: fileId, + recordNumber: recordNumber, + callback: callback.bind(this), + onerror: onerror}); + }, + /** * Read the PLMNsel (Public Land Mobile Network) from the ICC. *