зеркало из https://github.com/mozilla/gecko-dev.git
Back out 30b9fbf49c01:c7fc23428c3b (bug 823010) for being rotted by 8 hours
--HG-- extra : rebase_source : 0dde2f719d4963113b578d07a17a8001fb4e0f63
This commit is contained in:
Родитель
58056c0bdc
Коммит
6ab4075f60
|
@ -2,32 +2,12 @@
|
||||||
* 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"
|
||||||
|
|
||||||
interface nsIDOMMozSmsMessage;
|
[scriptable, uuid(71d7dd4e-5489-4e58-a489-171200378c3c)]
|
||||||
|
|
||||||
[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,
|
long saveReceivedMessage(in DOMString aSender, in DOMString aBody, in DOMString aMessageClass, in unsigned long long aDate);
|
||||||
in DOMString aBody,
|
long saveSendingMessage(in DOMString aReceiver, in DOMString aBody, in unsigned long long aDate);
|
||||||
in DOMString aMessageClass,
|
void setMessageDelivery(in long aMessageId, in DOMString aDelivery, in DOMString aDeliveryStatus);
|
||||||
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,41 +647,21 @@ SmsDatabaseService.prototype = {
|
||||||
return false;
|
return false;
|
||||||
},
|
},
|
||||||
|
|
||||||
saveMessage: function saveMessage(message, callback) {
|
saveMessage: function saveMessage(message) {
|
||||||
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));
|
||||||
|
|
||||||
let self = this;
|
|
||||||
function notifyResult(rv) {
|
|
||||||
if (!callback) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
let sms = self.createMessageFromRecord(message);
|
|
||||||
callback.notify(rv, sms);
|
|
||||||
}
|
|
||||||
|
|
||||||
this.newTxn(READ_WRITE, function(error, txn, stores) {
|
this.newTxn(READ_WRITE, function(error, txn, stores) {
|
||||||
if (error) {
|
if (error) {
|
||||||
// TODO bug 832140 check event.target.errorCode
|
|
||||||
notifyResult(Cr.NS_ERROR_FAILURE);
|
|
||||||
return;
|
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 onsuccess(event) {
|
stores[1].get(number).onsuccess = function(event) {
|
||||||
let mostRecentEntry = event.target.result;
|
let mostRecentEntry = event.target.result;
|
||||||
if (mostRecentEntry) {
|
if (mostRecentEntry) {
|
||||||
let needsUpdate = false;
|
let needsUpdate = false;
|
||||||
|
@ -707,7 +687,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;
|
||||||
|
@ -718,11 +698,8 @@ SmsDatabaseService.prototype = {
|
||||||
* nsIRilSmsDatabaseService API
|
* nsIRilSmsDatabaseService API
|
||||||
*/
|
*/
|
||||||
|
|
||||||
saveReceivedMessage: function saveReceivedMessage(
|
saveReceivedMessage: function saveReceivedMessage(aSender, aBody, aMessageClass, aDate) {
|
||||||
aSender, aBody, aMessageClass, aDate, aCallback) {
|
let receiver = this.mRIL.rilContext.icc ? this.mRIL.rilContext.icc.msisdn : null;
|
||||||
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
|
||||||
|
@ -759,14 +736,11 @@ SmsDatabaseService.prototype = {
|
||||||
timestamp: aDate,
|
timestamp: aDate,
|
||||||
read: FILTER_READ_UNREAD
|
read: FILTER_READ_UNREAD
|
||||||
};
|
};
|
||||||
return this.saveMessage(message, aCallback);
|
return this.saveMessage(message);
|
||||||
},
|
},
|
||||||
|
|
||||||
saveSendingMessage: function saveSendingMessage(
|
saveSendingMessage: function saveSendingMessage(aReceiver, aBody, aDate) {
|
||||||
aReceiver, aBody, aDeliveryStatus, aDate, aCallback) {
|
let sender = this.mRIL.rilContext.icc ? this.mRIL.rilContext.icc.msisdn : null;
|
||||||
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
|
||||||
|
@ -774,7 +748,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)
|
||||||
|
@ -795,7 +769,7 @@ SmsDatabaseService.prototype = {
|
||||||
readIndex: [FILTER_READ_READ, aDate],
|
readIndex: [FILTER_READ_READ, aDate],
|
||||||
|
|
||||||
delivery: DELIVERY_SENDING,
|
delivery: DELIVERY_SENDING,
|
||||||
deliveryStatus: aDeliveryStatus,
|
deliveryStatus: DELIVERY_STATUS_PENDING,
|
||||||
sender: sender,
|
sender: sender,
|
||||||
receiver: receiver,
|
receiver: receiver,
|
||||||
body: aBody,
|
body: aBody,
|
||||||
|
@ -803,46 +777,23 @@ SmsDatabaseService.prototype = {
|
||||||
timestamp: aDate,
|
timestamp: aDate,
|
||||||
read: FILTER_READ_READ
|
read: FILTER_READ_READ
|
||||||
};
|
};
|
||||||
return this.saveMessage(message, aCallback);
|
return this.saveMessage(message);
|
||||||
},
|
},
|
||||||
|
|
||||||
setMessageDelivery: function setMessageDelivery(
|
setMessageDelivery: function setMessageDelivery(messageId, delivery, deliveryStatus) {
|
||||||
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);
|
||||||
}
|
}
|
||||||
|
|
||||||
let self = this;
|
|
||||||
let message;
|
|
||||||
function notifyResult(rv) {
|
|
||||||
if (!callback) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
let sms = null;
|
|
||||||
if (message) {
|
|
||||||
sms = self.createMessageFromRecord(message);
|
|
||||||
}
|
|
||||||
callback.notify(rv, sms);
|
|
||||||
}
|
|
||||||
|
|
||||||
this.newTxn(READ_WRITE, function (error, txn, store) {
|
this.newTxn(READ_WRITE, function (error, txn, store) {
|
||||||
if (error) {
|
if (error) {
|
||||||
// TODO bug 832140 check event.target.errorCode
|
if (DEBUG) debug(error);
|
||||||
notifyResult(Cr.NS_ERROR_FAILURE);
|
|
||||||
return;
|
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) {
|
||||||
message = event.target.result;
|
let 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;
|
||||||
|
|
|
@ -6,17 +6,17 @@ MARIONETTE_TIMEOUT = 10000;
|
||||||
SpecialPowers.setBoolPref("dom.sms.enabled", true);
|
SpecialPowers.setBoolPref("dom.sms.enabled", true);
|
||||||
SpecialPowers.addPermission("sms", true, document);
|
SpecialPowers.addPermission("sms", true, document);
|
||||||
|
|
||||||
const REMOTE = "5559997777";
|
|
||||||
const REMOTE_FMT = "+15559997777"; // the normalized remote number
|
|
||||||
const EMU_FMT = "+15555215554"; // the emulator's number
|
|
||||||
|
|
||||||
let sms = window.navigator.mozSms;
|
let sms = window.navigator.mozSms;
|
||||||
|
let myNumber = "15555215554";
|
||||||
|
let myNumberFormats = ["15555215554", "+15555215554"];
|
||||||
let inText = "Incoming SMS message. Mozilla Firefox OS!";
|
let inText = "Incoming SMS message. Mozilla Firefox OS!";
|
||||||
|
let remoteNumber = "5559997777";
|
||||||
|
let remoteNumberFormats = ["5559997777", "+15559997777"];
|
||||||
let outText = "Outgoing SMS message. Mozilla Firefox OS!";
|
let outText = "Outgoing SMS message. Mozilla Firefox OS!";
|
||||||
let gotSmsOnsent = false;
|
let gotSmsOnsent = false;
|
||||||
let gotReqOnsuccess = false;
|
let gotReqOnsuccess = false;
|
||||||
let inSmsId = 0;
|
let inSmsid = 0;
|
||||||
let outSmsId = 0;
|
let outSmsid = 0;
|
||||||
let inSmsTimeStamp;
|
let inSmsTimeStamp;
|
||||||
let outSmsTimeStamp;
|
let outSmsTimeStamp;
|
||||||
|
|
||||||
|
@ -26,6 +26,10 @@ function verifyInitialState() {
|
||||||
simulateIncomingSms();
|
simulateIncomingSms();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function isIn(aVal, aArray, aMsg) {
|
||||||
|
ok(aArray.indexOf(aVal) >= 0, aMsg);
|
||||||
|
}
|
||||||
|
|
||||||
function simulateIncomingSms() {
|
function simulateIncomingSms() {
|
||||||
log("Simulating incoming SMS.");
|
log("Simulating incoming SMS.");
|
||||||
|
|
||||||
|
@ -40,15 +44,15 @@ function simulateIncomingSms() {
|
||||||
is(incomingSms.delivery, "received", "delivery");
|
is(incomingSms.delivery, "received", "delivery");
|
||||||
is(incomingSms.deliveryStatus, "success", "deliveryStatus");
|
is(incomingSms.deliveryStatus, "success", "deliveryStatus");
|
||||||
is(incomingSms.read, false, "read");
|
is(incomingSms.read, false, "read");
|
||||||
is(incomingSms.receiver, EMU_FMT, "receiver");
|
is(incomingSms.receiver, null, "receiver");
|
||||||
is(incomingSms.sender, REMOTE_FMT, "sender");
|
isIn(incomingSms.sender, remoteNumberFormats, "sender");
|
||||||
is(incomingSms.messageClass, "normal", "messageClass");
|
is(incomingSms.messageClass, "normal", "messageClass");
|
||||||
ok(incomingSms.timestamp instanceof Date, "timestamp is instanceof date");
|
ok(incomingSms.timestamp instanceof Date, "timestamp is instanceof date");
|
||||||
inSmsTimeStamp = incomingSms.timestamp;
|
inSmsTimeStamp = incomingSms.timestamp;
|
||||||
sendSms();
|
sendSms();
|
||||||
};
|
};
|
||||||
// Simulate incoming sms sent from remoteNumber to our emulator
|
// Simulate incoming sms sent from remoteNumber to our emulator
|
||||||
runEmulatorCmd("sms send " + REMOTE + " " + inText, function(result) {
|
runEmulatorCmd("sms send " + remoteNumber + " " + inText, function(result) {
|
||||||
is(result[0], "OK", "emulator output");
|
is(result[0], "OK", "emulator output");
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -67,8 +71,8 @@ function sendSms() {
|
||||||
is(sentSms.delivery, "sent", "delivery");
|
is(sentSms.delivery, "sent", "delivery");
|
||||||
is(sentSms.deliveryStatus, "pending", "deliveryStatus");
|
is(sentSms.deliveryStatus, "pending", "deliveryStatus");
|
||||||
is(sentSms.read, true, "read");
|
is(sentSms.read, true, "read");
|
||||||
is(sentSms.receiver, REMOTE_FMT, "receiver");
|
isIn(sentSms.receiver, remoteNumberFormats, "receiver");
|
||||||
is(sentSms.sender, EMU_FMT, "sender");
|
is(sentSms.sender, null, "sender");
|
||||||
is(sentSms.messageClass, "normal", "messageClass");
|
is(sentSms.messageClass, "normal", "messageClass");
|
||||||
ok(sentSms.timestamp instanceof Date, "timestamp is instanceof date");
|
ok(sentSms.timestamp instanceof Date, "timestamp is instanceof date");
|
||||||
outSmsTimeStamp = sentSms.timestamp;
|
outSmsTimeStamp = sentSms.timestamp;
|
||||||
|
@ -76,7 +80,7 @@ function sendSms() {
|
||||||
if (gotSmsOnsent && gotReqOnsuccess) { getReceivedSms(); }
|
if (gotSmsOnsent && gotReqOnsuccess) { getReceivedSms(); }
|
||||||
};
|
};
|
||||||
|
|
||||||
let requestRet = sms.send(REMOTE, outText);
|
let requestRet = sms.send(remoteNumber, outText);
|
||||||
ok(requestRet, "smsrequest obj returned");
|
ok(requestRet, "smsrequest obj returned");
|
||||||
|
|
||||||
requestRet.onsuccess = function(event) {
|
requestRet.onsuccess = function(event) {
|
||||||
|
@ -116,8 +120,8 @@ function getReceivedSms() {
|
||||||
is(foundSms.delivery, "received", "delivery");
|
is(foundSms.delivery, "received", "delivery");
|
||||||
is(foundSms.deliveryStatus, "success", "deliveryStatus");
|
is(foundSms.deliveryStatus, "success", "deliveryStatus");
|
||||||
is(foundSms.read, false, "read");
|
is(foundSms.read, false, "read");
|
||||||
is(foundSms.receiver, EMU_FMT, "receiver");
|
isIn(foundSms.receiver, myNumberFormats, "receiver");
|
||||||
is(foundSms.sender, REMOTE_FMT, "sender");
|
isIn(foundSms.sender, remoteNumberFormats, "sender");
|
||||||
is(foundSms.messageClass, "normal", "messageClass");
|
is(foundSms.messageClass, "normal", "messageClass");
|
||||||
ok(foundSms.timestamp instanceof Date, "timestamp is instanceof date");
|
ok(foundSms.timestamp instanceof Date, "timestamp is instanceof date");
|
||||||
is(foundSms.timestamp.getTime(), inSmsTimeStamp.getTime(), "timestamp matches");
|
is(foundSms.timestamp.getTime(), inSmsTimeStamp.getTime(), "timestamp matches");
|
||||||
|
@ -149,8 +153,8 @@ function getSentSms() {
|
||||||
is(foundSms.delivery, "sent", "delivery");
|
is(foundSms.delivery, "sent", "delivery");
|
||||||
is(foundSms.deliveryStatus, "pending", "deliveryStatus");
|
is(foundSms.deliveryStatus, "pending", "deliveryStatus");
|
||||||
is(foundSms.read, true, "read");
|
is(foundSms.read, true, "read");
|
||||||
is(foundSms.receiver, REMOTE_FMT, "receiver");
|
isIn(foundSms.receiver, remoteNumberFormats, "receiver");
|
||||||
is(foundSms.sender, EMU_FMT, "sender");
|
isIn(foundSms.sender, myNumberFormats, "sender");
|
||||||
is(foundSms.messageClass, "normal", "messageClass");
|
is(foundSms.messageClass, "normal", "messageClass");
|
||||||
ok(foundSms.timestamp instanceof Date, "timestamp is instanceof date");
|
ok(foundSms.timestamp instanceof Date, "timestamp is instanceof date");
|
||||||
is(foundSms.timestamp.getTime(), outSmsTimeStamp.getTime(), "timestamp matches");
|
is(foundSms.timestamp.getTime(), outSmsTimeStamp.getTime(), "timestamp matches");
|
||||||
|
|
|
@ -6,16 +6,13 @@ MARIONETTE_TIMEOUT = 10000;
|
||||||
SpecialPowers.setBoolPref("dom.sms.enabled", true);
|
SpecialPowers.setBoolPref("dom.sms.enabled", true);
|
||||||
SpecialPowers.addPermission("sms", true, document);
|
SpecialPowers.addPermission("sms", true, document);
|
||||||
|
|
||||||
const REMOTE = "5555552368";
|
|
||||||
const SENDER = "+15555552368"; // the normalized remote number
|
|
||||||
const RECEIVER = "+15555215554"; // the emulator's number
|
|
||||||
|
|
||||||
let sms = window.navigator.mozSms;
|
let sms = window.navigator.mozSms;
|
||||||
|
let sender = "5555552368";
|
||||||
let body = "Hello SMS world!";
|
let body = "Hello SMS world!";
|
||||||
let now = Date.now();
|
let now = Date.now();
|
||||||
|
|
||||||
let completed = false;
|
let completed = false;
|
||||||
runEmulatorCmd("sms send " + REMOTE + " " + body, function(result) {
|
runEmulatorCmd("sms send " + sender + " " + body, function(result) {
|
||||||
log("Sent fake SMS: " + result);
|
log("Sent fake SMS: " + result);
|
||||||
is(result[0], "OK");
|
is(result[0], "OK");
|
||||||
completed = true;
|
completed = true;
|
||||||
|
@ -29,8 +26,8 @@ sms.onreceived = function onreceived(event) {
|
||||||
|
|
||||||
is(message.delivery, "received");
|
is(message.delivery, "received");
|
||||||
is(message.deliveryStatus, "success");
|
is(message.deliveryStatus, "success");
|
||||||
is(message.sender, SENDER);
|
is(message.sender, sender);
|
||||||
is(message.receiver, RECEIVER);
|
is(message.receiver, null);
|
||||||
is(message.body, body);
|
is(message.body, body);
|
||||||
is(message.messageClass, "normal");
|
is(message.messageClass, "normal");
|
||||||
ok(message.timestamp instanceof Date);
|
ok(message.timestamp instanceof Date);
|
||||||
|
|
|
@ -6,11 +6,8 @@ MARIONETTE_TIMEOUT = 10000;
|
||||||
SpecialPowers.setBoolPref("dom.sms.enabled", true);
|
SpecialPowers.setBoolPref("dom.sms.enabled", true);
|
||||||
SpecialPowers.addPermission("sms", true, document);
|
SpecialPowers.addPermission("sms", true, document);
|
||||||
|
|
||||||
const REMOTE = "5555552368";
|
|
||||||
const SENDER = "+15555552368"; // the normalized remote number
|
|
||||||
const RECEIVER = "+15555215554"; // the emulator's number
|
|
||||||
|
|
||||||
let sms = window.navigator.mozSms;
|
let sms = window.navigator.mozSms;
|
||||||
|
let fromNumber = "5551234567";
|
||||||
let msgText = "Mozilla Firefox OS!";
|
let msgText = "Mozilla Firefox OS!";
|
||||||
|
|
||||||
function verifyInitialState() {
|
function verifyInitialState() {
|
||||||
|
@ -32,14 +29,14 @@ function simulateIncomingSms() {
|
||||||
is(incomingSms.delivery, "received", "delivery");
|
is(incomingSms.delivery, "received", "delivery");
|
||||||
is(incomingSms.deliveryStatus, "success", "deliveryStatus");
|
is(incomingSms.deliveryStatus, "success", "deliveryStatus");
|
||||||
is(incomingSms.read, false, "read");
|
is(incomingSms.read, false, "read");
|
||||||
is(incomingSms.receiver, RECEIVER, "receiver");
|
is(incomingSms.receiver, null, "receiver");
|
||||||
is(incomingSms.sender, SENDER, "sender");
|
is(incomingSms.sender, fromNumber, "sender");
|
||||||
is(incomingSms.messageClass, "normal", "messageClass");
|
is(incomingSms.messageClass, "normal", "messageClass");
|
||||||
ok(incomingSms.timestamp instanceof Date, "timestamp is istanceof date");
|
ok(incomingSms.timestamp instanceof Date, "timestamp is istanceof date");
|
||||||
|
|
||||||
verifySmsExists(incomingSms);
|
verifySmsExists(incomingSms);
|
||||||
};
|
};
|
||||||
runEmulatorCmd("sms send " + REMOTE + " " + msgText, function(result) {
|
runEmulatorCmd("sms send " + fromNumber + " " + msgText, function(result) {
|
||||||
is(result[0], "OK", "emulator output");
|
is(result[0], "OK", "emulator output");
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -55,12 +52,6 @@ function verifySmsExists(incomingSms) {
|
||||||
let foundSms = event.target.result;
|
let foundSms = event.target.result;
|
||||||
is(foundSms.id, incomingSms.id, "found SMS id matches");
|
is(foundSms.id, incomingSms.id, "found SMS id matches");
|
||||||
is(foundSms.body, msgText, "found SMS msg text matches");
|
is(foundSms.body, msgText, "found SMS msg text matches");
|
||||||
is(foundSms.delivery, "received", "delivery");
|
|
||||||
is(foundSms.deliveryStatus, "success", "deliveryStatus");
|
|
||||||
is(foundSms.read, false, "read");
|
|
||||||
is(foundSms.receiver, RECEIVER, "receiver");
|
|
||||||
is(foundSms.sender, SENDER, "sender");
|
|
||||||
is(foundSms.messageClass, "normal", "messageClass");
|
|
||||||
log("Got SMS (id: " + foundSms.id + ") as expected.");
|
log("Got SMS (id: " + foundSms.id + ") as expected.");
|
||||||
deleteSms(incomingSms);
|
deleteSms(incomingSms);
|
||||||
};
|
};
|
||||||
|
|
|
@ -6,10 +6,6 @@ MARIONETTE_TIMEOUT = 10000;
|
||||||
SpecialPowers.setBoolPref("dom.sms.enabled", true);
|
SpecialPowers.setBoolPref("dom.sms.enabled", true);
|
||||||
SpecialPowers.addPermission("sms", true, document);
|
SpecialPowers.addPermission("sms", true, document);
|
||||||
|
|
||||||
const REMOTE = "5555552368";
|
|
||||||
const SENDER = "+15555552368"; // the normalized remote number
|
|
||||||
const RECEIVER = "+15555215554"; // the emulator's number
|
|
||||||
|
|
||||||
let sms = window.navigator.mozSms;
|
let sms = window.navigator.mozSms;
|
||||||
|
|
||||||
function verifyInitialState() {
|
function verifyInitialState() {
|
||||||
|
@ -19,6 +15,7 @@ function verifyInitialState() {
|
||||||
}
|
}
|
||||||
|
|
||||||
function simulateIncomingSms() {
|
function simulateIncomingSms() {
|
||||||
|
let fromNumber = "5551234567";
|
||||||
let msgText = "";
|
let msgText = "";
|
||||||
|
|
||||||
log("Simulating incoming SMS.");
|
log("Simulating incoming SMS.");
|
||||||
|
@ -37,13 +34,13 @@ function simulateIncomingSms() {
|
||||||
is(incomingSms.body, msgText, "msg body");
|
is(incomingSms.body, msgText, "msg body");
|
||||||
is(incomingSms.delivery, "received", "delivery");
|
is(incomingSms.delivery, "received", "delivery");
|
||||||
is(incomingSms.read, false, "read");
|
is(incomingSms.read, false, "read");
|
||||||
is(incomingSms.receiver, RECEIVER, "receiver");
|
is(incomingSms.receiver, null, "receiver");
|
||||||
is(incomingSms.sender, SENDER, "sender");
|
is(incomingSms.sender, fromNumber, "sender");
|
||||||
ok(incomingSms.timestamp instanceof Date, "timestamp is istanceof date");
|
ok(incomingSms.timestamp instanceof Date, "timestamp is istanceof date");
|
||||||
|
|
||||||
verifySmsExists(incomingSms);
|
verifySmsExists(incomingSms);
|
||||||
};
|
};
|
||||||
runEmulatorCmd("sms send " + REMOTE + " " + msgText, function(result) {
|
runEmulatorCmd("sms send " + fromNumber + " " + msgText, function(result) {
|
||||||
is(result[0], "OK", "emulator output");
|
is(result[0], "OK", "emulator output");
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -59,10 +56,6 @@ function verifySmsExists(incomingSms) {
|
||||||
let foundSms = event.target.result;
|
let foundSms = event.target.result;
|
||||||
is(foundSms.id, incomingSms.id, "found SMS id matches");
|
is(foundSms.id, incomingSms.id, "found SMS id matches");
|
||||||
is(foundSms.body, incomingSms.body, "found SMS msg text matches");
|
is(foundSms.body, incomingSms.body, "found SMS msg text matches");
|
||||||
is(foundSms.delivery, "received", "delivery");
|
|
||||||
is(foundSms.read, false, "read");
|
|
||||||
is(foundSms.receiver, RECEIVER, "receiver");
|
|
||||||
is(foundSms.sender, SENDER, "sender");
|
|
||||||
log("Got SMS (id: " + foundSms.id + ") as expected.");
|
log("Got SMS (id: " + foundSms.id + ") as expected.");
|
||||||
deleteSms(incomingSms);
|
deleteSms(incomingSms);
|
||||||
};
|
};
|
||||||
|
|
|
@ -7,8 +7,6 @@ SpecialPowers.setBoolPref("dom.sms.enabled", true);
|
||||||
SpecialPowers.setBoolPref("dom.sms.strict7BitEncoding", false);
|
SpecialPowers.setBoolPref("dom.sms.strict7BitEncoding", false);
|
||||||
SpecialPowers.addPermission("sms", true, document);
|
SpecialPowers.addPermission("sms", true, document);
|
||||||
|
|
||||||
const SENDER = "+15555215554"; // the emulator's number
|
|
||||||
|
|
||||||
let sms = window.navigator.mozSms;
|
let sms = window.navigator.mozSms;
|
||||||
const SHORT_BODY = "Hello SMS world!";
|
const SHORT_BODY = "Hello SMS world!";
|
||||||
const LONG_BODY = "Let me not to the marriage of true minds\n"
|
const LONG_BODY = "Let me not to the marriage of true minds\n"
|
||||||
|
@ -34,7 +32,7 @@ function checkMessage(message, delivery, body) {
|
||||||
ok(message.id, "message.id");
|
ok(message.id, "message.id");
|
||||||
is(message.delivery, delivery, "message.delivery");
|
is(message.delivery, delivery, "message.delivery");
|
||||||
is(message.deliveryStatus, "pending", "message.deliveryStatus");
|
is(message.deliveryStatus, "pending", "message.deliveryStatus");
|
||||||
is(message.sender, SENDER, "message.sender");
|
is(message.sender, null, "message.sender");
|
||||||
ok(message.receiver, "message.receiver");
|
ok(message.receiver, "message.receiver");
|
||||||
is(message.body, body, "message.body");
|
is(message.body, body, "message.body");
|
||||||
is(message.messageClass, "normal", "message.messageClass");
|
is(message.messageClass, "normal", "message.messageClass");
|
||||||
|
|
|
@ -6,11 +6,8 @@ MARIONETTE_TIMEOUT = 10000;
|
||||||
SpecialPowers.setBoolPref("dom.sms.enabled", true);
|
SpecialPowers.setBoolPref("dom.sms.enabled", true);
|
||||||
SpecialPowers.addPermission("sms", true, document);
|
SpecialPowers.addPermission("sms", true, document);
|
||||||
|
|
||||||
const SENDER = "+15555215554"; // the emulator's number
|
|
||||||
const DEST = "5551117777";
|
|
||||||
const RECEIVER = "+15551117777"; // normalized destination number
|
|
||||||
|
|
||||||
let sms = window.navigator.mozSms;
|
let sms = window.navigator.mozSms;
|
||||||
|
let destNumber = "5551117777";
|
||||||
let msgText = "Mozilla Firefox OS!";
|
let msgText = "Mozilla Firefox OS!";
|
||||||
let gotSmsOnsent = false;
|
let gotSmsOnsent = false;
|
||||||
let gotReqOnsuccess = false;
|
let gotReqOnsuccess = false;
|
||||||
|
@ -37,15 +34,15 @@ function sendSms() {
|
||||||
is(sentSms.delivery, "sent", "delivery");
|
is(sentSms.delivery, "sent", "delivery");
|
||||||
is(sentSms.deliveryStatus, "pending", "deliveryStatus");
|
is(sentSms.deliveryStatus, "pending", "deliveryStatus");
|
||||||
is(sentSms.read, true, "read");
|
is(sentSms.read, true, "read");
|
||||||
is(sentSms.receiver, RECEIVER, "receiver");
|
is(sentSms.receiver, destNumber, "receiver");
|
||||||
is(sentSms.sender, SENDER, "sender");
|
is(sentSms.sender, null, "sender");
|
||||||
is(sentSms.messageClass, "normal", "messageClass");
|
is(sentSms.messageClass, "normal", "messageClass");
|
||||||
ok(sentSms.timestamp instanceof Date, "timestamp is istanceof date");
|
ok(sentSms.timestamp instanceof Date, "timestamp is istanceof date");
|
||||||
|
|
||||||
if (gotSmsOnsent && gotReqOnsuccess) { verifySmsExists(smsId); }
|
if (gotSmsOnsent && gotReqOnsuccess) { verifySmsExists(smsId); }
|
||||||
};
|
};
|
||||||
|
|
||||||
let requestRet = sms.send(DEST, msgText);
|
let requestRet = sms.send(destNumber, msgText);
|
||||||
ok(requestRet, "smsrequest obj returned");
|
ok(requestRet, "smsrequest obj returned");
|
||||||
|
|
||||||
requestRet.onsuccess = function(event) {
|
requestRet.onsuccess = function(event) {
|
||||||
|
@ -80,11 +77,6 @@ function verifySmsExists(smsId) {
|
||||||
let foundSms = event.target.result;
|
let foundSms = event.target.result;
|
||||||
is(foundSms.id, smsId, "found SMS id matches");
|
is(foundSms.id, smsId, "found SMS id matches");
|
||||||
is(foundSms.body, msgText, "found SMS msg text matches");
|
is(foundSms.body, msgText, "found SMS msg text matches");
|
||||||
is(foundSms.delivery, "sent", "delivery");
|
|
||||||
is(foundSms.read, true, "read");
|
|
||||||
is(foundSms.receiver, RECEIVER, "receiver");
|
|
||||||
is(foundSms.sender, SENDER, "sender");
|
|
||||||
is(foundSms.messageClass, "normal", "messageClass");
|
|
||||||
log("Got SMS (id: " + foundSms.id + ") as expected.");
|
log("Got SMS (id: " + foundSms.id + ") as expected.");
|
||||||
deleteSms(smsId);
|
deleteSms(smsId);
|
||||||
};
|
};
|
||||||
|
|
|
@ -1380,47 +1380,14 @@ RadioInterfaceLayer.prototype = {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
let notifyReceived = function notifyReceived(rv, sms) {
|
let id = -1;
|
||||||
let success = Components.isSuccessCode(rv);
|
|
||||||
|
|
||||||
// Acknowledge the reception of the SMS.
|
|
||||||
message.rilMessageType = "ackSMS";
|
|
||||||
if (!success) {
|
|
||||||
message.result = RIL.PDU_FCS_MEMORY_CAPACITY_EXCEEDED;
|
|
||||||
}
|
|
||||||
this.worker.postMessage(message);
|
|
||||||
|
|
||||||
if (!success) {
|
|
||||||
// At this point we could send a message to content to notify the user
|
|
||||||
// that storing an incoming SMS failed, most likely due to a full disk.
|
|
||||||
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]) {
|
if (message.messageClass != RIL.GECKO_SMS_MESSAGE_CLASSES[RIL.PDU_DCS_MSG_CLASS_0]) {
|
||||||
message.id = gSmsDatabaseService.saveReceivedMessage(
|
id = gSmsDatabaseService.saveReceivedMessage(message.sender || null,
|
||||||
message.sender || null,
|
|
||||||
message.fullBody || null,
|
message.fullBody || null,
|
||||||
message.messageClass,
|
message.messageClass,
|
||||||
message.timestamp,
|
message.timestamp);
|
||||||
notifyReceived);
|
}
|
||||||
} else {
|
let sms = gSmsService.createSmsMessage(id,
|
||||||
message.id = -1;
|
|
||||||
let sms = gSmsService.createSmsMessage(message.id,
|
|
||||||
DOM_SMS_DELIVERY_RECEIVED,
|
DOM_SMS_DELIVERY_RECEIVED,
|
||||||
RIL.GECKO_SMS_DELIVERY_STATUS_SUCCESS,
|
RIL.GECKO_SMS_DELIVERY_STATUS_SUCCESS,
|
||||||
message.sender || null,
|
message.sender || null,
|
||||||
|
@ -1429,8 +1396,18 @@ RadioInterfaceLayer.prototype = {
|
||||||
message.messageClass,
|
message.messageClass,
|
||||||
message.timestamp,
|
message.timestamp,
|
||||||
false);
|
false);
|
||||||
notifyReceived(Cr.NS_OK, sms);
|
|
||||||
}
|
gSystemMessenger.broadcastMessage("sms-received",
|
||||||
|
{id: 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);
|
||||||
},
|
},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -1457,10 +1434,19 @@ 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,
|
||||||
function notifyResult(rv, sms) {
|
null,
|
||||||
//TODO bug 832140 handle !Components.isSuccessCode(rv)
|
options.sms.receiver,
|
||||||
|
options.sms.body,
|
||||||
|
options.sms.messageClass,
|
||||||
|
options.sms.timestamp,
|
||||||
|
true);
|
||||||
|
|
||||||
gSystemMessenger.broadcastMessage("sms-sent",
|
gSystemMessenger.broadcastMessage("sms-sent",
|
||||||
{id: options.sms.id,
|
{id: options.sms.id,
|
||||||
delivery: DOM_SMS_DELIVERY_SENT,
|
delivery: DOM_SMS_DELIVERY_SENT,
|
||||||
|
@ -1482,7 +1468,6 @@ RadioInterfaceLayer.prototype = {
|
||||||
options.request.notifyMessageSent(sms);
|
options.request.notifyMessageSent(sms);
|
||||||
|
|
||||||
Services.obs.notifyObservers(sms, kSmsSentObserverTopic, null);
|
Services.obs.notifyObservers(sms, kSmsSentObserverTopic, null);
|
||||||
}.bind(this));
|
|
||||||
},
|
},
|
||||||
|
|
||||||
handleSmsDelivery: function handleSmsDelivery(message) {
|
handleSmsDelivery: function handleSmsDelivery(message) {
|
||||||
|
@ -1495,15 +1480,23 @@ 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,
|
||||||
function notifyResult(rv, sms) {
|
null,
|
||||||
//TODO bug 832140 handle !Components.isSuccessCode(rv)
|
options.sms.receiver,
|
||||||
|
options.sms.body,
|
||||||
|
options.sms.messageClass,
|
||||||
|
options.sms.timestamp,
|
||||||
|
true);
|
||||||
|
|
||||||
let topic = (message.deliveryStatus == RIL.GECKO_SMS_DELIVERY_STATUS_SUCCESS)
|
let topic = (message.deliveryStatus == RIL.GECKO_SMS_DELIVERY_STATUS_SUCCESS)
|
||||||
? kSmsDeliverySuccessObserverTopic
|
? kSmsDeliverySuccessObserverTopic
|
||||||
: kSmsDeliveryErrorObserverTopic;
|
: kSmsDeliveryErrorObserverTopic;
|
||||||
Services.obs.notifyObservers(sms, topic, null);
|
Services.obs.notifyObservers(sms, topic, null);
|
||||||
});
|
|
||||||
},
|
},
|
||||||
|
|
||||||
handleSmsSendFailed: function handleSmsSendFailed(message) {
|
handleSmsSendFailed: function handleSmsSendFailed(message) {
|
||||||
|
@ -1523,13 +1516,22 @@ 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,
|
||||||
function notifyResult(rv, sms) {
|
null,
|
||||||
//TODO bug 832140 handle !Components.isSuccessCode(rv)
|
options.sms.receiver,
|
||||||
|
options.sms.body,
|
||||||
|
options.sms.messageClass,
|
||||||
|
options.sms.timestamp,
|
||||||
|
true);
|
||||||
|
|
||||||
options.request.notifySendMessageFailed(error);
|
options.request.notifySendMessageFailed(error);
|
||||||
|
|
||||||
Services.obs.notifyObservers(sms, kSmsFailedObserverTopic, null);
|
Services.obs.notifyObservers(sms, kSmsFailedObserverTopic, null);
|
||||||
});
|
|
||||||
},
|
},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -2443,22 +2445,28 @@ 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 id = gSmsDatabaseService.saveSendingMessage(number, message, deliveryStatus, timestamp,
|
let sms = gSmsService.createSmsMessage(id,
|
||||||
function notifyResult(rv, sms) {
|
DOM_SMS_DELIVERY_SENDING,
|
||||||
//TODO bug 832140 handle !Components.isSuccessCode(rv)
|
deliveryStatus,
|
||||||
|
null,
|
||||||
|
number,
|
||||||
|
message,
|
||||||
|
messageClass,
|
||||||
|
timestamp,
|
||||||
|
true);
|
||||||
Services.obs.notifyObservers(sms, kSmsSendingObserverTopic, null);
|
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({
|
options.envelopeId = this.createSmsEnvelope({request: request,
|
||||||
request: request,
|
|
||||||
sms: sms,
|
sms: sms,
|
||||||
requestStatusReport: options.requestStatusReport
|
requestStatusReport: options.requestStatusReport});
|
||||||
});
|
|
||||||
this.worker.postMessage(options);
|
this.worker.postMessage(options);
|
||||||
}.bind(this));
|
|
||||||
},
|
},
|
||||||
|
|
||||||
registerDataCallCallback: function registerDataCallCallback(callback) {
|
registerDataCallCallback: function registerDataCallCallback(callback) {
|
||||||
|
|
|
@ -1207,11 +1207,6 @@ 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,19 +1713,6 @@ 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;
|
||||||
|
@ -3523,7 +3510,6 @@ 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
|
||||||
|
@ -3563,18 +3549,14 @@ 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);
|
||||||
|
}
|
||||||
|
|
||||||
// We will acknowledge receipt of the SMS after we try to store it
|
if (message && message.messageClass == GECKO_SMS_MESSAGE_CLASSES[PDU_DCS_MSG_CLASS_2]) {
|
||||||
// in the database.
|
// `MS shall ensure that the message has been to the SMS data field in
|
||||||
return MOZ_FCS_WAIT_FOR_EXPLICIT_ACK;
|
// the (U)SIM before sending an ACK to the SC.` ~ 3GPP 23.038 clause 4
|
||||||
|
return PDU_FCS_RESERVED;
|
||||||
}
|
}
|
||||||
|
|
||||||
return PDU_FCS_OK;
|
return PDU_FCS_OK;
|
||||||
|
@ -4982,11 +4964,10 @@ 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 || result == MOZ_FCS_WAIT_FOR_EXPLICIT_ACK) {
|
if (result != PDU_FCS_RESERVED) {
|
||||||
return;
|
|
||||||
}
|
|
||||||
// Not reserved FCS values, send ACK now.
|
// Not reserved FCS values, send ACK now.
|
||||||
this.acknowledgeSMS(result == PDU_FCS_OK, result);
|
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);
|
||||||
|
|
Загрузка…
Ссылка в новой задаче