bug #2780967: fix SMS sending message to the wrong person.

- there is an edge case where an old draft message (but w/ only recipient entered, no draft message) would confuse Compose activity to think it's the same
thread_id as a new message (coming into onNewIntent() from status notification). In that case, we don't re-initialize mConversation, which retained the old draft recipient

When the user sends a new message in that state, the message would be addressed to the old draft recipient instead of what's appearing in the UI.

Change-Id: Ic78c4343dc1d9a1639f586dcc8ac861adf73f44f
diff --git a/src/com/android/mms/ui/ComposeMessageActivity.java b/src/com/android/mms/ui/ComposeMessageActivity.java
index 78945ac..6364dfa 100644
--- a/src/com/android/mms/ui/ComposeMessageActivity.java
+++ b/src/com/android/mms/ui/ComposeMessageActivity.java
@@ -1826,17 +1826,23 @@
             log("     new conversation=" + conversation + ", mConversation=" + mConversation);
         }
 
-        long convThreadId = 0;
         if (conversation != null) {
             // Don't let any markAsRead DB updates occur before we've loaded the messages for
             // the thread.
             conversation.blockMarkAsRead(true);
-            convThreadId = conversation.getThreadId();
+
+            // this is probably paranoia to compare both thread_ids and recipient lists,
+            // but we want to make double sure because this is a last minute fix for Froyo
+            // and the previous code checked thread ids only.
+            // (we cannot just compare thread ids because there is a case where mConversation
+            // has a stale/obsolete thread id (=1) that could collide against the new thread_id(=1),
+            // even though the recipient lists are different)
+            sameThread = (conversation.getThreadId() == mConversation.getThreadId() &&
+                    conversation.equals(mConversation));
         }
-        if (sameThread || (convThreadId != 0 && convThreadId == mConversation.getThreadId())) {
-            if (Log.isLoggable(LogTag.APP, Log.VERBOSE)) {
-                log("onNewIntent: same conversation");
-            }
+
+        if (sameThread) {
+            log("onNewIntent: same conversation");
         } else {
             if (Log.isLoggable(LogTag.APP, Log.VERBOSE)) {
                 log("onNewIntent: different conversation, initialize...");
@@ -2945,7 +2951,7 @@
         if (Log.isLoggable(LogTag.APP, Log.VERBOSE)) {
             log("startMsgListQuery for " + conversationUri);
         }
-        
+
         // Cancel any pending queries
         mBackgroundQueryHandler.cancelOperation(MESSAGE_LIST_QUERY_TOKEN);
         try {