From a74478ffb247b006aaf9e335a721f2291221798e Mon Sep 17 00:00:00 2001 From: Gene Lian Date: Tue, 25 Jun 2013 20:57:57 +0800 Subject: [PATCH] Bug 886767 - [MMS] Disable grouping functionality when receiving a MMS (temporarily) and keep it for sending. r=vicamo,ctai a=leo+ --- .../src/ril/MobileMessageDatabaseService.js | 34 +++++++++++++------ 1 file changed, 23 insertions(+), 11 deletions(-) diff --git a/dom/mobilemessage/src/ril/MobileMessageDatabaseService.js b/dom/mobilemessage/src/ril/MobileMessageDatabaseService.js index 3104891f0489..4a4371ed3e0f 100644 --- a/dom/mobilemessage/src/ril/MobileMessageDatabaseService.js +++ b/dom/mobilemessage/src/ril/MobileMessageDatabaseService.js @@ -20,6 +20,9 @@ const RIL_GETTHREADSCURSOR_CID = Components.ID("{95ee7c3e-d6f2-4ec4-ade5-0c453c036d35}"); const DEBUG = false; +const DISABLE_MMS_GROUPING_FOR_RECEIVING = true; + + const DB_NAME = "sms"; const DB_VERSION = 11; const MESSAGE_STORE_NAME = "sms"; @@ -1133,13 +1136,15 @@ MobileMessageDatabaseService.prototype = { let self = this.getRilIccInfoMsisdn(); let threadParticipants = [aMessage.sender]; if (aMessage.type == "sms") { - // TODO Bug 853384 - for some SIMs we cannot retrieve the vaild - // phone number, thus setting the SMS' receiver to be null. + // For some SIMs we cannot retrieve the vaild MSISDN (i.e. the user's own + // phone number), thus setting the SMS' receiver to be null. aMessage.receiver = self; - } else if (aMessage.type == "mms") { + } else if (aMessage.type == "mms" && !DISABLE_MMS_GROUPING_FOR_RECEIVING) { let receivers = aMessage.receivers; - // We need to add the receivers (excluding our own) into the participants - // of a thread. Some cases we might encounter here: + // If we don't want to disable the MMS grouping for receiving, we need to + // add the receivers (excluding the user's own number) to the participants + // for creating the thread. Some cases might be investigated as below: + // // 1. receivers.length == 0 // This usually happens when receiving an MMS notification indication // which doesn't carry any receivers. @@ -1148,18 +1153,25 @@ MobileMessageDatabaseService.prototype = { // add it into participants because we know that number is our own. // 3. receivers.length >= 2 // If the receivers contain multiple phone numbers, we need to add all - // of them but not our own into participants. + // of them but not the user's own number into participants. if (receivers.length >= 2) { - // TODO Bug 853384 - for some SIM cards, the phone number might not be - // available, so we cannot correcly exclude our own from the receivers, - // thus wrongly building the thread index. + let isSuccess = false; let slicedReceivers = receivers.slice(); if (self) { let found = slicedReceivers.indexOf(self); if (found !== -1) { + isSuccess = true; slicedReceivers.splice(found, 1); } } + + 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. + if (DEBUG) debug("Error! Cannot strip out user's own phone number!"); + } + threadParticipants = threadParticipants.concat(slicedReceivers); } } @@ -1220,8 +1232,8 @@ MobileMessageDatabaseService.prototype = { } } - // TODO Bug 853384 - for some SIMs we cannot retrieve the vaild - // phone number, thus setting the message's sender to be null. + // For some SIMs we cannot retrieve the vaild MSISDN (i.e. the user's own + // phone number), thus setting the message's sender to be null. aMessage.sender = this.getRilIccInfoMsisdn(); let timestamp = aMessage.timestamp;