Bug 825841 - B2G RIL: not sendSyncMessage(RIL:GetRilContext) in RILContentHelper's constructor. r=vicamo

This commit is contained in:
Hsin-Yi Tsai 2013-01-08 15:57:34 +08:00
parent 9444aa196b
commit fac47c13f0

View File

@ -316,26 +316,17 @@ CellBroadcastEtwsInfo.prototype = {
}; };
function RILContentHelper() { function RILContentHelper() {
this.iccInfo = new MobileICCInfo(); this.rilContext = {
this.voiceConnectionInfo = new MobileConnectionInfo(); cardState: RIL.GECKO_CARDSTATE_UNAVAILABLE,
this.dataConnectionInfo = new MobileConnectionInfo(); iccInfo: new MobileICCInfo(),
voiceConnectionInfo: new MobileConnectionInfo(),
dataConnectionInfo: new MobileConnectionInfo()
};
this.voicemailInfo = new VoicemailInfo(); this.voicemailInfo = new VoicemailInfo();
this.initRequests(); this.initRequests();
this.initMessageListener(RIL_IPC_MSG_NAMES); this.initMessageListener(RIL_IPC_MSG_NAMES);
Services.obs.addObserver(this, "xpcom-shutdown", false); Services.obs.addObserver(this, "xpcom-shutdown", false);
// Request initial context.
let rilContext = cpmm.sendSyncMessage("RIL:GetRilContext")[0];
if (!rilContext) {
debug("Received null rilContext from chrome process.");
return;
}
this.cardState = rilContext.cardState;
this.updateICCInfo(rilContext.icc, this.iccInfo);
this.updateConnectionInfo(rilContext.voice, this.voiceConnectionInfo);
this.updateConnectionInfo(rilContext.data, this.dataConnectionInfo);
} }
RILContentHelper.prototype = { RILContentHelper.prototype = {
@ -404,12 +395,47 @@ RILContentHelper.prototype = {
// nsIRILContentHelper // nsIRILContentHelper
cardState: RIL.GECKO_CARDSTATE_UNAVAILABLE,
iccInfo: null,
voiceConnectionInfo: null,
dataConnectionInfo: null,
networkSelectionMode: RIL.GECKO_NETWORK_SELECTION_UNKNOWN, networkSelectionMode: RIL.GECKO_NETWORK_SELECTION_UNKNOWN,
rilContext: null,
getRilContext: function getRilContext() {
// Update ril context by sending IPC message to chrome only when the first
// time we require it. The information will be updated by following info
// changed messages.
this.getRilContext = function getRilContext() {
return this.rilContext;
};
let rilContext = cpmm.sendSyncMessage("RIL:GetRilContext")[0];
if (!rilContext) {
debug("Received null rilContext from chrome process.");
return;
}
this.rilContext.cardState = rilContext.cardState;
this.updateICCInfo(rilContext.icc, this.rilContext.iccInfo);
this.updateConnectionInfo(rilContext.voice, this.rilContext.voiceConnectionInfo);
this.updateConnectionInfo(rilContext.data, this.rilContext.dataConnectionInfo);
return this.rilContext;
},
get iccInfo() {
return this.getRilContext().iccInfo;
},
get voiceConnectionInfo() {
return this.getRilContext().voiceConnectionInfo;
},
get dataConnectionInfo() {
return this.getRilContext().dataConnectionInfo;
},
get cardState() {
return this.getRilContext().cardState;
},
/** /**
* The network that is currently trying to be selected (or "automatic"). * The network that is currently trying to be selected (or "automatic").
* This helps ensure that only one network is selected at a time. * This helps ensure that only one network is selected at a time.
@ -457,7 +483,7 @@ RILContentHelper.prototype = {
let requestId = this.getRequestId(request); let requestId = this.getRequestId(request);
if (this.networkSelectionMode == RIL.GECKO_NETWORK_SELECTION_MANUAL if (this.networkSelectionMode == RIL.GECKO_NETWORK_SELECTION_MANUAL
&& this.voiceConnectionInfo.network === network) { && this.rilContext.voiceConnectionInfo.network === network) {
// Already manually selected this network, so schedule // Already manually selected this network, so schedule
// onsuccess to be fired on the next tick // onsuccess to be fired on the next tick
@ -876,26 +902,26 @@ RILContentHelper.prototype = {
debug("Received message '" + msg.name + "': " + JSON.stringify(msg.json)); debug("Received message '" + msg.name + "': " + JSON.stringify(msg.json));
switch (msg.name) { switch (msg.name) {
case "RIL:CardStateChanged": case "RIL:CardStateChanged":
if (this.cardState != msg.json.cardState) { if (this.rilContext.cardState != msg.json.cardState) {
this.cardState = msg.json.cardState; this.rilContext.cardState = msg.json.cardState;
Services.obs.notifyObservers(null, kCardStateChangedTopic, null); Services.obs.notifyObservers(null, kCardStateChangedTopic, null);
} }
break; break;
case "RIL:IccInfoChanged": case "RIL:IccInfoChanged":
this.updateICCInfo(msg.json, this.iccInfo); this.updateICCInfo(msg.json, this.rilContext.iccInfo);
if (this.iccInfo.mcc) { if (this.rilContext.iccInfo.mcc) {
try { try {
Services.prefs.setIntPref("ril.lastKnownMcc", this.iccInfo.mcc); Services.prefs.setIntPref("ril.lastKnownMcc", this.rilContext.iccInfo.mcc);
} catch (e) {} } catch (e) {}
} }
Services.obs.notifyObservers(null, kIccInfoChangedTopic, null); Services.obs.notifyObservers(null, kIccInfoChangedTopic, null);
break; break;
case "RIL:VoiceInfoChanged": case "RIL:VoiceInfoChanged":
this.updateConnectionInfo(msg.json, this.voiceConnectionInfo); this.updateConnectionInfo(msg.json, this.rilContext.voiceConnectionInfo);
Services.obs.notifyObservers(null, kVoiceChangedTopic, null); Services.obs.notifyObservers(null, kVoiceChangedTopic, null);
break; break;
case "RIL:DataInfoChanged": case "RIL:DataInfoChanged":
this.updateConnectionInfo(msg.json, this.dataConnectionInfo); this.updateConnectionInfo(msg.json, this.rilContext.dataConnectionInfo);
Services.obs.notifyObservers(null, kDataChangedTopic, null); Services.obs.notifyObservers(null, kDataChangedTopic, null);
break; break;
case "RIL:EnumerateCalls": case "RIL:EnumerateCalls":
@ -972,7 +998,7 @@ RILContentHelper.prototype = {
Services.obs.notifyObservers(null, kStkSessionEndTopic, null); Services.obs.notifyObservers(null, kStkSessionEndTopic, null);
break; break;
case "RIL:DataError": case "RIL:DataError":
this.updateConnectionInfo(msg.json, this.dataConnectionInfo); this.updateConnectionInfo(msg.json, this.rilContext.dataConnectionInfo);
Services.obs.notifyObservers(null, kDataErrorTopic, msg.json.error); Services.obs.notifyObservers(null, kDataErrorTopic, msg.json.error);
break; break;
case "RIL:GetCallForwardingOption": case "RIL:GetCallForwardingOption":