Bug 835729 - Part 2: Refactor updateNetworkName and _processOperator. r=allstars.chh

This commit is contained in:
Edgar Chen 2013-02-01 17:04:12 +08:00
parent 94a26edf37
commit 0571a292e8

View File

@ -1282,87 +1282,6 @@ let RIL = {
Buf.sendParcel();
},
/**
* Choose network names using EF_OPL and EF_PNN
* See 3GPP TS 31.102 sec. 4.2.58 and sec. 4.2.59 for USIM,
* 3GPP TS 51.011 sec. 10.3.41 and sec. 10.3.42 for SIM.
*/
updateNetworkName: function updateNetworkName() {
let iccInfoPriv = this.iccInfoPrivate;
let iccInfo = this.iccInfo;
// We won't update network name if voice registration isn't ready
// or PNN file haven't been retrieved.
if (!iccInfoPriv.PNN ||
!this.voiceRegistrationState.cell ||
this.voiceRegistrationState.cell.gsmLocationAreaCode == -1) {
return null;
}
let pnnEntry;
let lac = this.voiceRegistrationState.cell.gsmLocationAreaCode;
let mcc = this.operator.mcc;
let mnc = this.operator.mnc;
// 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.
if (iccInfoPriv.OPL) {
for (let i in iccInfoPriv.OPL) {
let opl = iccInfoPriv.OPL[i];
// Try to match the MCC/MNC.
if (mcc != opl.mcc || 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.
if ((opl.lacTacStart == 0x0 && opl.lacTacEnd == 0xFFFE) ||
(opl.lacTacStart <= lac && opl.lacTacEnd >= lac)) {
if (opl.pnnRecordId == 0) {
// See 3GPP TS 31.102 Sec. 4.2.59 and 3GPP TS 51.011 Sec. 10.3.42,
// A value of '00' indicates that the name is to be taken from other
// sources.
return null;
}
pnnEntry = iccInfoPriv.PNN[opl.pnnRecordId - 1]
break;
}
}
}
// According to 3GPP TS 31.102 Sec. 4.2.58 and 3GPP TS 51.011 Sec. 10.3.41,
// the first record in this EF is used for the default network name when
// registered to the HPLMN.
// If we haven't get pnnEntry assigned, we should try to assign default
// value to it.
if (!pnnEntry && mcc == iccInfo.mcc && mnc == iccInfo.mnc) {
pnnEntry = iccInfoPriv.PNN[0]
}
if (DEBUG) {
if (pnnEntry) {
debug("updateNetworkName: Network names will be overriden: longName = " +
pnnEntry.fullName + ", shortName = " + pnnEntry.shortName);
} else {
debug("updateNetworkName: Network names will not be overriden");
}
}
// Return a new object to avoid global variable, PNN, be modified by accident.
let ret = null;
if (pnnEntry) {
ret = {
fullName: pnnEntry.fullName || "",
shortName: pnnEntry.shortName || "",
};
}
return ret;
},
/**
* Get UICC Phonebook.
*
@ -3093,8 +3012,23 @@ let RIL = {
}
}
let networkName = this.updateNetworkName();
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) {
debug("Operator names will be overriden: " +
"longName = " + networkName.fullName + ", " +
"shortName = " + networkName.shortName);
}
this.operator.longName = networkName.fullName;
this.operator.shortName = networkName.shortName;
} else {
@ -9638,6 +9572,75 @@ let ICCRecordHelper = {
* Helper functions for ICC utilities.
*/
let ICCUtilsHelper = {
/**
* Get network names by using EF_OPL and EF_PNN
*
* @See 3GPP TS 31.102 sec. 4.2.58 and sec. 4.2.59 for USIM,
* 3GPP TS 51.011 sec. 10.3.41 and sec. 10.3.42 for SIM.
*
* @param mcc The mobile country code of the network.
* @param mnc The mobile network code of the network.
* @param lac The location area code of the network.
*/
getNetworkNameFromICC: function getNetworkNameFromICC(mcc, mnc, lac) {
let iccInfoPriv = RIL.iccInfoPrivate;
let iccInfo = RIL.iccInfo;
let pnnEntry;
if (!mcc || !mnc || !lac) {
return null;
}
// We won't get network name if there is no PNN file.
if (!iccInfoPriv.PNN) {
return null;
}
// 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 opl = iccInfoPriv.OPL[i];
// Try to match the MCC/MNC.
if (mcc != opl.mcc || 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.
if ((opl.lacTacStart == 0x0 && opl.lacTacEnd == 0xFFFE) ||
(opl.lacTacStart <= lac && opl.lacTacEnd >= lac)) {
if (opl.pnnRecordId == 0) {
// See 3GPP TS 31.102 Sec. 4.2.59 and 3GPP TS 51.011 Sec. 10.3.42,
// A value of '00' indicates that the name is to be taken from other
// sources.
return null;
}
pnnEntry = iccInfoPriv.PNN[opl.pnnRecordId - 1]
break;
}
}
// According to 3GPP TS 31.102 Sec. 4.2.58 and 3GPP TS 51.011 Sec. 10.3.41,
// the first record in this EF is used for the default network name when
// registered to the HPLMN.
// If we haven't get pnnEntry assigned, we should try to assign default
// value to it.
if (!pnnEntry && mcc == iccInfo.mcc && mnc == iccInfo.mnc) {
pnnEntry = iccInfoPriv.PNN[0]
}
if (!pnnEntry) {
return null;
}
// Return a new object to avoid global variable, PNN, be modified by accident.
return {fullName: pnnEntry.fullName || "",
shortName: pnnEntry.shortName || ""};
},
/**
* This will compute the spnDisplay field of the network.
* See TS 22.101 Annex A and TS 51.011 10.3.11 for details.