From 1acf727488edaf0a0afd68c397f887cda8a938e7 Mon Sep 17 00:00:00 2001 From: Moez Bhatti Date: Sun, 14 Jan 2018 02:41:34 -0500 Subject: [PATCH] Ignore textonly field in mms --- .../android/mms/pdu_alt/PduPersister.java | 28 ++----------------- .../main/java/data/mapper/CursorToMessage.kt | 10 ++----- 2 files changed, 5 insertions(+), 33 deletions(-) diff --git a/android-smsmms/src/main/java/com/google/android/mms/pdu_alt/PduPersister.java b/android-smsmms/src/main/java/com/google/android/mms/pdu_alt/PduPersister.java index 71302476..8b4680e2 100755 --- a/android-smsmms/src/main/java/com/google/android/mms/pdu_alt/PduPersister.java +++ b/android-smsmms/src/main/java/com/google/android/mms/pdu_alt/PduPersister.java @@ -682,8 +682,7 @@ public class PduPersister { return pdu; } - private void persistAddress( - long msgId, int type, EncodedStringValue[] array) { + private void persistAddress(long msgId, int type, EncodedStringValue[] array) { ContentValues values = new ContentValues(3); for (EncodedStringValue addr : array) { @@ -1416,9 +1415,6 @@ public class PduPersister { // while saving the parts. long dummyId = System.currentTimeMillis(); // Dummy ID of the msg. - // Figure out if this PDU is a text-only message - boolean textOnly = true; - // Sum up the total message size int messageSize = 0; @@ -1427,32 +1423,14 @@ public class PduPersister { body = ((MultimediaMessagePdu) pdu).getBody(); // Start saving parts if necessary. if (body != null) { - int partsNum = body.getPartsNum(); - if (partsNum > 2) { - // For a text-only message there will be two parts: 1-the SMIL, 2-the text. - // Down a few lines below we're checking to make sure we've only got SMIL or - // text. We also have to check then we don't have more than two parts. - // Otherwise, a slideshow with two text slides would be marked as textOnly. - textOnly = false; - } - for (int i = 0; i < partsNum; i++) { + for (int i = 0; i < body.getPartsNum(); i++) { PduPart part = body.getPart(i); messageSize += part.getDataLength(); persistPart(part, dummyId, preOpenedFiles); - - // If we've got anything besides text/plain or SMIL part, then we've got - // an mms message with some other type of attachment. - String contentType = getPartContentType(part); - if (contentType != null && !ContentType.APP_SMIL.equals(contentType) - && !ContentType.TEXT_PLAIN.equals(contentType)) { - textOnly = false; - } } } } - // Record whether this mms message is a simple plain text or not. This is a hint for the - // UI. - // values.put(Mms.TEXT_ONLY, textOnly ? 1 : 0); + // The message-size might already have been inserted when parsing the // PDU header. If not, then we insert the message size as well. if (values.getAsInteger(Mms.MESSAGE_SIZE) == null) { diff --git a/qksms/src/main/java/data/mapper/CursorToMessage.kt b/qksms/src/main/java/data/mapper/CursorToMessage.kt index 296c2f0f..3caa8e7d 100644 --- a/qksms/src/main/java/data/mapper/CursorToMessage.kt +++ b/qksms/src/main/java/data/mapper/CursorToMessage.kt @@ -78,11 +78,7 @@ class CursorToMessage @Inject constructor( mmsStatus = cursor.getInt(columnsMap.mmsStatus) subject = cursor.getString(columnsMap.mmsSubject) ?: "" textContentType = "" - - attachmentType = when (cursor.getInt(columnsMap.mmsTextOnly)) { - 0 -> Message.AttachmentType.NOT_LOADED - else -> Message.AttachmentType.TEXT - } + attachmentType = Message.AttachmentType.NOT_LOADED } } } @@ -135,8 +131,7 @@ class CursorToMessage @Inject constructor( Mms.DELIVERY_REPORT, Mms.READ_REPORT, MmsSms.PendingMessages.ERROR_TYPE, - Mms.STATUS, - Mms.TEXT_ONLY) + Mms.STATUS) } class MessageColumns(private val cursor: Cursor) { @@ -166,7 +161,6 @@ class CursorToMessage @Inject constructor( val mmsReadReport by lazy { getColumnIndex(Mms.READ_REPORT) } val mmsErrorType by lazy { getColumnIndex(MmsSms.PendingMessages.ERROR_TYPE) } val mmsStatus by lazy { getColumnIndex(Mms.STATUS) } - val mmsTextOnly by lazy { getColumnIndex(Mms.TEXT_ONLY) } private fun getColumnIndex(columnsName: String) = try { cursor.getColumnIndexOrThrow(columnsName)