зеркало из https://github.com/mozilla/gecko-dev.git
Bug 912902 - MMS/SMS: retrieve GSM MSISDN / CDMA MDN correctly. r=gene
This commit is contained in:
Родитель
476fa360db
Коммит
e21eba7b94
|
@ -42,7 +42,7 @@ interface nsIRilMobileMessageDatabaseService : nsIMobileMessageDatabaseService
|
|||
* - |delivery| DOMString: the delivery state of received message
|
||||
* - |deliveryStatus| DOMString Array: the delivery status of received message
|
||||
* - |receivers| DOMString Array: the phone numbers of receivers
|
||||
* - |msisdn| DOMString: [optional] my own phone number.
|
||||
* - |phoneNumber| DOMString: [optional] my own phone number.
|
||||
* - |transactionId| DOMString: the transaction ID from MMS PDU header.
|
||||
*
|
||||
* Note: |deliveryStatus| should only contain single string to specify
|
||||
|
|
|
@ -1232,9 +1232,24 @@ MmsService.prototype = {
|
|||
return config >= CONFIG_SEND_REPORT_DEFAULT_YES;
|
||||
},
|
||||
|
||||
getMsisdn: function getMsisdn() {
|
||||
/**
|
||||
* Get phone number from iccInfo.
|
||||
*
|
||||
* If the icc card is gsm card, the phone number is in msisdn.
|
||||
* @see nsIDOMMozGsmIccInfo
|
||||
*
|
||||
* Otherwise, the phone number is in mdn.
|
||||
* @see nsIDOMMozCdmaIccInfo
|
||||
*/
|
||||
getPhoneNumber: function getPhoneNumber() {
|
||||
let iccInfo = gRadioInterface.rilContext.iccInfo;
|
||||
let number = iccInfo ? iccInfo.msisdn : null;
|
||||
|
||||
if (!iccInfo) {
|
||||
return null;
|
||||
}
|
||||
|
||||
let number = (iccInfo instanceof Ci.nsIDOMMozGsmIccInfo)
|
||||
? iccInfo.msisdn : iccInfo.mdn;
|
||||
|
||||
// Workaround an xpconnect issue with undefined string objects.
|
||||
// See bug 808220
|
||||
|
@ -1285,7 +1300,7 @@ MmsService.prototype = {
|
|||
intermediate.sender = "anonymous";
|
||||
}
|
||||
intermediate.receivers = [];
|
||||
intermediate.msisdn = this.getMsisdn();
|
||||
intermediate.phoneNumber = this.getPhoneNumber();
|
||||
return intermediate;
|
||||
},
|
||||
|
||||
|
@ -1771,7 +1786,7 @@ MmsService.prototype = {
|
|||
aMessage["type"] = "mms";
|
||||
aMessage["timestamp"] = Date.now();
|
||||
aMessage["receivers"] = receivers;
|
||||
aMessage["sender"] = this.getMsisdn();
|
||||
aMessage["sender"] = this.getPhoneNumber();
|
||||
try {
|
||||
aMessage["deliveryStatusRequested"] =
|
||||
Services.prefs.getBoolPref("dom.mms.requestStatusReport");
|
||||
|
|
|
@ -1373,8 +1373,8 @@ MobileMessageDatabaseService.prototype = {
|
|||
if (receivers.length >= 2) {
|
||||
let isSuccess = false;
|
||||
let slicedReceivers = receivers.slice();
|
||||
if (aMessage.msisdn) {
|
||||
let found = slicedReceivers.indexOf(aMessage.msisdn);
|
||||
if (aMessage.phoneNumber) {
|
||||
let found = slicedReceivers.indexOf(aMessage.phoneNumber);
|
||||
if (found !== -1) {
|
||||
isSuccess = true;
|
||||
slicedReceivers.splice(found, 1);
|
||||
|
@ -1382,9 +1382,10 @@ MobileMessageDatabaseService.prototype = {
|
|||
}
|
||||
|
||||
if (!isSuccess) {
|
||||
// For some SIMs we cannot retrieve the vaild MSISDN (i.e. the user's
|
||||
// own phone number), so we cannot correcly exclude the user's own
|
||||
// number from the receivers, thus wrongly building the thread index.
|
||||
// For some SIMs we cannot retrieve the vaild MSISDN or MDN (i.e. the
|
||||
// user's own phone number), so we cannot correcly exclude the user's
|
||||
// own number from the receivers, thus wrongly building the thread
|
||||
// index.
|
||||
if (DEBUG) debug("Error! Cannot strip out user's own phone number!");
|
||||
}
|
||||
|
||||
|
|
|
@ -47,6 +47,10 @@ const RADIOINTERFACE_CID =
|
|||
Components.ID("{6a7c91f0-a2b3-4193-8562-8969296c0b54}");
|
||||
const RILNETWORKINTERFACE_CID =
|
||||
Components.ID("{3bdd52a9-3965-4130-b569-0ac5afed045e}");
|
||||
const GSMICCINFO_CID =
|
||||
Components.ID("{d90c4261-a99d-47bc-8b05-b057bb7e8f8a}");
|
||||
const CDMAICCINFO_CID =
|
||||
Components.ID("{39ba3c08-aacc-46d0-8c04-9b619c387061}");
|
||||
|
||||
const kNetworkInterfaceStateChangedTopic = "network-interface-state-changed";
|
||||
const kSmsReceivedObserverTopic = "sms-received";
|
||||
|
@ -463,6 +467,52 @@ XPCOMUtils.defineLazyGetter(this, "gMessageManager", function () {
|
|||
};
|
||||
});
|
||||
|
||||
function IccInfo() {}
|
||||
IccInfo.prototype = {
|
||||
iccType: null,
|
||||
iccid: null,
|
||||
mcc: null,
|
||||
mnc: null,
|
||||
spn: null,
|
||||
isDisplayNetworkNameRequired: null,
|
||||
isDisplaySpnRequired: null
|
||||
};
|
||||
|
||||
function GsmIccInfo() {}
|
||||
GsmIccInfo.prototype = {
|
||||
__proto__: IccInfo.prototype,
|
||||
QueryInterface: XPCOMUtils.generateQI([Ci.nsIDOMMozGsmIccInfo]),
|
||||
classID: GSMICCINFO_CID,
|
||||
classInfo: XPCOMUtils.generateCI({
|
||||
classID: GSMICCINFO_CID,
|
||||
classDescription: "MozGsmIccInfo",
|
||||
flags: Ci.nsIClassInfo.DOM_OBJECT,
|
||||
interfaces: [Ci.nsIDOMMozGsmIccInfo]
|
||||
}),
|
||||
|
||||
// nsIDOMMozGsmIccInfo
|
||||
|
||||
msisdn: null
|
||||
};
|
||||
|
||||
function CdmaIccInfo() {}
|
||||
CdmaIccInfo.prototype = {
|
||||
__proto__: IccInfo.prototype,
|
||||
QueryInterface: XPCOMUtils.generateQI([Ci.nsIDOMMozCdmaIccInfo]),
|
||||
classID: CDMAICCINFO_CID,
|
||||
classInfo: XPCOMUtils.generateCI({
|
||||
classID: CDMAICCINFO_CID,
|
||||
classDescription: "MozCdmaIccInfo",
|
||||
flags: Ci.nsIClassInfo.DOM_OBJECT,
|
||||
interfaces: [Ci.nsIDOMMozCdmaIccInfo]
|
||||
}),
|
||||
|
||||
// nsIDOMMozCdmaIccInfo
|
||||
|
||||
mdn: null,
|
||||
min: null
|
||||
};
|
||||
|
||||
function RadioInterfaceLayer() {
|
||||
gMessageManager.init(this);
|
||||
|
||||
|
@ -1049,9 +1099,27 @@ RadioInterface.prototype = {
|
|||
}
|
||||
},
|
||||
|
||||
getMsisdn: function getMsisdn() {
|
||||
/**
|
||||
* Get phone number from iccInfo.
|
||||
*
|
||||
* If the icc card is gsm card, the phone number is in msisdn.
|
||||
* @see nsIDOMMozGsmIccInfo
|
||||
*
|
||||
* Otherwise, the phone number is in mdn.
|
||||
* @see nsIDOMMozCdmaIccInfo
|
||||
*/
|
||||
getPhoneNumber: function getPhoneNumber() {
|
||||
let iccInfo = this.rilContext.iccInfo;
|
||||
let number = iccInfo ? iccInfo.msisdn : null;
|
||||
|
||||
if (!iccInfo) {
|
||||
return null;
|
||||
}
|
||||
|
||||
// After moving SMS code out of RadioInterfaceLayer, we could use
|
||||
// |iccInfo instanceof Ci.nsIDOMMozGsmIccInfo| here.
|
||||
// TODO: Bug 873351 - B2G SMS: move SMS code out of RadioInterfaceLayer to
|
||||
// SmsService
|
||||
let number = (iccInfo instanceof GsmIccInfo) ? iccInfo.msisdn : iccInfo.mdn;
|
||||
|
||||
// Workaround an xpconnect issue with undefined string objects.
|
||||
// See bug 808220
|
||||
|
@ -1744,7 +1812,7 @@ RadioInterface.prototype = {
|
|||
|
||||
message.type = "sms";
|
||||
message.sender = message.sender || null;
|
||||
message.receiver = this.getMsisdn();
|
||||
message.receiver = this.getPhoneNumber();
|
||||
message.body = message.fullBody = message.fullBody || null;
|
||||
message.timestamp = Date.now();
|
||||
|
||||
|
@ -1991,12 +2059,27 @@ RadioInterface.prototype = {
|
|||
},
|
||||
|
||||
handleIccInfoChange: function handleIccInfoChange(message) {
|
||||
let oldIccInfo = this.rilContext.iccInfo;
|
||||
this.rilContext.iccInfo = message;
|
||||
let oldSpn = this.rilContext.iccInfo ? this.rilContext.iccInfo.spn : null;
|
||||
|
||||
if (!this.isInfoChanged(message, oldIccInfo)) {
|
||||
return;
|
||||
if (!message || !message.iccType) {
|
||||
// Card is not detected, clear iccInfo to null.
|
||||
this.rilContext.iccInfo = null;
|
||||
} else {
|
||||
if (!this.rilContext.iccInfo) {
|
||||
if (message.iccType === "ruim" || message.iccType === "csim") {
|
||||
this.rilContext.iccInfo = new CdmaIccInfo();
|
||||
} else {
|
||||
this.rilContext.iccInfo = new GsmIccInfo();
|
||||
}
|
||||
}
|
||||
|
||||
if (!this.isInfoChanged(message, this.rilContext.iccInfo)) {
|
||||
return;
|
||||
}
|
||||
|
||||
this.updateInfo(message, this.rilContext.iccInfo);
|
||||
}
|
||||
|
||||
// RIL:IccInfoChanged corresponds to a DOM event that gets fired only
|
||||
// when iccInfo has changed.
|
||||
gMessageManager.sendIccMessage("RIL:IccInfoChanged",
|
||||
|
@ -2020,7 +2103,6 @@ RadioInterface.prototype = {
|
|||
}
|
||||
|
||||
// If spn becomes available, we should check roaming again.
|
||||
let oldSpn = oldIccInfo ? oldIccInfo.spn : null;
|
||||
if (!oldSpn && message.spn) {
|
||||
let voice = this.rilContext.voice;
|
||||
let data = this.rilContext.data;
|
||||
|
@ -2945,7 +3027,7 @@ RadioInterface.prototype = {
|
|||
|
||||
let sendingMessage = {
|
||||
type: "sms",
|
||||
sender: this.getMsisdn(),
|
||||
sender: this.getPhoneNumber(),
|
||||
receiver: number,
|
||||
body: message,
|
||||
deliveryStatusRequested: options.requestStatusReport,
|
||||
|
|
Загрузка…
Ссылка в новой задаче