зеркало из https://github.com/mozilla/gecko-dev.git
Bug 823010 - B2G SMS: We should not ack reception when there's a storage error. r=vicamo, ferjm a=blocking-b2g
This commit is contained in:
Родитель
72faee30f7
Коммит
8e8c49a099
|
@ -2,12 +2,32 @@
|
||||||
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
|
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
|
||||||
* You can obtain one at http://mozilla.org/MPL/2.0/. */
|
* You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||||
|
|
||||||
|
#include "nsISupports.idl"
|
||||||
#include "nsISmsDatabaseService.idl"
|
#include "nsISmsDatabaseService.idl"
|
||||||
|
|
||||||
[scriptable, uuid(71d7dd4e-5489-4e58-a489-171200378c3c)]
|
interface nsIDOMMozSmsMessage;
|
||||||
|
|
||||||
|
[scriptable, function, uuid(04a08668-c020-469e-a1ad-8626c951ab2b)]
|
||||||
|
interface nsIRilSmsDatabaseCallback : nsISupports
|
||||||
|
{
|
||||||
|
void notify(in nsresult aRv, in nsIDOMMozSmsMessage aSms);
|
||||||
|
};
|
||||||
|
|
||||||
|
[scriptable, uuid(8e2acd73-0332-4d16-82cc-ff5bac59d245)]
|
||||||
interface nsIRilSmsDatabaseService : nsISmsDatabaseService
|
interface nsIRilSmsDatabaseService : nsISmsDatabaseService
|
||||||
{
|
{
|
||||||
long saveReceivedMessage(in DOMString aSender, in DOMString aBody, in DOMString aMessageClass, in unsigned long long aDate);
|
long saveReceivedMessage(in DOMString aSender,
|
||||||
long saveSendingMessage(in DOMString aReceiver, in DOMString aBody, in unsigned long long aDate);
|
in DOMString aBody,
|
||||||
void setMessageDelivery(in long aMessageId, in DOMString aDelivery, in DOMString aDeliveryStatus);
|
in DOMString aMessageClass,
|
||||||
|
in unsigned long long aDate,
|
||||||
|
[optional] in nsIRilSmsDatabaseCallback aCallback);
|
||||||
|
long saveSendingMessage(in DOMString aReceiver,
|
||||||
|
in DOMString aBody,
|
||||||
|
in DOMString aDeliveryStatus,
|
||||||
|
in unsigned long long aDate,
|
||||||
|
[optional] in nsIRilSmsDatabaseCallback aCallback);
|
||||||
|
void setMessageDelivery(in long aMessageId,
|
||||||
|
in DOMString aDelivery,
|
||||||
|
in DOMString aDeliveryStatus,
|
||||||
|
[optional] in nsIRilSmsDatabaseCallback aCallback);
|
||||||
};
|
};
|
||||||
|
|
|
@ -179,24 +179,24 @@ SmsDatabaseService.prototype = {
|
||||||
self.upgradeSchema(objectStore);
|
self.upgradeSchema(objectStore);
|
||||||
break;
|
break;
|
||||||
case 2:
|
case 2:
|
||||||
if (DEBUG) debug("Upgrade to version 3. Fix existing entries.")
|
if (DEBUG) debug("Upgrade to version 3. Fix existing entries.");
|
||||||
objectStore = event.target.transaction.objectStore(STORE_NAME);
|
objectStore = event.target.transaction.objectStore(STORE_NAME);
|
||||||
self.upgradeSchema2(objectStore);
|
self.upgradeSchema2(objectStore);
|
||||||
break;
|
break;
|
||||||
case 3:
|
case 3:
|
||||||
if (DEBUG) debug("Upgrade to version 4. Add quick threads view.")
|
if (DEBUG) debug("Upgrade to version 4. Add quick threads view.");
|
||||||
self.upgradeSchema3(db, event.target.transaction);
|
self.upgradeSchema3(db, event.target.transaction);
|
||||||
break;
|
break;
|
||||||
case 4:
|
case 4:
|
||||||
if (DEBUG) debug("Upgrade to version 5. Populate quick threads view.")
|
if (DEBUG) debug("Upgrade to version 5. Populate quick threads view.");
|
||||||
self.upgradeSchema4(event.target.transaction);
|
self.upgradeSchema4(event.target.transaction);
|
||||||
break;
|
break;
|
||||||
case 5:
|
case 5:
|
||||||
if (DEBUG) debug("Upgrade to version 6. Use PhonenumberJS.")
|
if (DEBUG) debug("Upgrade to version 6. Use PhonenumberJS.");
|
||||||
self.upgradeSchema5(event.target.transaction);
|
self.upgradeSchema5(event.target.transaction);
|
||||||
break;
|
break;
|
||||||
case 6:
|
case 6:
|
||||||
if (DEBUG) debug("Upgrade to version 7. Use multiple entry indexes.")
|
if (DEBUG) debug("Upgrade to version 7. Use multiple entry indexes.");
|
||||||
self.upgradeSchema6(event.target.transaction);
|
self.upgradeSchema6(event.target.transaction);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
|
@ -206,7 +206,7 @@ SmsDatabaseService.prototype = {
|
||||||
}
|
}
|
||||||
currentVersion++;
|
currentVersion++;
|
||||||
}
|
}
|
||||||
}
|
};
|
||||||
request.onerror = function (event) {
|
request.onerror = function (event) {
|
||||||
//TODO look at event.target.Code and change error constant accordingly
|
//TODO look at event.target.Code and change error constant accordingly
|
||||||
callback("Error opening database!", null);
|
callback("Error opening database!", null);
|
||||||
|
@ -298,7 +298,7 @@ SmsDatabaseService.prototype = {
|
||||||
message.deliveryStatus = DELIVERY_STATUS_NOT_APPLICABLE;
|
message.deliveryStatus = DELIVERY_STATUS_NOT_APPLICABLE;
|
||||||
cursor.update(message);
|
cursor.update(message);
|
||||||
cursor.continue();
|
cursor.continue();
|
||||||
}
|
};
|
||||||
},
|
},
|
||||||
|
|
||||||
upgradeSchema3: function upgradeSchema3(db, transaction) {
|
upgradeSchema3: function upgradeSchema3(db, transaction) {
|
||||||
|
@ -358,10 +358,10 @@ SmsDatabaseService.prototype = {
|
||||||
timestamp: message.timestamp,
|
timestamp: message.timestamp,
|
||||||
body: message.body,
|
body: message.body,
|
||||||
unreadCount: message.read ? 0 : 1
|
unreadCount: message.read ? 0 : 1
|
||||||
}
|
};
|
||||||
}
|
}
|
||||||
cursor.continue();
|
cursor.continue();
|
||||||
}
|
};
|
||||||
},
|
},
|
||||||
|
|
||||||
upgradeSchema5: function upgradeSchema5(transaction) {
|
upgradeSchema5: function upgradeSchema5(transaction) {
|
||||||
|
@ -410,7 +410,7 @@ SmsDatabaseService.prototype = {
|
||||||
message.readIndex = [message.read, timestamp];
|
message.readIndex = [message.read, timestamp];
|
||||||
cursor.update(message);
|
cursor.update(message);
|
||||||
cursor.continue();
|
cursor.continue();
|
||||||
}
|
};
|
||||||
},
|
},
|
||||||
|
|
||||||
createMessageFromRecord: function createMessageFromRecord(record) {
|
createMessageFromRecord: function createMessageFromRecord(record) {
|
||||||
|
@ -499,14 +499,14 @@ SmsDatabaseService.prototype = {
|
||||||
}
|
}
|
||||||
smsRequest.notifyMessageListCreated(aMessageList.listId, sms);
|
smsRequest.notifyMessageListCreated(aMessageList.listId, sms);
|
||||||
}
|
}
|
||||||
}
|
};
|
||||||
getRequest.onerror = function onerror(event) {
|
getRequest.onerror = function onerror(event) {
|
||||||
if (DEBUG) {
|
if (DEBUG) {
|
||||||
debug("notifyReadMessageListFailed - listId: "
|
debug("notifyReadMessageListFailed - listId: "
|
||||||
+ aMessageList.listId + ", messageId: " + firstMessageId);
|
+ aMessageList.listId + ", messageId: " + firstMessageId);
|
||||||
}
|
}
|
||||||
smsRequest.notifyReadMessageListFailed(Ci.nsISmsRequest.INTERNAL_ERROR);
|
smsRequest.notifyReadMessageListFailed(Ci.nsISmsRequest.INTERNAL_ERROR);
|
||||||
}
|
};
|
||||||
},
|
},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -647,21 +647,41 @@ SmsDatabaseService.prototype = {
|
||||||
return false;
|
return false;
|
||||||
},
|
},
|
||||||
|
|
||||||
saveMessage: function saveMessage(message) {
|
saveMessage: function saveMessage(message, callback) {
|
||||||
this.lastKey += 1;
|
this.lastKey += 1;
|
||||||
message.id = this.lastKey;
|
message.id = this.lastKey;
|
||||||
if (DEBUG) debug("Going to store " + JSON.stringify(message));
|
if (DEBUG) debug("Going to store " + JSON.stringify(message));
|
||||||
this.newTxn(READ_WRITE, function(error, txn, stores) {
|
|
||||||
if (error) {
|
let self = this;
|
||||||
|
function notifyResult(rv) {
|
||||||
|
if (!callback) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
let sms = self.createMessageFromRecord(message);
|
||||||
|
callback.notify(rv, sms);
|
||||||
|
}
|
||||||
|
|
||||||
|
this.newTxn(READ_WRITE, function(error, txn, stores) {
|
||||||
|
if (error) {
|
||||||
|
// TODO bug 832140 check event.target.errorCode
|
||||||
|
notifyResult(Cr.NS_ERROR_FAILURE);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
txn.oncomplete = function oncomplete(event) {
|
||||||
|
notifyResult(Cr.NS_OK);
|
||||||
|
};
|
||||||
|
txn.onabort = function onabort(event) {
|
||||||
|
// TODO bug 832140 check event.target.errorCode
|
||||||
|
notifyResult(Cr.NS_ERROR_FAILURE);
|
||||||
|
};
|
||||||
|
|
||||||
// First add to main objectStore.
|
// First add to main objectStore.
|
||||||
stores[0].put(message);
|
stores[0].put(message);
|
||||||
|
|
||||||
let number = numberFromMessage(message);
|
let number = numberFromMessage(message);
|
||||||
|
|
||||||
// Next update the other objectStore.
|
// Next update the other objectStore.
|
||||||
stores[1].get(number).onsuccess = function(event) {
|
stores[1].get(number).onsuccess = function onsuccess(event) {
|
||||||
let mostRecentEntry = event.target.result;
|
let mostRecentEntry = event.target.result;
|
||||||
if (mostRecentEntry) {
|
if (mostRecentEntry) {
|
||||||
let needsUpdate = false;
|
let needsUpdate = false;
|
||||||
|
@ -687,7 +707,7 @@ SmsDatabaseService.prototype = {
|
||||||
id: message.id,
|
id: message.id,
|
||||||
unreadCount: message.read ? 0 : 1 });
|
unreadCount: message.read ? 0 : 1 });
|
||||||
}
|
}
|
||||||
}
|
};
|
||||||
}, [STORE_NAME, MOST_RECENT_STORE_NAME]);
|
}, [STORE_NAME, MOST_RECENT_STORE_NAME]);
|
||||||
// We return the key that we expect to store in the db
|
// We return the key that we expect to store in the db
|
||||||
return message.id;
|
return message.id;
|
||||||
|
@ -698,8 +718,11 @@ SmsDatabaseService.prototype = {
|
||||||
* nsIRilSmsDatabaseService API
|
* nsIRilSmsDatabaseService API
|
||||||
*/
|
*/
|
||||||
|
|
||||||
saveReceivedMessage: function saveReceivedMessage(aSender, aBody, aMessageClass, aDate) {
|
saveReceivedMessage: function saveReceivedMessage(
|
||||||
let receiver = this.mRIL.rilContext.icc ? this.mRIL.rilContext.icc.msisdn : null;
|
aSender, aBody, aMessageClass, aDate, aCallback) {
|
||||||
|
let receiver = this.mRIL.rilContext.icc
|
||||||
|
? this.mRIL.rilContext.icc.msisdn
|
||||||
|
: null;
|
||||||
|
|
||||||
// Workaround an xpconnect issue with undefined string objects.
|
// Workaround an xpconnect issue with undefined string objects.
|
||||||
// See bug 808220
|
// See bug 808220
|
||||||
|
@ -736,11 +759,14 @@ SmsDatabaseService.prototype = {
|
||||||
timestamp: aDate,
|
timestamp: aDate,
|
||||||
read: FILTER_READ_UNREAD
|
read: FILTER_READ_UNREAD
|
||||||
};
|
};
|
||||||
return this.saveMessage(message);
|
return this.saveMessage(message, aCallback);
|
||||||
},
|
},
|
||||||
|
|
||||||
saveSendingMessage: function saveSendingMessage(aReceiver, aBody, aDate) {
|
saveSendingMessage: function saveSendingMessage(
|
||||||
let sender = this.mRIL.rilContext.icc ? this.mRIL.rilContext.icc.msisdn : null;
|
aReceiver, aBody, aDeliveryStatus, aDate, aCallback) {
|
||||||
|
let sender = this.mRIL.rilContext.icc
|
||||||
|
? this.mRIL.rilContext.icc.msisdn
|
||||||
|
: null;
|
||||||
|
|
||||||
// Workaround an xpconnect issue with undefined string objects.
|
// Workaround an xpconnect issue with undefined string objects.
|
||||||
// See bug 808220
|
// See bug 808220
|
||||||
|
@ -748,7 +774,7 @@ SmsDatabaseService.prototype = {
|
||||||
sender = null;
|
sender = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
let receiver = aReceiver
|
let receiver = aReceiver;
|
||||||
if (receiver) {
|
if (receiver) {
|
||||||
let parsedNumber = PhoneNumberUtils.parse(receiver.toString());
|
let parsedNumber = PhoneNumberUtils.parse(receiver.toString());
|
||||||
receiver = (parsedNumber && parsedNumber.internationalNumber)
|
receiver = (parsedNumber && parsedNumber.internationalNumber)
|
||||||
|
@ -769,7 +795,7 @@ SmsDatabaseService.prototype = {
|
||||||
readIndex: [FILTER_READ_READ, aDate],
|
readIndex: [FILTER_READ_READ, aDate],
|
||||||
|
|
||||||
delivery: DELIVERY_SENDING,
|
delivery: DELIVERY_SENDING,
|
||||||
deliveryStatus: DELIVERY_STATUS_PENDING,
|
deliveryStatus: aDeliveryStatus,
|
||||||
sender: sender,
|
sender: sender,
|
||||||
receiver: receiver,
|
receiver: receiver,
|
||||||
body: aBody,
|
body: aBody,
|
||||||
|
@ -777,23 +803,46 @@ SmsDatabaseService.prototype = {
|
||||||
timestamp: aDate,
|
timestamp: aDate,
|
||||||
read: FILTER_READ_READ
|
read: FILTER_READ_READ
|
||||||
};
|
};
|
||||||
return this.saveMessage(message);
|
return this.saveMessage(message, aCallback);
|
||||||
},
|
},
|
||||||
|
|
||||||
setMessageDelivery: function setMessageDelivery(messageId, delivery, deliveryStatus) {
|
setMessageDelivery: function setMessageDelivery(
|
||||||
|
messageId, delivery, deliveryStatus, callback) {
|
||||||
if (DEBUG) {
|
if (DEBUG) {
|
||||||
debug("Setting message " + messageId + " delivery to " + delivery
|
debug("Setting message " + messageId + " delivery to " + delivery
|
||||||
+ ", and deliveryStatus to " + deliveryStatus);
|
+ ", and deliveryStatus to " + deliveryStatus);
|
||||||
}
|
}
|
||||||
this.newTxn(READ_WRITE, function (error, txn, store) {
|
|
||||||
if (error) {
|
let self = this;
|
||||||
if (DEBUG) debug(error);
|
let message;
|
||||||
|
function notifyResult(rv) {
|
||||||
|
if (!callback) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
let sms = null;
|
||||||
|
if (message) {
|
||||||
|
sms = self.createMessageFromRecord(message);
|
||||||
|
}
|
||||||
|
callback.notify(rv, sms);
|
||||||
|
}
|
||||||
|
|
||||||
|
this.newTxn(READ_WRITE, function (error, txn, store) {
|
||||||
|
if (error) {
|
||||||
|
// TODO bug 832140 check event.target.errorCode
|
||||||
|
notifyResult(Cr.NS_ERROR_FAILURE);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
txn.oncomplete = function oncomplete(event) {
|
||||||
|
notifyResult(Cr.NS_OK);
|
||||||
|
};
|
||||||
|
txn.onabort = function onabort(event) {
|
||||||
|
// TODO bug 832140 check event.target.errorCode
|
||||||
|
notifyResult(Cr.NS_ERROR_FAILURE);
|
||||||
|
};
|
||||||
|
|
||||||
let getRequest = store.get(messageId);
|
let getRequest = store.get(messageId);
|
||||||
getRequest.onsuccess = function onsuccess(event) {
|
getRequest.onsuccess = function onsuccess(event) {
|
||||||
let message = event.target.result;
|
message = event.target.result;
|
||||||
if (!message) {
|
if (!message) {
|
||||||
if (DEBUG) debug("Message ID " + messageId + " not found");
|
if (DEBUG) debug("Message ID " + messageId + " not found");
|
||||||
return;
|
return;
|
||||||
|
|
|
@ -153,7 +153,7 @@ function convertRILCallState(state) {
|
||||||
return nsIRadioInterfaceLayer.CALL_STATE_ALERTING;
|
return nsIRadioInterfaceLayer.CALL_STATE_ALERTING;
|
||||||
case RIL.CALL_STATE_INCOMING:
|
case RIL.CALL_STATE_INCOMING:
|
||||||
case RIL.CALL_STATE_WAITING:
|
case RIL.CALL_STATE_WAITING:
|
||||||
return nsIRadioInterfaceLayer.CALL_STATE_INCOMING;
|
return nsIRadioInterfaceLayer.CALL_STATE_INCOMING;
|
||||||
case RIL.CALL_STATE_BUSY:
|
case RIL.CALL_STATE_BUSY:
|
||||||
return nsIRadioInterfaceLayer.CALL_STATE_BUSY;
|
return nsIRadioInterfaceLayer.CALL_STATE_BUSY;
|
||||||
default:
|
default:
|
||||||
|
@ -1108,13 +1108,13 @@ RadioInterfaceLayer.prototype = {
|
||||||
debug("We haven't read completely the APN data from the " +
|
debug("We haven't read completely the APN data from the " +
|
||||||
"settings DB yet. Wait for that.");
|
"settings DB yet. Wait for that.");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// This check avoids data call connection if the radio is not ready
|
// This check avoids data call connection if the radio is not ready
|
||||||
// yet after toggling off airplane mode.
|
// yet after toggling off airplane mode.
|
||||||
if (this.rilContext.radioState != RIL.GECKO_RADIOSTATE_READY) {
|
if (this.rilContext.radioState != RIL.GECKO_RADIOSTATE_READY) {
|
||||||
debug("RIL is not ready for data connection: radio's not ready");
|
debug("RIL is not ready for data connection: radio's not ready");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// We only watch at "ril.data.enabled" flag changes for connecting or
|
// We only watch at "ril.data.enabled" flag changes for connecting or
|
||||||
|
@ -1370,34 +1370,57 @@ RadioInterfaceLayer.prototype = {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
let id = -1;
|
let notifyReceived = function notifyReceived(rv, sms) {
|
||||||
if (message.messageClass != RIL.GECKO_SMS_MESSAGE_CLASSES[RIL.PDU_DCS_MSG_CLASS_0]) {
|
let success = Components.isSuccessCode(rv);
|
||||||
id = gSmsDatabaseService.saveReceivedMessage(message.sender || null,
|
|
||||||
message.fullBody || null,
|
|
||||||
message.messageClass,
|
|
||||||
message.timestamp);
|
|
||||||
}
|
|
||||||
let sms = gSmsService.createSmsMessage(id,
|
|
||||||
DOM_SMS_DELIVERY_RECEIVED,
|
|
||||||
RIL.GECKO_SMS_DELIVERY_STATUS_SUCCESS,
|
|
||||||
message.sender || null,
|
|
||||||
message.receiver || null,
|
|
||||||
message.fullBody || null,
|
|
||||||
message.messageClass,
|
|
||||||
message.timestamp,
|
|
||||||
false);
|
|
||||||
|
|
||||||
gSystemMessenger.broadcastMessage("sms-received",
|
// Acknowledge the reception of the SMS.
|
||||||
{id: id,
|
message.rilMessageType = "ackSMS";
|
||||||
delivery: DOM_SMS_DELIVERY_RECEIVED,
|
if (!success) {
|
||||||
deliveryStatus: RIL.GECKO_SMS_DELIVERY_STATUS_SUCCESS,
|
message.result = RIL.PDU_FCS_MEMORY_CAPACITY_EXCEEDED;
|
||||||
sender: message.sender || null,
|
}
|
||||||
receiver: message.receiver || null,
|
this.worker.postMessage(message);
|
||||||
body: message.fullBody || null,
|
|
||||||
messageClass: message.messageClass,
|
if (!success) {
|
||||||
timestamp: message.timestamp,
|
// At this point we could send a message to content to notify the user
|
||||||
read: false});
|
// that storing an incoming SMS failed, most likely due to a full disk.
|
||||||
Services.obs.notifyObservers(sms, kSmsReceivedObserverTopic, null);
|
debug("Could not store SMS " + message.id + ", error code " + rv);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
gSystemMessenger.broadcastMessage("sms-received", {
|
||||||
|
id: message.id,
|
||||||
|
delivery: DOM_SMS_DELIVERY_RECEIVED,
|
||||||
|
deliveryStatus: RIL.GECKO_SMS_DELIVERY_STATUS_SUCCESS,
|
||||||
|
sender: message.sender || null,
|
||||||
|
receiver: message.receiver || null,
|
||||||
|
body: message.fullBody || null,
|
||||||
|
messageClass: message.messageClass,
|
||||||
|
timestamp: message.timestamp,
|
||||||
|
read: false
|
||||||
|
});
|
||||||
|
Services.obs.notifyObservers(sms, kSmsReceivedObserverTopic, null);
|
||||||
|
}.bind(this);
|
||||||
|
|
||||||
|
if (message.messageClass != RIL.GECKO_SMS_MESSAGE_CLASSES[RIL.PDU_DCS_MSG_CLASS_0]) {
|
||||||
|
message.id = gSmsDatabaseService.saveReceivedMessage(
|
||||||
|
message.sender || null,
|
||||||
|
message.fullBody || null,
|
||||||
|
message.messageClass,
|
||||||
|
message.timestamp,
|
||||||
|
notifyReceived);
|
||||||
|
} else {
|
||||||
|
message.id = -1;
|
||||||
|
let sms = gSmsService.createSmsMessage(message.id,
|
||||||
|
DOM_SMS_DELIVERY_RECEIVED,
|
||||||
|
RIL.GECKO_SMS_DELIVERY_STATUS_SUCCESS,
|
||||||
|
message.sender || null,
|
||||||
|
message.receiver || null,
|
||||||
|
message.fullBody || null,
|
||||||
|
message.messageClass,
|
||||||
|
message.timestamp,
|
||||||
|
false);
|
||||||
|
notifyReceived(Cr.NS_OK, sms);
|
||||||
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -1424,40 +1447,32 @@ RadioInterfaceLayer.prototype = {
|
||||||
}
|
}
|
||||||
|
|
||||||
gSmsDatabaseService.setMessageDelivery(options.sms.id,
|
gSmsDatabaseService.setMessageDelivery(options.sms.id,
|
||||||
DOM_SMS_DELIVERY_SENT,
|
|
||||||
options.sms.deliveryStatus);
|
|
||||||
|
|
||||||
let sms = gSmsService.createSmsMessage(options.sms.id,
|
|
||||||
DOM_SMS_DELIVERY_SENT,
|
DOM_SMS_DELIVERY_SENT,
|
||||||
options.sms.deliveryStatus,
|
options.sms.deliveryStatus,
|
||||||
null,
|
function notifyResult(rv, sms) {
|
||||||
options.sms.receiver,
|
//TODO bug 832140 handle !Components.isSuccessCode(rv)
|
||||||
options.sms.body,
|
gSystemMessenger.broadcastMessage("sms-sent",
|
||||||
options.sms.messageClass,
|
{id: options.sms.id,
|
||||||
options.sms.timestamp,
|
delivery: DOM_SMS_DELIVERY_SENT,
|
||||||
true);
|
deliveryStatus: options.sms.deliveryStatus,
|
||||||
|
sender: message.sender || null,
|
||||||
|
receiver: options.sms.receiver,
|
||||||
|
body: options.sms.body,
|
||||||
|
messageClass: options.sms.messageClass,
|
||||||
|
timestamp: options.sms.timestamp,
|
||||||
|
read: true});
|
||||||
|
|
||||||
gSystemMessenger.broadcastMessage("sms-sent",
|
if (!options.requestStatusReport) {
|
||||||
{id: options.sms.id,
|
// No more used if STATUS-REPORT not requested.
|
||||||
delivery: DOM_SMS_DELIVERY_SENT,
|
delete this._sentSmsEnvelopes[message.envelopeId];
|
||||||
deliveryStatus: options.sms.deliveryStatus,
|
} else {
|
||||||
sender: message.sender || null,
|
options.sms = sms;
|
||||||
receiver: options.sms.receiver,
|
}
|
||||||
body: options.sms.body,
|
|
||||||
messageClass: options.sms.messageClass,
|
|
||||||
timestamp: options.sms.timestamp,
|
|
||||||
read: true});
|
|
||||||
|
|
||||||
if (!options.requestStatusReport) {
|
options.request.notifyMessageSent(sms);
|
||||||
// No more used if STATUS-REPORT not requested.
|
|
||||||
delete this._sentSmsEnvelopes[message.envelopeId];
|
|
||||||
} else {
|
|
||||||
options.sms = sms;
|
|
||||||
}
|
|
||||||
|
|
||||||
options.request.notifyMessageSent(sms);
|
Services.obs.notifyObservers(sms, kSmsSentObserverTopic, null);
|
||||||
|
}.bind(this));
|
||||||
Services.obs.notifyObservers(sms, kSmsSentObserverTopic, null);
|
|
||||||
},
|
},
|
||||||
|
|
||||||
handleSmsDelivery: function handleSmsDelivery(message) {
|
handleSmsDelivery: function handleSmsDelivery(message) {
|
||||||
|
@ -1470,23 +1485,15 @@ RadioInterfaceLayer.prototype = {
|
||||||
delete this._sentSmsEnvelopes[message.envelopeId];
|
delete this._sentSmsEnvelopes[message.envelopeId];
|
||||||
|
|
||||||
gSmsDatabaseService.setMessageDelivery(options.sms.id,
|
gSmsDatabaseService.setMessageDelivery(options.sms.id,
|
||||||
options.sms.delivery,
|
|
||||||
message.deliveryStatus);
|
|
||||||
|
|
||||||
let sms = gSmsService.createSmsMessage(options.sms.id,
|
|
||||||
options.sms.delivery,
|
options.sms.delivery,
|
||||||
message.deliveryStatus,
|
message.deliveryStatus,
|
||||||
null,
|
function notifyResult(rv, sms) {
|
||||||
options.sms.receiver,
|
//TODO bug 832140 handle !Components.isSuccessCode(rv)
|
||||||
options.sms.body,
|
let topic = (message.deliveryStatus == RIL.GECKO_SMS_DELIVERY_STATUS_SUCCESS)
|
||||||
options.sms.messageClass,
|
? kSmsDeliverySuccessObserverTopic
|
||||||
options.sms.timestamp,
|
: kSmsDeliveryErrorObserverTopic;
|
||||||
true);
|
Services.obs.notifyObservers(sms, topic, null);
|
||||||
|
});
|
||||||
let topic = (message.deliveryStatus == RIL.GECKO_SMS_DELIVERY_STATUS_SUCCESS)
|
|
||||||
? kSmsDeliverySuccessObserverTopic
|
|
||||||
: kSmsDeliveryErrorObserverTopic;
|
|
||||||
Services.obs.notifyObservers(sms, topic, null);
|
|
||||||
},
|
},
|
||||||
|
|
||||||
handleSmsSendFailed: function handleSmsSendFailed(message) {
|
handleSmsSendFailed: function handleSmsSendFailed(message) {
|
||||||
|
@ -1506,22 +1513,13 @@ RadioInterfaceLayer.prototype = {
|
||||||
}
|
}
|
||||||
|
|
||||||
gSmsDatabaseService.setMessageDelivery(options.sms.id,
|
gSmsDatabaseService.setMessageDelivery(options.sms.id,
|
||||||
DOM_SMS_DELIVERY_ERROR,
|
|
||||||
RIL.GECKO_SMS_DELIVERY_STATUS_ERROR);
|
|
||||||
|
|
||||||
let sms = gSmsService.createSmsMessage(options.sms.id,
|
|
||||||
DOM_SMS_DELIVERY_ERROR,
|
DOM_SMS_DELIVERY_ERROR,
|
||||||
RIL.GECKO_SMS_DELIVERY_STATUS_ERROR,
|
RIL.GECKO_SMS_DELIVERY_STATUS_ERROR,
|
||||||
null,
|
function notifyResult(rv, sms) {
|
||||||
options.sms.receiver,
|
//TODO bug 832140 handle !Components.isSuccessCode(rv)
|
||||||
options.sms.body,
|
options.request.notifySendMessageFailed(error);
|
||||||
options.sms.messageClass,
|
Services.obs.notifyObservers(sms, kSmsFailedObserverTopic, null);
|
||||||
options.sms.timestamp,
|
});
|
||||||
true);
|
|
||||||
|
|
||||||
options.request.notifySendMessageFailed(error);
|
|
||||||
|
|
||||||
Services.obs.notifyObservers(sms, kSmsFailedObserverTopic, null);
|
|
||||||
},
|
},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -1599,10 +1597,10 @@ RadioInterfaceLayer.prototype = {
|
||||||
handleICCInfoChange: function handleICCInfoChange(message) {
|
handleICCInfoChange: function handleICCInfoChange(message) {
|
||||||
let oldIcc = this.rilContext.icc;
|
let oldIcc = this.rilContext.icc;
|
||||||
this.rilContext.icc = message;
|
this.rilContext.icc = message;
|
||||||
|
|
||||||
let iccInfoChanged = !oldIcc ||
|
let iccInfoChanged = !oldIcc ||
|
||||||
oldIcc.iccid != message.iccid ||
|
oldIcc.iccid != message.iccid ||
|
||||||
oldIcc.mcc != message.mcc ||
|
oldIcc.mcc != message.mcc ||
|
||||||
oldIcc.mnc != message.mnc ||
|
oldIcc.mnc != message.mnc ||
|
||||||
oldIcc.spn != message.spn ||
|
oldIcc.spn != message.spn ||
|
||||||
oldIcc.isDisplayNetworkNameRequired != message.isDisplayNetworkNameRequired ||
|
oldIcc.isDisplayNetworkNameRequired != message.isDisplayNetworkNameRequired ||
|
||||||
|
@ -1729,7 +1727,7 @@ RadioInterfaceLayer.prototype = {
|
||||||
// Flag to ignore any radio power change requests during We're changing
|
// Flag to ignore any radio power change requests during We're changing
|
||||||
// the radio power.
|
// the radio power.
|
||||||
_changingRadioPower: false,
|
_changingRadioPower: false,
|
||||||
|
|
||||||
// Flag to determine whether we reject a waiting call directly or we
|
// Flag to determine whether we reject a waiting call directly or we
|
||||||
// notify the UI of a waiting call. It corresponds to the
|
// notify the UI of a waiting call. It corresponds to the
|
||||||
// 'ril.callwaiting.enbled' setting from the UI.
|
// 'ril.callwaiting.enbled' setting from the UI.
|
||||||
|
@ -1828,9 +1826,9 @@ RadioInterfaceLayer.prototype = {
|
||||||
this._radioEnabled = true;
|
this._radioEnabled = true;
|
||||||
this._ensureRadioState();
|
this._ensureRadioState();
|
||||||
|
|
||||||
// Clean data call setting.
|
// Clean data call setting.
|
||||||
this.dataCallSettings = {};
|
this.dataCallSettings = {};
|
||||||
this.dataCallSettings["enabled"] = false;
|
this.dataCallSettings["enabled"] = false;
|
||||||
},
|
},
|
||||||
|
|
||||||
// nsIRadioWorker
|
// nsIRadioWorker
|
||||||
|
@ -1895,7 +1893,7 @@ RadioInterfaceLayer.prototype = {
|
||||||
this.worker.postMessage({rilMessageType: "rejectCall",
|
this.worker.postMessage({rilMessageType: "rejectCall",
|
||||||
callIndex: callIndex});
|
callIndex: callIndex});
|
||||||
},
|
},
|
||||||
|
|
||||||
holdCall: function holdCall(callIndex) {
|
holdCall: function holdCall(callIndex) {
|
||||||
this.worker.postMessage({rilMessageType: "holdCall",
|
this.worker.postMessage({rilMessageType: "holdCall",
|
||||||
callIndex: callIndex});
|
callIndex: callIndex});
|
||||||
|
@ -2435,28 +2433,22 @@ RadioInterfaceLayer.prototype = {
|
||||||
}
|
}
|
||||||
|
|
||||||
let timestamp = Date.now();
|
let timestamp = Date.now();
|
||||||
let id = gSmsDatabaseService.saveSendingMessage(number, message, timestamp);
|
|
||||||
let messageClass = RIL.GECKO_SMS_MESSAGE_CLASSES[RIL.PDU_DCS_MSG_CLASS_NORMAL];
|
|
||||||
let deliveryStatus = options.requestStatusReport
|
let deliveryStatus = options.requestStatusReport
|
||||||
? RIL.GECKO_SMS_DELIVERY_STATUS_PENDING
|
? RIL.GECKO_SMS_DELIVERY_STATUS_PENDING
|
||||||
: RIL.GECKO_SMS_DELIVERY_STATUS_NOT_APPLICABLE;
|
: RIL.GECKO_SMS_DELIVERY_STATUS_NOT_APPLICABLE;
|
||||||
let sms = gSmsService.createSmsMessage(id,
|
let id = gSmsDatabaseService.saveSendingMessage(number, message, deliveryStatus, timestamp,
|
||||||
DOM_SMS_DELIVERY_SENDING,
|
function notifyResult(rv, sms) {
|
||||||
deliveryStatus,
|
//TODO bug 832140 handle !Components.isSuccessCode(rv)
|
||||||
null,
|
Services.obs.notifyObservers(sms, kSmsSendingObserverTopic, null);
|
||||||
number,
|
|
||||||
message,
|
|
||||||
messageClass,
|
|
||||||
timestamp,
|
|
||||||
true);
|
|
||||||
Services.obs.notifyObservers(sms, kSmsSendingObserverTopic, null);
|
|
||||||
|
|
||||||
// Keep current SMS message info for sent/delivered notifications
|
// Keep current SMS message info for sent/delivered notifications
|
||||||
options.envelopeId = this.createSmsEnvelope({request: request,
|
options.envelopeId = this.createSmsEnvelope({
|
||||||
sms: sms,
|
request: request,
|
||||||
requestStatusReport: options.requestStatusReport});
|
sms: sms,
|
||||||
|
requestStatusReport: options.requestStatusReport
|
||||||
this.worker.postMessage(options);
|
});
|
||||||
|
this.worker.postMessage(options);
|
||||||
|
}.bind(this));
|
||||||
},
|
},
|
||||||
|
|
||||||
registerDataCallCallback: function registerDataCallCallback(callback) {
|
registerDataCallCallback: function registerDataCallCallback(callback) {
|
||||||
|
@ -2807,8 +2799,8 @@ RILNetworkInterface.prototype = {
|
||||||
|
|
||||||
debug("Going to set up data connection with APN " + this.dataCallSettings["apn"]);
|
debug("Going to set up data connection with APN " + this.dataCallSettings["apn"]);
|
||||||
this.mRIL.setupDataCall(RIL.DATACALL_RADIOTECHNOLOGY_GSM,
|
this.mRIL.setupDataCall(RIL.DATACALL_RADIOTECHNOLOGY_GSM,
|
||||||
this.dataCallSettings["apn"],
|
this.dataCallSettings["apn"],
|
||||||
this.dataCallSettings["user"],
|
this.dataCallSettings["user"],
|
||||||
this.dataCallSettings["passwd"],
|
this.dataCallSettings["passwd"],
|
||||||
RIL.DATACALL_AUTH_PAP_OR_CHAP, "IP");
|
RIL.DATACALL_AUTH_PAP_OR_CHAP, "IP");
|
||||||
this.connecting = true;
|
this.connecting = true;
|
||||||
|
|
|
@ -1207,6 +1207,11 @@ this.PDU_FCS_USAT_BUSY = 0XD4;
|
||||||
this.PDU_FCS_USIM_DATA_DOWNLOAD_ERROR = 0xD5;
|
this.PDU_FCS_USIM_DATA_DOWNLOAD_ERROR = 0xD5;
|
||||||
this.PDU_FCS_RESERVED = 0xE0;
|
this.PDU_FCS_RESERVED = 0xE0;
|
||||||
this.PDU_FCS_UNSPECIFIED = 0xFF;
|
this.PDU_FCS_UNSPECIFIED = 0xFF;
|
||||||
|
// Special internal value that means we should not acknowledge an
|
||||||
|
// incoming text right away, but need to wait for other components
|
||||||
|
// (e.g. storage) to complete. This can be any value, so long it
|
||||||
|
// doesn't conflict with the PDU_FCS_* constants above.
|
||||||
|
this.MOZ_FCS_WAIT_FOR_EXPLICIT_ACK = 0x0F;
|
||||||
|
|
||||||
// ST - Status
|
// ST - Status
|
||||||
// Bit 7..0 = 000xxxxx, short message transaction completed
|
// Bit 7..0 = 000xxxxx, short message transaction completed
|
||||||
|
|
|
@ -1713,6 +1713,19 @@ let RIL = {
|
||||||
Buf.sendParcel();
|
Buf.sendParcel();
|
||||||
},
|
},
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Acknowledge the receipt and handling of an SMS.
|
||||||
|
*
|
||||||
|
* @param success
|
||||||
|
* Boolean indicating whether the message was successfuly handled.
|
||||||
|
*/
|
||||||
|
ackSMS: function ackSMS(options) {
|
||||||
|
if (options.result == PDU_FCS_RESERVED) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
this.acknowledgeSMS(options.result == PDU_FCS_OK, options.result);
|
||||||
|
},
|
||||||
|
|
||||||
setCellBroadcastSearchList: function setCellBroadcastSearchList(options) {
|
setCellBroadcastSearchList: function setCellBroadcastSearchList(options) {
|
||||||
try {
|
try {
|
||||||
let str = options.searchListStr;
|
let str = options.searchListStr;
|
||||||
|
@ -3510,6 +3523,7 @@ let RIL = {
|
||||||
// short message waiting.` ~ 3GPP TS 31.111 7.1.1.1
|
// short message waiting.` ~ 3GPP TS 31.111 7.1.1.1
|
||||||
return PDU_FCS_RESERVED;
|
return PDU_FCS_RESERVED;
|
||||||
}
|
}
|
||||||
|
// Fall through!
|
||||||
|
|
||||||
// If the service "data download via SMS-PP" is not available in the
|
// If the service "data download via SMS-PP" is not available in the
|
||||||
// (U)SIM Service Table, ..., then the ME shall store the message in
|
// (U)SIM Service Table, ..., then the ME shall store the message in
|
||||||
|
@ -3549,14 +3563,18 @@ let RIL = {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (message) {
|
if (message) {
|
||||||
|
message.result = PDU_FCS_OK;
|
||||||
|
if (message.messageClass == GECKO_SMS_MESSAGE_CLASSES[PDU_DCS_MSG_CLASS_2]) {
|
||||||
|
// `MS shall ensure that the message has been to the SMS data field in
|
||||||
|
// the (U)SIM before sending an ACK to the SC.` ~ 3GPP 23.038 clause 4
|
||||||
|
message.result = PDU_FCS_RESERVED;
|
||||||
|
}
|
||||||
message.rilMessageType = "sms-received";
|
message.rilMessageType = "sms-received";
|
||||||
this.sendDOMMessage(message);
|
this.sendDOMMessage(message);
|
||||||
}
|
|
||||||
|
|
||||||
if (message && message.messageClass == GECKO_SMS_MESSAGE_CLASSES[PDU_DCS_MSG_CLASS_2]) {
|
// We will acknowledge receipt of the SMS after we try to store it
|
||||||
// `MS shall ensure that the message has been to the SMS data field in
|
// in the database.
|
||||||
// the (U)SIM before sending an ACK to the SC.` ~ 3GPP 23.038 clause 4
|
return MOZ_FCS_WAIT_FOR_EXPLICIT_ACK;
|
||||||
return PDU_FCS_RESERVED;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return PDU_FCS_OK;
|
return PDU_FCS_OK;
|
||||||
|
@ -4964,10 +4982,11 @@ RIL[UNSOLICITED_RESPONSE_VOICE_NETWORK_STATE_CHANGED] = function UNSOLICITED_RES
|
||||||
};
|
};
|
||||||
RIL[UNSOLICITED_RESPONSE_NEW_SMS] = function UNSOLICITED_RESPONSE_NEW_SMS(length) {
|
RIL[UNSOLICITED_RESPONSE_NEW_SMS] = function UNSOLICITED_RESPONSE_NEW_SMS(length) {
|
||||||
let result = this._processSmsDeliver(length);
|
let result = this._processSmsDeliver(length);
|
||||||
if (result != PDU_FCS_RESERVED) {
|
if (result == PDU_FCS_RESERVED || result == MOZ_FCS_WAIT_FOR_EXPLICIT_ACK) {
|
||||||
// Not reserved FCS values, send ACK now.
|
return;
|
||||||
this.acknowledgeSMS(result == PDU_FCS_OK, result);
|
|
||||||
}
|
}
|
||||||
|
// Not reserved FCS values, send ACK now.
|
||||||
|
this.acknowledgeSMS(result == PDU_FCS_OK, result);
|
||||||
};
|
};
|
||||||
RIL[UNSOLICITED_RESPONSE_NEW_SMS_STATUS_REPORT] = function UNSOLICITED_RESPONSE_NEW_SMS_STATUS_REPORT(length) {
|
RIL[UNSOLICITED_RESPONSE_NEW_SMS_STATUS_REPORT] = function UNSOLICITED_RESPONSE_NEW_SMS_STATUS_REPORT(length) {
|
||||||
let result = this._processSmsStatusReport(length);
|
let result = this._processSmsStatusReport(length);
|
||||||
|
|
Загрузка…
Ссылка в новой задаче