Clean up some code

This commit is contained in:
ganfra 2022-03-04 12:36:31 +01:00
parent b8637ddaf2
commit 2f16a2ebd7
3 changed files with 10 additions and 10 deletions

View File

@ -146,7 +146,6 @@ internal class DefaultCryptoService @Inject constructor(
private val olmMachine by lazy { olmMachineProvider.olmMachine } private val olmMachine by lazy { olmMachineProvider.olmMachine }
// The verification service. // The verification service.
// private var verificationService: RustVerificationService? = null // private var verificationService: RustVerificationService? = null
@ -166,7 +165,7 @@ internal class DefaultCryptoService @Inject constructor(
} }
fun onLiveEvent(roomId: String, event: Event) { fun onLiveEvent(roomId: String, event: Event) {
if(event.isStateEvent()){ if (event.isStateEvent()) {
when (event.getClearType()) { when (event.getClearType()) {
EventType.STATE_ROOM_ENCRYPTION -> onRoomEncryptionEvent(roomId, event) EventType.STATE_ROOM_ENCRYPTION -> onRoomEncryptionEvent(roomId, event)
EventType.STATE_ROOM_MEMBER -> onRoomMembershipEvent(roomId, event) EventType.STATE_ROOM_MEMBER -> onRoomMembershipEvent(roomId, event)

View File

@ -372,22 +372,22 @@ internal class RustKeyBackupService @Inject constructor(
} }
} }
override suspend fun onSecretKeyGossip(curveKeyBase64: String) { override suspend fun onSecretKeyGossip(secret: String) {
Timber.i("## CrossSigning - onSecretKeyGossip") Timber.i("## CrossSigning - onSecretKeyGossip")
withContext(coroutineDispatchers.crypto) { withContext(coroutineDispatchers.crypto) {
try { try {
val version = sender.getKeyBackupVersion() val version = sender.getKeyBackupVersion()
if (version != null) { if (version != null) {
val key = BackupRecoveryKey.fromBase64(curveKeyBase64) val key = BackupRecoveryKey.fromBase64(secret)
if (isValidRecoveryKey(key, version)) { if (isValidRecoveryKey(key, version)) {
trustKeysBackupVersion(version, true) trustKeysBackupVersion(version, true)
// we don't want to wait for that // we don't want to wait for that
importScope.launch { importScope.launch {
try { try {
val importResult = restoreBackup(version, key, null, null, null) val importResult = restoreBackup(version, key, null, null, null)
val recoveredKeys = importResult.successfullyNumberOfImportedKeys
Timber.i("onSecretKeyGossip: Recovered keys ${importResult.successfullyNumberOfImportedKeys} out of ${importResult.totalNumberOfKeys}") Timber.i("onSecretKeyGossip: Recovered keys $recoveredKeys out of ${importResult.totalNumberOfKeys}")
} catch (failure: Throwable) { } catch (failure: Throwable) {
// fail silently.. // fail silently..
Timber.e(failure, "onSecretKeyGossip: Failed to import keys from backup") Timber.e(failure, "onSecretKeyGossip: Failed to import keys from backup")
@ -514,7 +514,8 @@ internal class RustKeyBackupService @Inject constructor(
.flatten() .flatten()
withContext(Dispatchers.Main) { withContext(Dispatchers.Main) {
stepProgressListener?.onStepProgress(StepProgressListener.Step.DecryptingKey(data.roomIdToRoomKeysBackupData.size, data.roomIdToRoomKeysBackupData.size)) val stepProgress = StepProgressListener.Step.DecryptingKey(data.roomIdToRoomKeysBackupData.size, data.roomIdToRoomKeysBackupData.size)
stepProgressListener?.onStepProgress(stepProgress)
} }
Timber.v("restoreKeysWithRecoveryKey: Decrypted ${sessionsData.size} keys out" + Timber.v("restoreKeysWithRecoveryKey: Decrypted ${sessionsData.size} keys out" +
@ -532,7 +533,8 @@ internal class RustKeyBackupService @Inject constructor(
object : ProgressListener { object : ProgressListener {
override fun onProgress(progress: Int, total: Int) { override fun onProgress(progress: Int, total: Int) {
cryptoCoroutineScope.launch(Dispatchers.Main) { cryptoCoroutineScope.launch(Dispatchers.Main) {
stepProgressListener.onStepProgress(StepProgressListener.Step.ImportingKey(progress, total)) val stepProgress = StepProgressListener.Step.ImportingKey(progress, total)
stepProgressListener.onStepProgress(stepProgress)
} }
} }
} }

View File

@ -18,9 +18,8 @@ package org.matrix.android.sdk.internal.session.room.summary
import io.realm.Realm import io.realm.Realm
import io.realm.kotlin.createObject import io.realm.kotlin.createObject
import org.matrix.android.sdk.api.session.crypto.crosssigning.CrossSigningService
import org.matrix.android.sdk.api.extensions.orFalse import org.matrix.android.sdk.api.extensions.orFalse
import org.matrix.android.sdk.api.extensions.tryOrNull import org.matrix.android.sdk.api.session.crypto.crosssigning.CrossSigningService
import org.matrix.android.sdk.api.session.events.model.EventType import org.matrix.android.sdk.api.session.events.model.EventType
import org.matrix.android.sdk.api.session.events.model.toModel import org.matrix.android.sdk.api.session.events.model.toModel
import org.matrix.android.sdk.api.session.room.accountdata.RoomAccountDataTypes import org.matrix.android.sdk.api.session.room.accountdata.RoomAccountDataTypes