Reduce DB updates on send path, move support SDK up to 24

// FREEBIE
This commit is contained in:
Moxie Marlinspike
2016-12-21 09:49:01 -08:00
parent 4e32fb21fe
commit cdf3a849e9
14 changed files with 66 additions and 81 deletions

View File

@@ -204,14 +204,12 @@ public abstract class CursorRecyclerViewAdapter<VH extends RecyclerView.ViewHold
public void onChanged() {
super.onChanged();
valid = true;
notifyDataSetChanged();
}
@Override
public void onInvalidated() {
super.onInvalidated();
valid = false;
notifyDataSetChanged();
}
}
}

View File

@@ -65,7 +65,7 @@ public class EncryptingSmsDatabase extends SmsDatabase {
OutgoingTextMessage message, boolean forceSms,
long timestamp)
{
long type = Types.BASE_OUTBOX_TYPE;
long type = Types.BASE_SENDING_TYPE;
if (masterSecret.getMasterSecret().isPresent()) {
message = message.withBody(getEncryptedBody(masterSecret.getMasterSecret().get(), message.getMessageBody()));

View File

@@ -382,11 +382,11 @@ public class MmsDatabase extends MessagingDatabase {
notifyConversationListeners(threadId);
}
public void markAsSending(long messageId) {
long threadId = getThreadIdForMessage(messageId);
updateMailboxBitmask(messageId, Types.BASE_TYPE_MASK, Types.BASE_SENDING_TYPE, Optional.of(threadId));
notifyConversationListeners(threadId);
}
// public void markAsSending(long messageId) {
// long threadId = getThreadIdForMessage(messageId);
// updateMailboxBitmask(messageId, Types.BASE_TYPE_MASK, Types.BASE_SENDING_TYPE, Optional.of(threadId));
// notifyConversationListeners(threadId);
// }
public void markAsSentFailed(long messageId) {
long threadId = getThreadIdForMessage(messageId);
@@ -394,9 +394,9 @@ public class MmsDatabase extends MessagingDatabase {
notifyConversationListeners(threadId);
}
public void markAsSent(long messageId) {
public void markAsSent(long messageId, boolean secure) {
long threadId = getThreadIdForMessage(messageId);
updateMailboxBitmask(messageId, Types.BASE_TYPE_MASK, Types.BASE_SENT_TYPE, Optional.of(threadId));
updateMailboxBitmask(messageId, Types.BASE_TYPE_MASK, Types.BASE_SENT_TYPE | (secure ? Types.PUSH_MESSAGE_BIT | Types.SECURE_MESSAGE_BIT : 0), Optional.of(threadId));
notifyConversationListeners(threadId);
}
@@ -414,17 +414,17 @@ public class MmsDatabase extends MessagingDatabase {
notifyConversationListeners(threadId);
}
public void markAsSecure(long messageId) {
updateMailboxBitmask(messageId, 0, Types.SECURE_MESSAGE_BIT, Optional.<Long>absent());
}
// public void markAsSecure(long messageId) {
// updateMailboxBitmask(messageId, 0, Types.SECURE_MESSAGE_BIT, Optional.<Long>absent());
// }
public void markAsInsecure(long messageId) {
updateMailboxBitmask(messageId, Types.SECURE_MESSAGE_BIT, 0, Optional.<Long>absent());
}
public void markAsPush(long messageId) {
updateMailboxBitmask(messageId, 0, Types.PUSH_MESSAGE_BIT, Optional.<Long>absent());
}
// public void markAsPush(long messageId) {
// updateMailboxBitmask(messageId, 0, Types.PUSH_MESSAGE_BIT, Optional.<Long>absent());
// }
public void markAsDecryptFailed(long messageId, long threadId) {
updateMailboxBitmask(messageId, Types.ENCRYPTION_MASK, Types.ENCRYPTION_REMOTE_FAILED_BIT, Optional.of(threadId));
@@ -847,12 +847,12 @@ public class MmsDatabase extends MessagingDatabase {
long threadId, boolean forceSms)
throws MmsException
{
long type = Types.BASE_OUTBOX_TYPE;
long type = Types.BASE_SENDING_TYPE;
if (masterSecret.getMasterSecret().isPresent()) type |= Types.ENCRYPTION_SYMMETRIC_BIT;
else type |= Types.ENCRYPTION_ASYMMETRIC_BIT;
if (message.isSecure()) type |= Types.SECURE_MESSAGE_BIT;
if (message.isSecure()) type |= (Types.SECURE_MESSAGE_BIT | Types.PUSH_MESSAGE_BIT);
if (forceSms) type |= Types.MESSAGE_FORCE_SMS_BIT;
if (message.isGroup()) {

View File

@@ -228,12 +228,8 @@ public class SmsDatabase extends MessagingDatabase {
updateTypeBitmask(id, Types.BASE_TYPE_MASK, Types.BASE_PENDING_INSECURE_SMS_FALLBACK);
}
public void markAsSending(long id) {
updateTypeBitmask(id, Types.BASE_TYPE_MASK, Types.BASE_SENDING_TYPE);
}
public void markAsSent(long id) {
updateTypeBitmask(id, Types.BASE_TYPE_MASK, Types.BASE_SENT_TYPE);
public void markAsSent(long id, boolean isSecure) {
updateTypeBitmask(id, Types.BASE_TYPE_MASK, Types.BASE_SENT_TYPE | (isSecure ? Types.PUSH_MESSAGE_BIT | Types.SECURE_MESSAGE_BIT : 0));
}
public void markExpireStarted(long id) {
@@ -575,7 +571,7 @@ public class SmsDatabase extends MessagingDatabase {
long type, boolean forceSms, long date)
{
if (message.isKeyExchange()) type |= Types.KEY_EXCHANGE_BIT;
else if (message.isSecureMessage()) type |= Types.SECURE_MESSAGE_BIT;
else if (message.isSecureMessage()) type |= (Types.SECURE_MESSAGE_BIT | Types.PUSH_MESSAGE_BIT);
else if (message.isEndSession()) type |= Types.END_SESSION_BIT;
if (forceSms) type |= Types.MESSAGE_FORCE_SMS_BIT;