Bug 830164 - Part 3: update read IMSI. r=vicamo

This commit is contained in:
Yoshi Huang 2013-01-11 10:20:12 +01:00
parent aefabc4809
commit ccdb765e1e
2 changed files with 20 additions and 8 deletions

View File

@ -216,6 +216,7 @@ function RadioInterfaceLayer() {
radioState: RIL.GECKO_RADIOSTATE_UNAVAILABLE,
cardState: RIL.GECKO_CARDSTATE_UNKNOWN,
iccInfo: null,
imsi: null,
// These objects implement the nsIDOMMozMobileConnectionInfo interface,
// although the actual implementation lives in the content process. So are
@ -607,6 +608,9 @@ RadioInterfaceLayer.prototype = {
case "iccinfochange":
this.handleICCInfoChange(message);
break;
case "iccimsi":
this.rilContext.imsi = message.imsi;
break;
case "iccGetCardLock":
case "iccSetCardLock":
case "iccUnlockCardLock":

View File

@ -793,7 +793,7 @@ let RIL = {
this.iccInfoPrivate = {};
/**
* ICC information, such as MSISDN, IMSI, ...etc.
* ICC information, such as MSISDN, MCC, MNC, SPN...etc.
*/
this.iccInfo = {};
@ -4355,7 +4355,14 @@ RIL[REQUEST_GET_IMSI] = function REQUEST_GET_IMSI(length, options) {
return;
}
this.iccInfo.imsi = Buf.readString();
this.iccInfoPrivate.imsi = Buf.readString();
if (DEBUG) {
debug("IMSI: " + this.iccInfoPrivate.imsi);
}
options.rilMessageType = "iccimsi";
options.imsi = this.iccInfoPrivate.imsi;
this.sendDOMMessage(options);
};
RIL[REQUEST_HANGUP] = function REQUEST_HANGUP(length, options) {
if (options.rilRequestError) {
@ -8851,22 +8858,23 @@ let ICCRecordHelper = {
let length = Buf.readUint32();
// Each octet is encoded into two chars.
let len = length / 2;
RIL.iccInfo.ad = GsmPDUHelper.readHexOctetArray(len);
let ad = GsmPDUHelper.readHexOctetArray(len);
Buf.readStringDelimiter(length);
if (DEBUG) {
let str = "";
for (let i = 0; i < RIL.iccInfo.ad.length; i++) {
str += RIL.iccInfo.ad[i] + ", ";
for (let i = 0; i < ad.length; i++) {
str += ad[i] + ", ";
}
debug("AD: " + str);
}
if (RIL.iccInfo.imsi) {
let imsi = RIL.iccInfoPrivate.imsi;
if (imsi) {
// MCC is the first 3 digits of IMSI.
RIL.iccInfo.mcc = parseInt(RIL.iccInfo.imsi.substr(0,3));
RIL.iccInfo.mcc = parseInt(imsi.substr(0,3));
// The 4th byte of the response is the length of MNC.
RIL.iccInfo.mnc = parseInt(RIL.iccInfo.imsi.substr(3, RIL.iccInfo.ad[3]));
RIL.iccInfo.mnc = parseInt(imsi.substr(3, ad[3]));
if (DEBUG) debug("MCC: " + RIL.iccInfo.mcc + " MNC: " + RIL.iccInfo.mnc);
ICCUtilsHelper.handleICCInfoChange();
}