Bug 1024747 - Do QueryInterface before accessing iccInfo from nsIRilContext. r=vyang, a=1.4+

This commit is contained in:
Nivedita Sarkar 2014-06-17 11:56:42 +08:00
parent a68e97ba67
commit bf219eba73

View File

@ -328,15 +328,25 @@ MmsConnection.prototype = {
* @see nsIDOMMozCdmaIccInfo
*/
getPhoneNumber: function() {
let iccInfo = this.radioInterface.rilContext.iccInfo;
if (!iccInfo) {
let number;
// Get the proper IccInfo based on the current card type.
try {
let iccInfo = null;
let baseIccInfo = this.radioInterface.rilContext.iccInfo;
if (baseIccInfo.iccType === 'ruim' || baseIccInfo.iccType === 'csim') {
iccInfo = baseIccInfo.QueryInterface(Ci.nsIDOMMozCdmaIccInfo);
number = iccInfo.mdn;
} else {
iccInfo = baseIccInfo.QueryInterface(Ci.nsIDOMMozGsmIccInfo);
number = iccInfo.msisdn;
}
} catch (e) {
if (DEBUG) {
debug("Exception - QueryInterface failed on iccinfo for GSM/CDMA info");
}
return null;
}
let number = (iccInfo instanceof Ci.nsIDOMMozGsmIccInfo)
? iccInfo.msisdn : iccInfo.mdn;
// Workaround an xpconnect issue with undefined string objects.
// See bug 808220
if (number === undefined || number === "undefined") {
@ -1135,8 +1145,8 @@ function SendTransaction(mmsConnection, cancellableId, msg, requestDeliveryRepor
// Insert Phone number if available.
// Otherwise, Let MMS Proxy Relay insert from address automatically for us.
let phoneNumber = mmsConnection.getPhoneNumber();
msg.headers["from"] = (phoneNumber) ?
{ address: phoneNumber, type: "PLMN" } : null;
let from = (phoneNumber) ? { address: phoneNumber, type: "PLMN" } : null;
msg.headers["from"] = from;
msg.headers["date"] = new Date();
msg.headers["x-mms-message-class"] = "personal";
@ -1433,8 +1443,8 @@ function ReadRecTransaction(mmsConnection, messageID, toAddress) {
// Insert Phone number if available.
// Otherwise, Let MMS Proxy Relay insert from address automatically for us.
let phoneNumber = mmsConnection.getPhoneNumber();
headers["from"] = (phoneNumber) ?
{ address: phoneNumber, type: "PLMN" } : null;
let from = (phoneNumber) ? { address: phoneNumber, type: "PLMN" } : null;
headers["from"] = from;
headers["x-mms-read-status"] = MMS.MMS_PDU_READ_STATUS_READ;
this.istream = MMS.PduHelper.compose(null, {headers: headers});