From 71c472cf88b65c65a4a60ce8eaa5a8743dc795cc Mon Sep 17 00:00:00 2001 From: Edgar Chen Date: Fri, 7 Jun 2013 18:48:10 +0800 Subject: [PATCH] Bug 880369 - Part 1: Check mcc table if EFad dose not contain the length of mnc. r=allstars.chh --- dom/system/gonk/ril_consts.js | 37 +++++++++++++++++++++++++++++++++++ dom/system/gonk/ril_worker.js | 9 ++++++++- 2 files changed, 45 insertions(+), 1 deletion(-) diff --git a/dom/system/gonk/ril_consts.js b/dom/system/gonk/ril_consts.js index 54514db42070..bfe602a23f48 100644 --- a/dom/system/gonk/ril_consts.js +++ b/dom/system/gonk/ril_consts.js @@ -2554,5 +2554,42 @@ this.PDU_CDMA_MSG_CODING_IS_91_TYPE_SMS_FULL = 0x83; this.PDU_CDMA_MSG_CODING_IS_91_TYPE_CLI = 0x84; this.PDU_CDMA_MSG_CODING_IS_91_TYPE_SMS = 0x85; +/** + * The table for MCC which the length of MNC is 3 + * + * This table is built from below links. + * - http://www.itu.int/pub/T-SP-E.212B-2013 + * - http://en.wikipedia.org/wiki/Mobile_Network_Code + */ +this.MCC_TABLE_FOR_MNC_LENGTH_IS_3 = [ + "302", // Canada + "310", // United States of America + "311", // United States of America + "312", // United States of America + "313", // United States of America + "316", // United States of America + "330", // Puerto Rico + "334", // Mexico + "338", // Jamaica + "342", // Barbados + "344", // Antigua and Barbuda + "346", // Cayman Islands + "348", // British Virgin Islands + "350", // Bermuda + "352", // Grenada + "354", // Montserrat + "356", // Saint Kitts and Nevis + "358", // Saint Lucia + "360", // Saint Vincent and the Grenadines + "365", // Anguilla + "366", // Dominica + "376", // Turks and Caicos Islands + "405", // India + "708", // Honduras + "722", // Argentina + "732", // Colombia + "750" // Falkland Islands (Malvinas) +]; + // Allow this file to be imported via Components.utils.import(). this.EXPORTED_SYMBOLS = Object.keys(this); diff --git a/dom/system/gonk/ril_worker.js b/dom/system/gonk/ril_worker.js index c7b9170c71a5..887e5d58908f 100644 --- a/dom/system/gonk/ril_worker.js +++ b/dom/system/gonk/ril_worker.js @@ -10203,7 +10203,14 @@ let ICCRecordHelper = { // MCC is the first 3 digits of IMSI. RIL.iccInfo.mcc = imsi.substr(0,3); // The 4th byte of the response is the length of MNC. - RIL.iccInfo.mnc = imsi.substr(3, ad[3]); + let mncLength = ad && ad[3]; + if (!mncLength) { + // If response dose not contain the length of MNC, check the MCC table + // to decide the length of MNC. + let index = MCC_TABLE_FOR_MNC_LENGTH_IS_3.indexOf(RIL.iccInfo.mcc); + mncLength = (index !== -1) ? 3 : 2; + } + RIL.iccInfo.mnc = imsi.substr(3, mncLength); if (DEBUG) debug("MCC: " + RIL.iccInfo.mcc + " MNC: " + RIL.iccInfo.mnc); ICCUtilsHelper.handleICCInfoChange(); }