diff --git a/app/src/main/java/im/conversations/android/transformer/Transformer.java b/app/src/main/java/im/conversations/android/transformer/Transformer.java index 421e06b0c..8e2ef90de 100644 --- a/app/src/main/java/im/conversations/android/transformer/Transformer.java +++ b/app/src/main/java/im/conversations/android/transformer/Transformer.java @@ -94,7 +94,8 @@ public class Transformer { try { final var payload = axolotlService.decrypt(transformation.from, encrypted); if (payload.hasPayload()) { - contents = ImmutableList.of(MessageContent.text(payload.payloadAsString(),null)); + contents = + ImmutableList.of(MessageContent.text(payload.payloadAsString(), null)); } else { return true; } diff --git a/app/src/main/java/im/conversations/android/xmpp/manager/AbstractManager.java b/app/src/main/java/im/conversations/android/xmpp/manager/AbstractManager.java index 9bde1e7a6..e75227a25 100644 --- a/app/src/main/java/im/conversations/android/xmpp/manager/AbstractManager.java +++ b/app/src/main/java/im/conversations/android/xmpp/manager/AbstractManager.java @@ -7,7 +7,8 @@ import java.util.concurrent.Executors; public class AbstractManager extends XmppConnection.Delegate { - protected static final Executor IO_EXECUTOR = Executors.newSingleThreadExecutor(); + protected static final Executor FILE_IO_EXECUTOR = Executors.newSingleThreadExecutor(); + protected static final Executor CPU_EXECUTOR = Executors.newSingleThreadExecutor(); protected AbstractManager(final Context context, final XmppConnection connection) { super(context, connection); diff --git a/app/src/main/java/im/conversations/android/xmpp/manager/AvatarManager.java b/app/src/main/java/im/conversations/android/xmpp/manager/AvatarManager.java index 68a4a2a85..c8e50e5b0 100644 --- a/app/src/main/java/im/conversations/android/xmpp/manager/AvatarManager.java +++ b/app/src/main/java/im/conversations/android/xmpp/manager/AvatarManager.java @@ -101,7 +101,8 @@ public class AvatarManager extends AbstractManager { } private ListenableFuture getCachedOrFetch(final Jid address, final String id) { - final var cachedFuture = Futures.submit(() -> getCachedAvatar(address, id), IO_EXECUTOR); + final var cachedFuture = + Futures.submit(() -> getCachedAvatar(address, id), FILE_IO_EXECUTOR); return Futures.catchingAsync( cachedFuture, Exception.class, @@ -133,7 +134,7 @@ public class AvatarManager extends AbstractManager { } throw new IllegalStateException("Avatar sha1hash did not match expected value"); }, - IO_EXECUTOR); + FILE_IO_EXECUTOR); } private File getCacheFile(final Jid address, final String id) { diff --git a/app/src/main/java/im/conversations/android/xmpp/manager/AxolotlManager.java b/app/src/main/java/im/conversations/android/xmpp/manager/AxolotlManager.java index e152673e2..079096c30 100644 --- a/app/src/main/java/im/conversations/android/xmpp/manager/AxolotlManager.java +++ b/app/src/main/java/im/conversations/android/xmpp/manager/AxolotlManager.java @@ -265,8 +265,7 @@ public class AxolotlManager extends AbstractManager { } private ListenableFuture publishBundle() { - final ListenableFuture bundleFuture = - Futures.submit(this::prepareBundle, IO_EXECUTOR); + final ListenableFuture bundleFuture = prepareBundle(); return Futures.transformAsync( bundleFuture, bundle -> { @@ -282,8 +281,13 @@ public class AxolotlManager extends AbstractManager { MoreExecutors.directExecutor()); } - private Bundle prepareBundle() { - refillPreKeys(); + private ListenableFuture prepareBundle() { + final var refillFuture = Futures.submit(this::refillPreKeys, CPU_EXECUTOR); + return Futures.transform( + refillFuture, this::prepareBundle, getDatabase().getQueryExecutor()); + } + + private Bundle prepareBundle(Void v) { final var bundle = new Bundle(); bundle.setIdentityKey( signalProtocolStore().getIdentityKeyPair().getPublicKey().getPublicKey());