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