Bug 787967 - B2G RIL: report roaming if SPN is different from operator name. r=philikon

This commit is contained in:
Alexandre Lissy 2012-09-03 23:50:55 +02:00
parent d45605e24f
commit e0c4aaabb7
2 changed files with 65 additions and 0 deletions

View File

@ -527,6 +527,9 @@ RadioInterfaceLayer.prototype = {
}
}
this.checkRoamingBetweenOperators(voice);
this.checkRoamingBetweenOperators(data);
if (voiceMessage || operatorMessage) {
ppmm.broadcastAsyncMessage("RIL:VoiceInfoChanged", voice);
}
@ -539,6 +542,32 @@ RadioInterfaceLayer.prototype = {
}
},
/**
* Fix the roaming. RIL can report roaming in some case it is not
* really the case. See bug 787967
*
* @param registration The voiceMessage or dataMessage from which the
* roaming state will be changed (maybe, if needed).
*/
checkRoamingBetweenOperators: function checkRoamingBetweenOperators(registration) {
let icc = this.rilContext.icc;
if (!icc || !registration.connected) {
return;
}
let spn = icc.spn;
let operator = registration.network;
let longName = operator.longName;
let shortName = operator.shortName;
let equalsLongName = longName && (spn == longName);
let equalsShortName = shortName && (spn == shortName);
let equalsMcc = icc.mcc == operator.mcc;
registration.roaming = registration.roaming &&
!(equalsMcc && (equalsLongName || equalsShortName));
},
/**
* Sends the RIL:VoiceInfoChanged message when the voice
* connection's state has changed.

View File

@ -1063,6 +1063,7 @@ let RIL = {
this.getIMSI();
this.getMSISDN();
this.getAD();
this.getSPN();
this.getSST();
this.getMBDN();
},
@ -1194,6 +1195,39 @@ let RIL = {
});
},
/**
* Read the SPN (Service Provider Name) from the ICC.
*/
getSPN: function getSPN() {
function callback() {
let length = Buf.readUint32();
// Each octet is encoded into two chars.
// Minus 1 because first is used to store display condition
let len = (length / 2) - 1;
let spnDisplayCondition = GsmPDUHelper.readHexOctet();
this.iccInfo.spn = GsmPDUHelper.readAlphaIdentifier(len);
Buf.readStringDelimiter(length);
if (DEBUG) {
debug("SPN: spn=" + this.iccInfo.spn + ", spnDisplayCondition=" + spnDisplayCondition);
}
this._handleICCInfoChange();
}
this.iccIO({
command: ICC_COMMAND_GET_RESPONSE,
fileId: ICC_EF_SPN,
pathId: this._getPathIdForICCRecord(ICC_EF_SPN),
p1: 0, // For GET_RESPONSE, p1 = 0
p2: 0, // For GET_RESPONSE, p2 = 0
p3: GET_RESPONSE_EF_SIZE_BYTES,
data: null,
pin2: null,
type: EF_TYPE_TRANSPARENT,
callback: callback,
});
},
/**
* Get whether specificed (U)SIM service is available.
*
@ -2431,6 +2465,7 @@ let RIL = {
case ICC_EF_AD:
case ICC_EF_MBDN:
case ICC_EF_SPN:
case ICC_EF_SST:
return EF_PATH_MF_SIM + EF_PATH_DF_GSM;
}
@ -2441,6 +2476,7 @@ let RIL = {
case ICC_EF_MBDN:
case ICC_EF_UST:
case ICC_EF_MSISDN:
case ICC_EF_SPN:
return EF_PATH_MF_SIM + EF_PATH_ADF_USIM;
default: