Sms sent to wrong recipient
Remove the empty conversation from the conversation cache.
Bug 3057952
Change-Id: I89d0a6445ae9126b51da3cc4bce929ba05e97853
diff --git a/src/com/android/mms/data/WorkingMessage.java b/src/com/android/mms/data/WorkingMessage.java
index 2cbb6b0..00c0e2c 100644
--- a/src/com/android/mms/data/WorkingMessage.java
+++ b/src/com/android/mms/data/WorkingMessage.java
@@ -756,11 +756,7 @@
asyncDelete(mMessageUri, null, null);
}
- // Delete any draft messages associated with this conversation.
- asyncDeleteDraftSmsMessage(mConversation);
-
- // Update state of the draft cache.
- mConversation.setDraftState(false);
+ clearConversation(mConversation);
}
public void unDiscard() {
@@ -1306,21 +1302,23 @@
// we will lose track of the original draft and be unable to delete
// it later. The message will be re-saved if necessary upon exit of
// the activity.
- asyncDeleteDraftSmsMessage(conv);
-
- if (DEBUG) LogTag.debug("readDraftSmsMessage calling clearThreadId");
- conv.clearThreadId();
-
- // since we removed the draft message in the db, and the conversation no longer
- // has a thread id, let's clear the draft state for 'thread_id' in the draft cache.
- // Otherwise if a new message arrives it could be assigned the same thread id, and
- // we'd mistaken it for a draft due to the stale draft cache.
- conv.setDraftState(false);
+ clearConversation(conv);
}
return body;
}
+ private void clearConversation(final Conversation conv) {
+ asyncDeleteDraftSmsMessage(conv);
+
+ if (conv.getMessageCount() == 0) {
+ if (DEBUG) LogTag.debug("clearConversation calling clearThreadId");
+ conv.clearThreadId();
+ }
+
+ conv.setDraftState(false);
+ }
+
private void asyncUpdateDraftSmsMessage(final Conversation conv, final String contents) {
new Thread(new Runnable() {
public void run() {