mirror of
https://github.com/oxen-io/session-android.git
synced 2024-12-31 20:27:44 +00:00
Reduce DB updates on send path, move support SDK up to 24
// FREEBIE
This commit is contained in:
parent
4e32fb21fe
commit
cdf3a849e9
28
build.gradle
28
build.gradle
@ -53,10 +53,10 @@ dependencies {
|
||||
compile 'de.greenrobot:eventbus:2.4.0'
|
||||
compile 'pl.tajchert:waitingdots:0.1.0'
|
||||
compile 'com.soundcloud.android:android-crop:0.9.10@aar'
|
||||
compile 'com.android.support:appcompat-v7:22.2.1'
|
||||
compile 'com.android.support:recyclerview-v7:22.2.1'
|
||||
compile 'com.android.support:design:22.2.1'
|
||||
compile 'com.android.support:cardview-v7:22.2.1'
|
||||
compile 'com.android.support:appcompat-v7:24.2.1'
|
||||
compile 'com.android.support:recyclerview-v7:24.2.1'
|
||||
compile 'com.android.support:design:24.2.1'
|
||||
compile 'com.android.support:cardview-v7:24.2.1'
|
||||
compile 'com.melnykov:floatingactionbutton:1.3.0'
|
||||
compile 'com.google.zxing:android-integration:3.1.0'
|
||||
compile ('com.android.support:support-v4-preferencefragment:1.0.0@aar'){
|
||||
@ -120,10 +120,10 @@ dependencyVerification {
|
||||
'de.greenrobot:eventbus:61d743a748156a372024d083de763b9e91ac2dcb3f6a1cbc74995c7ddab6e968',
|
||||
'pl.tajchert:waitingdots:2835d49e0787dbcb606c5a60021ced66578503b1e9fddcd7a5ef0cd5f095ba2c',
|
||||
'com.soundcloud.android:android-crop:ffd4b973cf6e97f7d64118a0dc088df50e9066fd5634fe6911dd0c0c5d346177',
|
||||
'com.android.support:appcompat-v7:4b5ccba8c4557ef04f99aa0a80f8aa7d50f05f926a709010a54afd5c878d3618',
|
||||
'com.android.support:recyclerview-v7:b0f530a5b14334d56ce0de85527ffe93ac419bc928e2884287ce1dddfedfb505',
|
||||
'com.android.support:design:58be3ca6a73789615f7ece0937d2f683b98b594bb90aa10565fa760fb10b07ee',
|
||||
'com.android.support:cardview-v7:2c2354761a4e20ba451ae903ab808f15c9acc8343b1e74001869c2d0a672c1fc',
|
||||
'com.android.support:appcompat-v7:ead7ac8011fb40676df8adc2856cae934edab55fc4444654c0ac6ea443736088',
|
||||
'com.android.support:recyclerview-v7:9077766a1a0f4e89528fbf9dcdf6d5880a8686f0266fa852d58d803beeef18fa',
|
||||
'com.android.support:design:89842bb1243507fe3079066ea4ea58795effe69cdf9a819e05274d21760adfc2',
|
||||
'com.android.support:cardview-v7:2303b351686d1db060b5fcf1a9c709c79b4a54a85bfda0fb3c4849e244606ee1',
|
||||
'com.melnykov:floatingactionbutton:15d58d4fac0f7a288d0e5301bbaf501a146f5b3f5921277811bf99bd3b397263',
|
||||
'com.google.zxing:android-integration:89e56aadf1164bd71e57949163c53abf90af368b51669c0d4a47a163335f95c4',
|
||||
'com.android.support:support-v4-preferencefragment:5470f5872514a6226fa1fc6f4e000991f38805691c534cf0bd2778911fc773ad',
|
||||
@ -139,7 +139,9 @@ dependencyVerification {
|
||||
'com.google.zxing:core:b4d82452e7a6bf6ec2698904b332431717ed8f9a850224f295aec89de80f2259',
|
||||
'cn.carbswang.android:NumberPickerView:18b3c316d62c7c277978a8d4ed57a5b8f4e943762264960f579a8a549c756729',
|
||||
'com.google.android.gms:play-services-base:ef36e50fa5c0415ed41f74dd399a889efd2fa327c449036e140c7c3786aa0e1f',
|
||||
'com.android.support:support-annotations:104f353b53d5dd8d64b2f77eece4b37f6b961de9732eb6b706395e91033ec70a',
|
||||
'com.android.support:support-annotations:1e4d471c5378b283d95abfb128e7ed3c6b3cb19bb6f0c317a9b75e48e99365ff',
|
||||
'com.android.support:support-compat:8e4fe0078b68073e8f5bcb52aa5b6407fd456d47c51aa0f8e8d1e23c69da06c1',
|
||||
'com.android.support:support-core-ui:ecc9184b7f438980e1c4a08b089d62dbc53ff90091f442d91fec27322a02c73c',
|
||||
'com.nineoldandroids:library:68025a14e3e7673d6ad2f95e4b46d78d7d068343aa99256b686fe59de1b3163a',
|
||||
'javax.inject:javax.inject:91c77044a50c481636c32d916fd89c9118a72195390452c81065080f957de7ff',
|
||||
'com.madgag.spongycastle:core:8d6240b974b0aca4d3da9c7dd44d42339d8a374358aca5fc98e50a995764511f',
|
||||
@ -156,10 +158,16 @@ dependencyVerification {
|
||||
'com.squareup.okio:okio:5e1098bd3fdee4c3347f5ab815b40ba851e4ab1b348c5e49a5b0362f0ce6e978',
|
||||
'com.fasterxml.jackson.core:jackson-annotations:0ca408c24202a7626ec8b861e99d85eca5e38b73311dd6dd12e3e9deecc3fe94',
|
||||
'com.fasterxml.jackson.core:jackson-core:cbf4604784b4de226262845447a1ad3bb38a6728cebe86562e2c5afada8be2c0',
|
||||
'com.android.support:support-v4:c62f0d025dafa86f423f48df9185b0d89496adbc5f6a9be5a7c394d84cf91423',
|
||||
'com.android.support:support-vector-drawable:6ee37a7f7b93c1df1294e6f6f97df3724ac989fcda0549faf677001085330548',
|
||||
'com.android.support:animated-vector-drawable:5aa30f578e1daefb26bef0ce06414266fbb4cdf5d4259f42a92c7bd83dcd81b4',
|
||||
'com.android.support:support-v4:cac2956f5c4bb363cc0ba824ac16ea2a687d1c305d434416a34772a5f9375ed7',
|
||||
'com.android.support:support-media-compat:fa29a23eadd685631584b2c0c624a36e3bb79a33e257b00304501ad682fa2be3',
|
||||
'com.android.support:support-core-utils:0fbc508e41dd6e8c634f310ee88452aaf8f48b6a843a369b115130b80d2fc05f',
|
||||
'com.android.support:support-fragment:d8030f0bf0f64214a29dc4e14d5ccd225e59f66ed15eb37f3a5022e773dd1fda',
|
||||
]
|
||||
}
|
||||
|
||||
|
||||
android {
|
||||
compileSdkVersion 24
|
||||
buildToolsVersion '23.0.3'
|
||||
|
@ -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();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -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()));
|
||||
|
@ -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()) {
|
||||
|
@ -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;
|
||||
|
||||
|
@ -207,7 +207,7 @@ public class GroupMessageProcessor {
|
||||
long threadId = DatabaseFactory.getThreadDatabase(context).getThreadIdFor(recipients);
|
||||
long messageId = mmsDatabase.insertMessageOutbox(masterSecret, outgoingMessage, threadId, false);
|
||||
|
||||
mmsDatabase.markAsSent(messageId);
|
||||
mmsDatabase.markAsSent(messageId, true);
|
||||
|
||||
return threadId;
|
||||
} else {
|
||||
|
@ -64,8 +64,8 @@ public class MmsSendJob extends SendJob {
|
||||
|
||||
@Override
|
||||
public void onAdded() {
|
||||
MmsDatabase database = DatabaseFactory.getMmsDatabase(context);
|
||||
database.markAsSending(messageId);
|
||||
// MmsDatabase database = DatabaseFactory.getMmsDatabase(context);
|
||||
// database.markAsSending(messageId);
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -82,7 +82,7 @@ public class MmsSendJob extends SendJob {
|
||||
final SendConf sendConf = new CompatMmsConnection(context).send(pduBytes, message.getSubscriptionId());
|
||||
final MmsSendResult result = getSendResult(sendConf, pdu);
|
||||
|
||||
database.markAsSent(messageId);
|
||||
database.markAsSent(messageId, false);
|
||||
markAttachmentsUploaded(messageId, message.getAttachments());
|
||||
} catch (UndeliverableMessageException | IOException e) {
|
||||
Log.w(TAG, e);
|
||||
|
@ -395,8 +395,7 @@ public class PushDecryptJob extends ContextJob {
|
||||
long threadId = DatabaseFactory.getThreadDatabase(context).getThreadIdFor(recipients);
|
||||
long messageId = database.insertMessageOutbox(masterSecret, expirationUpdateMessage, threadId, false);
|
||||
|
||||
database.markAsSent(messageId);
|
||||
database.markAsPush(messageId);
|
||||
database.markAsSent(messageId, true);
|
||||
|
||||
DatabaseFactory.getRecipientPreferenceDatabase(context).setExpireMessages(recipients, message.getMessage().getExpiresInSeconds());
|
||||
|
||||
@ -429,8 +428,7 @@ public class PushDecryptJob extends ContextJob {
|
||||
long threadId = DatabaseFactory.getThreadDatabase(context).getThreadIdFor(recipients);
|
||||
long messageId = database.insertMessageOutbox(masterSecret, mediaMessage, threadId, false);
|
||||
|
||||
database.markAsSent(messageId);
|
||||
database.markAsPush(messageId);
|
||||
database.markAsSent(messageId, true);
|
||||
|
||||
for (DatabaseAttachment attachment : DatabaseFactory.getAttachmentDatabase(context).getAttachmentsForMessage(messageId)) {
|
||||
ApplicationContext.getInstance(context)
|
||||
@ -506,9 +504,7 @@ public class PushDecryptJob extends ContextJob {
|
||||
long threadId = DatabaseFactory.getThreadDatabase(context).getThreadIdFor(recipients);
|
||||
long messageId = database.insertMessageOutbox(masterSecret, threadId, outgoingTextMessage, false, message.getTimestamp());
|
||||
|
||||
database.markAsSent(messageId);
|
||||
database.markAsPush(messageId);
|
||||
database.markAsSecure(messageId);
|
||||
database.markAsSent(messageId, true);
|
||||
|
||||
if (smsMessageId.isPresent()) {
|
||||
database.deleteMessage(smsMessageId.get());
|
||||
|
@ -70,8 +70,8 @@ public class PushGroupSendJob extends PushSendJob implements InjectableType {
|
||||
|
||||
@Override
|
||||
public void onAdded() {
|
||||
DatabaseFactory.getMmsDatabase(context)
|
||||
.markAsSending(messageId);
|
||||
// DatabaseFactory.getMmsDatabase(context)
|
||||
// .markAsSending(messageId);
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -84,9 +84,9 @@ public class PushGroupSendJob extends PushSendJob implements InjectableType {
|
||||
try {
|
||||
deliver(masterSecret, message, filterRecipientId);
|
||||
|
||||
database.markAsPush(messageId);
|
||||
database.markAsSecure(messageId);
|
||||
database.markAsSent(messageId);
|
||||
// database.markAsPush(messageId);
|
||||
// database.markAsSecure(messageId);
|
||||
database.markAsSent(messageId, true);
|
||||
markAttachmentsUploaded(messageId, message.getAttachments());
|
||||
|
||||
if (message.getExpiresIn() > 0 && !message.isExpirationUpdate()) {
|
||||
@ -114,11 +114,11 @@ public class PushGroupSendJob extends PushSendJob implements InjectableType {
|
||||
}
|
||||
|
||||
database.addFailures(messageId, failures);
|
||||
database.markAsPush(messageId);
|
||||
// database.markAsPush(messageId);
|
||||
|
||||
if (e.getNetworkExceptions().isEmpty() && e.getUntrustedIdentityExceptions().isEmpty()) {
|
||||
database.markAsSecure(messageId);
|
||||
database.markAsSent(messageId);
|
||||
// database.markAsSecure(messageId);
|
||||
database.markAsSent(messageId, true);
|
||||
markAttachmentsUploaded(messageId, message.getAttachments());
|
||||
} else {
|
||||
database.markAsSentFailed(messageId);
|
||||
|
@ -53,9 +53,9 @@ public class PushMediaSendJob extends PushSendJob implements InjectableType {
|
||||
|
||||
@Override
|
||||
public void onAdded() {
|
||||
MmsDatabase mmsDatabase = DatabaseFactory.getMmsDatabase(context);
|
||||
mmsDatabase.markAsSending(messageId);
|
||||
mmsDatabase.markAsPush(messageId);
|
||||
// MmsDatabase mmsDatabase = DatabaseFactory.getMmsDatabase(context);
|
||||
// mmsDatabase.markAsSending(messageId);
|
||||
// mmsDatabase.markAsPush(messageId);
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -69,9 +69,9 @@ public class PushMediaSendJob extends PushSendJob implements InjectableType {
|
||||
|
||||
try {
|
||||
deliver(masterSecret, message);
|
||||
database.markAsPush(messageId);
|
||||
database.markAsSecure(messageId);
|
||||
database.markAsSent(messageId);
|
||||
// database.markAsPush(messageId);
|
||||
// database.markAsSecure(messageId);
|
||||
database.markAsSent(messageId, true);
|
||||
markAttachmentsUploaded(messageId, message.getAttachments());
|
||||
|
||||
if (message.getExpiresIn() > 0 && !message.isExpirationUpdate()) {
|
||||
@ -91,7 +91,7 @@ public class PushMediaSendJob extends PushSendJob implements InjectableType {
|
||||
|
||||
database.addMismatchedIdentity(messageId, recipientId, uie.getIdentityKey());
|
||||
database.markAsSentFailed(messageId);
|
||||
database.markAsPush(messageId);
|
||||
// database.markAsPush(messageId);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -46,11 +46,7 @@ public class PushTextSendJob extends PushSendJob implements InjectableType {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onAdded() {
|
||||
SmsDatabase smsDatabase = DatabaseFactory.getSmsDatabase(context);
|
||||
smsDatabase.markAsSending(messageId);
|
||||
smsDatabase.markAsPush(messageId);
|
||||
}
|
||||
public void onAdded() {}
|
||||
|
||||
@Override
|
||||
public void onSend(MasterSecret masterSecret) throws NoSuchMessageException, RetryLaterException {
|
||||
@ -62,9 +58,7 @@ public class PushTextSendJob extends PushSendJob implements InjectableType {
|
||||
Log.w(TAG, "Sending message: " + messageId);
|
||||
|
||||
deliver(record);
|
||||
database.markAsPush(messageId);
|
||||
database.markAsSecure(messageId);
|
||||
database.markAsSent(messageId);
|
||||
database.markAsSent(messageId, true);
|
||||
|
||||
if (record.getExpiresIn() > 0) {
|
||||
database.markExpireStarted(messageId);
|
||||
|
@ -40,10 +40,7 @@ public class SmsSendJob extends SendJob {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onAdded() {
|
||||
SmsDatabase database = DatabaseFactory.getEncryptingSmsDatabase(context);
|
||||
database.markAsSending(messageId);
|
||||
}
|
||||
public void onAdded() {}
|
||||
|
||||
@Override
|
||||
public void onSend(MasterSecret masterSecret) throws NoSuchMessageException {
|
||||
|
@ -78,7 +78,7 @@ public class SmsSentJob extends MasterSecretJob {
|
||||
|
||||
switch (result) {
|
||||
case Activity.RESULT_OK:
|
||||
database.markAsSent(messageId);
|
||||
database.markAsSent(messageId, false);
|
||||
break;
|
||||
case SmsManager.RESULT_ERROR_NO_SERVICE:
|
||||
case SmsManager.RESULT_ERROR_RADIO_OFF:
|
||||
|
@ -171,8 +171,7 @@ public class MessageSender {
|
||||
private static void sendTextSelf(Context context, long messageId, long expiresIn) {
|
||||
EncryptingSmsDatabase database = DatabaseFactory.getEncryptingSmsDatabase(context);
|
||||
|
||||
database.markAsSent(messageId);
|
||||
database.markAsPush(messageId);
|
||||
database.markAsSent(messageId, true);
|
||||
|
||||
Pair<Long, Long> messageAndThreadId = database.copyMessageInbox(messageId);
|
||||
database.markAsPush(messageAndThreadId.first);
|
||||
@ -192,11 +191,8 @@ public class MessageSender {
|
||||
ExpiringMessageManager expiringMessageManager = ApplicationContext.getInstance(context).getExpiringMessageManager();
|
||||
MmsDatabase database = DatabaseFactory.getMmsDatabase(context);
|
||||
|
||||
database.markAsSent(messageId);
|
||||
database.markAsPush(messageId);
|
||||
|
||||
long newMessageId = database.copyMessageInbox(masterSecret, messageId);
|
||||
database.markAsPush(newMessageId);
|
||||
database.markAsSent(messageId, true);
|
||||
database.copyMessageInbox(masterSecret, messageId);
|
||||
|
||||
if (expiresIn > 0) {
|
||||
database.markExpireStarted(messageId);
|
||||
|
Loading…
x
Reference in New Issue
Block a user