mirror of
https://github.com/quik-sms/quik.git
synced 2026-11-16 19:18:52 +01:00
Respect threadId when sending MMS
This commit is contained in:
@@ -169,7 +169,7 @@ public class DownloadRequest extends MmsRequest {
|
||||
// }
|
||||
// Store the downloaded message
|
||||
final PduPersister persister = PduPersister.getPduPersister(context);
|
||||
final Uri messageUri = persister.persist(pdu, Telephony.Mms.Inbox.CONTENT_URI, true, true, null);
|
||||
final Uri messageUri = persister.persist(pdu, Telephony.Mms.Inbox.CONTENT_URI, PduPersister.DUMMY_THREAD_ID, true, true, null);
|
||||
if (messageUri == null) {
|
||||
Timber.e("DownloadRequest.persistIfRequired: can not persist message");
|
||||
return null;
|
||||
|
||||
+4
-5
@@ -110,9 +110,8 @@ public class NotificationTransaction extends Transaction implements Runnable {
|
||||
try {
|
||||
// Save the pdu. If we can start downloading the real pdu immediately, don't allow
|
||||
// persist() to create a thread for the notificationInd because it causes UI jank.
|
||||
mUri = PduPersister.getPduPersister(context).persist(
|
||||
ind, Inbox.CONTENT_URI, !allowAutoDownload(mContext),
|
||||
true, null);
|
||||
mUri = PduPersister.getPduPersister(context).persist(ind, Inbox.CONTENT_URI,
|
||||
PduPersister.DUMMY_THREAD_ID, !allowAutoDownload(mContext), true, null);
|
||||
} catch (MmsException e) {
|
||||
Timber.e(e, "Failed to save NotificationInd in constructor.");
|
||||
throw new IllegalArgumentException();
|
||||
@@ -185,8 +184,8 @@ public class NotificationTransaction extends Transaction implements Runnable {
|
||||
} else {
|
||||
// Save the received PDU (must be a M-RETRIEVE.CONF).
|
||||
PduPersister p = PduPersister.getPduPersister(mContext);
|
||||
Uri uri = p.persist(pdu, Inbox.CONTENT_URI, true,
|
||||
true, null);
|
||||
Uri uri = p.persist(pdu, Inbox.CONTENT_URI, PduPersister.DUMMY_THREAD_ID,
|
||||
true, true, null);
|
||||
|
||||
RetrieveConf retrieveConf = (RetrieveConf) pdu;
|
||||
|
||||
|
||||
@@ -107,8 +107,8 @@ public class PushReceiver extends BroadcastReceiver {
|
||||
break;
|
||||
}
|
||||
|
||||
Uri uri = p.persist(pdu, Uri.parse("content://mms/inbox"), true,
|
||||
true, null);
|
||||
Uri uri = p.persist(pdu, Uri.parse("content://mms/inbox"),
|
||||
PduPersister.DUMMY_THREAD_ID, true, true, null);
|
||||
// Update thread ID for ReadOrigInd & DeliveryInd.
|
||||
ContentValues values = new ContentValues(1);
|
||||
values.put(Mms.THREAD_ID, threadId);
|
||||
@@ -136,7 +136,8 @@ public class PushReceiver extends BroadcastReceiver {
|
||||
// Save the pdu. If we can start downloading the real pdu immediately,
|
||||
// don't allow persist() to create a thread for the notificationInd
|
||||
// because it causes UI jank.
|
||||
Uri uri = p.persist(pdu, Inbox.CONTENT_URI, true, true, null);
|
||||
Uri uri = p.persist(pdu, Inbox.CONTENT_URI,
|
||||
PduPersister.DUMMY_THREAD_ID, true, true, null);
|
||||
|
||||
String location = getContentLocation(mContext, uri);
|
||||
if (downloadedUrls.contains(location)) {
|
||||
|
||||
@@ -153,8 +153,8 @@ public class RetrieveTransaction extends Transaction implements Runnable {
|
||||
} else {
|
||||
// Store M-Retrieve.conf into Inbox
|
||||
PduPersister persister = PduPersister.getPduPersister(mContext);
|
||||
msgUri = persister.persist(retrieveConf, Inbox.CONTENT_URI, true,
|
||||
true, null);
|
||||
msgUri = persister.persist(retrieveConf, Inbox.CONTENT_URI,
|
||||
PduPersister.DUMMY_THREAD_ID, true, true, null);
|
||||
|
||||
// Use local time instead of PDU time
|
||||
ContentValues values = new ContentValues(3);
|
||||
|
||||
@@ -67,7 +67,7 @@ import java.util.Set;
|
||||
public class PduPersister {
|
||||
private static final boolean LOCAL_LOGV = false;
|
||||
|
||||
private static final long DUMMY_THREAD_ID = Long.MAX_VALUE;
|
||||
public static final long DUMMY_THREAD_ID = Long.MAX_VALUE;
|
||||
private static final int DEFAULT_SUBSCRIPTION = 0;
|
||||
private static final int MAX_TEXT_BODY_SIZE = 300 * 1024;
|
||||
|
||||
@@ -1263,6 +1263,7 @@ public class PduPersister {
|
||||
*
|
||||
* @param pdu The PDU object to be stored.
|
||||
* @param uri Where to store the given PDU object.
|
||||
* @param threadId
|
||||
* @param createThreadId if true, this function may create a thread id for the recipients
|
||||
* @param groupMmsEnabled if true, all of the recipients addressed in the PDU will be used
|
||||
* to create the associated thread. When false, only the sender will be used in finding or
|
||||
@@ -1271,7 +1272,7 @@ public class PduPersister {
|
||||
* @return A Uri which can be used to access the stored PDU.
|
||||
*/
|
||||
|
||||
public Uri persist(GenericPdu pdu, Uri uri, boolean createThreadId, boolean groupMmsEnabled,
|
||||
public Uri persist(GenericPdu pdu, Uri uri, long threadId, boolean createThreadId, boolean groupMmsEnabled,
|
||||
HashMap<Uri, InputStream> preOpenedFiles) throws MmsException {
|
||||
|
||||
if (uri == null) {
|
||||
@@ -1400,8 +1401,7 @@ public class PduPersister {
|
||||
loadRecipients(PduHeaders.TO, recipients, addressMap, false);
|
||||
break;
|
||||
}
|
||||
long threadId = DUMMY_THREAD_ID;
|
||||
if (createThreadId && !recipients.isEmpty()) {
|
||||
if (threadId == DUMMY_THREAD_ID && createThreadId && !recipients.isEmpty()) {
|
||||
// Given all the recipients associated with this message, find (or create) the
|
||||
// correct thread.
|
||||
threadId = Threads.getOrCreateThreadId(mContext, recipients);
|
||||
|
||||
@@ -94,7 +94,7 @@ class Transaction @JvmOverloads constructor(private val context: Context, settin
|
||||
|
||||
val sendReq = buildPdu(context, addresses, subject, parts)
|
||||
val persister = PduPersister.getPduPersister(context)
|
||||
val messageUri = existingUri ?: persister.persist(sendReq, Uri.parse("content://mms/outbox"), true, true, null)
|
||||
val messageUri = existingUri ?: persister.persist(sendReq, Uri.parse("content://mms/outbox"), threadId, true, true, null)
|
||||
|
||||
val sentIntent = Intent(MMS_SENT)
|
||||
BroadcastUtils.addClassName(context, sentIntent, MMS_SENT)
|
||||
|
||||
Reference in New Issue
Block a user