merge from open-source master
Change-Id: Ie2616d4bbc9f1f545accbf043176b698e2e7dc3f
diff --git a/src/com/android/providers/telephony/MmsProvider.java b/src/com/android/providers/telephony/MmsProvider.java
index 5ddffe8..a4e6919 100644
--- a/src/com/android/providers/telephony/MmsProvider.java
+++ b/src/com/android/providers/telephony/MmsProvider.java
@@ -29,6 +29,7 @@
import android.os.ParcelFileDescriptor;
import android.provider.BaseColumns;
import android.provider.Telephony;
+import android.provider.Telephony.CanonicalAddressesColumns;
import android.provider.Telephony.Mms;
import android.provider.Telephony.MmsSms;
import android.provider.Telephony.Mms.Addr;
@@ -43,6 +44,7 @@
import java.io.File;
import java.io.FileNotFoundException;
import java.io.IOException;
+import android.provider.Telephony.Threads;
/**
* The class to provide base facility to access MMS related content,
@@ -344,6 +346,14 @@
finalValues.put(Mms.READ, 1);
}
+ // thread_id
+ Long threadId = values.getAsLong(Mms.THREAD_ID);
+ String address = values.getAsString(CanonicalAddressesColumns.ADDRESS);
+
+ if (((threadId == null) || (threadId == 0)) && (address != null)) {
+ finalValues.put(Mms.THREAD_ID, Threads.getOrCreateThreadId(getContext(), address));
+ }
+
if ((rowId = db.insert(table, null, finalValues)) <= 0) {
Log.e(TAG, "MmsProvider.insert: failed! " + finalValues);
return null;