From 7f3843e4bdbaea6b382c051ec85bb64c5f262203 Mon Sep 17 00:00:00 2001 From: Shawn Ku Date: Wed, 13 Aug 2014 17:00:52 +0800 Subject: [PATCH] Bug 1046649 - Part 1: RIL patch - B2G RIL: Need to handle wild char for EF_OPL. v3. r=Edgar --- dom/system/gonk/ril_worker.js | 129 ++++++++++++++++++++++++++-------- 1 file changed, 100 insertions(+), 29 deletions(-) diff --git a/dom/system/gonk/ril_worker.js b/dom/system/gonk/ril_worker.js index 1a94ebde4b3..5a65f61e31e 100644 --- a/dom/system/gonk/ril_worker.js +++ b/dom/system/gonk/ril_worker.js @@ -1116,6 +1116,48 @@ RilObject.prototype = { } }, + /** + * Check if operator name needs to be overriden by current voiceRegistrationState + * , EFOPL and EFPNN. See 3GPP TS 31.102 clause 4.2.58 EFPNN and 4.2.59 EFOPL + * for detail. + * + * @return true if operator name is overridden, false otherwise. + */ + overrideICCNetworkName: function() { + if (!this.operator) { + return false; + } + + // We won't get network name using PNN and OPL if voice registration isn't + // ready. + if (!this.voiceRegistrationState.cell || + this.voiceRegistrationState.cell.gsmLocationAreaCode == -1) { + return false; + } + + let ICCUtilsHelper = this.context.ICCUtilsHelper; + let networkName = ICCUtilsHelper.getNetworkNameFromICC( + this.operator.mcc, + this.operator.mnc, + this.voiceRegistrationState.cell.gsmLocationAreaCode); + + if (!networkName) { + return false; + } + + if (DEBUG) { + this.context.debug("Operator names will be overriden: " + + "longName = " + networkName.fullName + ", " + + "shortName = " + networkName.shortName); + } + + this.operator.longName = networkName.fullName; + this.operator.shortName = networkName.shortName; + + this._sendNetworkInfoMessage(NETWORK_INFO_OPERATOR, this.operator); + return true; + }, + /** * Request the phone's radio to be enabled or disabled. * @@ -3903,35 +3945,20 @@ RilObject.prototype = { } } + this.operator.longName = longName; + this.operator.shortName = shortName; + let ICCUtilsHelper = this.context.ICCUtilsHelper; - let networkName; - // We won't get network name using PNN and OPL if voice registration isn't ready - if (this.voiceRegistrationState.cell && - this.voiceRegistrationState.cell.gsmLocationAreaCode != -1) { - networkName = ICCUtilsHelper.getNetworkNameFromICC( - this.operator.mcc, - this.operator.mnc, - this.voiceRegistrationState.cell.gsmLocationAreaCode); - } - - if (networkName) { - if (DEBUG) { - this.context.debug("Operator names will be overriden: " + - "longName = " + networkName.fullName + ", " + - "shortName = " + networkName.shortName); - } - - this.operator.longName = networkName.fullName; - this.operator.shortName = networkName.shortName; - } else { - this.operator.longName = longName; - this.operator.shortName = shortName; - } - if (ICCUtilsHelper.updateDisplayCondition()) { ICCUtilsHelper.handleICCInfoChange(); } - this._sendNetworkInfoMessage(NETWORK_INFO_OPERATOR, this.operator); + + // NETWORK_INFO_OPERATOR message will be sent out by overrideICCNetworkName + // itself if operator name is overridden after checking, or we have to + // do it by ourself. + if (!this.overrideICCNetworkName()) { + this._sendNetworkInfoMessage(NETWORK_INFO_OPERATOR, this.operator); + } } }, @@ -13695,11 +13722,14 @@ SimRecordHelperObject.prototype = { } Buf.readStringDelimiter(strLen); + let RIL = this.context.RIL; if (options.p1 < options.totalRecords) { ICCIOHelper.loadNextRecord(options); } else { - this.context.RIL.iccInfoPrivate.OPL = opl; + RIL.iccInfoPrivate.OPL = opl; } + + RIL.overrideICCNetworkName(); } ICCIOHelper.loadLinearFixedEF({fileId: ICC_EF_OPL, @@ -13757,6 +13787,7 @@ SimRecordHelperObject.prototype = { pnn.push(pnnElement); } + let RIL = this.context.RIL; // Will ignore remaining records when got the contents of a record are all 0xff. if (pnnElement && options.p1 < options.totalRecords) { ICCIOHelper.loadNextRecord(options); @@ -13766,8 +13797,10 @@ SimRecordHelperObject.prototype = { this.context.debug("PNN: [" + i + "]: " + JSON.stringify(pnn[i])); } } - this.context.RIL.iccInfoPrivate.PNN = pnn; + RIL.iccInfoPrivate.PNN = pnn; } + + RIL.overrideICCNetworkName(); } let pnn = []; @@ -14204,17 +14237,55 @@ ICCUtilsHelperObject.prototype = { pnnEntry = iccInfoPriv.PNN[0]; } } else { + let GsmPDUHelper = this.context.GsmPDUHelper; + let wildChar = GsmPDUHelper.bcdChars.charAt(0x0d); // According to 3GPP TS 31.102 Sec. 4.2.59 and 3GPP TS 51.011 Sec. 10.3.42, // the ME shall use this EF_OPL in association with the EF_PNN in place // of any network name stored within the ME's internal list and any network // name received when registered to the PLMN. let length = iccInfoPriv.OPL ? iccInfoPriv.OPL.length : 0; for (let i = 0; i < length; i++) { + let unmatch = false; let opl = iccInfoPriv.OPL[i]; - // Try to match the MCC/MNC. - if (mcc != opl.mcc || mnc != opl.mnc) { + // Try to match the MCC/MNC. Besides, A BCD value of 'D' in any of the + // MCC and/or MNC digits shall be used to indicate a "wild" value for + // that corresponding MCC/MNC digit. + if (opl.mcc.indexOf(wildChar) !== -1) { + for (let j = 0; j < opl.mcc.length; j++) { + if (opl.mcc[j] !== wildChar && opl.mcc[j] !== mcc[j]) { + unmatch = true; + break; + } + } + if (unmatch) { + continue; + } + } else { + if (mcc !== opl.mcc) { + continue; + } + } + + if (mnc.length !== opl.mnc.length) { continue; } + + if (opl.mnc.indexOf(wildChar) !== -1) { + for (let j = 0; j < opl.mnc.length; j++) { + if (opl.mnc[j] !== wildChar && opl.mnc[j] !== mnc[j]) { + unmatch = true; + break; + } + } + if (unmatch) { + continue; + } + } else { + if (mnc !== opl.mnc) { + continue; + } + } + // Try to match the location area code. If current local area code is // covered by lac range that specified in the OPL entry, use the PNN // that specified in the OPL entry.