diff --git a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/crypto/CryptoModule.kt b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/crypto/CryptoModule.kt index 2af51e72bc..98685c7194 100644 --- a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/crypto/CryptoModule.kt +++ b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/crypto/CryptoModule.kt @@ -16,7 +16,6 @@ package org.matrix.android.sdk.internal.crypto -import com.squareup.moshi.Moshi import dagger.Binds import dagger.Module import dagger.Provides @@ -57,7 +56,6 @@ import org.matrix.android.sdk.internal.crypto.keysbackup.tasks.StoreRoomSessionD import org.matrix.android.sdk.internal.crypto.keysbackup.tasks.StoreRoomSessionsDataTask import org.matrix.android.sdk.internal.crypto.keysbackup.tasks.StoreSessionsDataTask import org.matrix.android.sdk.internal.crypto.keysbackup.tasks.UpdateKeysBackupVersionTask -import org.matrix.android.sdk.internal.crypto.network.RequestSender import org.matrix.android.sdk.internal.crypto.store.IMXCryptoStore import org.matrix.android.sdk.internal.crypto.store.db.RealmCryptoStore import org.matrix.android.sdk.internal.crypto.store.db.RealmCryptoStoreMigration @@ -91,9 +89,7 @@ import org.matrix.android.sdk.internal.crypto.tasks.UploadSigningKeysTask import org.matrix.android.sdk.internal.crypto.verification.RustVerificationService import org.matrix.android.sdk.internal.database.RealmKeysUtils import org.matrix.android.sdk.internal.di.CryptoDatabase -import org.matrix.android.sdk.internal.di.DeviceId import org.matrix.android.sdk.internal.di.SessionFilesDirectory -import org.matrix.android.sdk.internal.di.UserId import org.matrix.android.sdk.internal.di.UserMd5 import org.matrix.android.sdk.internal.session.SessionScope import org.matrix.android.sdk.internal.session.cache.ClearCacheTask @@ -132,8 +128,8 @@ internal abstract class CryptoModule { @JvmStatic @Provides @SessionScope - fun providesCryptoCoroutineScope(): CoroutineScope { - return CoroutineScope(SupervisorJob()) + fun providesCryptoCoroutineScope(coroutineDispatchers: MatrixCoroutineDispatchers): CoroutineScope { + return CoroutineScope(SupervisorJob() + coroutineDispatchers.crypto) } @JvmStatic diff --git a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/crypto/DefaultCryptoService.kt b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/crypto/DefaultCryptoService.kt index fc00bed2ec..5b0483203d 100755 --- a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/crypto/DefaultCryptoService.kt +++ b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/crypto/DefaultCryptoService.kt @@ -78,7 +78,6 @@ import org.matrix.android.sdk.internal.di.DeviceId import org.matrix.android.sdk.internal.di.UserId import org.matrix.android.sdk.internal.session.SessionScope import org.matrix.android.sdk.internal.session.StreamEventsManager -import org.matrix.android.sdk.internal.session.room.membership.LoadRoomMembersTask import timber.log.Timber import java.util.concurrent.atomic.AtomicBoolean import javax.inject.Inject @@ -234,6 +233,7 @@ internal class DefaultCryptoService @Inject constructor( fun start() { internalStart() cryptoCoroutineScope.launch { + cryptoStore.open() // Just update fetchDevicesList() cryptoStore.tidyUpDataBase() @@ -264,9 +264,6 @@ internal class DefaultCryptoService @Inject constructor( } } - // Open the store - cryptoStore.open() - isStarting.set(false) isStarted.set(true) } @@ -277,7 +274,7 @@ internal class DefaultCryptoService @Inject constructor( fun close() { cryptoCoroutineScope.coroutineContext.cancelChildren(CancellationException("Closing crypto module")) cryptoCoroutineScope.launch { - withContext(coroutineDispatchers.crypto + NonCancellable) { + withContext(NonCancellable) { cryptoStore.close() } }