From 12a0cbb400d497729e7ec88935d31eda054da892 Mon Sep 17 00:00:00 2001 From: Benoit Marty Date: Wed, 7 Aug 2019 13:16:04 +0200 Subject: [PATCH 1/3] Fix crash observed on PlayStore --- .../crypto/verification/SasVerificationViewModel.kt | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/vector/src/main/java/im/vector/riotx/features/crypto/verification/SasVerificationViewModel.kt b/vector/src/main/java/im/vector/riotx/features/crypto/verification/SasVerificationViewModel.kt index 87a420d3..41c08e68 100644 --- a/vector/src/main/java/im/vector/riotx/features/crypto/verification/SasVerificationViewModel.kt +++ b/vector/src/main/java/im/vector/riotx/features/crypto/verification/SasVerificationViewModel.kt @@ -29,7 +29,7 @@ import javax.inject.Inject class SasVerificationViewModel @Inject constructor() : ViewModel(), - SasVerificationService.SasVerificationListener { + SasVerificationService.SasVerificationListener { companion object { @@ -40,7 +40,7 @@ class SasVerificationViewModel @Inject constructor() : ViewModel(), const val NAVIGATE_CANCELLED = "NAVIGATE_CANCELLED" } - lateinit var sasVerificationService: SasVerificationService + private lateinit var sasVerificationService: SasVerificationService var otherUserId: String? = null var otherDeviceId: String? = null @@ -154,8 +154,8 @@ class SasVerificationViewModel @Inject constructor() : ViewModel(), override fun onCleared() { super.onCleared() - sasVerificationService.removeListener(this) + if (::sasVerificationService.isInitialized) { + sasVerificationService.removeListener(this) + } } - - } \ No newline at end of file From 3584658c368c929f3989b94c2cecd3188d02e2d7 Mon Sep 17 00:00:00 2001 From: Benoit Marty Date: Wed, 7 Aug 2019 13:24:43 +0200 Subject: [PATCH 2/3] Fix crash (IllegalStateException) observed on PlayStore --- vector/src/main/java/im/vector/riotx/core/intent/Filename.kt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/vector/src/main/java/im/vector/riotx/core/intent/Filename.kt b/vector/src/main/java/im/vector/riotx/core/intent/Filename.kt index 2b8421f6..3ea25294 100644 --- a/vector/src/main/java/im/vector/riotx/core/intent/Filename.kt +++ b/vector/src/main/java/im/vector/riotx/core/intent/Filename.kt @@ -35,9 +35,9 @@ fun getFilenameFromUri(context: Context?, uri: Uri): String? { } if (result == null) { result = uri.path - val cut = result.lastIndexOf('/') + val cut = result?.lastIndexOf('/') ?: -1 if (cut != -1) { - result = result.substring(cut + 1) + result = result?.substring(cut + 1) } } return result From 9f53406e991bef92cbc3a6f1b7ddeee87e605ea1 Mon Sep 17 00:00:00 2001 From: Benoit Marty Date: Wed, 7 Aug 2019 13:35:44 +0200 Subject: [PATCH 3/3] Fix crash (KotlinNullPointerException) observed on PlayStore --- .../matrix/android/internal/crypto/MXOlmDevice.kt | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) 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 d9387ad3..7c5131fc 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 @@ -79,8 +79,7 @@ internal class MXOlmDevice @Inject constructor( // // The first level keys are timeline ids. // The second level keys are strings of form "||" - // Values are true. - private val inboundGroupSessionMessageIndexes: MutableMap> = HashMap() + private val inboundGroupSessionMessageIndexes: MutableMap> = HashMap() init { // Retrieve the account from the store @@ -662,19 +661,17 @@ internal class MXOlmDevice @Inject constructor( } if (null != timeline) { - if (!inboundGroupSessionMessageIndexes.containsKey(timeline)) { - inboundGroupSessionMessageIndexes[timeline] = HashMap() - } + val timelineSet = inboundGroupSessionMessageIndexes.getOrPut(timeline) { mutableSetOf() } val messageIndexKey = senderKey + "|" + sessionId + "|" + decryptResult.mIndex - if (inboundGroupSessionMessageIndexes[timeline]?.get(messageIndexKey) != null) { + if (timelineSet.contains(messageIndexKey)) { val reason = String.format(MXCryptoError.DUPLICATE_MESSAGE_INDEX_REASON, decryptResult.mIndex) Timber.e("## decryptGroupMessage() : $reason") throw MXCryptoError.Base(MXCryptoError.ErrorType.DUPLICATED_MESSAGE_INDEX, reason) } - inboundGroupSessionMessageIndexes[timeline]!!.put(messageIndexKey, true) + timelineSet.add(messageIndexKey) } store.storeInboundGroupSessions(listOf(session))