MMS creates a new thread when receiver is not in the Message thread
Bug 7334111
The bug is due to the phone not knowing its own number and hence, not being
able to remove the phone's own number from the list of recipients. The simple
fix for one-to-one chats is to not add the TO recipients when there's only
one recipient, because we know that's going to be ourself.
Change-Id: Iec54949e53c350974b8291e389f61b323f1b23f2
diff --git a/src/java/com/google/android/mms/pdu/PduPersister.java b/src/java/com/google/android/mms/pdu/PduPersister.java
index 7178c6c..7e68b21 100644
--- a/src/java/com/google/android/mms/pdu/PduPersister.java
+++ b/src/java/com/google/android/mms/pdu/PduPersister.java
@@ -1323,11 +1323,14 @@
switch (msgType) {
case PduHeaders.MESSAGE_TYPE_NOTIFICATION_IND:
case PduHeaders.MESSAGE_TYPE_RETRIEVE_CONF:
- // For received messages, we want to associate this message with the thread
- // composed of all the recipients. This includes the person who sent the
- // message or the FROM field in addition to the other people the message
- // was addressed to or the TO field.
loadRecipients(PduHeaders.FROM, recipients, addressMap, false);
+
+ // For received messages when group MMS is enabled, we want to associate this
+ // message with the thread composed of all the recipients -- all but our own
+ // number, that is. This includes the person who sent the
+ // message or the FROM field (above) in addition to the other people the message
+ // was addressed to or the TO field. Our own number is in that TO field and
+ // we have to ignore it in loadRecipients.
if (groupMmsEnabled) {
loadRecipients(PduHeaders.TO, recipients, addressMap, true);
}
@@ -1436,6 +1439,11 @@
if (array == null) {
return;
}
+ // If the TO recipients is only a single address, then we can skip loadRecipients when
+ // we're excluding our own number because we know that address is our own.
+ if (excludeMyNumber && array.length == 1) {
+ return;
+ }
String myNumber = excludeMyNumber ? mTelephonyManager.getLine1Number() : null;
for (EncodedStringValue v : array) {
if (v != null) {