Bug 782603 - Part 3: RIL implementation for exposing MCC/MNC codes. r=marshall_law

This commit is contained in:
Jose Antonio Olivera Ortega 2012-09-03 17:43:59 -04:00
parent 08d6f106c9
commit fd03e654fa
2 changed files with 48 additions and 4 deletions

View File

@ -29,6 +29,8 @@ const DEBUG = RIL.DEBUG_CONTENT_HELPER;
const RILCONTENTHELPER_CID =
Components.ID("{472816e1-1fd6-4405-996c-806f9ea68174}");
const MOBILEICCINFO_CID =
Components.ID("{8649c12f-f8f4-4664-bbdd-7d115c23e2a7}");
const MOBILECONNECTIONINFO_CID =
Components.ID("{a35cfd39-2d93-4489-ac7d-396475dacb27}");
const MOBILENETWORKINFO_CID =
@ -40,6 +42,7 @@ const VOICEMAILSTATUS_CID=
const RIL_IPC_MSG_NAMES = [
"RIL:CardStateChanged",
"RIL:IccInfoChanged",
"RIL:VoiceInfoChanged",
"RIL:DataInfoChanged",
"RIL:EnumerateCalls",
@ -64,6 +67,7 @@ const RIL_IPC_MSG_NAMES = [
const kVoiceChangedTopic = "mobile-connection-voice-changed";
const kDataChangedTopic = "mobile-connection-data-changed";
const kCardStateChangedTopic = "mobile-connection-cardstate-changed";
const kIccInfoChangedTopic = "mobile-connection-iccinfo-changed";
const kUssdReceivedTopic = "mobile-connection-ussd-received";
const kStkCommandTopic = "icc-manager-stk-command";
const kStkSessionEndTopic = "icc-manager-stk-session-end";
@ -76,6 +80,23 @@ XPCOMUtils.defineLazyServiceGetter(this, "gUUIDGenerator",
"@mozilla.org/uuid-generator;1",
"nsIUUIDGenerator");
function MobileICCInfo() {}
MobileICCInfo.prototype = {
QueryInterface: XPCOMUtils.generateQI([Ci.nsIDOMMozMobileICCInfo]),
classID: MOBILEICCINFO_CID,
classInfo: XPCOMUtils.generateCI({
classID: MOBILEICCINFO_CID,
classDescription: "MobileICCInfo",
flags: Ci.nsIClassInfo.DOM_OBJECT,
interfaces: [Ci.nsIDOMMozMobileICCInfo]
}),
// nsIDOMMozMobileICCInfo
mcc: 0,
mnc: 0
};
function MobileConnectionInfo() {}
MobileConnectionInfo.prototype = {
QueryInterface: XPCOMUtils.generateQI([Ci.nsIDOMMozMobileConnectionInfo]),
@ -157,6 +178,7 @@ VoicemailStatus.prototype = {
};
function RILContentHelper() {
this.iccInfo = new MobileICCInfo();
this.voiceConnectionInfo = new MobileConnectionInfo();
this.dataConnectionInfo = new MobileConnectionInfo();
@ -172,6 +194,7 @@ function RILContentHelper() {
return;
}
this.cardState = rilContext.cardState;
this.updateICCInfo(rilContext.icc, this.iccInfo);
this.updateConnectionInfo(rilContext.voice, this.voiceConnectionInfo);
this.updateConnectionInfo(rilContext.data, this.dataConnectionInfo);
}
@ -188,6 +211,11 @@ RILContentHelper.prototype = {
interfaces: [Ci.nsIMobileConnectionProvider,
Ci.nsIRILContentHelper]}),
updateICCInfo: function updateICCInfo(srcInfo, destInfo) {
destInfo.mcc = srcInfo.mcc;
destInfo.mnc = srcInfo.mnc;
},
updateConnectionInfo: function updateConnectionInfo(srcInfo, destInfo) {
for (let key in srcInfo) {
if ((key != "network") && (key != "cell")) {
@ -227,9 +255,10 @@ RILContentHelper.prototype = {
// nsIRILContentHelper
cardState: RIL.GECKO_CARDSTATE_UNAVAILABLE,
voiceConnectionInfo: null,
dataConnectionInfo: null,
cardState: RIL.GECKO_CARDSTATE_UNAVAILABLE,
iccInfo: null,
voiceConnectionInfo: null,
dataConnectionInfo: null,
networkSelectionMode: RIL.GECKO_NETWORK_SELECTION_UNKNOWN,
/**
@ -584,6 +613,10 @@ RILContentHelper.prototype = {
Services.obs.notifyObservers(null, kCardStateChangedTopic, null);
}
break;
case "RIL:IccInfoChanged":
this.updateICCInfo(msg.json, this.iccInfo);
Services.obs.notifyObservers(null, kIccInfoChangedTopic, null);
break;
case "RIL:VoiceInfoChanged":
this.updateConnectionInfo(msg.json, this.voiceConnectionInfo);
Services.obs.notifyObservers(null, kVoiceChangedTopic, null);

View File

@ -422,7 +422,7 @@ RadioInterfaceLayer.prototype = {
" timestamp=" + message.localTimeStampInMS);
break;
case "iccinfochange":
this.rilContext.icc = message;
this.handleICCInfoChange(message);
break;
case "iccGetCardLock":
case "iccSetCardLock":
@ -1017,6 +1017,17 @@ RadioInterfaceLayer.prototype = {
[message.datacalls, message.datacalls.length]);
},
handleICCInfoChange: function handleICCInfoChange(message) {
let oldIcc = this.rilContext.icc;
this.rilContext.icc = message;
if (oldIcc && (oldIcc.mcc == message.mcc || oldIcc.mnc == message.mnc)) {
return;
}
// RIL:IccInfoChanged corresponds to a DOM event that gets fired only
// when the MCC or MNC codes have changed.
ppmm.broadcastAsyncMessage("RIL:IccInfoChanged", message);
},
handleICCCardLockResult: function handleICCCardLockResult(message) {
this._sendRequestResults("RIL:CardLockResult", message);
},