2014-11-03 15:16:04 -08:00
|
|
|
package org.thoughtcrime.securesms.jobs;
|
|
|
|
|
|
|
|
import android.content.Context;
|
|
|
|
import android.util.Log;
|
|
|
|
import android.util.Pair;
|
|
|
|
|
|
|
|
import org.thoughtcrime.securesms.ApplicationContext;
|
|
|
|
import org.thoughtcrime.securesms.crypto.MasterSecret;
|
2014-11-04 15:01:32 -08:00
|
|
|
import org.thoughtcrime.securesms.crypto.SecurityEvent;
|
|
|
|
import org.thoughtcrime.securesms.crypto.storage.TextSecureAxolotlStore;
|
2014-11-03 15:16:04 -08:00
|
|
|
import org.thoughtcrime.securesms.crypto.storage.TextSecureSessionStore;
|
|
|
|
import org.thoughtcrime.securesms.database.DatabaseFactory;
|
|
|
|
import org.thoughtcrime.securesms.database.EncryptingSmsDatabase;
|
|
|
|
import org.thoughtcrime.securesms.database.MmsDatabase;
|
2014-11-08 11:35:58 -08:00
|
|
|
import org.thoughtcrime.securesms.database.NoSuchMessageException;
|
2014-11-03 15:16:04 -08:00
|
|
|
import org.thoughtcrime.securesms.database.PushDatabase;
|
|
|
|
import org.thoughtcrime.securesms.groups.GroupMessageProcessor;
|
|
|
|
import org.thoughtcrime.securesms.jobs.requirements.MasterSecretRequirement;
|
|
|
|
import org.thoughtcrime.securesms.mms.IncomingMediaMessage;
|
|
|
|
import org.thoughtcrime.securesms.notifications.MessageNotifier;
|
|
|
|
import org.thoughtcrime.securesms.recipients.RecipientFactory;
|
|
|
|
import org.thoughtcrime.securesms.recipients.Recipients;
|
|
|
|
import org.thoughtcrime.securesms.service.KeyCachingService;
|
|
|
|
import org.thoughtcrime.securesms.sms.IncomingEncryptedMessage;
|
|
|
|
import org.thoughtcrime.securesms.sms.IncomingEndSessionMessage;
|
|
|
|
import org.thoughtcrime.securesms.sms.IncomingPreKeyBundleMessage;
|
|
|
|
import org.thoughtcrime.securesms.sms.IncomingTextMessage;
|
2014-11-12 11:15:05 -08:00
|
|
|
import org.thoughtcrime.securesms.util.Base64;
|
2014-11-03 15:16:04 -08:00
|
|
|
import org.thoughtcrime.securesms.util.TextSecurePreferences;
|
|
|
|
import org.whispersystems.jobqueue.JobParameters;
|
|
|
|
import org.whispersystems.libaxolotl.DuplicateMessageException;
|
2015-01-15 13:35:35 -08:00
|
|
|
import org.whispersystems.libaxolotl.IdentityKey;
|
2014-11-03 15:16:04 -08:00
|
|
|
import org.whispersystems.libaxolotl.InvalidKeyException;
|
|
|
|
import org.whispersystems.libaxolotl.InvalidKeyIdException;
|
|
|
|
import org.whispersystems.libaxolotl.InvalidMessageException;
|
|
|
|
import org.whispersystems.libaxolotl.InvalidVersionException;
|
|
|
|
import org.whispersystems.libaxolotl.LegacyMessageException;
|
|
|
|
import org.whispersystems.libaxolotl.NoSessionException;
|
|
|
|
import org.whispersystems.libaxolotl.UntrustedIdentityException;
|
2015-01-15 13:35:35 -08:00
|
|
|
import org.whispersystems.libaxolotl.protocol.PreKeyWhisperMessage;
|
2014-11-04 15:01:32 -08:00
|
|
|
import org.whispersystems.libaxolotl.state.AxolotlStore;
|
2014-11-03 15:16:04 -08:00
|
|
|
import org.whispersystems.libaxolotl.state.SessionStore;
|
|
|
|
import org.whispersystems.libaxolotl.util.guava.Optional;
|
2015-01-15 13:35:35 -08:00
|
|
|
import org.whispersystems.textsecure.api.crypto.TextSecureCipher;
|
2014-11-04 15:01:32 -08:00
|
|
|
import org.whispersystems.textsecure.api.messages.TextSecureEnvelope;
|
2014-11-03 15:16:04 -08:00
|
|
|
import org.whispersystems.textsecure.api.messages.TextSecureGroup;
|
|
|
|
import org.whispersystems.textsecure.api.messages.TextSecureMessage;
|
|
|
|
|
|
|
|
import ws.com.google.android.mms.MmsException;
|
|
|
|
|
|
|
|
public class PushDecryptJob extends MasterSecretJob {
|
|
|
|
|
|
|
|
public static final String TAG = PushDecryptJob.class.getSimpleName();
|
|
|
|
|
|
|
|
private final long messageId;
|
2015-01-15 13:35:35 -08:00
|
|
|
private final long smsMessageId;
|
|
|
|
|
|
|
|
public PushDecryptJob(Context context, long pushMessageId, String sender) {
|
|
|
|
this(context, pushMessageId, -1, sender);
|
|
|
|
}
|
2014-11-03 15:16:04 -08:00
|
|
|
|
2015-01-15 13:35:35 -08:00
|
|
|
public PushDecryptJob(Context context, long pushMessageId, long smsMessageId, String sender) {
|
2014-11-03 15:16:04 -08:00
|
|
|
super(context, JobParameters.newBuilder()
|
|
|
|
.withPersistence()
|
|
|
|
.withRequirement(new MasterSecretRequirement(context))
|
2015-02-23 09:53:32 -08:00
|
|
|
.withGroupId(sender)
|
2014-11-03 15:16:04 -08:00
|
|
|
.create());
|
2015-01-15 13:35:35 -08:00
|
|
|
this.messageId = pushMessageId;
|
|
|
|
this.smsMessageId = smsMessageId;
|
2014-11-03 15:16:04 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void onAdded() {
|
|
|
|
if (KeyCachingService.getMasterSecret(context) == null) {
|
2014-12-04 15:49:09 -08:00
|
|
|
MessageNotifier.updateNotification(context, null, -2);
|
2014-11-03 15:16:04 -08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
2014-11-11 19:57:53 -08:00
|
|
|
public void onRun(MasterSecret masterSecret) throws NoSuchMessageException {
|
|
|
|
PushDatabase database = DatabaseFactory.getPushDatabase(context);
|
|
|
|
TextSecureEnvelope envelope = database.get(messageId);
|
2014-11-03 15:16:04 -08:00
|
|
|
|
2015-01-15 13:35:35 -08:00
|
|
|
handleMessage(masterSecret, envelope, smsMessageId);
|
2014-11-08 11:35:58 -08:00
|
|
|
database.delete(messageId);
|
2014-11-03 15:16:04 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
2014-11-11 21:11:57 -08:00
|
|
|
public boolean onShouldRetryThrowable(Exception exception) {
|
2014-11-11 19:57:53 -08:00
|
|
|
return false;
|
2014-11-03 15:16:04 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
2014-11-11 19:57:53 -08:00
|
|
|
public void onCanceled() {
|
|
|
|
|
2014-11-03 15:16:04 -08:00
|
|
|
}
|
|
|
|
|
2015-01-15 13:35:35 -08:00
|
|
|
private void handleMessage(MasterSecret masterSecret, TextSecureEnvelope envelope, long smsMessageId) {
|
2014-11-03 15:16:04 -08:00
|
|
|
try {
|
2014-11-04 15:01:32 -08:00
|
|
|
AxolotlStore axolotlStore = new TextSecureAxolotlStore(context, masterSecret);
|
2015-03-10 18:59:12 -07:00
|
|
|
TextSecureCipher cipher = new TextSecureCipher(axolotlStore);
|
2014-11-04 15:01:32 -08:00
|
|
|
|
|
|
|
TextSecureMessage message = cipher.decrypt(envelope);
|
|
|
|
|
2015-03-03 11:44:49 -08:00
|
|
|
if (message.isEndSession()) handleEndSessionMessage(masterSecret, envelope, message, smsMessageId);
|
2015-01-15 13:35:35 -08:00
|
|
|
else if (message.isGroupUpdate()) handleGroupMessage(masterSecret, envelope, message, smsMessageId);
|
|
|
|
else if (message.getAttachments().isPresent()) handleMediaMessage(masterSecret, envelope, message, smsMessageId);
|
|
|
|
else handleTextMessage(masterSecret, envelope, message, smsMessageId);
|
2014-11-11 20:29:55 -08:00
|
|
|
|
|
|
|
if (envelope.isPreKeyWhisperMessage()) {
|
|
|
|
ApplicationContext.getInstance(context).getJobManager().add(new RefreshPreKeysJob(context));
|
|
|
|
}
|
2014-11-03 15:16:04 -08:00
|
|
|
} catch (InvalidVersionException e) {
|
|
|
|
Log.w(TAG, e);
|
2015-01-15 13:35:35 -08:00
|
|
|
handleInvalidVersionMessage(masterSecret, envelope, smsMessageId);
|
2015-03-03 11:44:49 -08:00
|
|
|
} catch (InvalidMessageException | InvalidKeyIdException | InvalidKeyException | MmsException e) {
|
2014-11-03 15:16:04 -08:00
|
|
|
Log.w(TAG, e);
|
2015-01-15 13:35:35 -08:00
|
|
|
handleCorruptMessage(masterSecret, envelope, smsMessageId);
|
2014-11-03 15:16:04 -08:00
|
|
|
} catch (NoSessionException e) {
|
|
|
|
Log.w(TAG, e);
|
2015-01-15 13:35:35 -08:00
|
|
|
handleNoSessionMessage(masterSecret, envelope, smsMessageId);
|
2014-11-03 15:16:04 -08:00
|
|
|
} catch (LegacyMessageException e) {
|
|
|
|
Log.w(TAG, e);
|
2015-01-15 13:35:35 -08:00
|
|
|
handleLegacyMessage(masterSecret, envelope, smsMessageId);
|
2014-11-03 15:16:04 -08:00
|
|
|
} catch (DuplicateMessageException e) {
|
|
|
|
Log.w(TAG, e);
|
2015-01-15 13:35:35 -08:00
|
|
|
handleDuplicateMessage(masterSecret, envelope, smsMessageId);
|
2014-11-03 15:16:04 -08:00
|
|
|
} catch (UntrustedIdentityException e) {
|
|
|
|
Log.w(TAG, e);
|
2015-01-15 13:35:35 -08:00
|
|
|
handleUntrustedIdentityMessage(masterSecret, envelope, smsMessageId);
|
2014-11-03 15:16:04 -08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-03-03 11:44:49 -08:00
|
|
|
private void handleEndSessionMessage(MasterSecret masterSecret, TextSecureEnvelope envelope,
|
|
|
|
TextSecureMessage message, long smsMessageId)
|
2014-11-04 15:01:32 -08:00
|
|
|
{
|
2015-01-15 13:35:35 -08:00
|
|
|
EncryptingSmsDatabase smsDatabase = DatabaseFactory.getEncryptingSmsDatabase(context);
|
|
|
|
IncomingTextMessage incomingTextMessage = new IncomingTextMessage(envelope.getSource(),
|
|
|
|
envelope.getSourceDevice(),
|
|
|
|
message.getTimestamp(),
|
|
|
|
"", Optional.<TextSecureGroup>absent());
|
|
|
|
|
|
|
|
long threadId;
|
|
|
|
|
|
|
|
if (smsMessageId <= 0) {
|
|
|
|
IncomingEndSessionMessage incomingEndSessionMessage = new IncomingEndSessionMessage(incomingTextMessage);
|
|
|
|
Pair<Long, Long> messageAndThreadId = smsDatabase.insertMessageInbox(masterSecret, incomingEndSessionMessage);
|
|
|
|
threadId = messageAndThreadId.second;
|
|
|
|
} else {
|
|
|
|
smsDatabase.markAsEndSession(smsMessageId);
|
|
|
|
threadId = smsDatabase.getThreadIdForMessage(smsMessageId);
|
|
|
|
}
|
2014-11-03 15:16:04 -08:00
|
|
|
|
|
|
|
SessionStore sessionStore = new TextSecureSessionStore(context, masterSecret);
|
2015-03-03 11:44:49 -08:00
|
|
|
sessionStore.deleteAllSessions(envelope.getSource());
|
2014-11-03 15:16:04 -08:00
|
|
|
|
2015-01-15 13:35:35 -08:00
|
|
|
SecurityEvent.broadcastSecurityUpdateEvent(context, threadId);
|
|
|
|
MessageNotifier.updateNotification(context, masterSecret, threadId);
|
2014-11-03 15:16:04 -08:00
|
|
|
}
|
|
|
|
|
2015-01-15 13:35:35 -08:00
|
|
|
private void handleGroupMessage(MasterSecret masterSecret, TextSecureEnvelope envelope, TextSecureMessage message, long smsMessageId) {
|
2014-11-04 15:01:32 -08:00
|
|
|
GroupMessageProcessor.process(context, masterSecret, envelope, message);
|
2015-01-15 13:35:35 -08:00
|
|
|
|
|
|
|
if (smsMessageId > 0) {
|
|
|
|
DatabaseFactory.getSmsDatabase(context).deleteMessage(smsMessageId);
|
|
|
|
}
|
2014-11-03 15:16:04 -08:00
|
|
|
}
|
|
|
|
|
2015-01-15 13:35:35 -08:00
|
|
|
private void handleMediaMessage(MasterSecret masterSecret, TextSecureEnvelope envelope, TextSecureMessage message, long smsMessageId)
|
2014-11-03 15:16:04 -08:00
|
|
|
throws MmsException
|
|
|
|
{
|
|
|
|
String localNumber = TextSecurePreferences.getLocalNumber(context);
|
|
|
|
MmsDatabase database = DatabaseFactory.getMmsDatabase(context);
|
2014-11-04 15:01:32 -08:00
|
|
|
IncomingMediaMessage mediaMessage = new IncomingMediaMessage(masterSecret, envelope.getSource(),
|
2014-11-03 15:16:04 -08:00
|
|
|
localNumber, message.getTimestamp(),
|
2014-11-04 15:01:32 -08:00
|
|
|
Optional.fromNullable(envelope.getRelay()),
|
2014-11-03 15:16:04 -08:00
|
|
|
message.getBody(),
|
|
|
|
message.getGroupInfo(),
|
|
|
|
message.getAttachments());
|
|
|
|
|
|
|
|
Pair<Long, Long> messageAndThreadId;
|
|
|
|
|
|
|
|
if (message.isSecure()) {
|
|
|
|
messageAndThreadId = database.insertSecureDecryptedMessageInbox(masterSecret, mediaMessage, -1);
|
|
|
|
} else {
|
|
|
|
messageAndThreadId = database.insertMessageInbox(masterSecret, mediaMessage, null, -1);
|
|
|
|
}
|
|
|
|
|
|
|
|
ApplicationContext.getInstance(context)
|
|
|
|
.getJobManager()
|
|
|
|
.add(new AttachmentDownloadJob(context, messageAndThreadId.first));
|
|
|
|
|
2015-01-15 13:35:35 -08:00
|
|
|
if (smsMessageId >= 0) {
|
|
|
|
DatabaseFactory.getSmsDatabase(context).deleteMessage(smsMessageId);
|
|
|
|
}
|
|
|
|
|
2014-11-03 15:16:04 -08:00
|
|
|
MessageNotifier.updateNotification(context, masterSecret, messageAndThreadId.second);
|
|
|
|
}
|
|
|
|
|
2015-01-15 13:35:35 -08:00
|
|
|
private void handleTextMessage(MasterSecret masterSecret, TextSecureEnvelope envelope,
|
|
|
|
TextSecureMessage message, long smsMessageId)
|
|
|
|
{
|
|
|
|
EncryptingSmsDatabase database = DatabaseFactory.getEncryptingSmsDatabase(context);
|
|
|
|
String body = message.getBody().isPresent() ? message.getBody().get() : "";
|
|
|
|
|
|
|
|
if (smsMessageId > 0) {
|
|
|
|
database.updateBundleMessageBody(masterSecret, smsMessageId, body);
|
|
|
|
} else {
|
|
|
|
IncomingTextMessage textMessage = new IncomingTextMessage(envelope.getSource(),
|
2014-11-04 15:01:32 -08:00
|
|
|
envelope.getSourceDevice(),
|
2014-11-03 15:16:04 -08:00
|
|
|
message.getTimestamp(), body,
|
|
|
|
message.getGroupInfo());
|
|
|
|
|
2015-01-15 13:35:35 -08:00
|
|
|
if (message.isSecure()) {
|
|
|
|
textMessage = new IncomingEncryptedMessage(textMessage, body);
|
|
|
|
}
|
2014-11-03 15:16:04 -08:00
|
|
|
|
2015-01-15 13:35:35 -08:00
|
|
|
Pair<Long, Long> messageAndThreadId = database.insertMessageInbox(masterSecret, textMessage);
|
|
|
|
MessageNotifier.updateNotification(context, masterSecret, messageAndThreadId.second);
|
|
|
|
}
|
2014-11-03 15:16:04 -08:00
|
|
|
}
|
|
|
|
|
2015-01-15 13:35:35 -08:00
|
|
|
private void handleInvalidVersionMessage(MasterSecret masterSecret, TextSecureEnvelope envelope, long smsMessageId) {
|
|
|
|
EncryptingSmsDatabase smsDatabase = DatabaseFactory.getEncryptingSmsDatabase(context);
|
2014-11-03 15:16:04 -08:00
|
|
|
|
2015-01-15 13:35:35 -08:00
|
|
|
if (smsMessageId <= 0) {
|
|
|
|
Pair<Long, Long> messageAndThreadId = insertPlaceholder(masterSecret, envelope);
|
|
|
|
smsDatabase.markAsInvalidVersionKeyExchange(messageAndThreadId.first);
|
|
|
|
MessageNotifier.updateNotification(context, masterSecret, messageAndThreadId.second);
|
|
|
|
} else {
|
|
|
|
smsDatabase.markAsInvalidVersionKeyExchange(smsMessageId);
|
|
|
|
}
|
2014-11-03 15:16:04 -08:00
|
|
|
}
|
|
|
|
|
2015-01-15 13:35:35 -08:00
|
|
|
private void handleCorruptMessage(MasterSecret masterSecret, TextSecureEnvelope envelope, long smsMessageId) {
|
|
|
|
EncryptingSmsDatabase smsDatabase = DatabaseFactory.getEncryptingSmsDatabase(context);
|
2014-11-03 15:16:04 -08:00
|
|
|
|
2015-01-15 13:35:35 -08:00
|
|
|
if (smsMessageId <= 0) {
|
|
|
|
Pair<Long, Long> messageAndThreadId = insertPlaceholder(masterSecret, envelope);
|
|
|
|
smsDatabase.markAsDecryptFailed(messageAndThreadId.first);
|
|
|
|
MessageNotifier.updateNotification(context, masterSecret, messageAndThreadId.second);
|
|
|
|
} else {
|
|
|
|
smsDatabase.markAsDecryptFailed(smsMessageId);
|
|
|
|
}
|
2014-11-03 15:16:04 -08:00
|
|
|
}
|
|
|
|
|
2015-01-15 13:35:35 -08:00
|
|
|
private void handleNoSessionMessage(MasterSecret masterSecret, TextSecureEnvelope envelope, long smsMessageId) {
|
|
|
|
EncryptingSmsDatabase smsDatabase = DatabaseFactory.getEncryptingSmsDatabase(context);
|
2014-11-03 15:16:04 -08:00
|
|
|
|
2015-01-15 13:35:35 -08:00
|
|
|
if (smsMessageId <= 0) {
|
|
|
|
Pair<Long, Long> messageAndThreadId = insertPlaceholder(masterSecret, envelope);
|
|
|
|
smsDatabase.markAsNoSession(messageAndThreadId.first);
|
|
|
|
MessageNotifier.updateNotification(context, masterSecret, messageAndThreadId.second);
|
|
|
|
} else {
|
|
|
|
smsDatabase.markAsNoSession(smsMessageId);
|
|
|
|
}
|
2014-11-03 15:16:04 -08:00
|
|
|
}
|
|
|
|
|
2015-01-15 13:35:35 -08:00
|
|
|
private void handleLegacyMessage(MasterSecret masterSecret, TextSecureEnvelope envelope, long smsMessageId) {
|
|
|
|
EncryptingSmsDatabase smsDatabase = DatabaseFactory.getEncryptingSmsDatabase(context);
|
2014-11-03 15:16:04 -08:00
|
|
|
|
2015-01-15 13:35:35 -08:00
|
|
|
if (smsMessageId <= 0) {
|
|
|
|
Pair<Long, Long> messageAndThreadId = insertPlaceholder(masterSecret, envelope);
|
|
|
|
smsDatabase.markAsLegacyVersion(messageAndThreadId.first);
|
|
|
|
MessageNotifier.updateNotification(context, masterSecret, messageAndThreadId.second);
|
|
|
|
} else {
|
|
|
|
smsDatabase.markAsLegacyVersion(smsMessageId);
|
|
|
|
}
|
2014-11-03 15:16:04 -08:00
|
|
|
}
|
|
|
|
|
2015-01-15 13:35:35 -08:00
|
|
|
private void handleDuplicateMessage(MasterSecret masterSecret, TextSecureEnvelope envelope, long smsMessageId) {
|
|
|
|
// Let's start ignoring these now
|
|
|
|
// SmsDatabase smsDatabase = DatabaseFactory.getEncryptingSmsDatabase(context);
|
2015-01-25 17:43:24 -08:00
|
|
|
//
|
2015-01-15 13:35:35 -08:00
|
|
|
// if (smsMessageId <= 0) {
|
|
|
|
// Pair<Long, Long> messageAndThreadId = insertPlaceholder(masterSecret, envelope);
|
|
|
|
// smsDatabase.markAsDecryptDuplicate(messageAndThreadId.first);
|
|
|
|
// MessageNotifier.updateNotification(context, masterSecret, messageAndThreadId.second);
|
|
|
|
// } else {
|
|
|
|
// smsDatabase.markAsDecryptDuplicate(smsMessageId);
|
|
|
|
// }
|
2014-11-03 15:16:04 -08:00
|
|
|
}
|
|
|
|
|
2015-01-15 13:35:35 -08:00
|
|
|
private void handleUntrustedIdentityMessage(MasterSecret masterSecret, TextSecureEnvelope envelope, long smsMessageId) {
|
|
|
|
try {
|
|
|
|
EncryptingSmsDatabase database = DatabaseFactory.getEncryptingSmsDatabase(context);
|
|
|
|
Recipients recipients = RecipientFactory.getRecipientsFromString(context, envelope.getSource(), false);
|
|
|
|
long recipientId = recipients.getPrimaryRecipient().getRecipientId();
|
|
|
|
PreKeyWhisperMessage whisperMessage = new PreKeyWhisperMessage(envelope.getMessage());
|
|
|
|
IdentityKey identityKey = whisperMessage.getIdentityKey();
|
|
|
|
String encoded = Base64.encodeBytes(envelope.getMessage());
|
|
|
|
IncomingTextMessage textMessage = new IncomingTextMessage(envelope.getSource(), envelope.getSourceDevice(),
|
|
|
|
envelope.getTimestamp(), encoded,
|
|
|
|
Optional.<TextSecureGroup>absent());
|
|
|
|
|
|
|
|
if (smsMessageId <= 0) {
|
|
|
|
IncomingPreKeyBundleMessage bundleMessage = new IncomingPreKeyBundleMessage(textMessage, encoded);
|
|
|
|
Pair<Long, Long> messageAndThreadId = database.insertMessageInbox(masterSecret, bundleMessage);
|
|
|
|
|
|
|
|
database.addMismatchedIdentity(messageAndThreadId.first, recipientId, identityKey);
|
|
|
|
MessageNotifier.updateNotification(context, masterSecret, messageAndThreadId.second);
|
|
|
|
} else {
|
|
|
|
database.updateMessageBody(masterSecret, smsMessageId, encoded);
|
|
|
|
database.markAsPreKeyBundle(smsMessageId);
|
|
|
|
database.addMismatchedIdentity(smsMessageId, recipientId, identityKey);
|
|
|
|
}
|
2015-03-03 11:44:49 -08:00
|
|
|
} catch (InvalidMessageException | InvalidVersionException e) {
|
2015-01-15 13:35:35 -08:00
|
|
|
throw new AssertionError(e);
|
|
|
|
}
|
2014-11-03 15:16:04 -08:00
|
|
|
}
|
|
|
|
|
2014-11-04 15:01:32 -08:00
|
|
|
private Pair<Long, Long> insertPlaceholder(MasterSecret masterSecret, TextSecureEnvelope envelope) {
|
2014-11-03 15:16:04 -08:00
|
|
|
EncryptingSmsDatabase database = DatabaseFactory.getEncryptingSmsDatabase(context);
|
|
|
|
|
2014-11-04 15:01:32 -08:00
|
|
|
IncomingTextMessage textMessage = new IncomingTextMessage(envelope.getSource(), envelope.getSourceDevice(),
|
|
|
|
envelope.getTimestamp(), "",
|
2014-11-03 15:16:04 -08:00
|
|
|
Optional.<TextSecureGroup>absent());
|
|
|
|
|
|
|
|
textMessage = new IncomingEncryptedMessage(textMessage, "");
|
|
|
|
|
|
|
|
return database.insertMessageInbox(masterSecret, textMessage);
|
|
|
|
}
|
|
|
|
}
|