diff --git a/matrix-sdk-android/src/androidTest/java/org/matrix/android/sdk/common/CryptoTestHelper.kt b/matrix-sdk-android/src/androidTest/java/org/matrix/android/sdk/common/CryptoTestHelper.kt index 078a458e87..75881fb628 100644 --- a/matrix-sdk-android/src/androidTest/java/org/matrix/android/sdk/common/CryptoTestHelper.kt +++ b/matrix-sdk-android/src/androidTest/java/org/matrix/android/sdk/common/CryptoTestHelper.kt @@ -554,7 +554,7 @@ class CryptoTestHelper(val testHelper: CommonTestHelper) { senderKey = result.senderCurve25519Key, keysClaimed = result.claimedEd25519Key?.let { mapOf("ed25519" to it) }, forwardingCurve25519KeyChain = result.forwardingCurve25519KeyChain, - isSafe = result.isSafe + verificationState = result.messageVerificationState ) } } catch (error: MXCryptoError) { diff --git a/matrix-sdk-android/src/androidTestRustCrypto/java/org/matrix/android/sdk/internal/crypto/store/migration/ElementAndroidToElementRMigrationTest.kt b/matrix-sdk-android/src/androidTestRustCrypto/java/org/matrix/android/sdk/internal/crypto/store/migration/ElementAndroidToElementRMigrationTest.kt index 0c5fb8c975..c4f7abbd49 100644 --- a/matrix-sdk-android/src/androidTestRustCrypto/java/org/matrix/android/sdk/internal/crypto/store/migration/ElementAndroidToElementRMigrationTest.kt +++ b/matrix-sdk-android/src/androidTestRustCrypto/java/org/matrix/android/sdk/internal/crypto/store/migration/ElementAndroidToElementRMigrationTest.kt @@ -90,7 +90,7 @@ class ElementAndroidToElementRMigrationTest : InstrumentedTest { val targetFile = File(configurationFactory.root, "rust-sdk") - extractor.execute(realmConfiguration, targetFile) + extractor.execute(realmConfiguration, targetFile, null) val machine = OlmMachine(userId, deviceId, targetFile.path, null) diff --git a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/room/timeline/RoomSummaryEventDecryptor.kt b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/room/timeline/RoomSummaryEventDecryptor.kt index d77dec3a45..dfda82cc97 100644 --- a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/room/timeline/RoomSummaryEventDecryptor.kt +++ b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/room/timeline/RoomSummaryEventDecryptor.kt @@ -40,7 +40,7 @@ import javax.inject.Inject internal class RoomSummaryEventDecryptor @Inject constructor( @SessionDatabase private val monarchy: Monarchy, private val coroutineDispatchers: MatrixCoroutineDispatchers, - private val cryptoCoroutineScope: CoroutineScope, + cryptoCoroutineScope: CoroutineScope, private val cryptoService: dagger.Lazy ) { diff --git a/matrix-sdk-android/src/rustCrypto/java/org/matrix/android/sdk/internal/crypto/store/db/migration/rust/ExtractMigrationDataUseCase.kt b/matrix-sdk-android/src/rustCrypto/java/org/matrix/android/sdk/internal/crypto/store/db/migration/rust/ExtractMigrationDataUseCase.kt index 1b731efd8b..2403cfb803 100644 --- a/matrix-sdk-android/src/rustCrypto/java/org/matrix/android/sdk/internal/crypto/store/db/migration/rust/ExtractMigrationDataUseCase.kt +++ b/matrix-sdk-android/src/rustCrypto/java/org/matrix/android/sdk/internal/crypto/store/db/migration/rust/ExtractMigrationDataUseCase.kt @@ -29,6 +29,7 @@ import org.matrix.olm.OlmSession import org.matrix.olm.OlmUtility import org.matrix.rustcomponents.sdk.crypto.CrossSigningKeyExport import org.matrix.rustcomponents.sdk.crypto.MigrationData +import org.matrix.rustcomponents.sdk.crypto.MigrationException import org.matrix.rustcomponents.sdk.crypto.PickledAccount import org.matrix.rustcomponents.sdk.crypto.PickledInboundGroupSession import org.matrix.rustcomponents.sdk.crypto.PickledSession @@ -40,9 +41,9 @@ private val charset = Charset.forName("UTF-8") internal class ExtractMigrationDataUseCase { - fun extractData(realm: Realm, importPartial: ((MigrationData) -> Unit)): MigrationData { + fun extractData(realm: Realm, importPartial: ((MigrationData) -> Unit)) { return try { - extract(realm, importPartial) ?: throw ExtractMigrationDataFailure + extract(realm, importPartial) } catch (failure: Throwable) { throw ExtractMigrationDataFailure } @@ -57,10 +58,9 @@ internal class ExtractMigrationDataUseCase { } } - private fun extract(realm: Realm, importPartial: ((MigrationData) -> Unit)): MigrationData? { - val metadataEntity = realm.where().findFirst() ?: return null.also { - Timber.w("Rust db migration: No existing metadataEntity") - } + private fun extract(realm: Realm, importPartial: ((MigrationData) -> Unit)) { + val metadataEntity = realm.where().findFirst() + ?: throw java.lang.IllegalArgumentException("Rust db migration: No existing metadataEntity") val pickleKey = OlmUtility.getRandomKey() @@ -68,14 +68,18 @@ internal class ExtractMigrationDataUseCase { val userKey = metadataEntity.xSignUserPrivateKey val selfSignedKey = metadataEntity.xSignSelfSignedPrivateKey - val userId = metadataEntity.userId ?: return null - val deviceId = metadataEntity.deviceId ?: return null + val userId = metadataEntity.userId + ?: throw java.lang.IllegalArgumentException("Rust db migration: userId is null") + val deviceId = metadataEntity.deviceId + ?: throw java.lang.IllegalArgumentException("Rust db migration: deviceID is null") + val backupVersion = metadataEntity.backupVersion val backupRecoveryKey = metadataEntity.keyBackupRecoveryKey val isOlmAccountShared = metadataEntity.deviceKeysSentToServer - val olmAccount = metadataEntity.getOlmAccount() ?: return null + val olmAccount = metadataEntity.getOlmAccount() + ?: throw java.lang.IllegalArgumentException("Rust db migration: No existing account") val pickledOlmAccount = olmAccount.pickle(pickleKey, StringBuffer()).asString() olmAccount.oneTimeKeys() val pickledAccount = PickledAccount( @@ -168,7 +172,7 @@ internal class ExtractMigrationDataUseCase { // Timber.i("Migration: rust import time $writeTime") // } - return baseExtract +// return baseExtract } private fun OlmInboundGroupSessionEntity.toPickledInboundGroupSession(pickleKey: ByteArray): PickledInboundGroupSession? {