mirror of
https://github.com/element-hq/element-android
synced 2024-11-27 03:48:12 +03:00
cleaning
This commit is contained in:
parent
8593f2330f
commit
992ec7f3f4
4 changed files with 17 additions and 13 deletions
|
@ -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) {
|
||||
|
|
|
@ -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)
|
||||
|
||||
|
|
|
@ -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<CryptoService>
|
||||
) {
|
||||
|
||||
|
|
|
@ -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<CryptoMetadataEntity>().findFirst() ?: return null.also {
|
||||
Timber.w("Rust db migration: No existing metadataEntity")
|
||||
}
|
||||
private fun extract(realm: Realm, importPartial: ((MigrationData) -> Unit)) {
|
||||
val metadataEntity = realm.where<CryptoMetadataEntity>().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? {
|
||||
|
|
Loading…
Reference in a new issue