|  |  |  | @ -22,6 +22,7 @@ import android.database.Cursor; | 
		
	
		
			
				|  |  |  |  | import android.database.sqlite.SQLiteDatabase; | 
		
	
		
			
				|  |  |  |  | import android.database.sqlite.SQLiteOpenHelper; | 
		
	
		
			
				|  |  |  |  | import android.net.Uri; | 
		
	
		
			
				|  |  |  |  | import android.support.annotation.NonNull; | 
		
	
		
			
				|  |  |  |  | import android.telephony.TelephonyManager; | 
		
	
		
			
				|  |  |  |  | import android.text.TextUtils; | 
		
	
		
			
				|  |  |  |  | import android.util.Log; | 
		
	
	
		
			
				
					|  |  |  | @ -339,15 +340,13 @@ public class MmsDatabase extends MessagingDatabase { | 
		
	
		
			
				|  |  |  |  |     } | 
		
	
		
			
				|  |  |  |  |   } | 
		
	
		
			
				|  |  |  |  | 
 | 
		
	
		
			
				|  |  |  |  |   private long getThreadIdFor(NotificationInd notification) throws RecipientFormattingException { | 
		
	
		
			
				|  |  |  |  |     try { | 
		
	
		
			
				|  |  |  |  |       EncodedStringValue encodedString = notification.getFrom(); | 
		
	
		
			
				|  |  |  |  |       String fromString                = new String(encodedString.getTextString(), CharacterSets.MIMENAME_ISO_8859_1); | 
		
	
		
			
				|  |  |  |  |   private long getThreadIdFor(@NonNull NotificationInd notification) { | 
		
	
		
			
				|  |  |  |  |     String fromString = notification.getFrom() != null && notification.getFrom().getTextString() != null | 
		
	
		
			
				|  |  |  |  |                       ? Util.toIsoString(notification.getFrom().getTextString()) | 
		
	
		
			
				|  |  |  |  |                       : ""; | 
		
	
		
			
				|  |  |  |  |     Recipients recipients = RecipientFactory.getRecipientsFromString(context, fromString, false); | 
		
	
		
			
				|  |  |  |  |     if (recipients.isEmpty()) recipients = new Recipients(Recipient.getUnknownRecipient(context)); | 
		
	
		
			
				|  |  |  |  |     return DatabaseFactory.getThreadDatabase(context).getThreadIdFor(recipients); | 
		
	
		
			
				|  |  |  |  |     } catch (UnsupportedEncodingException e) { | 
		
	
		
			
				|  |  |  |  |       throw new AssertionError(e); | 
		
	
		
			
				|  |  |  |  |     } | 
		
	
		
			
				|  |  |  |  |   } | 
		
	
		
			
				|  |  |  |  | 
 | 
		
	
		
			
				|  |  |  |  |   public Cursor getMessage(long messageId) { | 
		
	
	
		
			
				
					|  |  |  | @ -646,21 +645,20 @@ public class MmsDatabase extends MessagingDatabase { | 
		
	
		
			
				|  |  |  |  |                               (retrieved.isPushMessage() ? Types.PUSH_MESSAGE_BIT : 0)); | 
		
	
		
			
				|  |  |  |  |   } | 
		
	
		
			
				|  |  |  |  | 
 | 
		
	
		
			
				|  |  |  |  |   public Pair<Long, Long> insertMessageInbox(NotificationInd notification) { | 
		
	
		
			
				|  |  |  |  |     try { | 
		
	
		
			
				|  |  |  |  |   public Pair<Long, Long> insertMessageInbox(@NonNull NotificationInd notification) { | 
		
	
		
			
				|  |  |  |  |     SQLiteDatabase     db              = databaseHelper.getWritableDatabase(); | 
		
	
		
			
				|  |  |  |  |     MmsAddressDatabase addressDatabase = DatabaseFactory.getMmsAddressDatabase(context); | 
		
	
		
			
				|  |  |  |  |     long               threadId        = getThreadIdFor(notification); | 
		
	
		
			
				|  |  |  |  |     PduHeaders         headers         = notification.getPduHeaders(); | 
		
	
		
			
				|  |  |  |  |     ContentValues      contentValues   = getContentValuesFromHeader(headers); | 
		
	
		
			
				|  |  |  |  | 
 | 
		
	
		
			
				|  |  |  |  |       Log.w("MmsDatabse", "Message received type: " + headers.getOctet(PduHeaders.MESSAGE_TYPE)); | 
		
	
		
			
				|  |  |  |  |     Log.w(TAG, "Message received type: " + headers.getOctet(PduHeaders.MESSAGE_TYPE)); | 
		
	
		
			
				|  |  |  |  | 
 | 
		
	
		
			
				|  |  |  |  |     contentValues.put(MESSAGE_BOX, Types.BASE_INBOX_TYPE); | 
		
	
		
			
				|  |  |  |  |     contentValues.put(THREAD_ID, threadId); | 
		
	
		
			
				|  |  |  |  |     contentValues.put(STATUS, Status.DOWNLOAD_INITIALIZED); | 
		
	
		
			
				|  |  |  |  |     contentValues.put(DATE_RECEIVED, System.currentTimeMillis() / 1000); | 
		
	
		
			
				|  |  |  |  |       contentValues.put(READ, org.thoughtcrime.securesms.util.Util.isDefaultSmsProvider(context) ? 0 : 1); | 
		
	
		
			
				|  |  |  |  |     contentValues.put(READ, Util.isDefaultSmsProvider(context) ? 0 : 1); | 
		
	
		
			
				|  |  |  |  | 
 | 
		
	
		
			
				|  |  |  |  |     if (!contentValues.containsKey(DATE_SENT)) | 
		
	
		
			
				|  |  |  |  |       contentValues.put(DATE_SENT, contentValues.getAsLong(DATE_RECEIVED)); | 
		
	
	
		
			
				
					|  |  |  | @ -668,16 +666,7 @@ public class MmsDatabase extends MessagingDatabase { | 
		
	
		
			
				|  |  |  |  |     long messageId = db.insert(TABLE_NAME, null, contentValues); | 
		
	
		
			
				|  |  |  |  |     addressDatabase.insertAddressesForId(messageId, headers); | 
		
	
		
			
				|  |  |  |  | 
 | 
		
	
		
			
				|  |  |  |  | //      notifyConversationListeners(threadId);
 | 
		
	
		
			
				|  |  |  |  | //      DatabaseFactory.getThreadDatabase(context).update(threadId);
 | 
		
	
		
			
				|  |  |  |  | //      DatabaseFactory.getThreadDatabase(context).setUnread(threadId);
 | 
		
	
		
			
				|  |  |  |  | //      Trimmer.trimThread(context, threadId);
 | 
		
	
		
			
				|  |  |  |  | 
 | 
		
	
		
			
				|  |  |  |  |       return new Pair<Long, Long>(messageId, threadId); | 
		
	
		
			
				|  |  |  |  |     } catch (RecipientFormattingException rfe) { | 
		
	
		
			
				|  |  |  |  |       Log.w("MmsDatabase", rfe); | 
		
	
		
			
				|  |  |  |  |       return new Pair<Long, Long>(-1L, -1L); | 
		
	
		
			
				|  |  |  |  |     } | 
		
	
		
			
				|  |  |  |  |     return new Pair<>(messageId, threadId); | 
		
	
		
			
				|  |  |  |  |   } | 
		
	
		
			
				|  |  |  |  | 
 | 
		
	
		
			
				|  |  |  |  |   public void markIncomingNotificationReceived(long threadId) { | 
		
	
	
		
			
				
					|  |  |  | 
 |