From a57393cafa59cb18545929cbe39b8e7079acee69 Mon Sep 17 00:00:00 2001 From: Valere Date: Tue, 28 Jan 2020 18:09:17 +0100 Subject: [PATCH] More log + quick fix in settings --- .../qrcode/DefaultQrCodeVerificationTransaction.kt | 9 +++++++-- .../settings/VectorSettingsSecurityPrivacyFragment.kt | 8 ++++++-- 2 files changed, 13 insertions(+), 4 deletions(-) diff --git a/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/crypto/verification/qrcode/DefaultQrCodeVerificationTransaction.kt b/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/crypto/verification/qrcode/DefaultQrCodeVerificationTransaction.kt index 4f4c3e9317..60216600f0 100644 --- a/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/crypto/verification/qrcode/DefaultQrCodeVerificationTransaction.kt +++ b/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/crypto/verification/qrcode/DefaultQrCodeVerificationTransaction.kt @@ -64,28 +64,33 @@ internal class DefaultQrCodeVerificationTransaction( override fun userHasScannedOtherQrCode(otherQrCodeText: String) { val otherQrCodeData = otherQrCodeText.toQrCodeData() ?: run { + Timber.d("## Verification QR: Invalid QR Code Data") cancel(CancelCode.QrCodeInvalid) return } // Perform some checks if (otherQrCodeData.action != QrCodeData.ACTION_VERIFY) { + Timber.d("## Verification QR: Invalid action ${otherQrCodeData.action}") cancel(CancelCode.QrCodeInvalid) return } if (otherQrCodeData.userId != otherUserId) { + Timber.d("## Verification QR: Mismatched user ${otherQrCodeData.userId}") cancel(CancelCode.MismatchedUser) return } if (otherQrCodeData.requestEventId != transactionId) { + Timber.d("## Verification QR: Invalid transaction actual ${otherQrCodeData.requestEventId} expected:$transactionId") cancel(CancelCode.QrCodeInvalid) return } // check master key if (otherQrCodeData.otherUserKey != crossSigningService.getUserCrossSigningKeys(userId)?.masterKey()?.unpaddedBase64PublicKey) { + Timber.d("## Verification QR: Invalid other master key ${otherQrCodeData.otherUserKey}") cancel(CancelCode.MismatchedKeys) return } @@ -95,7 +100,7 @@ internal class DefaultQrCodeVerificationTransaction( val otherDevices = cryptoStore.getUserDevices(otherUserId) otherQrCodeData.keys.keys.forEach { key -> - Timber.w("Checking key $key") + Timber.w("## Verification QR: Checking key $key") when (val keyNoPrefix = key.withoutPrefix("ed25519:")) { otherQrCodeData.keys[key] -> { @@ -150,7 +155,7 @@ internal class DefaultQrCodeVerificationTransaction( fun start(remoteSecret: String) { if (state != VerificationTxState.None) { - Timber.e("## SAS O: start verification from invalid state") + Timber.e("## Verification QR: start verification from invalid state") // should I cancel?? throw IllegalStateException("Interactive Key verification already started") } diff --git a/vector/src/main/java/im/vector/riotx/features/settings/VectorSettingsSecurityPrivacyFragment.kt b/vector/src/main/java/im/vector/riotx/features/settings/VectorSettingsSecurityPrivacyFragment.kt index bc56351106..e688b6b68e 100644 --- a/vector/src/main/java/im/vector/riotx/features/settings/VectorSettingsSecurityPrivacyFragment.kt +++ b/vector/src/main/java/im/vector/riotx/features/settings/VectorSettingsSecurityPrivacyFragment.kt @@ -429,11 +429,15 @@ class VectorSettingsSecurityPrivacyFragment @Inject constructor( // TODO Move to a ViewModel... session.getDevicesList(object : MatrixCallback { override fun onSuccess(data: DevicesListResponse) { - refreshCryptographyPreference(data.devices ?: emptyList()) + if (isAdded) { + refreshCryptographyPreference(data.devices ?: emptyList()) + } } override fun onFailure(failure: Throwable) { - refreshCryptographyPreference(emptyList()) + if (isAdded) { + refreshCryptographyPreference(emptyList()) + } } }) }