From 69b9ec3855c47154dedf6315a3cfd86190bc95a6 Mon Sep 17 00:00:00 2001 From: Yoshi Huang Date: Sat, 17 Mar 2012 22:23:17 +0800 Subject: [PATCH] Bug 733266 - B2G SMS DB: Use MSISDN from RIL as own phone number. [r=philikon] DONTBUILD because NPOTB --- dom/sms/src/ril/SmsDatabaseService.js | 10 ++++++++-- dom/system/gonk/RadioInterfaceLayer.js | 4 ++++ dom/system/gonk/ril_worker.js | 3 ++- 3 files changed, 14 insertions(+), 3 deletions(-) diff --git a/dom/sms/src/ril/SmsDatabaseService.js b/dom/sms/src/ril/SmsDatabaseService.js index 880466f9942..39dab2116b6 100644 --- a/dom/sms/src/ril/SmsDatabaseService.js +++ b/dom/sms/src/ril/SmsDatabaseService.js @@ -318,7 +318,7 @@ SmsDatabaseService.prototype = { saveReceivedMessage: function saveReceivedMessage(sender, body, date) { let message = {delivery: DELIVERY_RECEIVED, sender: sender, - receiver: null, //TODO see bug 733266 + receiver: this.mRIL.radioState.msisdn, body: body, timestamp: date}; return this.saveMessage(message); @@ -326,7 +326,7 @@ SmsDatabaseService.prototype = { saveSentMessage: function saveSentMessage(receiver, body, date) { let message = {delivery: DELIVERY_SENT, - sender: null, //TODO see bug 733266 + sender: this.mRIL.radioState.msisdn, receiver: receiver, body: body, timestamp: date}; @@ -603,6 +603,12 @@ SmsDatabaseService.prototype = { }; +XPCOMUtils.defineLazyGetter(SmsDatabaseService.prototype, "mRIL", function () { + return Cc["@mozilla.org/telephony/system-worker-manager;1"] + .getService(Ci.nsIInterfaceRequestor) + .getInterface(Ci.nsIRadioInterfaceLayer); +}); + const NSGetFactory = XPCOMUtils.generateNSGetFactory([SmsDatabaseService]); function debug() { diff --git a/dom/system/gonk/RadioInterfaceLayer.js b/dom/system/gonk/RadioInterfaceLayer.js index 85b0ad8c699..7decb81ee87 100644 --- a/dom/system/gonk/RadioInterfaceLayer.js +++ b/dom/system/gonk/RadioInterfaceLayer.js @@ -150,6 +150,7 @@ function RadioInterfaceLayer() { bars: null, operator: null, type: null, + msisdn: null, }; } RadioInterfaceLayer.prototype = { @@ -278,6 +279,9 @@ RadioInterfaceLayer.prototype = { + " timestamp=" + message.localTimeStampInMS); } break; + case "siminfo": + this.radioState.msisdn = message.msisdn; + break; default: throw new Error("Don't know about this message type: " + message.type); } diff --git a/dom/system/gonk/ril_worker.js b/dom/system/gonk/ril_worker.js index 29bfad85f34..da3f5eec1b1 100644 --- a/dom/system/gonk/ril_worker.js +++ b/dom/system/gonk/ril_worker.js @@ -1268,7 +1268,8 @@ let RIL = { // Ignore 2 bytes prefix, which is 4 chars let number = GsmPDUHelper.readStringAsBCD().toString().substr(4); if (DEBUG) debug("MSISDN: " + number); - this.MSISDN = number; + this.MSISDN = number || null; + this.sendDOMMessage({type: "siminfo", msisdn: this.MSISDN}); break; } },