From 4041e2e8cab974bc7232d82705b0854d5783cc22 Mon Sep 17 00:00:00 2001 From: Valere Date: Wed, 3 Jul 2019 18:17:36 +0200 Subject: [PATCH] code review --- .../matrix/android/internal/crypto/CryptoManager.kt | 10 +++++----- .../matrix/android/internal/crypto/MXOlmDevice.kt | 2 +- .../crypto/algorithms/megolm/MXMegolmDecryption.kt | 8 +------- 3 files changed, 7 insertions(+), 13 deletions(-) diff --git a/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/crypto/CryptoManager.kt b/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/crypto/CryptoManager.kt index 8d3ed754..154bfbc9 100755 --- a/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/crypto/CryptoManager.kt +++ b/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/crypto/CryptoManager.kt @@ -840,7 +840,7 @@ internal class CryptoManager @Inject constructor( val roomKeys = MXMegolmExportEncryption.decryptMegolmKeyFile(roomKeysAsArray, password) val t1 = System.currentTimeMillis() - Timber.v("""## importRoomKeys : decryptMegolmKeyFile done in ${t1 - t0} ms""") + Timber.v("## importRoomKeys : decryptMegolmKeyFile done in ${t1 - t0} ms") val importedSessions = MoshiProvider.providesMoshi() .adapter>(Types.newParameterizedType(List::class.java, MegolmSessionData::class.java)) @@ -848,7 +848,7 @@ internal class CryptoManager @Inject constructor( val t2 = System.currentTimeMillis() - Timber.v("""## importRoomKeys : JSON parsing ${t2 - t1} ms""") + Timber.v("## importRoomKeys : JSON parsing ${t2 - t1} ms") if (importedSessions == null) { throw Exception("Error") @@ -1000,9 +1000,9 @@ internal class CryptoManager @Inject constructor( val requestBody = RoomKeyRequestBody() requestBody.roomId = event.roomId - requestBody.algorithm = wireContent["algorithm"].toString() - requestBody.senderKey = wireContent["sender_key"].toString() - requestBody.sessionId = wireContent["session_id"].toString() + requestBody.algorithm = wireContent["algorithm"]?.toString() + requestBody.senderKey = wireContent["sender_key"]?.toString() + requestBody.sessionId = wireContent["session_id"]?.toString() outgoingRoomKeyRequestManager.resendRoomKeyRequest(requestBody) } diff --git a/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/crypto/MXOlmDevice.kt b/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/crypto/MXOlmDevice.kt index 8d71b934..39cbd5e0 100755 --- a/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/crypto/MXOlmDevice.kt +++ b/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/crypto/MXOlmDevice.kt @@ -114,7 +114,7 @@ internal class MXOlmDevice @Inject constructor( try { deviceCurve25519Key = olmAccount!!.identityKeys()[OlmAccount.JSON_KEY_IDENTITY_KEY] } catch (e: Exception) { - Timber.e(e, """## MXOlmDevice : cannot find ${OlmAccount.JSON_KEY_IDENTITY_KEY} with error""") + Timber.e(e, "## MXOlmDevice : cannot find ${OlmAccount.JSON_KEY_IDENTITY_KEY} with error") } try { diff --git a/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/crypto/algorithms/megolm/MXMegolmDecryption.kt b/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/crypto/algorithms/megolm/MXMegolmDecryption.kt index 44f4c18e..177754b0 100644 --- a/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/crypto/algorithms/megolm/MXMegolmDecryption.kt +++ b/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/crypto/algorithms/megolm/MXMegolmDecryption.kt @@ -77,7 +77,6 @@ internal class MXMegolmDecryption(private val credentials: Credentials, MXCryptoError.UNABLE_TO_DECRYPT, MXCryptoError.MISSING_FIELDS_REASON)) } - val eventDecryptionResult: MXEventDecryptionResult? var cryptoError: MXCryptoError? = null var decryptGroupMessageResult: MXDecryptionResult? = null @@ -88,7 +87,7 @@ internal class MXMegolmDecryption(private val credentials: Credentials, } // the decryption succeeds if (decryptGroupMessageResult?.payload != null) { - eventDecryptionResult = MXEventDecryptionResult() + val eventDecryptionResult = MXEventDecryptionResult() eventDecryptionResult.clearEvent = decryptGroupMessageResult.payload eventDecryptionResult.senderCurve25519Key = decryptGroupMessageResult.senderKey @@ -215,11 +214,6 @@ internal class MXMegolmDecryption(private val credentials: Credentials, forwardedRoomKeyContent.forwardingCurve25519KeyChain?.let { forwardingCurve25519KeyChain.addAll(it) } -// forwardingCurve25519KeyChain = if (forwardedRoomKeyContent.forwardingCurve25519KeyChain == null) { -// ArrayList() -// } else { -// ArrayList(forwardedRoomKeyContent.forwardingCurve25519KeyChain) -// } if (senderKey == null) { Timber.e("## onRoomKeyEvent() : event is missing sender_key field")