Bug 820762 - 0002.Access voicmail info with correct permission. r=hsinyi

This commit is contained in:
Chuck Lee 2012-12-26 18:49:08 +08:00
parent 96d35552ca
commit e1bf5df130
2 changed files with 33 additions and 13 deletions

View File

@ -136,8 +136,8 @@ MobileICCInfo.prototype = {
msisdn: null msisdn: null
}; };
function MobileVoicemailInfo() {} function VoicemailInfo() {}
MobileVoicemailInfo.prototype = { VoicemailInfo.prototype = {
number: null, number: null,
displayName: null displayName: null
}; };
@ -319,7 +319,7 @@ function RILContentHelper() {
this.iccInfo = new MobileICCInfo(); this.iccInfo = new MobileICCInfo();
this.voiceConnectionInfo = new MobileConnectionInfo(); this.voiceConnectionInfo = new MobileConnectionInfo();
this.dataConnectionInfo = new MobileConnectionInfo(); this.dataConnectionInfo = new MobileConnectionInfo();
this.voicemailInfo = new MobileVoicemailInfo(); this.voicemailInfo = new VoicemailInfo();
this.initRequests(); this.initRequests();
this.initMessageListener(RIL_IPC_MSG_NAMES); this.initMessageListener(RIL_IPC_MSG_NAMES);
@ -336,7 +336,6 @@ function RILContentHelper() {
this.updateICCInfo(rilContext.icc, this.iccInfo); this.updateICCInfo(rilContext.icc, this.iccInfo);
this.updateConnectionInfo(rilContext.voice, this.voiceConnectionInfo); this.updateConnectionInfo(rilContext.voice, this.voiceConnectionInfo);
this.updateConnectionInfo(rilContext.data, this.dataConnectionInfo); this.updateConnectionInfo(rilContext.data, this.dataConnectionInfo);
this.updateVoicemailInfo(rilContext.voicemail, this.voicemailInfo);
} }
RILContentHelper.prototype = { RILContentHelper.prototype = {
@ -651,11 +650,25 @@ RILContentHelper.prototype = {
_enumerateTelephonyCallbacks: null, _enumerateTelephonyCallbacks: null,
voicemailStatus: null, voicemailStatus: null,
getVoicemailInfo: function getVoicemailInfo() {
// Get voicemail infomation by IPC only on first time.
this.getVoicemailInfo = function getVoicemailInfo() {
return this.voicemailInfo;
};
let voicemailInfo = cpmm.sendSyncMessage("RIL:GetVoicemailInfo")[0];
if (voicemailInfo) {
this.updateVoicemailInfo(voicemailInfo, this.voicemailInfo);
}
return this.voicemailInfo;
},
get voicemailNumber() { get voicemailNumber() {
return this.voicemailInfo.number; return this.getVoicemailInfo().number;
}, },
get voicemailDisplayName() { get voicemailDisplayName() {
return this.voicemailInfo.displayName; return this.getVoicemailInfo().displayName;
}, },
registerCallback: function registerCallback(callbackType, callback) { registerCallback: function registerCallback(callbackType, callback) {

View File

@ -99,7 +99,8 @@ const RIL_IPC_MOBILECONNECTION_MSG_NAMES = [
]; ];
const RIL_IPC_VOICEMAIL_MSG_NAMES = [ const RIL_IPC_VOICEMAIL_MSG_NAMES = [
"RIL:RegisterVoicemailMsg" "RIL:RegisterVoicemailMsg",
"RIL:GetVoicemailInfo"
]; ];
const RIL_IPC_CELLBROADCAST_MSG_NAMES = [ const RIL_IPC_CELLBROADCAST_MSG_NAMES = [
@ -204,8 +205,6 @@ function RadioInterfaceLayer() {
radioState: RIL.GECKO_RADIOSTATE_UNAVAILABLE, radioState: RIL.GECKO_RADIOSTATE_UNAVAILABLE,
cardState: RIL.GECKO_CARDSTATE_UNAVAILABLE, cardState: RIL.GECKO_CARDSTATE_UNAVAILABLE,
icc: null, icc: null,
voicemail: {number: null,
displayName: null},
// These objects implement the nsIDOMMozMobileConnectionInfo interface, // These objects implement the nsIDOMMozMobileConnectionInfo interface,
// although the actual implementation lives in the content process. So are // although the actual implementation lives in the content process. So are
@ -229,6 +228,11 @@ function RadioInterfaceLayer() {
relSignalStrength: null}, relSignalStrength: null},
}; };
this.voicemailInfo = {
number: null,
displayName: null
};
this.callWaitingStatus = null; this.callWaitingStatus = null;
// Read the 'ril.radio.disabled' setting in order to start with a known // Read the 'ril.radio.disabled' setting in order to start with a known
@ -479,6 +483,9 @@ RadioInterfaceLayer.prototype = {
case "RIL:RegisterCellBroadcastMsg": case "RIL:RegisterCellBroadcastMsg":
this.registerMessageTarget("cellbroadcast", msg.target); this.registerMessageTarget("cellbroadcast", msg.target);
break; break;
case "RIL:GetVoicemailInfo":
// This message is sync.
return this.voicemailInfo;
} }
}, },
@ -1576,12 +1583,12 @@ RadioInterfaceLayer.prototype = {
}, },
handleICCMbdn: function handleICCMbdn(message) { handleICCMbdn: function handleICCMbdn(message) {
let voicemail = this.rilContext.voicemail; let voicemailInfo = this.voicemailInfo;
voicemail.number = message.number; voicemailInfo.number = message.number;
voicemail.displayName = message.alphaId; voicemailInfo.displayName = message.alphaId;
this._sendTargetMessage("voicemail", "RIL:VoicemailInfoChanged", voicemail); this._sendTargetMessage("voicemail", "RIL:VoicemailInfoChanged", voicemailInfo);
}, },
handleICCInfoChange: function handleICCInfoChange(message) { handleICCInfoChange: function handleICCInfoChange(message) {