Merge pull request #3957 from vector-im/feature/bma/ktlint_cleanup
Install ktlint plugin
This commit is contained in:
commit
587c634a49
@ -9,25 +9,6 @@ insert_final_newline=true
|
|||||||
# it's automatically set to 100 on `ktlint --android ...` (per Android Kotlin Style Guide)
|
# it's automatically set to 100 on `ktlint --android ...` (per Android Kotlin Style Guide)
|
||||||
max_line_length=off
|
max_line_length=off
|
||||||
|
|
||||||
# Comma-separated list of rules to disable (Since 0.34.0)
|
# From https://github.com/pinterest/ktlint#custom-ktlint-specific-editorconfig-properties
|
||||||
# Note that rules in any ruleset other than the standard ruleset will need to be prefixed
|
# default IntelliJ IDEA style, same as alphabetical, but with "java", "javax", "kotlin" and alias imports in the end of the imports list
|
||||||
# by the ruleset identifier.
|
ij_kotlin_imports_layout=*,java.**,javax.**,kotlin.**,^
|
||||||
disabled_rules=no-multi-spaces,colon-spacing,chain-wrapping,import-ordering,experimental:annotation
|
|
||||||
|
|
||||||
# The following (so far identified) rules are kept:
|
|
||||||
# no-blank-line-before-rbrace
|
|
||||||
# final-newline
|
|
||||||
# no-consecutive-blank-lines
|
|
||||||
# comment-spacing
|
|
||||||
# filename
|
|
||||||
# comma-spacing
|
|
||||||
# paren-spacing
|
|
||||||
# op-spacing
|
|
||||||
# string-template
|
|
||||||
# no-unused-imports
|
|
||||||
# curly-spacing
|
|
||||||
# no-semi
|
|
||||||
# no-empty-class-body
|
|
||||||
# experimental:multiline-if-else
|
|
||||||
# experimental:no-empty-first-line-in-method-block
|
|
||||||
# no-wildcard-imports
|
|
||||||
|
8
.github/workflows/quality.yml
vendored
8
.github/workflows/quality.yml
vendored
@ -21,8 +21,12 @@ jobs:
|
|||||||
- uses: actions/checkout@v2
|
- uses: actions/checkout@v2
|
||||||
- name: Run klint
|
- name: Run klint
|
||||||
run: |
|
run: |
|
||||||
curl -sSLO https://github.com/pinterest/ktlint/releases/download/0.36.0/ktlint && chmod a+x ktlint
|
./gradlew ktlintCheck --continue
|
||||||
./ktlint --android --experimental -v
|
- name: Upload reports
|
||||||
|
uses: actions/upload-artifact@v2
|
||||||
|
with:
|
||||||
|
name: ktlinting-report
|
||||||
|
path: vector/build/reports/ktlint/*.*
|
||||||
|
|
||||||
# Lint for main module and all the other modules
|
# Lint for main module and all the other modules
|
||||||
android-lint:
|
android-lint:
|
||||||
|
2
.gitignore
vendored
2
.gitignore
vendored
@ -16,4 +16,4 @@
|
|||||||
/fastlane/private
|
/fastlane/private
|
||||||
/fastlane/report.xml
|
/fastlane/report.xml
|
||||||
|
|
||||||
ktlint
|
/library/build
|
||||||
|
@ -80,14 +80,13 @@ Make sure the following commands execute without any error:
|
|||||||
#### ktlint
|
#### ktlint
|
||||||
|
|
||||||
<pre>
|
<pre>
|
||||||
curl -sSLO https://github.com/pinterest/ktlint/releases/download/0.34.2/ktlint && chmod a+x ktlint
|
./gradlew ktlintCheck --continue
|
||||||
./ktlint --android --experimental -v
|
|
||||||
</pre>
|
</pre>
|
||||||
|
|
||||||
Note that you can run
|
Note that you can run
|
||||||
|
|
||||||
<pre>
|
<pre>
|
||||||
./ktlint --android --experimental -v -F
|
./gradlew ktlintFormat
|
||||||
</pre>
|
</pre>
|
||||||
|
|
||||||
For ktlint to fix some detected errors for you (you still have to check and commit the fix of course)
|
For ktlint to fix some detected errors for you (you still have to check and commit the fix of course)
|
||||||
|
@ -39,7 +39,6 @@ import androidx.core.view.updatePadding
|
|||||||
import androidx.transition.TransitionManager
|
import androidx.transition.TransitionManager
|
||||||
import androidx.viewpager2.widget.ViewPager2
|
import androidx.viewpager2.widget.ViewPager2
|
||||||
import im.vector.lib.attachmentviewer.databinding.ActivityAttachmentViewerBinding
|
import im.vector.lib.attachmentviewer.databinding.ActivityAttachmentViewerBinding
|
||||||
|
|
||||||
import java.lang.ref.WeakReference
|
import java.lang.ref.WeakReference
|
||||||
import kotlin.math.abs
|
import kotlin.math.abs
|
||||||
|
|
||||||
@ -291,8 +290,8 @@ abstract class AttachmentViewerActivity : AppCompatActivity(), AttachmentEventLi
|
|||||||
private fun calculateTranslationAlpha(translationY: Float, translationLimit: Int): Float =
|
private fun calculateTranslationAlpha(translationY: Float, translationLimit: Int): Float =
|
||||||
1.0f - 1.0f / translationLimit.toFloat() / 4f * abs(translationY)
|
1.0f - 1.0f / translationLimit.toFloat() / 4f * abs(translationY)
|
||||||
|
|
||||||
private fun createSwipeToDismissHandler()
|
private fun createSwipeToDismissHandler(): SwipeToDismissHandler =
|
||||||
: SwipeToDismissHandler = SwipeToDismissHandler(
|
SwipeToDismissHandler(
|
||||||
swipeView = views.dismissContainer,
|
swipeView = views.dismissContainer,
|
||||||
shouldAnimateDismiss = { shouldAnimateDismiss() },
|
shouldAnimateDismiss = { shouldAnimateDismiss() },
|
||||||
onDismiss = { animateClose() },
|
onDismiss = { animateClose() },
|
||||||
|
@ -36,8 +36,8 @@ interface ImageLoaderTarget {
|
|||||||
fun onResourceReady(uid: String, resource: Drawable)
|
fun onResourceReady(uid: String, resource: Drawable)
|
||||||
}
|
}
|
||||||
|
|
||||||
internal class DefaultImageLoaderTarget(val holder: AnimatedImageViewHolder, private val contextView: ImageView)
|
internal class DefaultImageLoaderTarget(val holder: AnimatedImageViewHolder, private val contextView: ImageView) :
|
||||||
: ImageLoaderTarget {
|
ImageLoaderTarget {
|
||||||
override fun contextView(): ImageView {
|
override fun contextView(): ImageView {
|
||||||
return contextView
|
return contextView
|
||||||
}
|
}
|
||||||
|
27
build.gradle
27
build.gradle
@ -27,7 +27,14 @@ buildscript {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ktlint Plugin
|
||||||
|
plugins {
|
||||||
|
id "org.jlleitschuh.gradle.ktlint" version "10.1.0"
|
||||||
|
}
|
||||||
|
|
||||||
allprojects {
|
allprojects {
|
||||||
|
apply plugin: "org.jlleitschuh.gradle.ktlint"
|
||||||
|
|
||||||
repositories {
|
repositories {
|
||||||
// For olm library. This has to be declared first, to ensure that Olm library is not downloaded from another repo
|
// For olm library. This has to be declared first, to ensure that Olm library is not downloaded from another repo
|
||||||
maven {
|
maven {
|
||||||
@ -75,6 +82,26 @@ allprojects {
|
|||||||
// You can override by passing `-PallWarningsAsErrors=false` in the command line
|
// You can override by passing `-PallWarningsAsErrors=false` in the command line
|
||||||
kotlinOptions.allWarningsAsErrors = project.getProperties().getOrDefault("allWarningsAsErrors", "true").toBoolean()
|
kotlinOptions.allWarningsAsErrors = project.getProperties().getOrDefault("allWarningsAsErrors", "true").toBoolean()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Fix "Java heap space" issue
|
||||||
|
tasks.withType(org.jlleitschuh.gradle.ktlint.tasks.BaseKtLintCheckTask).configureEach {
|
||||||
|
it.workerMaxHeapSize.set("2G")
|
||||||
|
}
|
||||||
|
|
||||||
|
// See https://github.com/JLLeitschuh/ktlint-gradle#configuration
|
||||||
|
ktlint {
|
||||||
|
android = true
|
||||||
|
ignoreFailures = false
|
||||||
|
enableExperimentalRules = true
|
||||||
|
// display the corresponding rule
|
||||||
|
verbose = true
|
||||||
|
disabledRules = [
|
||||||
|
"spacing-between-declarations-with-comments",
|
||||||
|
"no-multi-spaces",
|
||||||
|
"experimental:spacing-between-declarations-with-annotations",
|
||||||
|
"experimental:annotation"
|
||||||
|
]
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
task clean(type: Delete) {
|
task clean(type: Delete) {
|
||||||
|
1
changelog.d/3957.misc
Normal file
1
changelog.d/3957.misc
Normal file
@ -0,0 +1 @@
|
|||||||
|
Use ktlint plugin. See [the documentation](https://github.com/vector-im/element-android/blob/develop/CONTRIBUTING.md#ktlint) for more detail.
|
@ -34,8 +34,8 @@ private class LiveDataObservable<T>(
|
|||||||
liveData.observeForever(relay)
|
liveData.observeForever(relay)
|
||||||
}
|
}
|
||||||
|
|
||||||
private inner class RemoveObserverInMainThread(private val observer: io.reactivex.Observer<in T>)
|
private inner class RemoveObserverInMainThread(private val observer: io.reactivex.Observer<in T>) :
|
||||||
: MainThreadDisposable(), Observer<T> {
|
MainThreadDisposable(), Observer<T> {
|
||||||
|
|
||||||
override fun onChanged(t: T?) {
|
override fun onChanged(t: T?) {
|
||||||
if (!isDisposed) {
|
if (!isDisposed) {
|
||||||
|
@ -16,8 +16,8 @@
|
|||||||
|
|
||||||
package org.matrix.android.sdk.rx
|
package org.matrix.android.sdk.rx
|
||||||
|
|
||||||
import org.matrix.android.sdk.api.util.Optional
|
|
||||||
import io.reactivex.Observable
|
import io.reactivex.Observable
|
||||||
|
import org.matrix.android.sdk.api.util.Optional
|
||||||
|
|
||||||
fun <T : Any> Observable<Optional<T>>.unwrap(): Observable<T> {
|
fun <T : Any> Observable<Optional<T>>.unwrap(): Observable<T> {
|
||||||
return filter { it.hasValue() }.map { it.get() }
|
return filter { it.hasValue() }.map { it.get() }
|
||||||
|
@ -18,8 +18,8 @@ package org.matrix.android.sdk
|
|||||||
|
|
||||||
import android.content.Context
|
import android.content.Context
|
||||||
import androidx.test.core.app.ApplicationProvider
|
import androidx.test.core.app.ApplicationProvider
|
||||||
import org.matrix.android.sdk.test.shared.createTimberTestRule
|
|
||||||
import org.junit.Rule
|
import org.junit.Rule
|
||||||
|
import org.matrix.android.sdk.test.shared.createTimberTestRule
|
||||||
|
|
||||||
interface InstrumentedTest {
|
interface InstrumentedTest {
|
||||||
|
|
||||||
|
@ -16,9 +16,9 @@
|
|||||||
|
|
||||||
package org.matrix.android.sdk
|
package org.matrix.android.sdk
|
||||||
|
|
||||||
import org.matrix.android.sdk.internal.util.MatrixCoroutineDispatchers
|
|
||||||
import kotlinx.coroutines.Dispatchers.Main
|
import kotlinx.coroutines.Dispatchers.Main
|
||||||
import kotlinx.coroutines.asCoroutineDispatcher
|
import kotlinx.coroutines.asCoroutineDispatcher
|
||||||
|
import org.matrix.android.sdk.internal.util.MatrixCoroutineDispatchers
|
||||||
import java.util.concurrent.Executors
|
import java.util.concurrent.Executors
|
||||||
|
|
||||||
internal val testCoroutineDispatchers = MatrixCoroutineDispatchers(Main, Main, Main, Main,
|
internal val testCoroutineDispatchers = MatrixCoroutineDispatchers(Main, Main, Main, Main,
|
||||||
|
@ -16,16 +16,16 @@
|
|||||||
|
|
||||||
package org.matrix.android.sdk.account
|
package org.matrix.android.sdk.account
|
||||||
|
|
||||||
import org.matrix.android.sdk.InstrumentedTest
|
|
||||||
import org.matrix.android.sdk.common.CommonTestHelper
|
|
||||||
import org.matrix.android.sdk.common.CryptoTestHelper
|
|
||||||
import org.matrix.android.sdk.common.SessionTestParams
|
|
||||||
import org.matrix.android.sdk.common.TestConstants
|
|
||||||
import org.junit.FixMethodOrder
|
import org.junit.FixMethodOrder
|
||||||
import org.junit.Test
|
import org.junit.Test
|
||||||
import org.junit.runner.RunWith
|
import org.junit.runner.RunWith
|
||||||
import org.junit.runners.JUnit4
|
import org.junit.runners.JUnit4
|
||||||
import org.junit.runners.MethodSorters
|
import org.junit.runners.MethodSorters
|
||||||
|
import org.matrix.android.sdk.InstrumentedTest
|
||||||
|
import org.matrix.android.sdk.common.CommonTestHelper
|
||||||
|
import org.matrix.android.sdk.common.CryptoTestHelper
|
||||||
|
import org.matrix.android.sdk.common.SessionTestParams
|
||||||
|
import org.matrix.android.sdk.common.TestConstants
|
||||||
|
|
||||||
@RunWith(JUnit4::class)
|
@RunWith(JUnit4::class)
|
||||||
@FixMethodOrder(MethodSorters.JVM)
|
@FixMethodOrder(MethodSorters.JVM)
|
||||||
|
@ -16,17 +16,17 @@
|
|||||||
|
|
||||||
package org.matrix.android.sdk.account
|
package org.matrix.android.sdk.account
|
||||||
|
|
||||||
import org.matrix.android.sdk.InstrumentedTest
|
|
||||||
import org.matrix.android.sdk.api.failure.isInvalidPassword
|
|
||||||
import org.matrix.android.sdk.common.CommonTestHelper
|
|
||||||
import org.matrix.android.sdk.common.SessionTestParams
|
|
||||||
import org.matrix.android.sdk.common.TestConstants
|
|
||||||
import org.amshove.kluent.shouldBeTrue
|
import org.amshove.kluent.shouldBeTrue
|
||||||
import org.junit.FixMethodOrder
|
import org.junit.FixMethodOrder
|
||||||
import org.junit.Test
|
import org.junit.Test
|
||||||
import org.junit.runner.RunWith
|
import org.junit.runner.RunWith
|
||||||
import org.junit.runners.JUnit4
|
import org.junit.runners.JUnit4
|
||||||
import org.junit.runners.MethodSorters
|
import org.junit.runners.MethodSorters
|
||||||
|
import org.matrix.android.sdk.InstrumentedTest
|
||||||
|
import org.matrix.android.sdk.api.failure.isInvalidPassword
|
||||||
|
import org.matrix.android.sdk.common.CommonTestHelper
|
||||||
|
import org.matrix.android.sdk.common.SessionTestParams
|
||||||
|
import org.matrix.android.sdk.common.TestConstants
|
||||||
|
|
||||||
@RunWith(JUnit4::class)
|
@RunWith(JUnit4::class)
|
||||||
@FixMethodOrder(MethodSorters.JVM)
|
@FixMethodOrder(MethodSorters.JVM)
|
||||||
|
@ -67,9 +67,9 @@ class DeactivateAccountTest : InstrumentedTest {
|
|||||||
val throwable = commonTestHelper.logAccountWithError(session.myUserId, TestConstants.PASSWORD)
|
val throwable = commonTestHelper.logAccountWithError(session.myUserId, TestConstants.PASSWORD)
|
||||||
|
|
||||||
// Test the error
|
// Test the error
|
||||||
assertTrue(throwable is Failure.ServerError
|
assertTrue(throwable is Failure.ServerError &&
|
||||||
&& throwable.error.code == MatrixError.M_USER_DEACTIVATED
|
throwable.error.code == MatrixError.M_USER_DEACTIVATED &&
|
||||||
&& throwable.error.message == "This account has been deactivated")
|
throwable.error.message == "This account has been deactivated")
|
||||||
|
|
||||||
// Try to create an account with the deactivate account user id, it will fail (M_USER_IN_USE)
|
// Try to create an account with the deactivate account user id, it will fail (M_USER_IN_USE)
|
||||||
val hs = commonTestHelper.createHomeServerConfig()
|
val hs = commonTestHelper.createHomeServerConfig()
|
||||||
@ -95,8 +95,8 @@ class DeactivateAccountTest : InstrumentedTest {
|
|||||||
|
|
||||||
// Test the error
|
// Test the error
|
||||||
accountCreationError.let {
|
accountCreationError.let {
|
||||||
assertTrue(it is Failure.ServerError
|
assertTrue(it is Failure.ServerError &&
|
||||||
&& it.error.code == MatrixError.M_USER_IN_USE)
|
it.error.code == MatrixError.M_USER_IN_USE)
|
||||||
}
|
}
|
||||||
|
|
||||||
// No need to close the session, it has been deactivated
|
// No need to close the session, it has been deactivated
|
||||||
|
@ -15,12 +15,12 @@
|
|||||||
*/
|
*/
|
||||||
package org.matrix.android.sdk.common
|
package org.matrix.android.sdk.common
|
||||||
|
|
||||||
import org.matrix.android.sdk.internal.session.TestInterceptor
|
|
||||||
import okhttp3.Interceptor
|
import okhttp3.Interceptor
|
||||||
import okhttp3.Protocol
|
import okhttp3.Protocol
|
||||||
import okhttp3.Request
|
import okhttp3.Request
|
||||||
import okhttp3.Response
|
import okhttp3.Response
|
||||||
import okhttp3.ResponseBody.Companion.toResponseBody
|
import okhttp3.ResponseBody.Companion.toResponseBody
|
||||||
|
import org.matrix.android.sdk.internal.session.TestInterceptor
|
||||||
import javax.net.ssl.HttpsURLConnection
|
import javax.net.ssl.HttpsURLConnection
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -17,8 +17,8 @@
|
|||||||
package org.matrix.android.sdk.common
|
package org.matrix.android.sdk.common
|
||||||
|
|
||||||
import androidx.annotation.CallSuper
|
import androidx.annotation.CallSuper
|
||||||
import org.matrix.android.sdk.api.MatrixCallback
|
|
||||||
import org.junit.Assert.fail
|
import org.junit.Assert.fail
|
||||||
|
import org.matrix.android.sdk.api.MatrixCallback
|
||||||
import timber.log.Timber
|
import timber.log.Timber
|
||||||
import java.util.concurrent.CountDownLatch
|
import java.util.concurrent.CountDownLatch
|
||||||
|
|
||||||
|
@ -26,9 +26,9 @@ import org.junit.Test
|
|||||||
import org.junit.runner.RunWith
|
import org.junit.runner.RunWith
|
||||||
import org.junit.runners.MethodSorters
|
import org.junit.runners.MethodSorters
|
||||||
import org.matrix.android.sdk.internal.crypto.attachments.MXEncryptedAttachments
|
import org.matrix.android.sdk.internal.crypto.attachments.MXEncryptedAttachments
|
||||||
|
import org.matrix.android.sdk.internal.crypto.attachments.toElementToDecrypt
|
||||||
import org.matrix.android.sdk.internal.crypto.model.rest.EncryptedFileInfo
|
import org.matrix.android.sdk.internal.crypto.model.rest.EncryptedFileInfo
|
||||||
import org.matrix.android.sdk.internal.crypto.model.rest.EncryptedFileKey
|
import org.matrix.android.sdk.internal.crypto.model.rest.EncryptedFileKey
|
||||||
import org.matrix.android.sdk.internal.crypto.attachments.toElementToDecrypt
|
|
||||||
import java.io.ByteArrayOutputStream
|
import java.io.ByteArrayOutputStream
|
||||||
import java.io.InputStream
|
import java.io.InputStream
|
||||||
|
|
||||||
|
@ -16,12 +16,12 @@
|
|||||||
|
|
||||||
package org.matrix.android.sdk.internal.crypto
|
package org.matrix.android.sdk.internal.crypto
|
||||||
|
|
||||||
|
import io.realm.RealmConfiguration
|
||||||
import org.matrix.android.sdk.internal.crypto.store.IMXCryptoStore
|
import org.matrix.android.sdk.internal.crypto.store.IMXCryptoStore
|
||||||
import org.matrix.android.sdk.internal.crypto.store.db.RealmCryptoStore
|
import org.matrix.android.sdk.internal.crypto.store.db.RealmCryptoStore
|
||||||
import org.matrix.android.sdk.internal.crypto.store.db.RealmCryptoStoreModule
|
import org.matrix.android.sdk.internal.crypto.store.db.RealmCryptoStoreModule
|
||||||
import org.matrix.android.sdk.internal.crypto.store.db.mapper.CrossSigningKeysMapper
|
import org.matrix.android.sdk.internal.crypto.store.db.mapper.CrossSigningKeysMapper
|
||||||
import org.matrix.android.sdk.internal.di.MoshiProvider
|
import org.matrix.android.sdk.internal.di.MoshiProvider
|
||||||
import io.realm.RealmConfiguration
|
|
||||||
import kotlin.random.Random
|
import kotlin.random.Random
|
||||||
|
|
||||||
internal class CryptoStoreHelper {
|
internal class CryptoStoreHelper {
|
||||||
|
@ -17,9 +17,6 @@
|
|||||||
package org.matrix.android.sdk.internal.crypto
|
package org.matrix.android.sdk.internal.crypto
|
||||||
|
|
||||||
import androidx.test.ext.junit.runners.AndroidJUnit4
|
import androidx.test.ext.junit.runners.AndroidJUnit4
|
||||||
import org.matrix.android.sdk.InstrumentedTest
|
|
||||||
import org.matrix.android.sdk.internal.crypto.model.OlmSessionWrapper
|
|
||||||
import org.matrix.android.sdk.internal.crypto.store.IMXCryptoStore
|
|
||||||
import io.realm.Realm
|
import io.realm.Realm
|
||||||
import org.junit.Assert.assertEquals
|
import org.junit.Assert.assertEquals
|
||||||
import org.junit.Assert.assertNotEquals
|
import org.junit.Assert.assertNotEquals
|
||||||
@ -27,6 +24,9 @@ import org.junit.Assert.assertNull
|
|||||||
import org.junit.Before
|
import org.junit.Before
|
||||||
import org.junit.Test
|
import org.junit.Test
|
||||||
import org.junit.runner.RunWith
|
import org.junit.runner.RunWith
|
||||||
|
import org.matrix.android.sdk.InstrumentedTest
|
||||||
|
import org.matrix.android.sdk.internal.crypto.model.OlmSessionWrapper
|
||||||
|
import org.matrix.android.sdk.internal.crypto.store.IMXCryptoStore
|
||||||
import org.matrix.olm.OlmAccount
|
import org.matrix.olm.OlmAccount
|
||||||
import org.matrix.olm.OlmManager
|
import org.matrix.olm.OlmManager
|
||||||
import org.matrix.olm.OlmSession
|
import org.matrix.olm.OlmSession
|
||||||
|
@ -50,8 +50,8 @@ class PreShareKeysTest : InstrumentedTest {
|
|||||||
aliceSession.cryptoService().discardOutboundSession(e2eRoomID)
|
aliceSession.cryptoService().discardOutboundSession(e2eRoomID)
|
||||||
|
|
||||||
val preShareCount = bobSession.cryptoService().getGossipingEvents().count {
|
val preShareCount = bobSession.cryptoService().getGossipingEvents().count {
|
||||||
it.senderId == aliceSession.myUserId
|
it.senderId == aliceSession.myUserId &&
|
||||||
&& it.getClearType() == EventType.ROOM_KEY
|
it.getClearType() == EventType.ROOM_KEY
|
||||||
}
|
}
|
||||||
|
|
||||||
assertEquals("Bob should not have receive any key from alice at this point", 0, preShareCount)
|
assertEquals("Bob should not have receive any key from alice at this point", 0, preShareCount)
|
||||||
@ -65,16 +65,16 @@ class PreShareKeysTest : InstrumentedTest {
|
|||||||
mTestHelper.waitWithLatch { latch ->
|
mTestHelper.waitWithLatch { latch ->
|
||||||
mTestHelper.retryPeriodicallyWithLatch(latch) {
|
mTestHelper.retryPeriodicallyWithLatch(latch) {
|
||||||
val newGossipCount = bobSession.cryptoService().getGossipingEvents().count {
|
val newGossipCount = bobSession.cryptoService().getGossipingEvents().count {
|
||||||
it.senderId == aliceSession.myUserId
|
it.senderId == aliceSession.myUserId &&
|
||||||
&& it.getClearType() == EventType.ROOM_KEY
|
it.getClearType() == EventType.ROOM_KEY
|
||||||
}
|
}
|
||||||
newGossipCount > preShareCount
|
newGossipCount > preShareCount
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
val latest = bobSession.cryptoService().getGossipingEvents().lastOrNull {
|
val latest = bobSession.cryptoService().getGossipingEvents().lastOrNull {
|
||||||
it.senderId == aliceSession.myUserId
|
it.senderId == aliceSession.myUserId &&
|
||||||
&& it.getClearType() == EventType.ROOM_KEY
|
it.getClearType() == EventType.ROOM_KEY
|
||||||
}
|
}
|
||||||
|
|
||||||
val content = latest?.getClearContent().toModel<RoomKeyContent>()
|
val content = latest?.getClearContent().toModel<RoomKeyContent>()
|
||||||
|
@ -18,6 +18,11 @@ package org.matrix.android.sdk.internal.crypto.gossiping
|
|||||||
|
|
||||||
import android.util.Log
|
import android.util.Log
|
||||||
import androidx.test.ext.junit.runners.AndroidJUnit4
|
import androidx.test.ext.junit.runners.AndroidJUnit4
|
||||||
|
import org.junit.Assert
|
||||||
|
import org.junit.FixMethodOrder
|
||||||
|
import org.junit.Test
|
||||||
|
import org.junit.runner.RunWith
|
||||||
|
import org.junit.runners.MethodSorters
|
||||||
import org.matrix.android.sdk.InstrumentedTest
|
import org.matrix.android.sdk.InstrumentedTest
|
||||||
import org.matrix.android.sdk.api.NoOpMatrixCallback
|
import org.matrix.android.sdk.api.NoOpMatrixCallback
|
||||||
import org.matrix.android.sdk.api.extensions.tryOrNull
|
import org.matrix.android.sdk.api.extensions.tryOrNull
|
||||||
@ -31,11 +36,6 @@ import org.matrix.android.sdk.common.SessionTestParams
|
|||||||
import org.matrix.android.sdk.common.TestConstants
|
import org.matrix.android.sdk.common.TestConstants
|
||||||
import org.matrix.android.sdk.internal.crypto.model.event.EncryptedEventContent
|
import org.matrix.android.sdk.internal.crypto.model.event.EncryptedEventContent
|
||||||
import org.matrix.android.sdk.internal.crypto.model.event.WithHeldCode
|
import org.matrix.android.sdk.internal.crypto.model.event.WithHeldCode
|
||||||
import org.junit.Assert
|
|
||||||
import org.junit.FixMethodOrder
|
|
||||||
import org.junit.Test
|
|
||||||
import org.junit.runner.RunWith
|
|
||||||
import org.junit.runners.MethodSorters
|
|
||||||
|
|
||||||
@RunWith(AndroidJUnit4::class)
|
@RunWith(AndroidJUnit4::class)
|
||||||
@FixMethodOrder(MethodSorters.JVM)
|
@FixMethodOrder(MethodSorters.JVM)
|
||||||
|
@ -17,9 +17,6 @@
|
|||||||
package org.matrix.android.sdk.internal.crypto.keysbackup
|
package org.matrix.android.sdk.internal.crypto.keysbackup
|
||||||
|
|
||||||
import androidx.test.ext.junit.runners.AndroidJUnit4
|
import androidx.test.ext.junit.runners.AndroidJUnit4
|
||||||
import org.matrix.android.sdk.InstrumentedTest
|
|
||||||
import org.matrix.android.sdk.api.listeners.ProgressListener
|
|
||||||
import org.matrix.android.sdk.common.assertByteArrayNotEqual
|
|
||||||
import org.junit.Assert.assertArrayEquals
|
import org.junit.Assert.assertArrayEquals
|
||||||
import org.junit.Assert.assertEquals
|
import org.junit.Assert.assertEquals
|
||||||
import org.junit.Assert.assertTrue
|
import org.junit.Assert.assertTrue
|
||||||
@ -28,6 +25,9 @@ import org.junit.FixMethodOrder
|
|||||||
import org.junit.Test
|
import org.junit.Test
|
||||||
import org.junit.runner.RunWith
|
import org.junit.runner.RunWith
|
||||||
import org.junit.runners.MethodSorters
|
import org.junit.runners.MethodSorters
|
||||||
|
import org.matrix.android.sdk.InstrumentedTest
|
||||||
|
import org.matrix.android.sdk.api.listeners.ProgressListener
|
||||||
|
import org.matrix.android.sdk.common.assertByteArrayNotEqual
|
||||||
import org.matrix.olm.OlmManager
|
import org.matrix.olm.OlmManager
|
||||||
import org.matrix.olm.OlmPkDecryption
|
import org.matrix.olm.OlmPkDecryption
|
||||||
|
|
||||||
|
@ -17,6 +17,16 @@
|
|||||||
package org.matrix.android.sdk.internal.crypto.keysbackup
|
package org.matrix.android.sdk.internal.crypto.keysbackup
|
||||||
|
|
||||||
import androidx.test.ext.junit.runners.AndroidJUnit4
|
import androidx.test.ext.junit.runners.AndroidJUnit4
|
||||||
|
import org.junit.Assert.assertEquals
|
||||||
|
import org.junit.Assert.assertFalse
|
||||||
|
import org.junit.Assert.assertNotNull
|
||||||
|
import org.junit.Assert.assertNull
|
||||||
|
import org.junit.Assert.assertTrue
|
||||||
|
import org.junit.Assert.fail
|
||||||
|
import org.junit.FixMethodOrder
|
||||||
|
import org.junit.Test
|
||||||
|
import org.junit.runner.RunWith
|
||||||
|
import org.junit.runners.MethodSorters
|
||||||
import org.matrix.android.sdk.InstrumentedTest
|
import org.matrix.android.sdk.InstrumentedTest
|
||||||
import org.matrix.android.sdk.api.listeners.ProgressListener
|
import org.matrix.android.sdk.api.listeners.ProgressListener
|
||||||
import org.matrix.android.sdk.api.listeners.StepProgressListener
|
import org.matrix.android.sdk.api.listeners.StepProgressListener
|
||||||
@ -33,16 +43,6 @@ import org.matrix.android.sdk.internal.crypto.keysbackup.model.MegolmBackupCreat
|
|||||||
import org.matrix.android.sdk.internal.crypto.keysbackup.model.rest.KeysVersion
|
import org.matrix.android.sdk.internal.crypto.keysbackup.model.rest.KeysVersion
|
||||||
import org.matrix.android.sdk.internal.crypto.keysbackup.model.rest.KeysVersionResult
|
import org.matrix.android.sdk.internal.crypto.keysbackup.model.rest.KeysVersionResult
|
||||||
import org.matrix.android.sdk.internal.crypto.model.ImportRoomKeysResult
|
import org.matrix.android.sdk.internal.crypto.model.ImportRoomKeysResult
|
||||||
import org.junit.Assert.assertEquals
|
|
||||||
import org.junit.Assert.assertFalse
|
|
||||||
import org.junit.Assert.assertNotNull
|
|
||||||
import org.junit.Assert.assertNull
|
|
||||||
import org.junit.Assert.assertTrue
|
|
||||||
import org.junit.Assert.fail
|
|
||||||
import org.junit.FixMethodOrder
|
|
||||||
import org.junit.Test
|
|
||||||
import org.junit.runner.RunWith
|
|
||||||
import org.junit.runners.MethodSorters
|
|
||||||
import java.util.ArrayList
|
import java.util.ArrayList
|
||||||
import java.util.Collections
|
import java.util.Collections
|
||||||
import java.util.concurrent.CountDownLatch
|
import java.util.concurrent.CountDownLatch
|
||||||
|
@ -16,6 +16,7 @@
|
|||||||
|
|
||||||
package org.matrix.android.sdk.internal.crypto.keysbackup
|
package org.matrix.android.sdk.internal.crypto.keysbackup
|
||||||
|
|
||||||
|
import org.junit.Assert
|
||||||
import org.matrix.android.sdk.api.listeners.ProgressListener
|
import org.matrix.android.sdk.api.listeners.ProgressListener
|
||||||
import org.matrix.android.sdk.api.session.Session
|
import org.matrix.android.sdk.api.session.Session
|
||||||
import org.matrix.android.sdk.api.session.crypto.keysbackup.KeysBackupService
|
import org.matrix.android.sdk.api.session.crypto.keysbackup.KeysBackupService
|
||||||
@ -28,7 +29,6 @@ import org.matrix.android.sdk.common.assertListEquals
|
|||||||
import org.matrix.android.sdk.internal.crypto.MegolmSessionData
|
import org.matrix.android.sdk.internal.crypto.MegolmSessionData
|
||||||
import org.matrix.android.sdk.internal.crypto.keysbackup.model.MegolmBackupCreationInfo
|
import org.matrix.android.sdk.internal.crypto.keysbackup.model.MegolmBackupCreationInfo
|
||||||
import org.matrix.android.sdk.internal.crypto.keysbackup.model.rest.KeysVersion
|
import org.matrix.android.sdk.internal.crypto.keysbackup.model.rest.KeysVersion
|
||||||
import org.junit.Assert
|
|
||||||
import java.util.concurrent.CountDownLatch
|
import java.util.concurrent.CountDownLatch
|
||||||
|
|
||||||
class KeysBackupTestHelper(
|
class KeysBackupTestHelper(
|
||||||
|
@ -16,11 +16,11 @@
|
|||||||
|
|
||||||
package org.matrix.android.sdk.internal.crypto.keysbackup
|
package org.matrix.android.sdk.internal.crypto.keysbackup
|
||||||
|
|
||||||
|
import org.junit.Assert.assertEquals
|
||||||
|
import org.junit.Assert.assertNull
|
||||||
import org.matrix.android.sdk.api.session.crypto.keysbackup.KeysBackupService
|
import org.matrix.android.sdk.api.session.crypto.keysbackup.KeysBackupService
|
||||||
import org.matrix.android.sdk.api.session.crypto.keysbackup.KeysBackupState
|
import org.matrix.android.sdk.api.session.crypto.keysbackup.KeysBackupState
|
||||||
import org.matrix.android.sdk.api.session.crypto.keysbackup.KeysBackupStateListener
|
import org.matrix.android.sdk.api.session.crypto.keysbackup.KeysBackupStateListener
|
||||||
import org.junit.Assert.assertEquals
|
|
||||||
import org.junit.Assert.assertNull
|
|
||||||
import java.util.concurrent.CountDownLatch
|
import java.util.concurrent.CountDownLatch
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -91,8 +91,8 @@ internal class StateObserver(private val keysBackup: KeysBackupService,
|
|||||||
stateList.add(newState)
|
stateList.add(newState)
|
||||||
|
|
||||||
// Check that state transition is valid
|
// Check that state transition is valid
|
||||||
if (stateList.size >= 2
|
if (stateList.size >= 2 &&
|
||||||
&& !allowedStateTransitions.contains(stateList[stateList.size - 2] to newState)) {
|
!allowedStateTransitions.contains(stateList[stateList.size - 2] to newState)) {
|
||||||
// Forbidden transition detected
|
// Forbidden transition detected
|
||||||
lastTransitionError = "Forbidden transition detected from " + stateList[stateList.size - 2] + " to " + newState
|
lastTransitionError = "Forbidden transition detected from " + stateList[stateList.size - 2] + " to " + newState
|
||||||
}
|
}
|
||||||
|
@ -18,8 +18,20 @@ package org.matrix.android.sdk.internal.crypto.ssss
|
|||||||
|
|
||||||
import androidx.lifecycle.Observer
|
import androidx.lifecycle.Observer
|
||||||
import androidx.test.ext.junit.runners.AndroidJUnit4
|
import androidx.test.ext.junit.runners.AndroidJUnit4
|
||||||
|
import kotlinx.coroutines.Dispatchers
|
||||||
|
import kotlinx.coroutines.GlobalScope
|
||||||
|
import kotlinx.coroutines.launch
|
||||||
|
import kotlinx.coroutines.runBlocking
|
||||||
|
import org.junit.Assert.assertEquals
|
||||||
|
import org.junit.Assert.assertNotNull
|
||||||
|
import org.junit.Assert.assertNull
|
||||||
|
import org.junit.FixMethodOrder
|
||||||
|
import org.junit.Test
|
||||||
|
import org.junit.runner.RunWith
|
||||||
|
import org.junit.runners.MethodSorters
|
||||||
import org.matrix.android.sdk.InstrumentedTest
|
import org.matrix.android.sdk.InstrumentedTest
|
||||||
import org.matrix.android.sdk.api.session.Session
|
import org.matrix.android.sdk.api.session.Session
|
||||||
|
import org.matrix.android.sdk.api.session.accountdata.UserAccountDataEvent
|
||||||
import org.matrix.android.sdk.api.session.securestorage.EncryptedSecretContent
|
import org.matrix.android.sdk.api.session.securestorage.EncryptedSecretContent
|
||||||
import org.matrix.android.sdk.api.session.securestorage.KeySigner
|
import org.matrix.android.sdk.api.session.securestorage.KeySigner
|
||||||
import org.matrix.android.sdk.api.session.securestorage.RawBytesKeySpec
|
import org.matrix.android.sdk.api.session.securestorage.RawBytesKeySpec
|
||||||
@ -33,18 +45,6 @@ import org.matrix.android.sdk.common.TestConstants
|
|||||||
import org.matrix.android.sdk.internal.crypto.SSSS_ALGORITHM_AES_HMAC_SHA2
|
import org.matrix.android.sdk.internal.crypto.SSSS_ALGORITHM_AES_HMAC_SHA2
|
||||||
import org.matrix.android.sdk.internal.crypto.crosssigning.toBase64NoPadding
|
import org.matrix.android.sdk.internal.crypto.crosssigning.toBase64NoPadding
|
||||||
import org.matrix.android.sdk.internal.crypto.secrets.DefaultSharedSecretStorageService
|
import org.matrix.android.sdk.internal.crypto.secrets.DefaultSharedSecretStorageService
|
||||||
import org.matrix.android.sdk.api.session.accountdata.UserAccountDataEvent
|
|
||||||
import kotlinx.coroutines.Dispatchers
|
|
||||||
import kotlinx.coroutines.GlobalScope
|
|
||||||
import kotlinx.coroutines.launch
|
|
||||||
import kotlinx.coroutines.runBlocking
|
|
||||||
import org.junit.Assert.assertEquals
|
|
||||||
import org.junit.Assert.assertNotNull
|
|
||||||
import org.junit.Assert.assertNull
|
|
||||||
import org.junit.FixMethodOrder
|
|
||||||
import org.junit.Test
|
|
||||||
import org.junit.runner.RunWith
|
|
||||||
import org.junit.runners.MethodSorters
|
|
||||||
import java.util.concurrent.CountDownLatch
|
import java.util.concurrent.CountDownLatch
|
||||||
|
|
||||||
@RunWith(AndroidJUnit4::class)
|
@RunWith(AndroidJUnit4::class)
|
||||||
|
@ -18,6 +18,16 @@ package org.matrix.android.sdk.internal.crypto.verification
|
|||||||
|
|
||||||
import android.util.Log
|
import android.util.Log
|
||||||
import androidx.test.ext.junit.runners.AndroidJUnit4
|
import androidx.test.ext.junit.runners.AndroidJUnit4
|
||||||
|
import org.junit.Assert.assertEquals
|
||||||
|
import org.junit.Assert.assertFalse
|
||||||
|
import org.junit.Assert.assertNotNull
|
||||||
|
import org.junit.Assert.assertNull
|
||||||
|
import org.junit.Assert.assertTrue
|
||||||
|
import org.junit.Assert.fail
|
||||||
|
import org.junit.FixMethodOrder
|
||||||
|
import org.junit.Test
|
||||||
|
import org.junit.runner.RunWith
|
||||||
|
import org.junit.runners.MethodSorters
|
||||||
import org.matrix.android.sdk.InstrumentedTest
|
import org.matrix.android.sdk.InstrumentedTest
|
||||||
import org.matrix.android.sdk.api.session.Session
|
import org.matrix.android.sdk.api.session.Session
|
||||||
import org.matrix.android.sdk.api.session.crypto.verification.CancelCode
|
import org.matrix.android.sdk.api.session.crypto.verification.CancelCode
|
||||||
@ -38,16 +48,6 @@ import org.matrix.android.sdk.internal.crypto.model.MXUsersDevicesMap
|
|||||||
import org.matrix.android.sdk.internal.crypto.model.rest.KeyVerificationCancel
|
import org.matrix.android.sdk.internal.crypto.model.rest.KeyVerificationCancel
|
||||||
import org.matrix.android.sdk.internal.crypto.model.rest.KeyVerificationStart
|
import org.matrix.android.sdk.internal.crypto.model.rest.KeyVerificationStart
|
||||||
import org.matrix.android.sdk.internal.crypto.model.rest.toValue
|
import org.matrix.android.sdk.internal.crypto.model.rest.toValue
|
||||||
import org.junit.Assert.assertEquals
|
|
||||||
import org.junit.Assert.assertFalse
|
|
||||||
import org.junit.Assert.assertNotNull
|
|
||||||
import org.junit.Assert.assertNull
|
|
||||||
import org.junit.Assert.assertTrue
|
|
||||||
import org.junit.Assert.fail
|
|
||||||
import org.junit.FixMethodOrder
|
|
||||||
import org.junit.Test
|
|
||||||
import org.junit.runner.RunWith
|
|
||||||
import org.junit.runners.MethodSorters
|
|
||||||
import java.util.concurrent.CountDownLatch
|
import java.util.concurrent.CountDownLatch
|
||||||
|
|
||||||
@RunWith(AndroidJUnit4::class)
|
@RunWith(AndroidJUnit4::class)
|
||||||
@ -551,7 +551,7 @@ class SASTest : InstrumentedTest {
|
|||||||
cryptoTestData.roomId
|
cryptoTestData.roomId
|
||||||
)
|
)
|
||||||
|
|
||||||
var requestID : String? = null
|
var requestID: String? = null
|
||||||
|
|
||||||
mTestHelper.waitWithLatch {
|
mTestHelper.waitWithLatch {
|
||||||
mTestHelper.retryPeriodicallyWithLatch(it) {
|
mTestHelper.retryPeriodicallyWithLatch(it) {
|
||||||
|
@ -17,13 +17,13 @@
|
|||||||
package org.matrix.android.sdk.internal.crypto.verification.qrcode
|
package org.matrix.android.sdk.internal.crypto.verification.qrcode
|
||||||
|
|
||||||
import androidx.test.ext.junit.runners.AndroidJUnit4
|
import androidx.test.ext.junit.runners.AndroidJUnit4
|
||||||
import org.matrix.android.sdk.InstrumentedTest
|
|
||||||
import org.amshove.kluent.shouldBe
|
import org.amshove.kluent.shouldBe
|
||||||
import org.amshove.kluent.shouldNotBeEqualTo
|
import org.amshove.kluent.shouldNotBeEqualTo
|
||||||
import org.junit.FixMethodOrder
|
import org.junit.FixMethodOrder
|
||||||
import org.junit.Test
|
import org.junit.Test
|
||||||
import org.junit.runner.RunWith
|
import org.junit.runner.RunWith
|
||||||
import org.junit.runners.MethodSorters
|
import org.junit.runners.MethodSorters
|
||||||
|
import org.matrix.android.sdk.InstrumentedTest
|
||||||
|
|
||||||
@RunWith(AndroidJUnit4::class)
|
@RunWith(AndroidJUnit4::class)
|
||||||
@FixMethodOrder(MethodSorters.JVM)
|
@FixMethodOrder(MethodSorters.JVM)
|
||||||
|
@ -17,10 +17,10 @@
|
|||||||
package org.matrix.android.sdk.internal.util
|
package org.matrix.android.sdk.internal.util
|
||||||
|
|
||||||
import androidx.test.ext.junit.runners.AndroidJUnit4
|
import androidx.test.ext.junit.runners.AndroidJUnit4
|
||||||
import org.matrix.android.sdk.InstrumentedTest
|
|
||||||
import org.junit.Assert.assertEquals
|
import org.junit.Assert.assertEquals
|
||||||
import org.junit.Test
|
import org.junit.Test
|
||||||
import org.junit.runner.RunWith
|
import org.junit.runner.RunWith
|
||||||
|
import org.matrix.android.sdk.InstrumentedTest
|
||||||
|
|
||||||
@RunWith(AndroidJUnit4::class)
|
@RunWith(AndroidJUnit4::class)
|
||||||
internal class JsonCanonicalizerTest : InstrumentedTest {
|
internal class JsonCanonicalizerTest : InstrumentedTest {
|
||||||
|
@ -16,6 +16,14 @@
|
|||||||
|
|
||||||
package org.matrix.android.sdk.session.room.timeline
|
package org.matrix.android.sdk.session.room.timeline
|
||||||
|
|
||||||
|
import org.amshove.kluent.shouldBeFalse
|
||||||
|
import org.amshove.kluent.shouldBeTrue
|
||||||
|
import org.junit.Assert.assertTrue
|
||||||
|
import org.junit.FixMethodOrder
|
||||||
|
import org.junit.Test
|
||||||
|
import org.junit.runner.RunWith
|
||||||
|
import org.junit.runners.JUnit4
|
||||||
|
import org.junit.runners.MethodSorters
|
||||||
import org.matrix.android.sdk.InstrumentedTest
|
import org.matrix.android.sdk.InstrumentedTest
|
||||||
import org.matrix.android.sdk.api.extensions.orFalse
|
import org.matrix.android.sdk.api.extensions.orFalse
|
||||||
import org.matrix.android.sdk.api.session.events.model.EventType
|
import org.matrix.android.sdk.api.session.events.model.EventType
|
||||||
@ -26,14 +34,6 @@ import org.matrix.android.sdk.api.session.room.timeline.TimelineSettings
|
|||||||
import org.matrix.android.sdk.common.CommonTestHelper
|
import org.matrix.android.sdk.common.CommonTestHelper
|
||||||
import org.matrix.android.sdk.common.CryptoTestHelper
|
import org.matrix.android.sdk.common.CryptoTestHelper
|
||||||
import org.matrix.android.sdk.common.checkSendOrder
|
import org.matrix.android.sdk.common.checkSendOrder
|
||||||
import org.amshove.kluent.shouldBeFalse
|
|
||||||
import org.amshove.kluent.shouldBeTrue
|
|
||||||
import org.junit.Assert.assertTrue
|
|
||||||
import org.junit.FixMethodOrder
|
|
||||||
import org.junit.Test
|
|
||||||
import org.junit.runner.RunWith
|
|
||||||
import org.junit.runners.JUnit4
|
|
||||||
import org.junit.runners.MethodSorters
|
|
||||||
import timber.log.Timber
|
import timber.log.Timber
|
||||||
import java.util.concurrent.CountDownLatch
|
import java.util.concurrent.CountDownLatch
|
||||||
|
|
||||||
@ -111,8 +111,8 @@ class TimelineBackToPreviousLastForwardTest : InstrumentedTest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Ok, we have the 10 last messages from Alice.
|
// Ok, we have the 10 last messages from Alice.
|
||||||
snapshot.size == 10
|
snapshot.size == 10 &&
|
||||||
&& snapshot.all { it.root.content.toModel<MessageContent>()?.body?.startsWith(messageRoot).orFalse() }
|
snapshot.all { it.root.content.toModel<MessageContent>()?.body?.startsWith(messageRoot).orFalse() }
|
||||||
}
|
}
|
||||||
|
|
||||||
bobTimeline.addListener(eventsListener)
|
bobTimeline.addListener(eventsListener)
|
||||||
@ -160,10 +160,10 @@ class TimelineBackToPreviousLastForwardTest : InstrumentedTest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Bob can see the first event of the room (so Back pagination has worked)
|
// Bob can see the first event of the room (so Back pagination has worked)
|
||||||
snapshot.lastOrNull()?.root?.getClearType() == EventType.STATE_ROOM_CREATE
|
snapshot.lastOrNull()?.root?.getClearType() == EventType.STATE_ROOM_CREATE &&
|
||||||
// 8 for room creation item, and 30 for the forward pagination
|
// 8 for room creation item, and 30 for the forward pagination
|
||||||
&& snapshot.size == 38
|
snapshot.size == 38 &&
|
||||||
&& snapshot.checkSendOrder(messageRoot, 30, 0)
|
snapshot.checkSendOrder(messageRoot, 30, 0)
|
||||||
}
|
}
|
||||||
|
|
||||||
bobTimeline.addListener(eventsListener)
|
bobTimeline.addListener(eventsListener)
|
||||||
|
@ -16,6 +16,13 @@
|
|||||||
|
|
||||||
package org.matrix.android.sdk.session.room.timeline
|
package org.matrix.android.sdk.session.room.timeline
|
||||||
|
|
||||||
|
import org.amshove.kluent.shouldBeFalse
|
||||||
|
import org.amshove.kluent.shouldBeTrue
|
||||||
|
import org.junit.FixMethodOrder
|
||||||
|
import org.junit.Test
|
||||||
|
import org.junit.runner.RunWith
|
||||||
|
import org.junit.runners.JUnit4
|
||||||
|
import org.junit.runners.MethodSorters
|
||||||
import org.matrix.android.sdk.InstrumentedTest
|
import org.matrix.android.sdk.InstrumentedTest
|
||||||
import org.matrix.android.sdk.api.extensions.orFalse
|
import org.matrix.android.sdk.api.extensions.orFalse
|
||||||
import org.matrix.android.sdk.api.session.events.model.EventType
|
import org.matrix.android.sdk.api.session.events.model.EventType
|
||||||
@ -26,13 +33,6 @@ import org.matrix.android.sdk.api.session.room.timeline.TimelineSettings
|
|||||||
import org.matrix.android.sdk.common.CommonTestHelper
|
import org.matrix.android.sdk.common.CommonTestHelper
|
||||||
import org.matrix.android.sdk.common.CryptoTestHelper
|
import org.matrix.android.sdk.common.CryptoTestHelper
|
||||||
import org.matrix.android.sdk.common.checkSendOrder
|
import org.matrix.android.sdk.common.checkSendOrder
|
||||||
import org.amshove.kluent.shouldBeFalse
|
|
||||||
import org.amshove.kluent.shouldBeTrue
|
|
||||||
import org.junit.FixMethodOrder
|
|
||||||
import org.junit.Test
|
|
||||||
import org.junit.runner.RunWith
|
|
||||||
import org.junit.runners.JUnit4
|
|
||||||
import org.junit.runners.MethodSorters
|
|
||||||
import timber.log.Timber
|
import timber.log.Timber
|
||||||
import java.util.concurrent.CountDownLatch
|
import java.util.concurrent.CountDownLatch
|
||||||
|
|
||||||
@ -86,8 +86,8 @@ class TimelineForwardPaginationTest : InstrumentedTest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Ok, we have the 10 last messages of the initial sync
|
// Ok, we have the 10 last messages of the initial sync
|
||||||
snapshot.size == 10
|
snapshot.size == 10 &&
|
||||||
&& snapshot.all { it.root.content.toModel<MessageContent>()?.body?.startsWith(message).orFalse() }
|
snapshot.all { it.root.content.toModel<MessageContent>()?.body?.startsWith(message).orFalse() }
|
||||||
}
|
}
|
||||||
|
|
||||||
// Open the timeline at last sent message
|
// Open the timeline at last sent message
|
||||||
@ -110,8 +110,8 @@ class TimelineForwardPaginationTest : InstrumentedTest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// The event is not in db, so it is fetch alone
|
// The event is not in db, so it is fetch alone
|
||||||
snapshot.size == 1
|
snapshot.size == 1 &&
|
||||||
&& snapshot.all { it.root.content.toModel<MessageContent>()?.body?.startsWith("Message from Alice").orFalse() }
|
snapshot.all { it.root.content.toModel<MessageContent>()?.body?.startsWith("Message from Alice").orFalse() }
|
||||||
}
|
}
|
||||||
|
|
||||||
aliceTimeline.addListener(aliceEventsListener)
|
aliceTimeline.addListener(aliceEventsListener)
|
||||||
@ -137,9 +137,9 @@ class TimelineForwardPaginationTest : InstrumentedTest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Alice can see the first event of the room (so Back pagination has worked)
|
// Alice can see the first event of the room (so Back pagination has worked)
|
||||||
snapshot.lastOrNull()?.root?.getClearType() == EventType.STATE_ROOM_CREATE
|
snapshot.lastOrNull()?.root?.getClearType() == EventType.STATE_ROOM_CREATE &&
|
||||||
// 6 for room creation item (backward pagination), 1 for the context, and 50 for the forward pagination
|
// 6 for room creation item (backward pagination), 1 for the context, and 50 for the forward pagination
|
||||||
&& snapshot.size == 57 // 6 + 1 + 50
|
snapshot.size == 57 // 6 + 1 + 50
|
||||||
}
|
}
|
||||||
|
|
||||||
aliceTimeline.addListener(aliceEventsListener)
|
aliceTimeline.addListener(aliceEventsListener)
|
||||||
@ -166,8 +166,8 @@ class TimelineForwardPaginationTest : InstrumentedTest {
|
|||||||
Timber.w(" event ${it.root.content}")
|
Timber.w(" event ${it.root.content}")
|
||||||
}
|
}
|
||||||
// 6 for room creation item (backward pagination),and numberOfMessagesToSend (all the message of the room)
|
// 6 for room creation item (backward pagination),and numberOfMessagesToSend (all the message of the room)
|
||||||
snapshot.size == 6 + numberOfMessagesToSend
|
snapshot.size == 6 + numberOfMessagesToSend &&
|
||||||
&& snapshot.checkSendOrder(message, numberOfMessagesToSend, 0)
|
snapshot.checkSendOrder(message, numberOfMessagesToSend, 0)
|
||||||
}
|
}
|
||||||
|
|
||||||
aliceTimeline.addListener(aliceEventsListener)
|
aliceTimeline.addListener(aliceEventsListener)
|
||||||
|
@ -16,6 +16,13 @@
|
|||||||
|
|
||||||
package org.matrix.android.sdk.session.room.timeline
|
package org.matrix.android.sdk.session.room.timeline
|
||||||
|
|
||||||
|
import org.amshove.kluent.shouldBeFalse
|
||||||
|
import org.amshove.kluent.shouldBeTrue
|
||||||
|
import org.junit.FixMethodOrder
|
||||||
|
import org.junit.Test
|
||||||
|
import org.junit.runner.RunWith
|
||||||
|
import org.junit.runners.JUnit4
|
||||||
|
import org.junit.runners.MethodSorters
|
||||||
import org.matrix.android.sdk.InstrumentedTest
|
import org.matrix.android.sdk.InstrumentedTest
|
||||||
import org.matrix.android.sdk.api.extensions.orFalse
|
import org.matrix.android.sdk.api.extensions.orFalse
|
||||||
import org.matrix.android.sdk.api.session.events.model.EventType
|
import org.matrix.android.sdk.api.session.events.model.EventType
|
||||||
@ -26,13 +33,6 @@ import org.matrix.android.sdk.api.session.room.timeline.TimelineSettings
|
|||||||
import org.matrix.android.sdk.common.CommonTestHelper
|
import org.matrix.android.sdk.common.CommonTestHelper
|
||||||
import org.matrix.android.sdk.common.CryptoTestHelper
|
import org.matrix.android.sdk.common.CryptoTestHelper
|
||||||
import org.matrix.android.sdk.common.checkSendOrder
|
import org.matrix.android.sdk.common.checkSendOrder
|
||||||
import org.amshove.kluent.shouldBeFalse
|
|
||||||
import org.amshove.kluent.shouldBeTrue
|
|
||||||
import org.junit.FixMethodOrder
|
|
||||||
import org.junit.Test
|
|
||||||
import org.junit.runner.RunWith
|
|
||||||
import org.junit.runners.JUnit4
|
|
||||||
import org.junit.runners.MethodSorters
|
|
||||||
import timber.log.Timber
|
import timber.log.Timber
|
||||||
import java.util.concurrent.CountDownLatch
|
import java.util.concurrent.CountDownLatch
|
||||||
|
|
||||||
@ -107,8 +107,8 @@ class TimelinePreviousLastForwardTest : InstrumentedTest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Ok, we have the 10 last messages from Alice. This will be our future previous lastForward chunk
|
// Ok, we have the 10 last messages from Alice. This will be our future previous lastForward chunk
|
||||||
snapshot.size == 10
|
snapshot.size == 10 &&
|
||||||
&& snapshot.all { it.root.content.toModel<MessageContent>()?.body?.startsWith(firstMessage).orFalse() }
|
snapshot.all { it.root.content.toModel<MessageContent>()?.body?.startsWith(firstMessage).orFalse() }
|
||||||
}
|
}
|
||||||
|
|
||||||
bobTimeline.addListener(eventsListener)
|
bobTimeline.addListener(eventsListener)
|
||||||
@ -141,8 +141,8 @@ class TimelinePreviousLastForwardTest : InstrumentedTest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Ok, we have the 10 last messages from Alice. This will be our future previous lastForward chunk
|
// Ok, we have the 10 last messages from Alice. This will be our future previous lastForward chunk
|
||||||
snapshot.size == 10
|
snapshot.size == 10 &&
|
||||||
&& snapshot.all { it.root.content.toModel<MessageContent>()?.body?.startsWith(secondMessage).orFalse() }
|
snapshot.all { it.root.content.toModel<MessageContent>()?.body?.startsWith(secondMessage).orFalse() }
|
||||||
}
|
}
|
||||||
|
|
||||||
bobTimeline.addListener(eventsListener)
|
bobTimeline.addListener(eventsListener)
|
||||||
@ -216,11 +216,11 @@ class TimelinePreviousLastForwardTest : InstrumentedTest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Bob can see the first event of the room (so Back pagination has worked)
|
// Bob can see the first event of the room (so Back pagination has worked)
|
||||||
snapshot.lastOrNull()?.root?.getClearType() == EventType.STATE_ROOM_CREATE
|
snapshot.lastOrNull()?.root?.getClearType() == EventType.STATE_ROOM_CREATE &&
|
||||||
// 8 for room creation item 60 message from Alice
|
// 8 for room creation item 60 message from Alice
|
||||||
&& snapshot.size == 68 // 8 + 60
|
snapshot.size == 68 && // 8 + 60
|
||||||
&& snapshot.checkSendOrder(secondMessage, 30, 0)
|
snapshot.checkSendOrder(secondMessage, 30, 0) &&
|
||||||
&& snapshot.checkSendOrder(firstMessage, 30, 30)
|
snapshot.checkSendOrder(firstMessage, 30, 30)
|
||||||
}
|
}
|
||||||
|
|
||||||
bobTimeline.addListener(eventsListener)
|
bobTimeline.addListener(eventsListener)
|
||||||
|
@ -17,10 +17,10 @@
|
|||||||
|
|
||||||
package org.matrix.android.sdk.internal.network.interceptors
|
package org.matrix.android.sdk.internal.network.interceptors
|
||||||
|
|
||||||
import org.matrix.android.sdk.internal.di.MatrixScope
|
|
||||||
import okhttp3.Interceptor
|
import okhttp3.Interceptor
|
||||||
import okhttp3.Response
|
import okhttp3.Response
|
||||||
import okio.Buffer
|
import okio.Buffer
|
||||||
|
import org.matrix.android.sdk.internal.di.MatrixScope
|
||||||
import timber.log.Timber
|
import timber.log.Timber
|
||||||
import java.io.IOException
|
import java.io.IOException
|
||||||
import java.nio.charset.Charset
|
import java.nio.charset.Charset
|
||||||
@ -36,8 +36,8 @@ import javax.inject.Inject
|
|||||||
* non-production environment.
|
* non-production environment.
|
||||||
*/
|
*/
|
||||||
@MatrixScope
|
@MatrixScope
|
||||||
internal class CurlLoggingInterceptor @Inject constructor()
|
internal class CurlLoggingInterceptor @Inject constructor() :
|
||||||
: Interceptor {
|
Interceptor {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set any additional curl command options (see 'curl --help').
|
* Set any additional curl command options (see 'curl --help').
|
||||||
@ -90,8 +90,8 @@ internal class CurlLoggingInterceptor @Inject constructor()
|
|||||||
|
|
||||||
curlCmd += ((if (compressed) " --compressed " else " ") + "'" + request.url.toString()
|
curlCmd += ((if (compressed) " --compressed " else " ") + "'" + request.url.toString()
|
||||||
// Replace localhost for emulator by localhost for shell
|
// Replace localhost for emulator by localhost for shell
|
||||||
.replace("://10.0.2.2:8080/".toRegex(), "://127.0.0.1:8080/")
|
.replace("://10.0.2.2:8080/".toRegex(), "://127.0.0.1:8080/") +
|
||||||
+ "'")
|
"'")
|
||||||
|
|
||||||
// Add Json formatting
|
// Add Json formatting
|
||||||
curlCmd += " | python -m json.tool"
|
curlCmd += " | python -m json.tool"
|
||||||
|
@ -128,10 +128,10 @@ object MatrixPatterns {
|
|||||||
* @return true if the string is a valid event id.
|
* @return true if the string is a valid event id.
|
||||||
*/
|
*/
|
||||||
fun isEventId(str: String?): Boolean {
|
fun isEventId(str: String?): Boolean {
|
||||||
return str != null
|
return str != null &&
|
||||||
&& (str matches PATTERN_CONTAIN_MATRIX_EVENT_IDENTIFIER
|
(str matches PATTERN_CONTAIN_MATRIX_EVENT_IDENTIFIER ||
|
||||||
|| str matches PATTERN_CONTAIN_MATRIX_EVENT_IDENTIFIER_V3
|
str matches PATTERN_CONTAIN_MATRIX_EVENT_IDENTIFIER_V3 ||
|
||||||
|| str matches PATTERN_CONTAIN_MATRIX_EVENT_IDENTIFIER_V4)
|
str matches PATTERN_CONTAIN_MATRIX_EVENT_IDENTIFIER_V4)
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -27,5 +27,5 @@ interface UIABaseAuth {
|
|||||||
|
|
||||||
fun copyWithSession(session: String): UIABaseAuth
|
fun copyWithSession(session: String): UIABaseAuth
|
||||||
|
|
||||||
fun asMap() : Map<String, *>
|
fun asMap(): Map<String, *>
|
||||||
}
|
}
|
||||||
|
@ -23,20 +23,20 @@ import java.io.IOException
|
|||||||
import javax.net.ssl.HttpsURLConnection
|
import javax.net.ssl.HttpsURLConnection
|
||||||
|
|
||||||
fun Throwable.is401() =
|
fun Throwable.is401() =
|
||||||
this is Failure.ServerError
|
this is Failure.ServerError &&
|
||||||
&& httpCode == HttpsURLConnection.HTTP_UNAUTHORIZED /* 401 */
|
httpCode == HttpsURLConnection.HTTP_UNAUTHORIZED && /* 401 */
|
||||||
&& error.code == MatrixError.M_UNAUTHORIZED
|
error.code == MatrixError.M_UNAUTHORIZED
|
||||||
|
|
||||||
fun Throwable.isTokenError() =
|
fun Throwable.isTokenError() =
|
||||||
this is Failure.ServerError
|
this is Failure.ServerError &&
|
||||||
&& (error.code == MatrixError.M_UNKNOWN_TOKEN
|
(error.code == MatrixError.M_UNKNOWN_TOKEN ||
|
||||||
|| error.code == MatrixError.M_MISSING_TOKEN
|
error.code == MatrixError.M_MISSING_TOKEN ||
|
||||||
|| error.code == MatrixError.ORG_MATRIX_EXPIRED_ACCOUNT)
|
error.code == MatrixError.ORG_MATRIX_EXPIRED_ACCOUNT)
|
||||||
|
|
||||||
fun Throwable.shouldBeRetried(): Boolean {
|
fun Throwable.shouldBeRetried(): Boolean {
|
||||||
return this is Failure.NetworkConnection
|
return this is Failure.NetworkConnection ||
|
||||||
|| this is IOException
|
this is IOException ||
|
||||||
|| (this is Failure.ServerError && error.code == MatrixError.M_LIMIT_EXCEEDED)
|
(this is Failure.ServerError && error.code == MatrixError.M_LIMIT_EXCEEDED)
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -52,31 +52,31 @@ fun Throwable.getRetryDelay(defaultValue: Long): Long {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fun Throwable.isInvalidPassword(): Boolean {
|
fun Throwable.isInvalidPassword(): Boolean {
|
||||||
return this is Failure.ServerError
|
return this is Failure.ServerError &&
|
||||||
&& error.code == MatrixError.M_FORBIDDEN
|
error.code == MatrixError.M_FORBIDDEN &&
|
||||||
&& error.message == "Invalid password"
|
error.message == "Invalid password"
|
||||||
}
|
}
|
||||||
|
|
||||||
fun Throwable.isInvalidUIAAuth(): Boolean {
|
fun Throwable.isInvalidUIAAuth(): Boolean {
|
||||||
return this is Failure.ServerError
|
return this is Failure.ServerError &&
|
||||||
&& error.code == MatrixError.M_FORBIDDEN
|
error.code == MatrixError.M_FORBIDDEN &&
|
||||||
&& error.flows != null
|
error.flows != null
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Try to convert to a RegistrationFlowResponse. Return null in the cases it's not possible
|
* Try to convert to a RegistrationFlowResponse. Return null in the cases it's not possible
|
||||||
*/
|
*/
|
||||||
fun Throwable.toRegistrationFlowResponse(): RegistrationFlowResponse? {
|
fun Throwable.toRegistrationFlowResponse(): RegistrationFlowResponse? {
|
||||||
return if (this is Failure.OtherServerError
|
return if (this is Failure.OtherServerError &&
|
||||||
&& httpCode == HttpsURLConnection.HTTP_UNAUTHORIZED /* 401 */) {
|
httpCode == HttpsURLConnection.HTTP_UNAUTHORIZED /* 401 */) {
|
||||||
tryOrNull {
|
tryOrNull {
|
||||||
MoshiProvider.providesMoshi()
|
MoshiProvider.providesMoshi()
|
||||||
.adapter(RegistrationFlowResponse::class.java)
|
.adapter(RegistrationFlowResponse::class.java)
|
||||||
.fromJson(errorBody)
|
.fromJson(errorBody)
|
||||||
}
|
}
|
||||||
} else if (this is Failure.ServerError
|
} else if (this is Failure.ServerError &&
|
||||||
&& httpCode == HttpsURLConnection.HTTP_UNAUTHORIZED /* 401 */
|
httpCode == HttpsURLConnection.HTTP_UNAUTHORIZED && /* 401 */
|
||||||
&& error.code == MatrixError.M_FORBIDDEN) {
|
error.code == MatrixError.M_FORBIDDEN) {
|
||||||
// This happens when the submission for this stage was bad (like bad password)
|
// This happens when the submission for this stage was bad (like bad password)
|
||||||
if (error.session != null && error.flows != null) {
|
if (error.session != null && error.flows != null) {
|
||||||
RegistrationFlowResponse(
|
RegistrationFlowResponse(
|
||||||
@ -94,9 +94,9 @@ fun Throwable.toRegistrationFlowResponse(): RegistrationFlowResponse? {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fun Throwable.isRegistrationAvailabilityError(): Boolean {
|
fun Throwable.isRegistrationAvailabilityError(): Boolean {
|
||||||
return this is Failure.ServerError
|
return this is Failure.ServerError &&
|
||||||
&& httpCode == HttpsURLConnection.HTTP_BAD_REQUEST /* 400 */
|
httpCode == HttpsURLConnection.HTTP_BAD_REQUEST && /* 400 */
|
||||||
&& (error.code == MatrixError.M_USER_IN_USE
|
(error.code == MatrixError.M_USER_IN_USE ||
|
||||||
|| error.code == MatrixError.M_INVALID_USERNAME
|
error.code == MatrixError.M_INVALID_USERNAME ||
|
||||||
|| error.code == MatrixError.M_EXCLUSIVE)
|
error.code == MatrixError.M_EXCLUSIVE)
|
||||||
}
|
}
|
||||||
|
@ -26,7 +26,7 @@ sealed class CallState {
|
|||||||
/**
|
/**
|
||||||
* CreateOffer. Intermediate state between Idle and Dialing.
|
* CreateOffer. Intermediate state between Idle and Dialing.
|
||||||
*/
|
*/
|
||||||
object CreateOffer: CallState()
|
object CreateOffer : CallState()
|
||||||
|
|
||||||
/** Dialing. Outgoing call is signaling the remote peer */
|
/** Dialing. Outgoing call is signaling the remote peer */
|
||||||
object Dialing : CallState()
|
object Dialing : CallState()
|
||||||
|
@ -24,8 +24,8 @@ data class MXCrossSigningInfo(
|
|||||||
val crossSigningKeys: List<CryptoCrossSigningKey>
|
val crossSigningKeys: List<CryptoCrossSigningKey>
|
||||||
) {
|
) {
|
||||||
|
|
||||||
fun isTrusted(): Boolean = masterKey()?.trustLevel?.isVerified() == true
|
fun isTrusted(): Boolean = masterKey()?.trustLevel?.isVerified() == true &&
|
||||||
&& selfSigningKey()?.trustLevel?.isVerified() == true
|
selfSigningKey()?.trustLevel?.isVerified() == true
|
||||||
|
|
||||||
fun masterKey(): CryptoCrossSigningKey? = crossSigningKeys
|
fun masterKey(): CryptoCrossSigningKey? = crossSigningKeys
|
||||||
.firstOrNull { it.usages?.contains(KeyUsage.MASTER.value) == true }
|
.firstOrNull { it.usages?.contains(KeyUsage.MASTER.value) == true }
|
||||||
|
@ -16,8 +16,8 @@
|
|||||||
|
|
||||||
package org.matrix.android.sdk.api.session.crypto.keyshare
|
package org.matrix.android.sdk.api.session.crypto.keyshare
|
||||||
|
|
||||||
import org.matrix.android.sdk.internal.crypto.IncomingRoomKeyRequest
|
|
||||||
import org.matrix.android.sdk.internal.crypto.IncomingRequestCancellation
|
import org.matrix.android.sdk.internal.crypto.IncomingRequestCancellation
|
||||||
|
import org.matrix.android.sdk.internal.crypto.IncomingRoomKeyRequest
|
||||||
import org.matrix.android.sdk.internal.crypto.IncomingSecretShareRequest
|
import org.matrix.android.sdk.internal.crypto.IncomingSecretShareRequest
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -48,8 +48,8 @@ data class PendingVerificationRequest(
|
|||||||
* SAS is supported if I support it and the other party support it
|
* SAS is supported if I support it and the other party support it
|
||||||
*/
|
*/
|
||||||
fun isSasSupported(): Boolean {
|
fun isSasSupported(): Boolean {
|
||||||
return requestInfo?.methods?.contains(VERIFICATION_METHOD_SAS).orFalse()
|
return requestInfo?.methods?.contains(VERIFICATION_METHOD_SAS).orFalse() &&
|
||||||
&& readyInfo?.methods?.contains(VERIFICATION_METHOD_SAS).orFalse()
|
readyInfo?.methods?.contains(VERIFICATION_METHOD_SAS).orFalse()
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -57,11 +57,11 @@ data class PendingVerificationRequest(
|
|||||||
*/
|
*/
|
||||||
fun otherCanShowQrCode(): Boolean {
|
fun otherCanShowQrCode(): Boolean {
|
||||||
return if (isIncoming) {
|
return if (isIncoming) {
|
||||||
requestInfo?.methods?.contains(VERIFICATION_METHOD_QR_CODE_SHOW).orFalse()
|
requestInfo?.methods?.contains(VERIFICATION_METHOD_QR_CODE_SHOW).orFalse() &&
|
||||||
&& readyInfo?.methods?.contains(VERIFICATION_METHOD_QR_CODE_SCAN).orFalse()
|
readyInfo?.methods?.contains(VERIFICATION_METHOD_QR_CODE_SCAN).orFalse()
|
||||||
} else {
|
} else {
|
||||||
requestInfo?.methods?.contains(VERIFICATION_METHOD_QR_CODE_SCAN).orFalse()
|
requestInfo?.methods?.contains(VERIFICATION_METHOD_QR_CODE_SCAN).orFalse() &&
|
||||||
&& readyInfo?.methods?.contains(VERIFICATION_METHOD_QR_CODE_SHOW).orFalse()
|
readyInfo?.methods?.contains(VERIFICATION_METHOD_QR_CODE_SHOW).orFalse()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -70,11 +70,11 @@ data class PendingVerificationRequest(
|
|||||||
*/
|
*/
|
||||||
fun otherCanScanQrCode(): Boolean {
|
fun otherCanScanQrCode(): Boolean {
|
||||||
return if (isIncoming) {
|
return if (isIncoming) {
|
||||||
requestInfo?.methods?.contains(VERIFICATION_METHOD_QR_CODE_SCAN).orFalse()
|
requestInfo?.methods?.contains(VERIFICATION_METHOD_QR_CODE_SCAN).orFalse() &&
|
||||||
&& readyInfo?.methods?.contains(VERIFICATION_METHOD_QR_CODE_SHOW).orFalse()
|
readyInfo?.methods?.contains(VERIFICATION_METHOD_QR_CODE_SHOW).orFalse()
|
||||||
} else {
|
} else {
|
||||||
requestInfo?.methods?.contains(VERIFICATION_METHOD_QR_CODE_SHOW).orFalse()
|
requestInfo?.methods?.contains(VERIFICATION_METHOD_QR_CODE_SHOW).orFalse() &&
|
||||||
&& readyInfo?.methods?.contains(VERIFICATION_METHOD_QR_CODE_SCAN).orFalse()
|
readyInfo?.methods?.contains(VERIFICATION_METHOD_QR_CODE_SCAN).orFalse()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -18,6 +18,9 @@ package org.matrix.android.sdk.api.session.events.model
|
|||||||
|
|
||||||
import com.squareup.moshi.Json
|
import com.squareup.moshi.Json
|
||||||
import com.squareup.moshi.JsonClass
|
import com.squareup.moshi.JsonClass
|
||||||
|
import org.json.JSONObject
|
||||||
|
import org.matrix.android.sdk.api.extensions.tryOrNull
|
||||||
|
import org.matrix.android.sdk.api.failure.MatrixError
|
||||||
import org.matrix.android.sdk.api.session.crypto.MXCryptoError
|
import org.matrix.android.sdk.api.session.crypto.MXCryptoError
|
||||||
import org.matrix.android.sdk.api.session.room.model.message.MessageContent
|
import org.matrix.android.sdk.api.session.room.model.message.MessageContent
|
||||||
import org.matrix.android.sdk.api.session.room.model.message.MessageType
|
import org.matrix.android.sdk.api.session.room.model.message.MessageType
|
||||||
@ -27,9 +30,6 @@ import org.matrix.android.sdk.api.util.JsonDict
|
|||||||
import org.matrix.android.sdk.internal.crypto.algorithms.olm.OlmDecryptionResult
|
import org.matrix.android.sdk.internal.crypto.algorithms.olm.OlmDecryptionResult
|
||||||
import org.matrix.android.sdk.internal.crypto.model.event.EncryptedEventContent
|
import org.matrix.android.sdk.internal.crypto.model.event.EncryptedEventContent
|
||||||
import org.matrix.android.sdk.internal.di.MoshiProvider
|
import org.matrix.android.sdk.internal.di.MoshiProvider
|
||||||
import org.json.JSONObject
|
|
||||||
import org.matrix.android.sdk.api.extensions.tryOrNull
|
|
||||||
import org.matrix.android.sdk.api.failure.MatrixError
|
|
||||||
import timber.log.Timber
|
import timber.log.Timber
|
||||||
|
|
||||||
typealias Content = JsonDict
|
typealias Content = JsonDict
|
||||||
@ -238,8 +238,8 @@ data class Event(
|
|||||||
}
|
}
|
||||||
|
|
||||||
fun Event.isTextMessage(): Boolean {
|
fun Event.isTextMessage(): Boolean {
|
||||||
return getClearType() == EventType.MESSAGE
|
return getClearType() == EventType.MESSAGE &&
|
||||||
&& when (getClearContent()?.get(MessageContent.MSG_TYPE_JSON_KEY)) {
|
when (getClearContent()?.get(MessageContent.MSG_TYPE_JSON_KEY)) {
|
||||||
MessageType.MSGTYPE_TEXT,
|
MessageType.MSGTYPE_TEXT,
|
||||||
MessageType.MSGTYPE_EMOTE,
|
MessageType.MSGTYPE_EMOTE,
|
||||||
MessageType.MSGTYPE_NOTICE -> true
|
MessageType.MSGTYPE_NOTICE -> true
|
||||||
@ -248,40 +248,40 @@ fun Event.isTextMessage(): Boolean {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fun Event.isImageMessage(): Boolean {
|
fun Event.isImageMessage(): Boolean {
|
||||||
return getClearType() == EventType.MESSAGE
|
return getClearType() == EventType.MESSAGE &&
|
||||||
&& when (getClearContent()?.get(MessageContent.MSG_TYPE_JSON_KEY)) {
|
when (getClearContent()?.get(MessageContent.MSG_TYPE_JSON_KEY)) {
|
||||||
MessageType.MSGTYPE_IMAGE -> true
|
MessageType.MSGTYPE_IMAGE -> true
|
||||||
else -> false
|
else -> false
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fun Event.isVideoMessage(): Boolean {
|
fun Event.isVideoMessage(): Boolean {
|
||||||
return getClearType() == EventType.MESSAGE
|
return getClearType() == EventType.MESSAGE &&
|
||||||
&& when (getClearContent()?.get(MessageContent.MSG_TYPE_JSON_KEY)) {
|
when (getClearContent()?.get(MessageContent.MSG_TYPE_JSON_KEY)) {
|
||||||
MessageType.MSGTYPE_VIDEO -> true
|
MessageType.MSGTYPE_VIDEO -> true
|
||||||
else -> false
|
else -> false
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fun Event.isAudioMessage(): Boolean {
|
fun Event.isAudioMessage(): Boolean {
|
||||||
return getClearType() == EventType.MESSAGE
|
return getClearType() == EventType.MESSAGE &&
|
||||||
&& when (getClearContent()?.get(MessageContent.MSG_TYPE_JSON_KEY)) {
|
when (getClearContent()?.get(MessageContent.MSG_TYPE_JSON_KEY)) {
|
||||||
MessageType.MSGTYPE_AUDIO -> true
|
MessageType.MSGTYPE_AUDIO -> true
|
||||||
else -> false
|
else -> false
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fun Event.isFileMessage(): Boolean {
|
fun Event.isFileMessage(): Boolean {
|
||||||
return getClearType() == EventType.MESSAGE
|
return getClearType() == EventType.MESSAGE &&
|
||||||
&& when (getClearContent()?.get(MessageContent.MSG_TYPE_JSON_KEY)) {
|
when (getClearContent()?.get(MessageContent.MSG_TYPE_JSON_KEY)) {
|
||||||
MessageType.MSGTYPE_FILE -> true
|
MessageType.MSGTYPE_FILE -> true
|
||||||
else -> false
|
else -> false
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fun Event.isAttachmentMessage(): Boolean {
|
fun Event.isAttachmentMessage(): Boolean {
|
||||||
return getClearType() == EventType.MESSAGE
|
return getClearType() == EventType.MESSAGE &&
|
||||||
&& when (getClearContent()?.get(MessageContent.MSG_TYPE_JSON_KEY)) {
|
when (getClearContent()?.get(MessageContent.MSG_TYPE_JSON_KEY)) {
|
||||||
MessageType.MSGTYPE_IMAGE,
|
MessageType.MSGTYPE_IMAGE,
|
||||||
MessageType.MSGTYPE_AUDIO,
|
MessageType.MSGTYPE_AUDIO,
|
||||||
MessageType.MSGTYPE_VIDEO,
|
MessageType.MSGTYPE_VIDEO,
|
||||||
|
@ -106,13 +106,13 @@ object EventType {
|
|||||||
internal const val DUMMY = "m.dummy"
|
internal const val DUMMY = "m.dummy"
|
||||||
|
|
||||||
fun isCallEvent(type: String): Boolean {
|
fun isCallEvent(type: String): Boolean {
|
||||||
return type == CALL_INVITE
|
return type == CALL_INVITE ||
|
||||||
|| type == CALL_CANDIDATES
|
type == CALL_CANDIDATES ||
|
||||||
|| type == CALL_ANSWER
|
type == CALL_ANSWER ||
|
||||||
|| type == CALL_HANGUP
|
type == CALL_HANGUP ||
|
||||||
|| type == CALL_SELECT_ANSWER
|
type == CALL_SELECT_ANSWER ||
|
||||||
|| type == CALL_NEGOTIATE
|
type == CALL_NEGOTIATE ||
|
||||||
|| type == CALL_REJECT
|
type == CALL_REJECT ||
|
||||||
|| type == CALL_REPLACES
|
type == CALL_REPLACES
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -89,7 +89,7 @@ data class HomeServerCapabilities(
|
|||||||
* You can also use #isFeatureSupported prior to this call to check if the
|
* You can also use #isFeatureSupported prior to this call to check if the
|
||||||
* feature is supported and report some feedback to user.
|
* feature is supported and report some feedback to user.
|
||||||
*/
|
*/
|
||||||
fun versionOverrideForFeature(feature: String) : String? {
|
fun versionOverrideForFeature(feature: String): String? {
|
||||||
val cap = roomVersions?.capabilities?.get(feature)
|
val cap = roomVersions?.capabilities?.get(feature)
|
||||||
return cap?.preferred ?: cap?.support?.lastOrNull()
|
return cap?.preferred ?: cap?.support?.lastOrNull()
|
||||||
}
|
}
|
||||||
|
@ -132,7 +132,7 @@ interface IdentityService {
|
|||||||
* the identity server offers some crypto functionality to help in accepting invitations.
|
* the identity server offers some crypto functionality to help in accepting invitations.
|
||||||
* This is less secure than the client doing it itself, but may be useful where this isn't possible.
|
* This is less secure than the client doing it itself, but may be useful where this isn't possible.
|
||||||
*/
|
*/
|
||||||
suspend fun sign3pidInvitation(identiyServer: String, token: String, secret: String) : SignInvitationResult
|
suspend fun sign3pidInvitation(identiyServer: String, token: String, secret: String): SignInvitationResult
|
||||||
|
|
||||||
fun addListener(listener: IdentityServiceListener)
|
fun addListener(listener: IdentityServiceListener)
|
||||||
|
|
||||||
|
@ -25,7 +25,7 @@ interface SyncStatusService {
|
|||||||
/**
|
/**
|
||||||
* For initial sync
|
* For initial sync
|
||||||
*/
|
*/
|
||||||
abstract class InitialSyncStatus: Status()
|
abstract class InitialSyncStatus : Status()
|
||||||
|
|
||||||
object Idle : InitialSyncStatus()
|
object Idle : InitialSyncStatus()
|
||||||
data class Progressing(
|
data class Progressing(
|
||||||
@ -36,7 +36,7 @@ interface SyncStatusService {
|
|||||||
/**
|
/**
|
||||||
* For incremental sync
|
* For incremental sync
|
||||||
*/
|
*/
|
||||||
abstract class IncrementalSyncStatus: Status()
|
abstract class IncrementalSyncStatus : Status()
|
||||||
|
|
||||||
object IncrementalSyncIdle : IncrementalSyncStatus()
|
object IncrementalSyncIdle : IncrementalSyncStatus()
|
||||||
data class IncrementalSyncParsing(
|
data class IncrementalSyncParsing(
|
||||||
|
@ -50,11 +50,11 @@ object MatrixLinkify {
|
|||||||
if (startPos == 0 || text[startPos - 1] != '/') {
|
if (startPos == 0 || text[startPos - 1] != '/') {
|
||||||
val endPos = match.range.last + 1
|
val endPos = match.range.last + 1
|
||||||
var url = text.substring(match.range)
|
var url = text.substring(match.range)
|
||||||
if (MatrixPatterns.isUserId(url)
|
if (MatrixPatterns.isUserId(url) ||
|
||||||
|| MatrixPatterns.isRoomAlias(url)
|
MatrixPatterns.isRoomAlias(url) ||
|
||||||
|| MatrixPatterns.isRoomId(url)
|
MatrixPatterns.isRoomId(url) ||
|
||||||
|| MatrixPatterns.isGroupId(url)
|
MatrixPatterns.isGroupId(url) ||
|
||||||
|| MatrixPatterns.isEventId(url)) {
|
MatrixPatterns.isEventId(url)) {
|
||||||
url = PermalinkService.MATRIX_TO_URL_BASE + url
|
url = PermalinkService.MATRIX_TO_URL_BASE + url
|
||||||
}
|
}
|
||||||
val span = MatrixPermalinkSpan(url, callback)
|
val span = MatrixPermalinkSpan(url, callback)
|
||||||
|
@ -19,6 +19,6 @@ package org.matrix.android.sdk.api.session.room
|
|||||||
import org.matrix.android.sdk.api.session.room.alias.RoomAliasError
|
import org.matrix.android.sdk.api.session.room.alias.RoomAliasError
|
||||||
|
|
||||||
sealed class AliasAvailabilityResult {
|
sealed class AliasAvailabilityResult {
|
||||||
object Available: AliasAvailabilityResult()
|
object Available : AliasAvailabilityResult()
|
||||||
data class NotAvailable(val roomAliasError: RoomAliasError) : AliasAvailabilityResult()
|
data class NotAvailable(val roomAliasError: RoomAliasError) : AliasAvailabilityResult()
|
||||||
}
|
}
|
||||||
|
@ -41,5 +41,5 @@ interface RoomDirectoryService {
|
|||||||
*/
|
*/
|
||||||
suspend fun setRoomDirectoryVisibility(roomId: String, roomDirectoryVisibility: RoomDirectoryVisibility)
|
suspend fun setRoomDirectoryVisibility(roomId: String, roomDirectoryVisibility: RoomDirectoryVisibility)
|
||||||
|
|
||||||
suspend fun checkAliasAvailability(aliasLocalPart: String?) : AliasAvailabilityResult
|
suspend fun checkAliasAvailability(aliasLocalPart: String?): AliasAvailabilityResult
|
||||||
}
|
}
|
||||||
|
@ -220,7 +220,7 @@ interface RoomService {
|
|||||||
.setPrefetchDistance(10)
|
.setPrefetchDistance(10)
|
||||||
.build()
|
.build()
|
||||||
|
|
||||||
fun getFlattenRoomSummaryChildrenOf(spaceId: String?, memberships: List<Membership> = Membership.activeMemberships()) : List<RoomSummary>
|
fun getFlattenRoomSummaryChildrenOf(spaceId: String?, memberships: List<Membership> = Membership.activeMemberships()): List<RoomSummary>
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns all the children of this space, as LiveData
|
* Returns all the children of this space, as LiveData
|
||||||
|
@ -44,7 +44,7 @@ data class CallAnswerContent(
|
|||||||
* Capability advertisement.
|
* Capability advertisement.
|
||||||
*/
|
*/
|
||||||
@Json(name = "capabilities") val capabilities: CallCapabilities? = null
|
@Json(name = "capabilities") val capabilities: CallCapabilities? = null
|
||||||
): CallSignalingContent {
|
) : CallSignalingContent {
|
||||||
|
|
||||||
@JsonClass(generateAdapter = true)
|
@JsonClass(generateAdapter = true)
|
||||||
data class Answer(
|
data class Answer(
|
||||||
|
@ -41,4 +41,4 @@ data class CallCandidatesContent(
|
|||||||
* Required. The version of the VoIP specification this messages adheres to.
|
* Required. The version of the VoIP specification this messages adheres to.
|
||||||
*/
|
*/
|
||||||
@Json(name = "version") override val version: String?
|
@Json(name = "version") override val version: String?
|
||||||
): CallSignalingContent
|
) : CallSignalingContent
|
||||||
|
@ -55,7 +55,7 @@ data class CallInviteContent(
|
|||||||
*/
|
*/
|
||||||
@Json(name = "capabilities") val capabilities: CallCapabilities? = null
|
@Json(name = "capabilities") val capabilities: CallCapabilities? = null
|
||||||
|
|
||||||
): CallSignalingContent {
|
) : CallSignalingContent {
|
||||||
@JsonClass(generateAdapter = true)
|
@JsonClass(generateAdapter = true)
|
||||||
data class Offer(
|
data class Offer(
|
||||||
/**
|
/**
|
||||||
|
@ -47,7 +47,7 @@ data class CallNegotiateContent(
|
|||||||
*/
|
*/
|
||||||
@Json(name = "version") override val version: String?
|
@Json(name = "version") override val version: String?
|
||||||
|
|
||||||
): CallSignalingContent {
|
) : CallSignalingContent {
|
||||||
@JsonClass(generateAdapter = true)
|
@JsonClass(generateAdapter = true)
|
||||||
data class Description(
|
data class Description(
|
||||||
/**
|
/**
|
||||||
|
@ -61,7 +61,7 @@ data class CallReplacesContent(
|
|||||||
* Required. The version of the VoIP specification this messages adheres to.
|
* Required. The version of the VoIP specification this messages adheres to.
|
||||||
*/
|
*/
|
||||||
@Json(name = "version") override val version: String?
|
@Json(name = "version") override val version: String?
|
||||||
): CallSignalingContent {
|
) : CallSignalingContent {
|
||||||
|
|
||||||
@JsonClass(generateAdapter = true)
|
@JsonClass(generateAdapter = true)
|
||||||
data class TargetUser(
|
data class TargetUser(
|
||||||
|
@ -41,4 +41,4 @@ data class CallSelectAnswerContent(
|
|||||||
* Required. The version of the VoIP specification this message adheres to.
|
* Required. The version of the VoIP specification this message adheres to.
|
||||||
*/
|
*/
|
||||||
@Json(name = "version") override val version: String?
|
@Json(name = "version") override val version: String?
|
||||||
): CallSignalingContent
|
) : CallSignalingContent
|
||||||
|
@ -31,7 +31,7 @@ interface RoomVersionService {
|
|||||||
/**
|
/**
|
||||||
* Get the recommended room version for the current homeserver
|
* Get the recommended room version for the current homeserver
|
||||||
*/
|
*/
|
||||||
fun getRecommendedVersion() : String
|
fun getRecommendedVersion(): String
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Ask if the user has enough power level to upgrade the room
|
* Ask if the user has enough power level to upgrade the room
|
||||||
|
@ -22,8 +22,8 @@ sealed class SharedSecretStorageError(message: String?) : Throwable(message) {
|
|||||||
data class UnknownAlgorithm(val keyId: String) : SharedSecretStorageError("Unknown algorithm $keyId")
|
data class UnknownAlgorithm(val keyId: String) : SharedSecretStorageError("Unknown algorithm $keyId")
|
||||||
data class UnsupportedAlgorithm(val algorithm: String) : SharedSecretStorageError("Unknown algorithm $algorithm")
|
data class UnsupportedAlgorithm(val algorithm: String) : SharedSecretStorageError("Unknown algorithm $algorithm")
|
||||||
data class SecretNotEncrypted(val secretName: String) : SharedSecretStorageError("Missing content for secret $secretName")
|
data class SecretNotEncrypted(val secretName: String) : SharedSecretStorageError("Missing content for secret $secretName")
|
||||||
data class SecretNotEncryptedWithKey(val secretName: String, val keyId: String)
|
data class SecretNotEncryptedWithKey(val secretName: String, val keyId: String) :
|
||||||
: SharedSecretStorageError("Missing content for secret $secretName with key $keyId")
|
SharedSecretStorageError("Missing content for secret $secretName with key $keyId")
|
||||||
|
|
||||||
object BadKeyFormat : SharedSecretStorageError("Bad Key Format")
|
object BadKeyFormat : SharedSecretStorageError("Bad Key Format")
|
||||||
object ParsingError : SharedSecretStorageError("parsing Error")
|
object ParsingError : SharedSecretStorageError("parsing Error")
|
||||||
|
@ -34,8 +34,8 @@ sealed class MatrixItem(
|
|||||||
) {
|
) {
|
||||||
data class UserItem(override val id: String,
|
data class UserItem(override val id: String,
|
||||||
override val displayName: String? = null,
|
override val displayName: String? = null,
|
||||||
override val avatarUrl: String? = null)
|
override val avatarUrl: String? = null) :
|
||||||
: MatrixItem(id, displayName?.removeSuffix(ircPattern), avatarUrl) {
|
MatrixItem(id, displayName?.removeSuffix(ircPattern), avatarUrl) {
|
||||||
init {
|
init {
|
||||||
if (BuildConfig.DEBUG) checkId()
|
if (BuildConfig.DEBUG) checkId()
|
||||||
}
|
}
|
||||||
@ -45,8 +45,8 @@ sealed class MatrixItem(
|
|||||||
|
|
||||||
data class EventItem(override val id: String,
|
data class EventItem(override val id: String,
|
||||||
override val displayName: String? = null,
|
override val displayName: String? = null,
|
||||||
override val avatarUrl: String? = null)
|
override val avatarUrl: String? = null) :
|
||||||
: MatrixItem(id, displayName, avatarUrl) {
|
MatrixItem(id, displayName, avatarUrl) {
|
||||||
init {
|
init {
|
||||||
if (BuildConfig.DEBUG) checkId()
|
if (BuildConfig.DEBUG) checkId()
|
||||||
}
|
}
|
||||||
@ -56,8 +56,8 @@ sealed class MatrixItem(
|
|||||||
|
|
||||||
data class RoomItem(override val id: String,
|
data class RoomItem(override val id: String,
|
||||||
override val displayName: String? = null,
|
override val displayName: String? = null,
|
||||||
override val avatarUrl: String? = null)
|
override val avatarUrl: String? = null) :
|
||||||
: MatrixItem(id, displayName, avatarUrl) {
|
MatrixItem(id, displayName, avatarUrl) {
|
||||||
init {
|
init {
|
||||||
if (BuildConfig.DEBUG) checkId()
|
if (BuildConfig.DEBUG) checkId()
|
||||||
}
|
}
|
||||||
@ -67,8 +67,8 @@ sealed class MatrixItem(
|
|||||||
|
|
||||||
data class SpaceItem(override val id: String,
|
data class SpaceItem(override val id: String,
|
||||||
override val displayName: String? = null,
|
override val displayName: String? = null,
|
||||||
override val avatarUrl: String? = null)
|
override val avatarUrl: String? = null) :
|
||||||
: MatrixItem(id, displayName, avatarUrl) {
|
MatrixItem(id, displayName, avatarUrl) {
|
||||||
init {
|
init {
|
||||||
if (BuildConfig.DEBUG) checkId()
|
if (BuildConfig.DEBUG) checkId()
|
||||||
}
|
}
|
||||||
@ -78,8 +78,8 @@ sealed class MatrixItem(
|
|||||||
|
|
||||||
data class RoomAliasItem(override val id: String,
|
data class RoomAliasItem(override val id: String,
|
||||||
override val displayName: String? = null,
|
override val displayName: String? = null,
|
||||||
override val avatarUrl: String? = null)
|
override val avatarUrl: String? = null) :
|
||||||
: MatrixItem(id, displayName, avatarUrl) {
|
MatrixItem(id, displayName, avatarUrl) {
|
||||||
init {
|
init {
|
||||||
if (BuildConfig.DEBUG) checkId()
|
if (BuildConfig.DEBUG) checkId()
|
||||||
}
|
}
|
||||||
@ -92,8 +92,8 @@ sealed class MatrixItem(
|
|||||||
|
|
||||||
data class GroupItem(override val id: String,
|
data class GroupItem(override val id: String,
|
||||||
override val displayName: String? = null,
|
override val displayName: String? = null,
|
||||||
override val avatarUrl: String? = null)
|
override val avatarUrl: String? = null) :
|
||||||
: MatrixItem(id, displayName, avatarUrl) {
|
MatrixItem(id, displayName, avatarUrl) {
|
||||||
init {
|
init {
|
||||||
if (BuildConfig.DEBUG) checkId()
|
if (BuildConfig.DEBUG) checkId()
|
||||||
}
|
}
|
||||||
|
@ -172,8 +172,8 @@ internal class DefaultAuthenticationService @Inject constructor(
|
|||||||
return try {
|
return try {
|
||||||
getWellknownLoginFlowInternal(homeServerConnectionConfig)
|
getWellknownLoginFlowInternal(homeServerConnectionConfig)
|
||||||
} catch (failure: Throwable) {
|
} catch (failure: Throwable) {
|
||||||
if (failure is Failure.OtherServerError
|
if (failure is Failure.OtherServerError &&
|
||||||
&& failure.httpCode == HttpsURLConnection.HTTP_NOT_FOUND /* 404 */) {
|
failure.httpCode == HttpsURLConnection.HTTP_NOT_FOUND /* 404 */) {
|
||||||
// 404, no well-known data, try direct access to the API
|
// 404, no well-known data, try direct access to the API
|
||||||
// First check the homeserver version
|
// First check the homeserver version
|
||||||
return runCatching {
|
return runCatching {
|
||||||
@ -190,8 +190,8 @@ internal class DefaultAuthenticationService @Inject constructor(
|
|||||||
it
|
it
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
if (it is Failure.OtherServerError
|
if (it is Failure.OtherServerError &&
|
||||||
&& it.httpCode == HttpsURLConnection.HTTP_NOT_FOUND /* 404 */) {
|
it.httpCode == HttpsURLConnection.HTTP_NOT_FOUND /* 404 */) {
|
||||||
// It's maybe a Web client url?
|
// It's maybe a Web client url?
|
||||||
getWebClientDomainLoginFlowInternal(homeServerConnectionConfig)
|
getWebClientDomainLoginFlowInternal(homeServerConnectionConfig)
|
||||||
} else {
|
} else {
|
||||||
@ -225,8 +225,8 @@ internal class DefaultAuthenticationService @Inject constructor(
|
|||||||
it
|
it
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
if (it is Failure.OtherServerError
|
if (it is Failure.OtherServerError &&
|
||||||
&& it.httpCode == HttpsURLConnection.HTTP_NOT_FOUND /* 404 */) {
|
it.httpCode == HttpsURLConnection.HTTP_NOT_FOUND /* 404 */) {
|
||||||
// Try with config.json
|
// Try with config.json
|
||||||
getWebClientLoginFlowInternal(homeServerConnectionConfig)
|
getWebClientLoginFlowInternal(homeServerConnectionConfig)
|
||||||
} else {
|
} else {
|
||||||
|
@ -54,8 +54,8 @@ internal class DefaultIsValidClientServerApiTask @Inject constructor(
|
|||||||
// We get a response, so the API is valid
|
// We get a response, so the API is valid
|
||||||
true
|
true
|
||||||
} catch (failure: Throwable) {
|
} catch (failure: Throwable) {
|
||||||
if (failure is Failure.OtherServerError
|
if (failure is Failure.OtherServerError &&
|
||||||
&& failure.httpCode == HttpsURLConnection.HTTP_NOT_FOUND /* 404 */) {
|
failure.httpCode == HttpsURLConnection.HTTP_NOT_FOUND /* 404 */) {
|
||||||
// Probably not valid
|
// Probably not valid
|
||||||
false
|
false
|
||||||
} else {
|
} else {
|
||||||
|
@ -16,11 +16,11 @@
|
|||||||
|
|
||||||
package org.matrix.android.sdk.internal.auth.db
|
package org.matrix.android.sdk.internal.auth.db
|
||||||
|
|
||||||
|
import io.realm.Realm
|
||||||
|
import io.realm.RealmConfiguration
|
||||||
import org.matrix.android.sdk.internal.auth.PendingSessionStore
|
import org.matrix.android.sdk.internal.auth.PendingSessionStore
|
||||||
import org.matrix.android.sdk.internal.database.awaitTransaction
|
import org.matrix.android.sdk.internal.database.awaitTransaction
|
||||||
import org.matrix.android.sdk.internal.di.AuthDatabase
|
import org.matrix.android.sdk.internal.di.AuthDatabase
|
||||||
import io.realm.Realm
|
|
||||||
import io.realm.RealmConfiguration
|
|
||||||
import javax.inject.Inject
|
import javax.inject.Inject
|
||||||
|
|
||||||
internal class RealmPendingSessionStore @Inject constructor(private val mapper: PendingSessionMapper,
|
internal class RealmPendingSessionStore @Inject constructor(private val mapper: PendingSessionMapper,
|
||||||
|
@ -16,15 +16,15 @@
|
|||||||
|
|
||||||
package org.matrix.android.sdk.internal.auth.db
|
package org.matrix.android.sdk.internal.auth.db
|
||||||
|
|
||||||
|
import io.realm.Realm
|
||||||
|
import io.realm.RealmConfiguration
|
||||||
|
import io.realm.exceptions.RealmPrimaryKeyConstraintException
|
||||||
import org.matrix.android.sdk.api.auth.data.Credentials
|
import org.matrix.android.sdk.api.auth.data.Credentials
|
||||||
import org.matrix.android.sdk.api.auth.data.SessionParams
|
import org.matrix.android.sdk.api.auth.data.SessionParams
|
||||||
import org.matrix.android.sdk.api.auth.data.sessionId
|
import org.matrix.android.sdk.api.auth.data.sessionId
|
||||||
import org.matrix.android.sdk.internal.auth.SessionParamsStore
|
import org.matrix.android.sdk.internal.auth.SessionParamsStore
|
||||||
import org.matrix.android.sdk.internal.database.awaitTransaction
|
import org.matrix.android.sdk.internal.database.awaitTransaction
|
||||||
import org.matrix.android.sdk.internal.di.AuthDatabase
|
import org.matrix.android.sdk.internal.di.AuthDatabase
|
||||||
import io.realm.Realm
|
|
||||||
import io.realm.RealmConfiguration
|
|
||||||
import io.realm.exceptions.RealmPrimaryKeyConstraintException
|
|
||||||
import timber.log.Timber
|
import timber.log.Timber
|
||||||
import javax.inject.Inject
|
import javax.inject.Inject
|
||||||
|
|
||||||
|
@ -17,6 +17,7 @@
|
|||||||
package org.matrix.android.sdk.internal.auth.login
|
package org.matrix.android.sdk.internal.auth.login
|
||||||
|
|
||||||
import dagger.Lazy
|
import dagger.Lazy
|
||||||
|
import okhttp3.OkHttpClient
|
||||||
import org.matrix.android.sdk.api.auth.data.HomeServerConnectionConfig
|
import org.matrix.android.sdk.api.auth.data.HomeServerConnectionConfig
|
||||||
import org.matrix.android.sdk.api.failure.Failure
|
import org.matrix.android.sdk.api.failure.Failure
|
||||||
import org.matrix.android.sdk.api.session.Session
|
import org.matrix.android.sdk.api.session.Session
|
||||||
@ -29,7 +30,6 @@ import org.matrix.android.sdk.internal.network.executeRequest
|
|||||||
import org.matrix.android.sdk.internal.network.httpclient.addSocketFactory
|
import org.matrix.android.sdk.internal.network.httpclient.addSocketFactory
|
||||||
import org.matrix.android.sdk.internal.network.ssl.UnrecognizedCertificateException
|
import org.matrix.android.sdk.internal.network.ssl.UnrecognizedCertificateException
|
||||||
import org.matrix.android.sdk.internal.task.Task
|
import org.matrix.android.sdk.internal.task.Task
|
||||||
import okhttp3.OkHttpClient
|
|
||||||
import javax.inject.Inject
|
import javax.inject.Inject
|
||||||
|
|
||||||
internal interface DirectLoginTask : Task<DirectLoginTask.Params, Session> {
|
internal interface DirectLoginTask : Task<DirectLoginTask.Params, Session> {
|
||||||
|
@ -63,9 +63,9 @@ internal fun Versions.isSupportedBySdk(): Boolean {
|
|||||||
* Return true if the SDK supports this homeserver version for login and registration
|
* Return true if the SDK supports this homeserver version for login and registration
|
||||||
*/
|
*/
|
||||||
internal fun Versions.isLoginAndRegistrationSupportedBySdk(): Boolean {
|
internal fun Versions.isLoginAndRegistrationSupportedBySdk(): Boolean {
|
||||||
return !doesServerRequireIdentityServerParam()
|
return !doesServerRequireIdentityServerParam() &&
|
||||||
&& doesServerAcceptIdentityAccessToken()
|
doesServerAcceptIdentityAccessToken() &&
|
||||||
&& doesServerSeparatesAddAndBind()
|
doesServerSeparatesAddAndBind()
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -74,8 +74,8 @@ internal fun Versions.isLoginAndRegistrationSupportedBySdk(): Boolean {
|
|||||||
* @return true if the server support the lazy loading of room members
|
* @return true if the server support the lazy loading of room members
|
||||||
*/
|
*/
|
||||||
private fun Versions.supportLazyLoadMembers(): Boolean {
|
private fun Versions.supportLazyLoadMembers(): Boolean {
|
||||||
return getMaxVersion() >= HomeServerVersion.r0_5_0
|
return getMaxVersion() >= HomeServerVersion.r0_5_0 ||
|
||||||
|| unstableFeatures?.get(FEATURE_LAZY_LOAD_MEMBERS) == true
|
unstableFeatures?.get(FEATURE_LAZY_LOAD_MEMBERS) == true
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -92,13 +92,13 @@ private fun Versions.doesServerRequireIdentityServerParam(): Boolean {
|
|||||||
* Some homeservers may trigger errors if they are not prepared for the new parameter.
|
* Some homeservers may trigger errors if they are not prepared for the new parameter.
|
||||||
*/
|
*/
|
||||||
private fun Versions.doesServerAcceptIdentityAccessToken(): Boolean {
|
private fun Versions.doesServerAcceptIdentityAccessToken(): Boolean {
|
||||||
return getMaxVersion() >= HomeServerVersion.r0_6_0
|
return getMaxVersion() >= HomeServerVersion.r0_6_0 ||
|
||||||
|| unstableFeatures?.get(FEATURE_ID_ACCESS_TOKEN) ?: false
|
unstableFeatures?.get(FEATURE_ID_ACCESS_TOKEN) ?: false
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun Versions.doesServerSeparatesAddAndBind(): Boolean {
|
private fun Versions.doesServerSeparatesAddAndBind(): Boolean {
|
||||||
return getMaxVersion() >= HomeServerVersion.r0_6_0
|
return getMaxVersion() >= HomeServerVersion.r0_6_0 ||
|
||||||
|| unstableFeatures?.get(FEATURE_SEPARATE_ADD_AND_BIND) ?: false
|
unstableFeatures?.get(FEATURE_SEPARATE_ADD_AND_BIND) ?: false
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun Versions.getMaxVersion(): HomeServerVersion {
|
private fun Versions.getMaxVersion(): HomeServerVersion {
|
||||||
|
@ -35,8 +35,8 @@ import org.matrix.android.sdk.internal.worker.SessionWorkerParams
|
|||||||
import javax.inject.Inject
|
import javax.inject.Inject
|
||||||
|
|
||||||
internal class CancelGossipRequestWorker(context: Context,
|
internal class CancelGossipRequestWorker(context: Context,
|
||||||
params: WorkerParameters)
|
params: WorkerParameters) :
|
||||||
: SessionSafeCoroutineWorker<CancelGossipRequestWorker.Params>(context, params, Params::class.java) {
|
SessionSafeCoroutineWorker<CancelGossipRequestWorker.Params>(context, params, Params::class.java) {
|
||||||
|
|
||||||
@JsonClass(generateAdapter = true)
|
@JsonClass(generateAdapter = true)
|
||||||
internal data class Params(
|
internal data class Params(
|
||||||
|
@ -19,6 +19,9 @@ package org.matrix.android.sdk.internal.crypto
|
|||||||
import dagger.Binds
|
import dagger.Binds
|
||||||
import dagger.Module
|
import dagger.Module
|
||||||
import dagger.Provides
|
import dagger.Provides
|
||||||
|
import io.realm.RealmConfiguration
|
||||||
|
import kotlinx.coroutines.CoroutineScope
|
||||||
|
import kotlinx.coroutines.SupervisorJob
|
||||||
import org.matrix.android.sdk.api.session.crypto.CryptoService
|
import org.matrix.android.sdk.api.session.crypto.CryptoService
|
||||||
import org.matrix.android.sdk.api.session.crypto.crosssigning.CrossSigningService
|
import org.matrix.android.sdk.api.session.crypto.crosssigning.CrossSigningService
|
||||||
import org.matrix.android.sdk.internal.crypto.api.CryptoApi
|
import org.matrix.android.sdk.internal.crypto.api.CryptoApi
|
||||||
@ -93,9 +96,6 @@ import org.matrix.android.sdk.internal.di.UserMd5
|
|||||||
import org.matrix.android.sdk.internal.session.SessionScope
|
import org.matrix.android.sdk.internal.session.SessionScope
|
||||||
import org.matrix.android.sdk.internal.session.cache.ClearCacheTask
|
import org.matrix.android.sdk.internal.session.cache.ClearCacheTask
|
||||||
import org.matrix.android.sdk.internal.session.cache.RealmClearCacheTask
|
import org.matrix.android.sdk.internal.session.cache.RealmClearCacheTask
|
||||||
import io.realm.RealmConfiguration
|
|
||||||
import kotlinx.coroutines.CoroutineScope
|
|
||||||
import kotlinx.coroutines.SupervisorJob
|
|
||||||
import retrofit2.Retrofit
|
import retrofit2.Retrofit
|
||||||
import java.io.File
|
import java.io.File
|
||||||
|
|
||||||
|
@ -868,8 +868,8 @@ internal class DefaultCryptoService @Inject constructor(
|
|||||||
}
|
}
|
||||||
|
|
||||||
private fun getRoomUserIds(roomId: String): List<String> {
|
private fun getRoomUserIds(roomId: String): List<String> {
|
||||||
val encryptForInvitedMembers = isEncryptionEnabledForInvitedUser()
|
val encryptForInvitedMembers = isEncryptionEnabledForInvitedUser() &&
|
||||||
&& shouldEncryptForInvitedMembers(roomId)
|
shouldEncryptForInvitedMembers(roomId)
|
||||||
return cryptoSessionInfoProvider.getRoomUserIds(roomId, encryptForInvitedMembers)
|
return cryptoSessionInfoProvider.getRoomUserIds(roomId, encryptForInvitedMembers)
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -887,9 +887,9 @@ internal class DefaultCryptoService @Inject constructor(
|
|||||||
if (membership == Membership.JOIN) {
|
if (membership == Membership.JOIN) {
|
||||||
// make sure we are tracking the deviceList for this user.
|
// make sure we are tracking the deviceList for this user.
|
||||||
deviceListManager.startTrackingDeviceList(listOf(userId))
|
deviceListManager.startTrackingDeviceList(listOf(userId))
|
||||||
} else if (membership == Membership.INVITE
|
} else if (membership == Membership.INVITE &&
|
||||||
&& shouldEncryptForInvitedMembers(roomId)
|
shouldEncryptForInvitedMembers(roomId) &&
|
||||||
&& isEncryptionEnabledForInvitedUser()) {
|
isEncryptionEnabledForInvitedUser()) {
|
||||||
// track the deviceList for this invited user.
|
// track the deviceList for this invited user.
|
||||||
// Caution: there's a big edge case here in that federated servers do not
|
// Caution: there's a big edge case here in that federated servers do not
|
||||||
// know what other servers are in the room at the time they've been invited.
|
// know what other servers are in the room at the time they've been invited.
|
||||||
|
@ -475,8 +475,8 @@ internal class DeviceListManager @Inject constructor(private val cryptoStore: IM
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (!isVerified) {
|
if (!isVerified) {
|
||||||
Timber.e("## CRYPTO | validateDeviceKeys() : Unable to verify signature on device " + userId + ":"
|
Timber.e("## CRYPTO | validateDeviceKeys() : Unable to verify signature on device " + userId + ":" +
|
||||||
+ deviceKeys.deviceId + " with error " + errorMessage)
|
deviceKeys.deviceId + " with error " + errorMessage)
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -486,9 +486,9 @@ internal class DeviceListManager @Inject constructor(private val cryptoStore: IM
|
|||||||
// best off sticking with the original keys.
|
// best off sticking with the original keys.
|
||||||
//
|
//
|
||||||
// Should we warn the user about it somehow?
|
// Should we warn the user about it somehow?
|
||||||
Timber.e("## CRYPTO | validateDeviceKeys() : WARNING:Ed25519 key for device " + userId + ":"
|
Timber.e("## CRYPTO | validateDeviceKeys() : WARNING:Ed25519 key for device " + userId + ":" +
|
||||||
+ deviceKeys.deviceId + " has changed : "
|
deviceKeys.deviceId + " has changed : " +
|
||||||
+ previouslyStoredDeviceKeys.fingerprint() + " -> " + signKey)
|
previouslyStoredDeviceKeys.fingerprint() + " -> " + signKey)
|
||||||
|
|
||||||
Timber.e("## CRYPTO | validateDeviceKeys() : $previouslyStoredDeviceKeys -> $deviceKeys")
|
Timber.e("## CRYPTO | validateDeviceKeys() : $previouslyStoredDeviceKeys -> $deviceKeys")
|
||||||
Timber.e("## CRYPTO | validateDeviceKeys() : ${previouslyStoredDeviceKeys.keys} -> ${deviceKeys.keys}")
|
Timber.e("## CRYPTO | validateDeviceKeys() : ${previouslyStoredDeviceKeys.keys} -> ${deviceKeys.keys}")
|
||||||
|
@ -107,8 +107,8 @@ internal class EventDecryptor @Inject constructor(
|
|||||||
} catch (mxCryptoError: MXCryptoError) {
|
} catch (mxCryptoError: MXCryptoError) {
|
||||||
Timber.v("## CRYPTO | internalDecryptEvent : Failed to decrypt ${event.eventId} reason: $mxCryptoError")
|
Timber.v("## CRYPTO | internalDecryptEvent : Failed to decrypt ${event.eventId} reason: $mxCryptoError")
|
||||||
if (algorithm == MXCRYPTO_ALGORITHM_OLM) {
|
if (algorithm == MXCRYPTO_ALGORITHM_OLM) {
|
||||||
if (mxCryptoError is MXCryptoError.Base
|
if (mxCryptoError is MXCryptoError.Base &&
|
||||||
&& mxCryptoError.errorType == MXCryptoError.ErrorType.BAD_ENCRYPTED_MESSAGE) {
|
mxCryptoError.errorType == MXCryptoError.ErrorType.BAD_ENCRYPTED_MESSAGE) {
|
||||||
// need to find sending device
|
// need to find sending device
|
||||||
cryptoCoroutineScope.launch(coroutineDispatchers.crypto) {
|
cryptoCoroutineScope.launch(coroutineDispatchers.crypto) {
|
||||||
val olmContent = event.content.toModel<OlmEventContent>()
|
val olmContent = event.content.toModel<OlmEventContent>()
|
||||||
|
@ -16,17 +16,17 @@
|
|||||||
|
|
||||||
package org.matrix.android.sdk.internal.crypto
|
package org.matrix.android.sdk.internal.crypto
|
||||||
|
|
||||||
|
import kotlinx.coroutines.CoroutineScope
|
||||||
|
import kotlinx.coroutines.delay
|
||||||
|
import kotlinx.coroutines.launch
|
||||||
import org.matrix.android.sdk.internal.crypto.model.rest.RoomKeyRequestBody
|
import org.matrix.android.sdk.internal.crypto.model.rest.RoomKeyRequestBody
|
||||||
import org.matrix.android.sdk.internal.crypto.store.IMXCryptoStore
|
import org.matrix.android.sdk.internal.crypto.store.IMXCryptoStore
|
||||||
|
import org.matrix.android.sdk.internal.crypto.tasks.createUniqueTxnId
|
||||||
|
import org.matrix.android.sdk.internal.crypto.util.RequestIdHelper
|
||||||
import org.matrix.android.sdk.internal.di.SessionId
|
import org.matrix.android.sdk.internal.di.SessionId
|
||||||
import org.matrix.android.sdk.internal.session.SessionScope
|
import org.matrix.android.sdk.internal.session.SessionScope
|
||||||
import org.matrix.android.sdk.internal.util.MatrixCoroutineDispatchers
|
import org.matrix.android.sdk.internal.util.MatrixCoroutineDispatchers
|
||||||
import org.matrix.android.sdk.internal.worker.WorkerParamsFactory
|
import org.matrix.android.sdk.internal.worker.WorkerParamsFactory
|
||||||
import kotlinx.coroutines.CoroutineScope
|
|
||||||
import kotlinx.coroutines.delay
|
|
||||||
import kotlinx.coroutines.launch
|
|
||||||
import org.matrix.android.sdk.internal.crypto.tasks.createUniqueTxnId
|
|
||||||
import org.matrix.android.sdk.internal.crypto.util.RequestIdHelper
|
|
||||||
import timber.log.Timber
|
import timber.log.Timber
|
||||||
import javax.inject.Inject
|
import javax.inject.Inject
|
||||||
|
|
||||||
@ -112,9 +112,8 @@ internal class OutgoingGossipingRequestManager @Inject constructor(
|
|||||||
* @param andResend true to resend the key request
|
* @param andResend true to resend the key request
|
||||||
*/
|
*/
|
||||||
private fun cancelRoomKeyRequest(requestBody: RoomKeyRequestBody, andResend: Boolean) {
|
private fun cancelRoomKeyRequest(requestBody: RoomKeyRequestBody, andResend: Boolean) {
|
||||||
val req = cryptoStore.getOutgoingRoomKeyRequest(requestBody)
|
val req = cryptoStore.getOutgoingRoomKeyRequest(requestBody) // no request was made for this key
|
||||||
?: // no request was made for this key
|
?: return Unit.also {
|
||||||
return Unit.also {
|
|
||||||
Timber.v("## CRYPTO - GOSSIP cancelRoomKeyRequest() Unknown request $requestBody")
|
Timber.v("## CRYPTO - GOSSIP cancelRoomKeyRequest() Unknown request $requestBody")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -38,8 +38,8 @@ import timber.log.Timber
|
|||||||
import javax.inject.Inject
|
import javax.inject.Inject
|
||||||
|
|
||||||
internal class SendGossipRequestWorker(context: Context,
|
internal class SendGossipRequestWorker(context: Context,
|
||||||
params: WorkerParameters)
|
params: WorkerParameters) :
|
||||||
: SessionSafeCoroutineWorker<SendGossipRequestWorker.Params>(context, params, Params::class.java) {
|
SessionSafeCoroutineWorker<SendGossipRequestWorker.Params>(context, params, Params::class.java) {
|
||||||
|
|
||||||
@JsonClass(generateAdapter = true)
|
@JsonClass(generateAdapter = true)
|
||||||
internal data class Params(
|
internal data class Params(
|
||||||
|
@ -38,8 +38,8 @@ import timber.log.Timber
|
|||||||
import javax.inject.Inject
|
import javax.inject.Inject
|
||||||
|
|
||||||
internal class SendGossipWorker(context: Context,
|
internal class SendGossipWorker(context: Context,
|
||||||
params: WorkerParameters)
|
params: WorkerParameters) :
|
||||||
: SessionSafeCoroutineWorker<SendGossipWorker.Params>(context, params, Params::class.java) {
|
SessionSafeCoroutineWorker<SendGossipWorker.Params>(context, params, Params::class.java) {
|
||||||
|
|
||||||
@JsonClass(generateAdapter = true)
|
@JsonClass(generateAdapter = true)
|
||||||
internal data class Params(
|
internal data class Params(
|
||||||
|
@ -90,8 +90,8 @@ internal class EnsureOlmSessionsForDevicesAction @Inject constructor(
|
|||||||
oneTimeKey = key
|
oneTimeKey = key
|
||||||
}
|
}
|
||||||
if (oneTimeKey == null) {
|
if (oneTimeKey == null) {
|
||||||
Timber.w("## CRYPTO | ensureOlmSessionsForDevices() : No one-time keys " + oneTimeKeyAlgorithm
|
Timber.w("## CRYPTO | ensureOlmSessionsForDevices() : No one-time keys " + oneTimeKeyAlgorithm +
|
||||||
+ " for device " + userId + " : " + deviceId)
|
" for device " + userId + " : " + deviceId)
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
// Update the result for this device in results
|
// Update the result for this device in results
|
||||||
@ -126,15 +126,15 @@ internal class EnsureOlmSessionsForDevicesAction @Inject constructor(
|
|||||||
sessionId = olmDevice.createOutboundSession(deviceInfo.identityKey()!!, oneTimeKey.value)
|
sessionId = olmDevice.createOutboundSession(deviceInfo.identityKey()!!, oneTimeKey.value)
|
||||||
|
|
||||||
if (!sessionId.isNullOrEmpty()) {
|
if (!sessionId.isNullOrEmpty()) {
|
||||||
Timber.v("## CRYPTO | verifyKeyAndStartSession() : Started new sessionid " + sessionId
|
Timber.v("## CRYPTO | verifyKeyAndStartSession() : Started new sessionid " + sessionId +
|
||||||
+ " for device " + deviceInfo + "(theirOneTimeKey: " + oneTimeKey.value + ")")
|
" for device " + deviceInfo + "(theirOneTimeKey: " + oneTimeKey.value + ")")
|
||||||
} else {
|
} else {
|
||||||
// Possibly a bad key
|
// Possibly a bad key
|
||||||
Timber.e("## CRYPTO | verifyKeyAndStartSession() : Error starting session with device $userId:$deviceId")
|
Timber.e("## CRYPTO | verifyKeyAndStartSession() : Error starting session with device $userId:$deviceId")
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
Timber.e("## CRYPTO | verifyKeyAndStartSession() : Unable to verify signature on one-time key for device " + userId
|
Timber.e("## CRYPTO | verifyKeyAndStartSession() : Unable to verify signature on one-time key for device " + userId +
|
||||||
+ ":" + deviceId + " Error " + errorMessage)
|
":" + deviceId + " Error " + errorMessage)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -38,9 +38,9 @@ internal class EnsureOlmSessionsForUsersAction @Inject constructor(private val o
|
|||||||
|
|
||||||
devices.filter {
|
devices.filter {
|
||||||
// Don't bother setting up session to ourself
|
// Don't bother setting up session to ourself
|
||||||
it.identityKey() != olmDevice.deviceCurve25519Key
|
it.identityKey() != olmDevice.deviceCurve25519Key &&
|
||||||
// Don't bother setting up sessions with blocked users
|
// Don't bother setting up sessions with blocked users
|
||||||
&& !(it.trustLevel?.isVerified() ?: false)
|
!(it.trustLevel?.isVerified() ?: false)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return ensureOlmSessionsForDevicesAction.handle(devicesByUser)
|
return ensureOlmSessionsForDevicesAction.handle(devicesByUser)
|
||||||
|
@ -16,6 +16,8 @@
|
|||||||
|
|
||||||
package org.matrix.android.sdk.internal.crypto.algorithms.megolm
|
package org.matrix.android.sdk.internal.crypto.algorithms.megolm
|
||||||
|
|
||||||
|
import kotlinx.coroutines.CoroutineScope
|
||||||
|
import kotlinx.coroutines.launch
|
||||||
import org.matrix.android.sdk.api.session.crypto.MXCryptoError
|
import org.matrix.android.sdk.api.session.crypto.MXCryptoError
|
||||||
import org.matrix.android.sdk.api.session.events.model.Event
|
import org.matrix.android.sdk.api.session.events.model.Event
|
||||||
import org.matrix.android.sdk.api.session.events.model.EventType
|
import org.matrix.android.sdk.api.session.events.model.EventType
|
||||||
@ -40,8 +42,6 @@ import org.matrix.android.sdk.internal.crypto.model.rest.RoomKeyRequestBody
|
|||||||
import org.matrix.android.sdk.internal.crypto.store.IMXCryptoStore
|
import org.matrix.android.sdk.internal.crypto.store.IMXCryptoStore
|
||||||
import org.matrix.android.sdk.internal.crypto.tasks.SendToDeviceTask
|
import org.matrix.android.sdk.internal.crypto.tasks.SendToDeviceTask
|
||||||
import org.matrix.android.sdk.internal.util.MatrixCoroutineDispatchers
|
import org.matrix.android.sdk.internal.util.MatrixCoroutineDispatchers
|
||||||
import kotlinx.coroutines.CoroutineScope
|
|
||||||
import kotlinx.coroutines.launch
|
|
||||||
import timber.log.Timber
|
import timber.log.Timber
|
||||||
|
|
||||||
internal class MXMegolmDecryption(private val userId: String,
|
internal class MXMegolmDecryption(private val userId: String,
|
||||||
@ -82,9 +82,9 @@ internal class MXMegolmDecryption(private val userId: String,
|
|||||||
val encryptedEventContent = event.content.toModel<EncryptedEventContent>()
|
val encryptedEventContent = event.content.toModel<EncryptedEventContent>()
|
||||||
?: throw MXCryptoError.Base(MXCryptoError.ErrorType.MISSING_FIELDS, MXCryptoError.MISSING_FIELDS_REASON)
|
?: throw MXCryptoError.Base(MXCryptoError.ErrorType.MISSING_FIELDS, MXCryptoError.MISSING_FIELDS_REASON)
|
||||||
|
|
||||||
if (encryptedEventContent.senderKey.isNullOrBlank()
|
if (encryptedEventContent.senderKey.isNullOrBlank() ||
|
||||||
|| encryptedEventContent.sessionId.isNullOrBlank()
|
encryptedEventContent.sessionId.isNullOrBlank() ||
|
||||||
|| encryptedEventContent.ciphertext.isNullOrBlank()) {
|
encryptedEventContent.ciphertext.isNullOrBlank()) {
|
||||||
throw MXCryptoError.Base(MXCryptoError.ErrorType.MISSING_FIELDS, MXCryptoError.MISSING_FIELDS_REASON)
|
throw MXCryptoError.Base(MXCryptoError.ErrorType.MISSING_FIELDS, MXCryptoError.MISSING_FIELDS_REASON)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -16,6 +16,7 @@
|
|||||||
|
|
||||||
package org.matrix.android.sdk.internal.crypto.algorithms.megolm
|
package org.matrix.android.sdk.internal.crypto.algorithms.megolm
|
||||||
|
|
||||||
|
import kotlinx.coroutines.CoroutineScope
|
||||||
import org.matrix.android.sdk.internal.crypto.DeviceListManager
|
import org.matrix.android.sdk.internal.crypto.DeviceListManager
|
||||||
import org.matrix.android.sdk.internal.crypto.MXOlmDevice
|
import org.matrix.android.sdk.internal.crypto.MXOlmDevice
|
||||||
import org.matrix.android.sdk.internal.crypto.OutgoingGossipingRequestManager
|
import org.matrix.android.sdk.internal.crypto.OutgoingGossipingRequestManager
|
||||||
@ -25,7 +26,6 @@ import org.matrix.android.sdk.internal.crypto.store.IMXCryptoStore
|
|||||||
import org.matrix.android.sdk.internal.crypto.tasks.SendToDeviceTask
|
import org.matrix.android.sdk.internal.crypto.tasks.SendToDeviceTask
|
||||||
import org.matrix.android.sdk.internal.di.UserId
|
import org.matrix.android.sdk.internal.di.UserId
|
||||||
import org.matrix.android.sdk.internal.util.MatrixCoroutineDispatchers
|
import org.matrix.android.sdk.internal.util.MatrixCoroutineDispatchers
|
||||||
import kotlinx.coroutines.CoroutineScope
|
|
||||||
import javax.inject.Inject
|
import javax.inject.Inject
|
||||||
|
|
||||||
internal class MXMegolmDecryptionFactory @Inject constructor(
|
internal class MXMegolmDecryptionFactory @Inject constructor(
|
||||||
|
@ -155,11 +155,11 @@ internal class MXMegolmEncryption(
|
|||||||
private suspend fun ensureOutboundSession(devicesInRoom: MXUsersDevicesMap<CryptoDeviceInfo>): MXOutboundSessionInfo {
|
private suspend fun ensureOutboundSession(devicesInRoom: MXUsersDevicesMap<CryptoDeviceInfo>): MXOutboundSessionInfo {
|
||||||
Timber.v("## CRYPTO | ensureOutboundSession start")
|
Timber.v("## CRYPTO | ensureOutboundSession start")
|
||||||
var session = outboundSession
|
var session = outboundSession
|
||||||
if (session == null
|
if (session == null ||
|
||||||
// Need to make a brand new session?
|
// Need to make a brand new session?
|
||||||
|| session.needsRotation(sessionRotationPeriodMsgs, sessionRotationPeriodMs)
|
session.needsRotation(sessionRotationPeriodMsgs, sessionRotationPeriodMs) ||
|
||||||
// Determine if we have shared with anyone we shouldn't have
|
// Determine if we have shared with anyone we shouldn't have
|
||||||
|| session.sharedWithTooManyDevices(devicesInRoom)) {
|
session.sharedWithTooManyDevices(devicesInRoom)) {
|
||||||
session = prepareNewSessionInRoom()
|
session = prepareNewSessionInRoom()
|
||||||
outboundSession = session
|
outboundSession = session
|
||||||
}
|
}
|
||||||
@ -380,8 +380,8 @@ internal class MXMegolmEncryption(
|
|||||||
// with them, which means that they will have announced any new devices via
|
// with them, which means that they will have announced any new devices via
|
||||||
// an m.new_device.
|
// an m.new_device.
|
||||||
val keys = deviceListManager.downloadKeys(userIds, false)
|
val keys = deviceListManager.downloadKeys(userIds, false)
|
||||||
val encryptToVerifiedDevicesOnly = cryptoStore.getGlobalBlacklistUnverifiedDevices()
|
val encryptToVerifiedDevicesOnly = cryptoStore.getGlobalBlacklistUnverifiedDevices() ||
|
||||||
|| cryptoStore.getRoomsListBlacklistUnverifiedDevices().contains(roomId)
|
cryptoStore.getRoomsListBlacklistUnverifiedDevices().contains(roomId)
|
||||||
|
|
||||||
val devicesInRoom = DeviceInRoomInfo()
|
val devicesInRoom = DeviceInRoomInfo()
|
||||||
val unknownDevices = MXUsersDevicesMap<CryptoDeviceInfo>()
|
val unknownDevices = MXUsersDevicesMap<CryptoDeviceInfo>()
|
||||||
@ -446,10 +446,9 @@ internal class MXMegolmEncryption(
|
|||||||
val devicesByUser = mapOf(userId to listOf(deviceInfo))
|
val devicesByUser = mapOf(userId to listOf(deviceInfo))
|
||||||
val usersDeviceMap = ensureOlmSessionsForDevicesAction.handle(devicesByUser)
|
val usersDeviceMap = ensureOlmSessionsForDevicesAction.handle(devicesByUser)
|
||||||
val olmSessionResult = usersDeviceMap.getObject(userId, deviceId)
|
val olmSessionResult = usersDeviceMap.getObject(userId, deviceId)
|
||||||
olmSessionResult?.sessionId
|
olmSessionResult?.sessionId // no session with this device, probably because there were no one-time keys.
|
||||||
?: // no session with this device, probably because there were no one-time keys.
|
|
||||||
// ensureOlmSessionsForDevicesAction has already done the logging, so just skip it.
|
// ensureOlmSessionsForDevicesAction has already done the logging, so just skip it.
|
||||||
return false.also {
|
?: return false.also {
|
||||||
Timber.w("## Crypto reshareKey: no session with this device, probably because there were no one-time keys")
|
Timber.w("## Crypto reshareKey: no session with this device, probably because there were no one-time keys")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -34,8 +34,8 @@ internal class MXOlmDecryption(
|
|||||||
// The olm device interface
|
// The olm device interface
|
||||||
private val olmDevice: MXOlmDevice,
|
private val olmDevice: MXOlmDevice,
|
||||||
// the matrix userId
|
// the matrix userId
|
||||||
private val userId: String)
|
private val userId: String) :
|
||||||
: IMXDecrypting {
|
IMXDecrypting {
|
||||||
|
|
||||||
@Throws(MXCryptoError::class)
|
@Throws(MXCryptoError::class)
|
||||||
override fun decryptEvent(event: Event, timeline: String): MXEventDecryptionResult {
|
override fun decryptEvent(event: Event, timeline: String): MXEventDecryptionResult {
|
||||||
|
@ -32,8 +32,8 @@ internal class MXOlmEncryption(
|
|||||||
private val cryptoStore: IMXCryptoStore,
|
private val cryptoStore: IMXCryptoStore,
|
||||||
private val messageEncrypter: MessageEncrypter,
|
private val messageEncrypter: MessageEncrypter,
|
||||||
private val deviceListManager: DeviceListManager,
|
private val deviceListManager: DeviceListManager,
|
||||||
private val ensureOlmSessionsForUsersAction: EnsureOlmSessionsForUsersAction)
|
private val ensureOlmSessionsForUsersAction: EnsureOlmSessionsForUsersAction) :
|
||||||
: IMXEncrypting {
|
IMXEncrypting {
|
||||||
|
|
||||||
override suspend fun encryptEventContent(eventContent: Content, eventType: String, userIds: List<String>): Content {
|
override suspend fun encryptEventContent(eventContent: Content, eventType: String, userIds: List<String>): Content {
|
||||||
// pick the list of recipients based on the membership list.
|
// pick the list of recipients based on the membership list.
|
||||||
|
@ -17,8 +17,8 @@
|
|||||||
package org.matrix.android.sdk.internal.crypto.attachments
|
package org.matrix.android.sdk.internal.crypto.attachments
|
||||||
|
|
||||||
import android.os.Parcelable
|
import android.os.Parcelable
|
||||||
import org.matrix.android.sdk.internal.crypto.model.rest.EncryptedFileInfo
|
|
||||||
import kotlinx.parcelize.Parcelize
|
import kotlinx.parcelize.Parcelize
|
||||||
|
import org.matrix.android.sdk.internal.crypto.model.rest.EncryptedFileInfo
|
||||||
|
|
||||||
fun EncryptedFileInfo.toElementToDecrypt(): ElementToDecrypt? {
|
fun EncryptedFileInfo.toElementToDecrypt(): ElementToDecrypt? {
|
||||||
// Check the validity of some fields
|
// Check the validity of some fields
|
||||||
|
@ -15,6 +15,7 @@
|
|||||||
*/
|
*/
|
||||||
package org.matrix.android.sdk.internal.crypto.crosssigning
|
package org.matrix.android.sdk.internal.crypto.crosssigning
|
||||||
|
|
||||||
|
import kotlinx.coroutines.withContext
|
||||||
import org.matrix.android.sdk.api.crypto.RoomEncryptionTrustLevel
|
import org.matrix.android.sdk.api.crypto.RoomEncryptionTrustLevel
|
||||||
import org.matrix.android.sdk.api.extensions.orFalse
|
import org.matrix.android.sdk.api.extensions.orFalse
|
||||||
import org.matrix.android.sdk.api.session.crypto.crosssigning.MXCrossSigningInfo
|
import org.matrix.android.sdk.api.session.crypto.crosssigning.MXCrossSigningInfo
|
||||||
@ -22,7 +23,6 @@ import org.matrix.android.sdk.internal.crypto.store.IMXCryptoStore
|
|||||||
import org.matrix.android.sdk.internal.di.UserId
|
import org.matrix.android.sdk.internal.di.UserId
|
||||||
import org.matrix.android.sdk.internal.task.Task
|
import org.matrix.android.sdk.internal.task.Task
|
||||||
import org.matrix.android.sdk.internal.util.MatrixCoroutineDispatchers
|
import org.matrix.android.sdk.internal.util.MatrixCoroutineDispatchers
|
||||||
import kotlinx.coroutines.withContext
|
|
||||||
import javax.inject.Inject
|
import javax.inject.Inject
|
||||||
|
|
||||||
internal interface ComputeTrustTask : Task<ComputeTrustTask.Params, RoomEncryptionTrustLevel> {
|
internal interface ComputeTrustTask : Task<ComputeTrustTask.Params, RoomEncryptionTrustLevel> {
|
||||||
|
@ -529,13 +529,13 @@ internal class DefaultCrossSigningService @Inject constructor(
|
|||||||
}
|
}
|
||||||
|
|
||||||
override fun canCrossSign(): Boolean {
|
override fun canCrossSign(): Boolean {
|
||||||
return checkSelfTrust().isVerified() && cryptoStore.getCrossSigningPrivateKeys()?.selfSigned != null
|
return checkSelfTrust().isVerified() && cryptoStore.getCrossSigningPrivateKeys()?.selfSigned != null &&
|
||||||
&& cryptoStore.getCrossSigningPrivateKeys()?.user != null
|
cryptoStore.getCrossSigningPrivateKeys()?.user != null
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun allPrivateKeysKnown(): Boolean {
|
override fun allPrivateKeysKnown(): Boolean {
|
||||||
return checkSelfTrust().isVerified()
|
return checkSelfTrust().isVerified() &&
|
||||||
&& cryptoStore.getCrossSigningPrivateKeys()?.allKnown().orFalse()
|
cryptoStore.getCrossSigningPrivateKeys()?.allKnown().orFalse()
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun trustUser(otherUserId: String, callback: MatrixCallback<Unit>) {
|
override fun trustUser(otherUserId: String, callback: MatrixCallback<Unit>) {
|
||||||
|
@ -51,8 +51,8 @@ import timber.log.Timber
|
|||||||
import javax.inject.Inject
|
import javax.inject.Inject
|
||||||
|
|
||||||
internal class UpdateTrustWorker(context: Context,
|
internal class UpdateTrustWorker(context: Context,
|
||||||
params: WorkerParameters)
|
params: WorkerParameters) :
|
||||||
: SessionSafeCoroutineWorker<UpdateTrustWorker.Params>(context, params, Params::class.java) {
|
SessionSafeCoroutineWorker<UpdateTrustWorker.Params>(context, params, Params::class.java) {
|
||||||
|
|
||||||
@JsonClass(generateAdapter = true)
|
@JsonClass(generateAdapter = true)
|
||||||
internal data class Params(
|
internal data class Params(
|
||||||
|
@ -21,6 +21,10 @@ import android.os.Looper
|
|||||||
import androidx.annotation.UiThread
|
import androidx.annotation.UiThread
|
||||||
import androidx.annotation.VisibleForTesting
|
import androidx.annotation.VisibleForTesting
|
||||||
import androidx.annotation.WorkerThread
|
import androidx.annotation.WorkerThread
|
||||||
|
import kotlinx.coroutines.CoroutineScope
|
||||||
|
import kotlinx.coroutines.delay
|
||||||
|
import kotlinx.coroutines.launch
|
||||||
|
import kotlinx.coroutines.withContext
|
||||||
import org.matrix.android.sdk.api.MatrixCallback
|
import org.matrix.android.sdk.api.MatrixCallback
|
||||||
import org.matrix.android.sdk.api.auth.data.Credentials
|
import org.matrix.android.sdk.api.auth.data.Credentials
|
||||||
import org.matrix.android.sdk.api.failure.Failure
|
import org.matrix.android.sdk.api.failure.Failure
|
||||||
@ -40,6 +44,7 @@ import org.matrix.android.sdk.internal.crypto.keysbackup.model.KeysBackupVersion
|
|||||||
import org.matrix.android.sdk.internal.crypto.keysbackup.model.KeysBackupVersionTrustSignature
|
import org.matrix.android.sdk.internal.crypto.keysbackup.model.KeysBackupVersionTrustSignature
|
||||||
import org.matrix.android.sdk.internal.crypto.keysbackup.model.MegolmBackupAuthData
|
import org.matrix.android.sdk.internal.crypto.keysbackup.model.MegolmBackupAuthData
|
||||||
import org.matrix.android.sdk.internal.crypto.keysbackup.model.MegolmBackupCreationInfo
|
import org.matrix.android.sdk.internal.crypto.keysbackup.model.MegolmBackupCreationInfo
|
||||||
|
import org.matrix.android.sdk.internal.crypto.keysbackup.model.SignalableMegolmBackupAuthData
|
||||||
import org.matrix.android.sdk.internal.crypto.keysbackup.model.rest.BackupKeysResult
|
import org.matrix.android.sdk.internal.crypto.keysbackup.model.rest.BackupKeysResult
|
||||||
import org.matrix.android.sdk.internal.crypto.keysbackup.model.rest.CreateKeysBackupVersionBody
|
import org.matrix.android.sdk.internal.crypto.keysbackup.model.rest.CreateKeysBackupVersionBody
|
||||||
import org.matrix.android.sdk.internal.crypto.keysbackup.model.rest.KeyBackupData
|
import org.matrix.android.sdk.internal.crypto.keysbackup.model.rest.KeyBackupData
|
||||||
@ -80,11 +85,6 @@ import org.matrix.android.sdk.internal.task.configureWith
|
|||||||
import org.matrix.android.sdk.internal.util.JsonCanonicalizer
|
import org.matrix.android.sdk.internal.util.JsonCanonicalizer
|
||||||
import org.matrix.android.sdk.internal.util.MatrixCoroutineDispatchers
|
import org.matrix.android.sdk.internal.util.MatrixCoroutineDispatchers
|
||||||
import org.matrix.android.sdk.internal.util.awaitCallback
|
import org.matrix.android.sdk.internal.util.awaitCallback
|
||||||
import kotlinx.coroutines.CoroutineScope
|
|
||||||
import kotlinx.coroutines.delay
|
|
||||||
import kotlinx.coroutines.launch
|
|
||||||
import kotlinx.coroutines.withContext
|
|
||||||
import org.matrix.android.sdk.internal.crypto.keysbackup.model.SignalableMegolmBackupAuthData
|
|
||||||
import org.matrix.olm.OlmException
|
import org.matrix.olm.OlmException
|
||||||
import org.matrix.olm.OlmPkDecryption
|
import org.matrix.olm.OlmPkDecryption
|
||||||
import org.matrix.olm.OlmPkEncryption
|
import org.matrix.olm.OlmPkEncryption
|
||||||
@ -860,8 +860,8 @@ internal class DefaultKeysBackupService @Inject constructor(
|
|||||||
}
|
}
|
||||||
|
|
||||||
override fun onFailure(failure: Throwable) {
|
override fun onFailure(failure: Throwable) {
|
||||||
if (failure is Failure.ServerError
|
if (failure is Failure.ServerError &&
|
||||||
&& failure.error.code == MatrixError.M_NOT_FOUND) {
|
failure.error.code == MatrixError.M_NOT_FOUND) {
|
||||||
// Workaround because the homeserver currently returns M_NOT_FOUND when there is no key backup
|
// Workaround because the homeserver currently returns M_NOT_FOUND when there is no key backup
|
||||||
callback.onSuccess(null)
|
callback.onSuccess(null)
|
||||||
} else {
|
} else {
|
||||||
@ -883,8 +883,8 @@ internal class DefaultKeysBackupService @Inject constructor(
|
|||||||
}
|
}
|
||||||
|
|
||||||
override fun onFailure(failure: Throwable) {
|
override fun onFailure(failure: Throwable) {
|
||||||
if (failure is Failure.ServerError
|
if (failure is Failure.ServerError &&
|
||||||
&& failure.error.code == MatrixError.M_NOT_FOUND) {
|
failure.error.code == MatrixError.M_NOT_FOUND) {
|
||||||
// Workaround because the homeserver currently returns M_NOT_FOUND when there is no key backup
|
// Workaround because the homeserver currently returns M_NOT_FOUND when there is no key backup
|
||||||
callback.onSuccess(null)
|
callback.onSuccess(null)
|
||||||
} else {
|
} else {
|
||||||
@ -1042,8 +1042,8 @@ internal class DefaultKeysBackupService @Inject constructor(
|
|||||||
return null
|
return null
|
||||||
}
|
}
|
||||||
|
|
||||||
if (authData.privateKeySalt.isNullOrBlank()
|
if (authData.privateKeySalt.isNullOrBlank() ||
|
||||||
|| authData.privateKeyIterations == null) {
|
authData.privateKeyIterations == null) {
|
||||||
Timber.w("recoveryKeyFromPassword: Salt and/or iterations not found in key backup auth data")
|
Timber.w("recoveryKeyFromPassword: Salt and/or iterations not found in key backup auth data")
|
||||||
|
|
||||||
return null
|
return null
|
||||||
|
@ -44,16 +44,16 @@ internal class KeysBackupStateManager(private val uiHandler: Handler) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
val isEnabled: Boolean
|
val isEnabled: Boolean
|
||||||
get() = state == KeysBackupState.ReadyToBackUp
|
get() = state == KeysBackupState.ReadyToBackUp ||
|
||||||
|| state == KeysBackupState.WillBackUp
|
state == KeysBackupState.WillBackUp ||
|
||||||
|| state == KeysBackupState.BackingUp
|
state == KeysBackupState.BackingUp
|
||||||
|
|
||||||
// True if unknown or bad state
|
// True if unknown or bad state
|
||||||
val isStucked: Boolean
|
val isStucked: Boolean
|
||||||
get() = state == KeysBackupState.Unknown
|
get() = state == KeysBackupState.Unknown ||
|
||||||
|| state == KeysBackupState.Disabled
|
state == KeysBackupState.Disabled ||
|
||||||
|| state == KeysBackupState.WrongBackUpVersion
|
state == KeysBackupState.WrongBackUpVersion ||
|
||||||
|| state == KeysBackupState.NotTrusted
|
state == KeysBackupState.NotTrusted
|
||||||
|
|
||||||
fun addListener(listener: KeysBackupStateListener) {
|
fun addListener(listener: KeysBackupStateListener) {
|
||||||
synchronized(listeners) {
|
synchronized(listeners) {
|
||||||
|
@ -16,6 +16,8 @@
|
|||||||
|
|
||||||
package org.matrix.android.sdk.internal.crypto.secrets
|
package org.matrix.android.sdk.internal.crypto.secrets
|
||||||
|
|
||||||
|
import kotlinx.coroutines.CoroutineScope
|
||||||
|
import kotlinx.coroutines.withContext
|
||||||
import org.matrix.android.sdk.api.extensions.orFalse
|
import org.matrix.android.sdk.api.extensions.orFalse
|
||||||
import org.matrix.android.sdk.api.listeners.ProgressListener
|
import org.matrix.android.sdk.api.listeners.ProgressListener
|
||||||
import org.matrix.android.sdk.api.session.accountdata.SessionAccountDataService
|
import org.matrix.android.sdk.api.session.accountdata.SessionAccountDataService
|
||||||
@ -43,8 +45,6 @@ import org.matrix.android.sdk.internal.crypto.tools.HkdfSha256
|
|||||||
import org.matrix.android.sdk.internal.crypto.tools.withOlmDecryption
|
import org.matrix.android.sdk.internal.crypto.tools.withOlmDecryption
|
||||||
import org.matrix.android.sdk.internal.di.UserId
|
import org.matrix.android.sdk.internal.di.UserId
|
||||||
import org.matrix.android.sdk.internal.util.MatrixCoroutineDispatchers
|
import org.matrix.android.sdk.internal.util.MatrixCoroutineDispatchers
|
||||||
import kotlinx.coroutines.CoroutineScope
|
|
||||||
import kotlinx.coroutines.withContext
|
|
||||||
import org.matrix.olm.OlmPkMessage
|
import org.matrix.olm.OlmPkMessage
|
||||||
import java.security.SecureRandom
|
import java.security.SecureRandom
|
||||||
import javax.crypto.Cipher
|
import javax.crypto.Cipher
|
||||||
@ -359,8 +359,8 @@ internal class DefaultSharedSecretStorageService @Inject constructor(
|
|||||||
val keyInfo = (keyInfoResult as? KeyInfoResult.Success)?.keyInfo
|
val keyInfo = (keyInfoResult as? KeyInfoResult.Success)?.keyInfo
|
||||||
?: return IntegrityResult.Error(SharedSecretStorageError.UnknownKey(keyId ?: ""))
|
?: return IntegrityResult.Error(SharedSecretStorageError.UnknownKey(keyId ?: ""))
|
||||||
|
|
||||||
if (keyInfo.content.algorithm != SSSS_ALGORITHM_AES_HMAC_SHA2
|
if (keyInfo.content.algorithm != SSSS_ALGORITHM_AES_HMAC_SHA2 &&
|
||||||
&& keyInfo.content.algorithm != SSSS_ALGORITHM_CURVE25519_AES_SHA2) {
|
keyInfo.content.algorithm != SSSS_ALGORITHM_CURVE25519_AES_SHA2) {
|
||||||
// Unsupported algorithm
|
// Unsupported algorithm
|
||||||
return IntegrityResult.Error(
|
return IntegrityResult.Error(
|
||||||
SharedSecretStorageError.UnsupportedAlgorithm(keyInfo.content.algorithm ?: "")
|
SharedSecretStorageError.UnsupportedAlgorithm(keyInfo.content.algorithm ?: "")
|
||||||
|
@ -152,8 +152,8 @@ internal class RealmCryptoStore @Inject constructor(
|
|||||||
// Check credentials
|
// Check credentials
|
||||||
// The device id may not have been provided in credentials.
|
// The device id may not have been provided in credentials.
|
||||||
// Check it only if provided, else trust the stored one.
|
// Check it only if provided, else trust the stored one.
|
||||||
if (currentMetadata.userId != userId
|
if (currentMetadata.userId != userId ||
|
||||||
|| (deviceId != null && deviceId != currentMetadata.deviceId)) {
|
(deviceId != null && deviceId != currentMetadata.deviceId)) {
|
||||||
Timber.w("## open() : Credentials do not match, close this store and delete data")
|
Timber.w("## open() : Credentials do not match, close this store and delete data")
|
||||||
deleteAll = true
|
deleteAll = true
|
||||||
currentMetadata = null
|
currentMetadata = null
|
||||||
@ -178,9 +178,9 @@ internal class RealmCryptoStore @Inject constructor(
|
|||||||
|
|
||||||
override fun hasData(): Boolean {
|
override fun hasData(): Boolean {
|
||||||
return doWithRealm(realmConfiguration) {
|
return doWithRealm(realmConfiguration) {
|
||||||
!it.isEmpty
|
!it.isEmpty &&
|
||||||
// Check if there is a MetaData object
|
// Check if there is a MetaData object
|
||||||
&& it.where<CryptoMetadataEntity>().count() > 0
|
it.where<CryptoMetadataEntity>().count() > 0
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1025,10 +1025,10 @@ internal class RealmCryptoStore @Inject constructor(
|
|||||||
}.mapNotNull {
|
}.mapNotNull {
|
||||||
it.toOutgoingGossipingRequest() as? OutgoingRoomKeyRequest
|
it.toOutgoingGossipingRequest() as? OutgoingRoomKeyRequest
|
||||||
}.firstOrNull {
|
}.firstOrNull {
|
||||||
it.requestBody?.algorithm == requestBody.algorithm
|
it.requestBody?.algorithm == requestBody.algorithm &&
|
||||||
&& it.requestBody?.roomId == requestBody.roomId
|
it.requestBody?.roomId == requestBody.roomId &&
|
||||||
&& it.requestBody?.senderKey == requestBody.senderKey
|
it.requestBody?.senderKey == requestBody.senderKey &&
|
||||||
&& it.requestBody?.sessionId == requestBody.sessionId
|
it.requestBody?.sessionId == requestBody.sessionId
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1113,10 +1113,10 @@ internal class RealmCryptoStore @Inject constructor(
|
|||||||
.mapNotNull {
|
.mapNotNull {
|
||||||
it.toOutgoingGossipingRequest() as? OutgoingRoomKeyRequest
|
it.toOutgoingGossipingRequest() as? OutgoingRoomKeyRequest
|
||||||
}.firstOrNull {
|
}.firstOrNull {
|
||||||
it.requestBody?.algorithm == requestBody.algorithm
|
it.requestBody?.algorithm == requestBody.algorithm &&
|
||||||
&& it.requestBody?.sessionId == requestBody.sessionId
|
it.requestBody?.sessionId == requestBody.sessionId &&
|
||||||
&& it.requestBody?.senderKey == requestBody.senderKey
|
it.requestBody?.senderKey == requestBody.senderKey &&
|
||||||
&& it.requestBody?.roomId == requestBody.roomId
|
it.requestBody?.roomId == requestBody.roomId
|
||||||
}
|
}
|
||||||
|
|
||||||
if (existing == null) {
|
if (existing == null) {
|
||||||
|
@ -16,6 +16,7 @@
|
|||||||
|
|
||||||
package org.matrix.android.sdk.internal.crypto.store.db
|
package org.matrix.android.sdk.internal.crypto.store.db
|
||||||
|
|
||||||
|
import io.realm.annotations.RealmModule
|
||||||
import org.matrix.android.sdk.internal.crypto.store.db.model.CrossSigningInfoEntity
|
import org.matrix.android.sdk.internal.crypto.store.db.model.CrossSigningInfoEntity
|
||||||
import org.matrix.android.sdk.internal.crypto.store.db.model.CryptoMetadataEntity
|
import org.matrix.android.sdk.internal.crypto.store.db.model.CryptoMetadataEntity
|
||||||
import org.matrix.android.sdk.internal.crypto.store.db.model.CryptoRoomEntity
|
import org.matrix.android.sdk.internal.crypto.store.db.model.CryptoRoomEntity
|
||||||
@ -27,13 +28,12 @@ import org.matrix.android.sdk.internal.crypto.store.db.model.KeysBackupDataEntit
|
|||||||
import org.matrix.android.sdk.internal.crypto.store.db.model.MyDeviceLastSeenInfoEntity
|
import org.matrix.android.sdk.internal.crypto.store.db.model.MyDeviceLastSeenInfoEntity
|
||||||
import org.matrix.android.sdk.internal.crypto.store.db.model.OlmInboundGroupSessionEntity
|
import org.matrix.android.sdk.internal.crypto.store.db.model.OlmInboundGroupSessionEntity
|
||||||
import org.matrix.android.sdk.internal.crypto.store.db.model.OlmSessionEntity
|
import org.matrix.android.sdk.internal.crypto.store.db.model.OlmSessionEntity
|
||||||
|
import org.matrix.android.sdk.internal.crypto.store.db.model.OutboundGroupSessionInfoEntity
|
||||||
import org.matrix.android.sdk.internal.crypto.store.db.model.OutgoingGossipingRequestEntity
|
import org.matrix.android.sdk.internal.crypto.store.db.model.OutgoingGossipingRequestEntity
|
||||||
import org.matrix.android.sdk.internal.crypto.store.db.model.SharedSessionEntity
|
import org.matrix.android.sdk.internal.crypto.store.db.model.SharedSessionEntity
|
||||||
import org.matrix.android.sdk.internal.crypto.store.db.model.TrustLevelEntity
|
import org.matrix.android.sdk.internal.crypto.store.db.model.TrustLevelEntity
|
||||||
import org.matrix.android.sdk.internal.crypto.store.db.model.UserEntity
|
import org.matrix.android.sdk.internal.crypto.store.db.model.UserEntity
|
||||||
import org.matrix.android.sdk.internal.crypto.store.db.model.WithHeldSessionEntity
|
import org.matrix.android.sdk.internal.crypto.store.db.model.WithHeldSessionEntity
|
||||||
import io.realm.annotations.RealmModule
|
|
||||||
import org.matrix.android.sdk.internal.crypto.store.db.model.OutboundGroupSessionInfoEntity
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Realm module for Crypto store classes
|
* Realm module for Crypto store classes
|
||||||
|
@ -18,10 +18,10 @@ package org.matrix.android.sdk.internal.crypto.store.db.mapper
|
|||||||
|
|
||||||
import com.squareup.moshi.Moshi
|
import com.squareup.moshi.Moshi
|
||||||
import com.squareup.moshi.Types
|
import com.squareup.moshi.Types
|
||||||
|
import io.realm.RealmList
|
||||||
import org.matrix.android.sdk.internal.crypto.crosssigning.DeviceTrustLevel
|
import org.matrix.android.sdk.internal.crypto.crosssigning.DeviceTrustLevel
|
||||||
import org.matrix.android.sdk.internal.crypto.model.CryptoCrossSigningKey
|
import org.matrix.android.sdk.internal.crypto.model.CryptoCrossSigningKey
|
||||||
import org.matrix.android.sdk.internal.crypto.store.db.model.KeyInfoEntity
|
import org.matrix.android.sdk.internal.crypto.store.db.model.KeyInfoEntity
|
||||||
import io.realm.RealmList
|
|
||||||
import timber.log.Timber
|
import timber.log.Timber
|
||||||
import javax.inject.Inject
|
import javax.inject.Inject
|
||||||
|
|
||||||
|
@ -16,10 +16,10 @@
|
|||||||
|
|
||||||
package org.matrix.android.sdk.internal.crypto.store.db.model
|
package org.matrix.android.sdk.internal.crypto.store.db.model
|
||||||
|
|
||||||
import org.matrix.android.sdk.internal.crypto.store.db.deserializeFromRealm
|
|
||||||
import org.matrix.android.sdk.internal.crypto.store.db.serializeForRealm
|
|
||||||
import io.realm.RealmObject
|
import io.realm.RealmObject
|
||||||
import io.realm.annotations.PrimaryKey
|
import io.realm.annotations.PrimaryKey
|
||||||
|
import org.matrix.android.sdk.internal.crypto.store.db.deserializeFromRealm
|
||||||
|
import org.matrix.android.sdk.internal.crypto.store.db.serializeForRealm
|
||||||
import org.matrix.olm.OlmAccount
|
import org.matrix.olm.OlmAccount
|
||||||
|
|
||||||
internal open class CryptoMetadataEntity(
|
internal open class CryptoMetadataEntity(
|
||||||
|
@ -28,8 +28,8 @@ internal open class CryptoRoomEntity(
|
|||||||
// to avoid re-create and re-share at each startup (if rotation not needed..)
|
// to avoid re-create and re-share at each startup (if rotation not needed..)
|
||||||
// This is specific to megolm but not sure how to model it better
|
// This is specific to megolm but not sure how to model it better
|
||||||
var outboundSessionInfo: OutboundGroupSessionInfoEntity? = null
|
var outboundSessionInfo: OutboundGroupSessionInfoEntity? = null
|
||||||
)
|
) :
|
||||||
: RealmObject() {
|
RealmObject() {
|
||||||
|
|
||||||
companion object
|
companion object
|
||||||
}
|
}
|
||||||
|
@ -17,6 +17,8 @@
|
|||||||
package org.matrix.android.sdk.internal.crypto.store.db.model
|
package org.matrix.android.sdk.internal.crypto.store.db.model
|
||||||
|
|
||||||
import com.squareup.moshi.JsonDataException
|
import com.squareup.moshi.JsonDataException
|
||||||
|
import io.realm.RealmObject
|
||||||
|
import io.realm.annotations.Index
|
||||||
import org.matrix.android.sdk.api.session.crypto.MXCryptoError
|
import org.matrix.android.sdk.api.session.crypto.MXCryptoError
|
||||||
import org.matrix.android.sdk.api.session.events.model.Event
|
import org.matrix.android.sdk.api.session.events.model.Event
|
||||||
import org.matrix.android.sdk.api.session.room.send.SendState
|
import org.matrix.android.sdk.api.session.room.send.SendState
|
||||||
@ -24,8 +26,6 @@ import org.matrix.android.sdk.internal.crypto.MXEventDecryptionResult
|
|||||||
import org.matrix.android.sdk.internal.crypto.algorithms.olm.OlmDecryptionResult
|
import org.matrix.android.sdk.internal.crypto.algorithms.olm.OlmDecryptionResult
|
||||||
import org.matrix.android.sdk.internal.database.mapper.ContentMapper
|
import org.matrix.android.sdk.internal.database.mapper.ContentMapper
|
||||||
import org.matrix.android.sdk.internal.di.MoshiProvider
|
import org.matrix.android.sdk.internal.di.MoshiProvider
|
||||||
import io.realm.RealmObject
|
|
||||||
import io.realm.annotations.Index
|
|
||||||
import timber.log.Timber
|
import timber.log.Timber
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -16,6 +16,8 @@
|
|||||||
|
|
||||||
package org.matrix.android.sdk.internal.crypto.store.db.model
|
package org.matrix.android.sdk.internal.crypto.store.db.model
|
||||||
|
|
||||||
|
import io.realm.RealmObject
|
||||||
|
import io.realm.annotations.Index
|
||||||
import org.matrix.android.sdk.api.extensions.tryOrNull
|
import org.matrix.android.sdk.api.extensions.tryOrNull
|
||||||
import org.matrix.android.sdk.internal.crypto.GossipRequestType
|
import org.matrix.android.sdk.internal.crypto.GossipRequestType
|
||||||
import org.matrix.android.sdk.internal.crypto.GossipingRequestState
|
import org.matrix.android.sdk.internal.crypto.GossipingRequestState
|
||||||
@ -23,8 +25,6 @@ import org.matrix.android.sdk.internal.crypto.IncomingRoomKeyRequest
|
|||||||
import org.matrix.android.sdk.internal.crypto.IncomingSecretShareRequest
|
import org.matrix.android.sdk.internal.crypto.IncomingSecretShareRequest
|
||||||
import org.matrix.android.sdk.internal.crypto.IncomingShareRequestCommon
|
import org.matrix.android.sdk.internal.crypto.IncomingShareRequestCommon
|
||||||
import org.matrix.android.sdk.internal.crypto.model.rest.RoomKeyRequestBody
|
import org.matrix.android.sdk.internal.crypto.model.rest.RoomKeyRequestBody
|
||||||
import io.realm.RealmObject
|
|
||||||
import io.realm.annotations.Index
|
|
||||||
|
|
||||||
internal open class IncomingGossipingRequestEntity(@Index var requestId: String? = "",
|
internal open class IncomingGossipingRequestEntity(@Index var requestId: String? = "",
|
||||||
@Index var typeStr: String? = null,
|
@Index var typeStr: String? = null,
|
||||||
|
@ -16,11 +16,11 @@
|
|||||||
|
|
||||||
package org.matrix.android.sdk.internal.crypto.store.db.model
|
package org.matrix.android.sdk.internal.crypto.store.db.model
|
||||||
|
|
||||||
|
import io.realm.RealmObject
|
||||||
|
import io.realm.annotations.PrimaryKey
|
||||||
import org.matrix.android.sdk.internal.crypto.model.OlmInboundGroupSessionWrapper2
|
import org.matrix.android.sdk.internal.crypto.model.OlmInboundGroupSessionWrapper2
|
||||||
import org.matrix.android.sdk.internal.crypto.store.db.deserializeFromRealm
|
import org.matrix.android.sdk.internal.crypto.store.db.deserializeFromRealm
|
||||||
import org.matrix.android.sdk.internal.crypto.store.db.serializeForRealm
|
import org.matrix.android.sdk.internal.crypto.store.db.serializeForRealm
|
||||||
import io.realm.RealmObject
|
|
||||||
import io.realm.annotations.PrimaryKey
|
|
||||||
import timber.log.Timber
|
import timber.log.Timber
|
||||||
|
|
||||||
internal fun OlmInboundGroupSessionEntity.Companion.createPrimaryKey(sessionId: String?, senderKey: String?) = "$sessionId|$senderKey"
|
internal fun OlmInboundGroupSessionEntity.Companion.createPrimaryKey(sessionId: String?, senderKey: String?) = "$sessionId|$senderKey"
|
||||||
@ -33,8 +33,8 @@ internal open class OlmInboundGroupSessionEntity(
|
|||||||
// olmInboundGroupSessionData contains Json
|
// olmInboundGroupSessionData contains Json
|
||||||
var olmInboundGroupSessionData: String? = null,
|
var olmInboundGroupSessionData: String? = null,
|
||||||
// Indicate if the key has been backed up to the homeserver
|
// Indicate if the key has been backed up to the homeserver
|
||||||
var backedUp: Boolean = false)
|
var backedUp: Boolean = false) :
|
||||||
: RealmObject() {
|
RealmObject() {
|
||||||
|
|
||||||
fun getInboundGroupSession(): OlmInboundGroupSessionWrapper2? {
|
fun getInboundGroupSession(): OlmInboundGroupSessionWrapper2? {
|
||||||
return try {
|
return try {
|
||||||
|
@ -16,10 +16,10 @@
|
|||||||
|
|
||||||
package org.matrix.android.sdk.internal.crypto.store.db.model
|
package org.matrix.android.sdk.internal.crypto.store.db.model
|
||||||
|
|
||||||
import org.matrix.android.sdk.internal.crypto.store.db.deserializeFromRealm
|
|
||||||
import org.matrix.android.sdk.internal.crypto.store.db.serializeForRealm
|
|
||||||
import io.realm.RealmObject
|
import io.realm.RealmObject
|
||||||
import io.realm.annotations.PrimaryKey
|
import io.realm.annotations.PrimaryKey
|
||||||
|
import org.matrix.android.sdk.internal.crypto.store.db.deserializeFromRealm
|
||||||
|
import org.matrix.android.sdk.internal.crypto.store.db.serializeForRealm
|
||||||
import org.matrix.olm.OlmSession
|
import org.matrix.olm.OlmSession
|
||||||
|
|
||||||
internal fun OlmSessionEntity.Companion.createPrimaryKey(sessionId: String, deviceKey: String) = "$sessionId|$deviceKey"
|
internal fun OlmSessionEntity.Companion.createPrimaryKey(sessionId: String, deviceKey: String) = "$sessionId|$deviceKey"
|
||||||
@ -29,8 +29,8 @@ internal open class OlmSessionEntity(@PrimaryKey var primaryKey: String = "",
|
|||||||
var sessionId: String? = null,
|
var sessionId: String? = null,
|
||||||
var deviceKey: String? = null,
|
var deviceKey: String? = null,
|
||||||
var olmSessionData: String? = null,
|
var olmSessionData: String? = null,
|
||||||
var lastReceivedMessageTs: Long = 0)
|
var lastReceivedMessageTs: Long = 0) :
|
||||||
: RealmObject() {
|
RealmObject() {
|
||||||
|
|
||||||
fun getOlmSession(): OlmSession? {
|
fun getOlmSession(): OlmSession? {
|
||||||
return deserializeFromRealm(olmSessionData)
|
return deserializeFromRealm(olmSessionData)
|
||||||
|
@ -18,6 +18,8 @@ package org.matrix.android.sdk.internal.crypto.store.db.model
|
|||||||
|
|
||||||
import com.squareup.moshi.JsonAdapter
|
import com.squareup.moshi.JsonAdapter
|
||||||
import com.squareup.moshi.Types
|
import com.squareup.moshi.Types
|
||||||
|
import io.realm.RealmObject
|
||||||
|
import io.realm.annotations.Index
|
||||||
import org.matrix.android.sdk.api.extensions.tryOrNull
|
import org.matrix.android.sdk.api.extensions.tryOrNull
|
||||||
import org.matrix.android.sdk.internal.crypto.GossipRequestType
|
import org.matrix.android.sdk.internal.crypto.GossipRequestType
|
||||||
import org.matrix.android.sdk.internal.crypto.OutgoingGossipingRequest
|
import org.matrix.android.sdk.internal.crypto.OutgoingGossipingRequest
|
||||||
@ -26,8 +28,6 @@ import org.matrix.android.sdk.internal.crypto.OutgoingRoomKeyRequest
|
|||||||
import org.matrix.android.sdk.internal.crypto.OutgoingSecretRequest
|
import org.matrix.android.sdk.internal.crypto.OutgoingSecretRequest
|
||||||
import org.matrix.android.sdk.internal.crypto.model.rest.RoomKeyRequestBody
|
import org.matrix.android.sdk.internal.crypto.model.rest.RoomKeyRequestBody
|
||||||
import org.matrix.android.sdk.internal.di.MoshiProvider
|
import org.matrix.android.sdk.internal.di.MoshiProvider
|
||||||
import io.realm.RealmObject
|
|
||||||
import io.realm.annotations.Index
|
|
||||||
|
|
||||||
internal open class OutgoingGossipingRequestEntity(
|
internal open class OutgoingGossipingRequestEntity(
|
||||||
@Index var requestId: String? = null,
|
@Index var requestId: String? = null,
|
||||||
|
@ -16,9 +16,9 @@
|
|||||||
|
|
||||||
package org.matrix.android.sdk.internal.crypto.store.db.model
|
package org.matrix.android.sdk.internal.crypto.store.db.model
|
||||||
|
|
||||||
import org.matrix.android.sdk.internal.crypto.model.event.WithHeldCode
|
|
||||||
import io.realm.RealmObject
|
import io.realm.RealmObject
|
||||||
import io.realm.annotations.Index
|
import io.realm.annotations.Index
|
||||||
|
import org.matrix.android.sdk.internal.crypto.model.event.WithHeldCode
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* When an encrypted message is sent in a room, the megolm key might not be sent to all devices present in the room.
|
* When an encrypted message is sent in a room, the megolm key might not be sent to all devices present in the room.
|
||||||
|
@ -16,11 +16,11 @@
|
|||||||
|
|
||||||
package org.matrix.android.sdk.internal.crypto.store.db.query
|
package org.matrix.android.sdk.internal.crypto.store.db.query
|
||||||
|
|
||||||
import org.matrix.android.sdk.internal.crypto.store.db.model.CrossSigningInfoEntity
|
|
||||||
import org.matrix.android.sdk.internal.crypto.store.db.model.UserEntityFields
|
|
||||||
import io.realm.Realm
|
import io.realm.Realm
|
||||||
import io.realm.kotlin.createObject
|
import io.realm.kotlin.createObject
|
||||||
import io.realm.kotlin.where
|
import io.realm.kotlin.where
|
||||||
|
import org.matrix.android.sdk.internal.crypto.store.db.model.CrossSigningInfoEntity
|
||||||
|
import org.matrix.android.sdk.internal.crypto.store.db.model.UserEntityFields
|
||||||
|
|
||||||
internal fun CrossSigningInfoEntity.Companion.getOrCreate(realm: Realm, userId: String): CrossSigningInfoEntity {
|
internal fun CrossSigningInfoEntity.Companion.getOrCreate(realm: Realm, userId: String): CrossSigningInfoEntity {
|
||||||
return realm.where<CrossSigningInfoEntity>()
|
return realm.where<CrossSigningInfoEntity>()
|
||||||
|
@ -16,11 +16,11 @@
|
|||||||
|
|
||||||
package org.matrix.android.sdk.internal.crypto.store.db.query
|
package org.matrix.android.sdk.internal.crypto.store.db.query
|
||||||
|
|
||||||
import org.matrix.android.sdk.internal.crypto.store.db.model.CryptoRoomEntity
|
|
||||||
import org.matrix.android.sdk.internal.crypto.store.db.model.CryptoRoomEntityFields
|
|
||||||
import io.realm.Realm
|
import io.realm.Realm
|
||||||
import io.realm.kotlin.createObject
|
import io.realm.kotlin.createObject
|
||||||
import io.realm.kotlin.where
|
import io.realm.kotlin.where
|
||||||
|
import org.matrix.android.sdk.internal.crypto.store.db.model.CryptoRoomEntity
|
||||||
|
import org.matrix.android.sdk.internal.crypto.store.db.model.CryptoRoomEntityFields
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get or create a room
|
* Get or create a room
|
||||||
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
x
Reference in New Issue
Block a user