aboutsummaryrefslogtreecommitdiffstats
path: root/src/main/java/de/pixart/messenger
diff options
context:
space:
mode:
Diffstat (limited to 'src/main/java/de/pixart/messenger')
-rw-r--r--src/main/java/de/pixart/messenger/crypto/axolotl/AxolotlService.java2
-rw-r--r--src/main/java/de/pixart/messenger/crypto/axolotl/SQLiteAxolotlStore.java7
-rw-r--r--src/main/java/de/pixart/messenger/persistance/DatabaseBackend.java19
-rw-r--r--src/main/java/de/pixart/messenger/services/XmppConnectionService.java14
4 files changed, 35 insertions, 7 deletions
diff --git a/src/main/java/de/pixart/messenger/crypto/axolotl/AxolotlService.java b/src/main/java/de/pixart/messenger/crypto/axolotl/AxolotlService.java
index a5ed758c3..b76630873 100644
--- a/src/main/java/de/pixart/messenger/crypto/axolotl/AxolotlService.java
+++ b/src/main/java/de/pixart/messenger/crypto/axolotl/AxolotlService.java
@@ -599,7 +599,7 @@ public class AxolotlService implements OnAdvancedStreamFeaturesLoaded {
// Validate signedPreKeyRecord + ID
SignedPreKeyRecord signedPreKeyRecord;
- int numSignedPreKeys = axolotlStore.loadSignedPreKeys().size();
+ int numSignedPreKeys = axolotlStore.getSignedPreKeysCount();
try {
signedPreKeyRecord = axolotlStore.loadSignedPreKey(bundle.getSignedPreKeyId());
if (flush
diff --git a/src/main/java/de/pixart/messenger/crypto/axolotl/SQLiteAxolotlStore.java b/src/main/java/de/pixart/messenger/crypto/axolotl/SQLiteAxolotlStore.java
index ed944b45a..23024a610 100644
--- a/src/main/java/de/pixart/messenger/crypto/axolotl/SQLiteAxolotlStore.java
+++ b/src/main/java/de/pixart/messenger/crypto/axolotl/SQLiteAxolotlStore.java
@@ -79,9 +79,6 @@ public class SQLiteAxolotlStore implements AxolotlStore {
this.mXmppConnectionService = service;
this.localRegistrationId = loadRegistrationId();
this.currentPreKeyId = loadCurrentPreKeyId();
- for (SignedPreKeyRecord record : loadSignedPreKeys()) {
- Log.d(Config.LOGTAG, AxolotlService.getLogprefix(account) + "Got Axolotl signed prekey record:" + record.getId());
- }
}
public int getCurrentPreKeyId() {
@@ -415,6 +412,10 @@ public class SQLiteAxolotlStore implements AxolotlStore {
return mXmppConnectionService.databaseBackend.loadSignedPreKeys(account);
}
+ public int getSignedPreKeysCount() {
+ return mXmppConnectionService.databaseBackend.getSignedPreKeysCount(account);
+ }
+
/**
* Store a local SignedPreKeyRecord.
*
diff --git a/src/main/java/de/pixart/messenger/persistance/DatabaseBackend.java b/src/main/java/de/pixart/messenger/persistance/DatabaseBackend.java
index 8f264639d..d6e45f5fe 100644
--- a/src/main/java/de/pixart/messenger/persistance/DatabaseBackend.java
+++ b/src/main/java/de/pixart/messenger/persistance/DatabaseBackend.java
@@ -1097,6 +1097,25 @@ public class DatabaseBackend extends SQLiteOpenHelper {
return prekeys;
}
+ public int getSignedPreKeysCount(Account account) {
+ String[] columns = {"count(" + SQLiteAxolotlStore.KEY + ")"};
+ String[] selectionArgs = {account.getUuid()};
+ SQLiteDatabase db = this.getReadableDatabase();
+ Cursor cursor = db.query(SQLiteAxolotlStore.SIGNED_PREKEY_TABLENAME,
+ columns,
+ SQLiteAxolotlStore.ACCOUNT + "=?",
+ selectionArgs,
+ null, null, null);
+ final int count;
+ if (cursor.moveToFirst()) {
+ count = cursor.getInt(0);
+ } else {
+ count = 0;
+ }
+ cursor.close();
+ return count;
+ }
+
public boolean containsSignedPreKey(Account account, int signedPreKeyId) {
Cursor cursor = getCursorForPreKey(account, signedPreKeyId);
int count = cursor.getCount();
diff --git a/src/main/java/de/pixart/messenger/services/XmppConnectionService.java b/src/main/java/de/pixart/messenger/services/XmppConnectionService.java
index 8ad433b0f..a09bc5761 100644
--- a/src/main/java/de/pixart/messenger/services/XmppConnectionService.java
+++ b/src/main/java/de/pixart/messenger/services/XmppConnectionService.java
@@ -1093,7 +1093,9 @@ public class XmppConnectionService extends Service {
}
};
+ Log.d(Config.LOGTAG, "initializing database...");
this.databaseBackend = DatabaseBackend.getInstance(getApplicationContext());
+ Log.d(Config.LOGTAG, "restoring accounts...");
this.accounts = databaseBackend.getAccounts();
if (databaseBackend.startTimeCountExceedsThreshold()) {
@@ -1559,6 +1561,8 @@ public class XmppConnectionService extends Service {
for (Account account : this.accounts) {
accountLookupTable.put(account.getUuid(), account);
}
+ Log.d(Config.LOGTAG, "restoring conversations...");
+ final long startTimeConversationsRestore = SystemClock.elapsedRealtime();
this.conversations.addAll(databaseBackend.getConversations(Conversation.STATUS_AVAILABLE));
for (Iterator<Conversation> iterator = conversations.listIterator(); iterator.hasNext(); ) {
Conversation conversation = iterator.next();
@@ -1570,6 +1574,8 @@ public class XmppConnectionService extends Service {
iterator.remove();
}
}
+ long diffConversationsRestore = SystemClock.elapsedRealtime() - startTimeConversationsRestore;
+ Log.d(Config.LOGTAG, "finished restoring conversations in " + diffConversationsRestore + "ms");
Runnable runnable = new Runnable() {
@Override
public void run() {
@@ -1579,14 +1585,15 @@ public class XmppConnectionService extends Service {
Log.d(Config.LOGTAG, "deleting messages that are older than " + AbstractGenerator.getTimestamp(deletionDate));
databaseBackend.expireOldMessages(deletionDate);
}
- Log.d(Config.LOGTAG, "restoring roster");
+ Log.d(Config.LOGTAG, "restoring roster...");
for (Account account : accounts) {
databaseBackend.readRoster(account.getRoster());
account.initAccountServices(XmppConnectionService.this); //roster needs to be loaded at this stage
}
getBitmapCache().evictAll();
loadPhoneContacts();
- Log.d(Config.LOGTAG, "restoring messages");
+ Log.d(Config.LOGTAG, "restoring messages...");
+ final long startMessageRestore = SystemClock.elapsedRealtime();
for (Conversation conversation : conversations) {
conversation.addAll(0, databaseBackend.getMessages(conversation, Config.PAGE_SIZE));
checkDeletedFiles(conversation);
@@ -1606,7 +1613,8 @@ public class XmppConnectionService extends Service {
}
mNotificationService.finishBacklog(false);
mRestoredFromDatabase = true;
- Log.d(Config.LOGTAG, "restored all messages");
+ final long diffMessageRestore = SystemClock.elapsedRealtime() - startMessageRestore;
+ Log.d(Config.LOGTAG, "finished restoring messages in " + diffMessageRestore + "ms");
updateConversationUi();
}
};