mirror of
https://github.com/SchildiChat/SchildiChat-android.git
synced 2024-12-28 03:48:37 +03:00
post rebase fix
This commit is contained in:
parent
f209ae26bc
commit
9e055d9793
12 changed files with 23 additions and 48 deletions
|
@ -24,6 +24,7 @@ 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.crosssigning.CrossSigningService
|
||||
import org.matrix.android.sdk.api.session.crypto.verification.VerificationService
|
||||
import org.matrix.android.sdk.internal.crypto.api.CryptoApi
|
||||
import org.matrix.android.sdk.internal.crypto.crosssigning.ComputeTrustTask
|
||||
import org.matrix.android.sdk.internal.crypto.crosssigning.DefaultComputeTrustTask
|
||||
|
@ -88,6 +89,7 @@ import org.matrix.android.sdk.internal.crypto.tasks.SetDeviceNameTask
|
|||
import org.matrix.android.sdk.internal.crypto.tasks.UploadKeysTask
|
||||
import org.matrix.android.sdk.internal.crypto.tasks.UploadSignaturesTask
|
||||
import org.matrix.android.sdk.internal.crypto.tasks.UploadSigningKeysTask
|
||||
import org.matrix.android.sdk.internal.crypto.verification.RustVerificationService
|
||||
import org.matrix.android.sdk.internal.database.RealmKeysUtils
|
||||
import org.matrix.android.sdk.internal.di.CryptoDatabase
|
||||
import org.matrix.android.sdk.internal.di.SessionFilesDirectory
|
||||
|
@ -95,11 +97,6 @@ import org.matrix.android.sdk.internal.di.UserMd5
|
|||
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.RealmClearCacheTask
|
||||
import io.realm.RealmConfiguration
|
||||
import kotlinx.coroutines.CoroutineScope
|
||||
import kotlinx.coroutines.SupervisorJob
|
||||
import org.matrix.android.sdk.api.session.crypto.verification.VerificationService
|
||||
import org.matrix.android.sdk.internal.crypto.verification.RustVerificationService
|
||||
import retrofit2.Retrofit
|
||||
import java.io.File
|
||||
|
||||
|
|
|
@ -20,8 +20,6 @@ import android.content.Context
|
|||
import androidx.annotation.VisibleForTesting
|
||||
import androidx.lifecycle.LiveData
|
||||
import androidx.paging.PagedList
|
||||
import com.squareup.moshi.Types
|
||||
import dagger.Lazy
|
||||
import kotlinx.coroutines.CancellationException
|
||||
import kotlinx.coroutines.CoroutineScope
|
||||
import kotlinx.coroutines.async
|
||||
|
@ -39,14 +37,12 @@ import org.matrix.android.sdk.api.auth.UserInteractiveAuthInterceptor
|
|||
import org.matrix.android.sdk.api.crypto.MXCryptoConfig
|
||||
import org.matrix.android.sdk.api.extensions.tryOrNull
|
||||
import org.matrix.android.sdk.api.failure.Failure
|
||||
import org.matrix.android.sdk.api.failure.MatrixError
|
||||
import org.matrix.android.sdk.api.listeners.ProgressListener
|
||||
import org.matrix.android.sdk.api.session.crypto.CryptoService
|
||||
import org.matrix.android.sdk.api.session.crypto.MXCryptoError
|
||||
import org.matrix.android.sdk.api.session.crypto.crosssigning.CrossSigningService
|
||||
import org.matrix.android.sdk.api.session.crypto.keysbackup.KeysBackupService
|
||||
import org.matrix.android.sdk.api.session.crypto.keyshare.GossipingRequestListener
|
||||
import org.matrix.android.sdk.api.session.crypto.verification.VerificationService
|
||||
import org.matrix.android.sdk.api.session.events.model.Content
|
||||
import org.matrix.android.sdk.api.session.events.model.Event
|
||||
import org.matrix.android.sdk.api.session.events.model.EventType
|
||||
|
@ -58,26 +54,8 @@ import org.matrix.android.sdk.api.session.room.model.RoomMemberContent
|
|||
import org.matrix.android.sdk.api.session.sync.model.DeviceListResponse
|
||||
import org.matrix.android.sdk.api.session.sync.model.DeviceOneTimeKeysCountSyncResponse
|
||||
import org.matrix.android.sdk.api.session.sync.model.ToDeviceSyncResponse
|
||||
import org.matrix.android.sdk.api.util.JsonDict
|
||||
import org.matrix.android.sdk.internal.auth.registration.handleUIA
|
||||
import org.matrix.android.sdk.internal.crypto.crosssigning.DeviceTrustLevel
|
||||
import org.matrix.android.sdk.internal.crypto.keysbackup.RustKeyBackupService
|
||||
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.KeysBackupData
|
||||
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.RoomKeysBackupData
|
||||
import org.matrix.android.sdk.internal.crypto.keysbackup.model.rest.UpdateKeysBackupVersionBody
|
||||
import org.matrix.android.sdk.internal.crypto.keysbackup.tasks.CreateKeysBackupVersionTask
|
||||
import org.matrix.android.sdk.internal.crypto.keysbackup.tasks.DeleteBackupTask
|
||||
import org.matrix.android.sdk.internal.crypto.keysbackup.tasks.GetKeysBackupLastVersionTask
|
||||
import org.matrix.android.sdk.internal.crypto.keysbackup.tasks.GetKeysBackupVersionTask
|
||||
import org.matrix.android.sdk.internal.crypto.keysbackup.tasks.GetRoomSessionDataTask
|
||||
import org.matrix.android.sdk.internal.crypto.keysbackup.tasks.GetRoomSessionsDataTask
|
||||
import org.matrix.android.sdk.internal.crypto.keysbackup.tasks.GetSessionsDataTask
|
||||
import org.matrix.android.sdk.internal.crypto.keysbackup.tasks.StoreSessionsDataTask
|
||||
import org.matrix.android.sdk.internal.crypto.keysbackup.tasks.UpdateKeysBackupVersionTask
|
||||
import org.matrix.android.sdk.internal.crypto.model.CryptoDeviceInfo
|
||||
import org.matrix.android.sdk.internal.crypto.model.ImportRoomKeysResult
|
||||
import org.matrix.android.sdk.internal.crypto.model.MXEncryptEventContentResult
|
||||
|
@ -96,7 +74,6 @@ import org.matrix.android.sdk.internal.crypto.tasks.GetDevicesTask
|
|||
import org.matrix.android.sdk.internal.crypto.tasks.SetDeviceNameTask
|
||||
import org.matrix.android.sdk.internal.crypto.verification.RustVerificationService
|
||||
import org.matrix.android.sdk.internal.di.DeviceId
|
||||
import org.matrix.android.sdk.internal.di.SessionFilesDirectory
|
||||
import org.matrix.android.sdk.internal.di.UserId
|
||||
import org.matrix.android.sdk.internal.extensions.foldToCallback
|
||||
import org.matrix.android.sdk.internal.session.SessionScope
|
||||
|
@ -152,6 +129,7 @@ internal class DefaultCryptoService @Inject constructor(
|
|||
private val sender: RequestSender,
|
||||
private val crossSigningService: CrossSigningService,
|
||||
private val verificationService: RustVerificationService,
|
||||
private val keysBackupService: RustKeyBackupService,
|
||||
private val olmMachineProvider: OlmMachineProvider
|
||||
) : CryptoService {
|
||||
|
||||
|
@ -165,11 +143,6 @@ internal class DefaultCryptoService @Inject constructor(
|
|||
|
||||
// private val deviceObserver: DeviceUpdateObserver = DeviceUpdateObserver()
|
||||
|
||||
// The key backup service.
|
||||
private var keysBackupService: RustKeyBackupService? = null
|
||||
|
||||
private val deviceObserver: DeviceUpdateObserver = DeviceUpdateObserver()
|
||||
|
||||
// Locks for some of our operations
|
||||
private val keyClaimLock: Mutex = Mutex()
|
||||
private val outgoingRequestsLock: Mutex = Mutex()
|
||||
|
@ -335,7 +308,6 @@ internal class DefaultCryptoService @Inject constructor(
|
|||
|
||||
try {
|
||||
setRustLogger()
|
||||
keysBackupService = RustKeyBackupService(machine, sender, coroutineDispatchers, cryptoCoroutineScope)
|
||||
Timber.v(
|
||||
"## CRYPTO | Successfully started up an Olm machine for " +
|
||||
"${userId}, ${deviceId}, identity keys: ${this.olmMachine.identityKeys()}")
|
||||
|
@ -346,7 +318,7 @@ internal class DefaultCryptoService @Inject constructor(
|
|||
// We try to enable key backups, if the backup version on the server is trusted,
|
||||
// we're gonna continue backing up.
|
||||
tryOrNull {
|
||||
keysBackupService!!.checkAndStartKeysBackup()
|
||||
keysBackupService.checkAndStartKeysBackup()
|
||||
}
|
||||
|
||||
// Open the store
|
||||
|
@ -370,12 +342,7 @@ internal class DefaultCryptoService @Inject constructor(
|
|||
/**
|
||||
* @return the Keys backup Service
|
||||
*/
|
||||
override fun keysBackupService(): KeysBackupService {
|
||||
if (keysBackupService == null) {
|
||||
internalStart()
|
||||
}
|
||||
return keysBackupService!!
|
||||
}
|
||||
override fun keysBackupService() = keysBackupService
|
||||
|
||||
/**
|
||||
* @return the VerificationService
|
||||
|
@ -400,7 +367,7 @@ internal class DefaultCryptoService @Inject constructor(
|
|||
// This could be omitted but then devices might be waiting for the next
|
||||
sendOutgoingRequests()
|
||||
|
||||
keysBackupService?.maybeBackupKeys()
|
||||
keysBackupService.maybeBackupKeys()
|
||||
}
|
||||
|
||||
cryptoCoroutineScope.launch(coroutineDispatchers.crypto) {
|
||||
|
@ -431,7 +398,7 @@ internal class DefaultCryptoService @Inject constructor(
|
|||
|
||||
override fun getCryptoDeviceInfo(userId: String): List<CryptoDeviceInfo> {
|
||||
return runBlocking {
|
||||
this@DefaultCryptoService.olmMachine.getCryptoDeviceInfo(userId) ?: listOf()
|
||||
this@DefaultCryptoService.olmMachine.getCryptoDeviceInfo(userId)
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -633,6 +600,7 @@ internal class DefaultCryptoService @Inject constructor(
|
|||
olmMachine.updateTrackedUsers(userIds)
|
||||
}
|
||||
}
|
||||
|
||||
private fun getRoomUserIds(roomId: String): List<String> {
|
||||
val encryptForInvitedMembers = isEncryptionEnabledForInvitedUser() &&
|
||||
shouldEncryptForInvitedMembers(roomId)
|
||||
|
@ -726,7 +694,7 @@ internal class DefaultCryptoService @Inject constructor(
|
|||
|
||||
notifyRoomKeyReceived(roomId, sessionId)
|
||||
}
|
||||
EventType.SEND_SECRET -> {
|
||||
EventType.SEND_SECRET -> {
|
||||
// The rust-sdk will clear this event if it's invalid, this will produce an invalid base64 error
|
||||
// when we try to construct the recovery key.
|
||||
val secretContent = event.getClearContent().toModel<SecretSendEventContent>() ?: return@forEach
|
||||
|
@ -808,7 +776,6 @@ internal class DefaultCryptoService @Inject constructor(
|
|||
cryptoSessionInfoProvider.updateShieldForRoom(roomId, shield)
|
||||
}
|
||||
}
|
||||
|
||||
} catch (throwable: Throwable) {
|
||||
Timber.e(throwable, "## CRYPTO | doKeyDownloadForUsers(): error")
|
||||
}
|
||||
|
|
|
@ -41,6 +41,7 @@ import java.net.URLEncoder
|
|||
import javax.inject.Inject
|
||||
|
||||
// The libolm wrapper.
|
||||
@Deprecated("rust")
|
||||
@SessionScope
|
||||
internal class MXOlmDevice @Inject constructor(
|
||||
/**
|
||||
|
|
|
@ -30,18 +30,18 @@ import org.matrix.android.sdk.internal.crypto.crosssigning.DeviceTrustResult
|
|||
import org.matrix.android.sdk.internal.crypto.crosssigning.UserTrustResult
|
||||
import org.matrix.android.sdk.internal.crypto.crosssigning.isVerified
|
||||
import org.matrix.android.sdk.internal.crypto.store.PrivateKeysInfo
|
||||
import org.matrix.android.sdk.internal.di.SessionId
|
||||
import org.matrix.android.sdk.internal.di.UserId
|
||||
import org.matrix.android.sdk.internal.extensions.foldToCallback
|
||||
import javax.inject.Inject
|
||||
|
||||
internal class RustCrossSigningService @Inject constructor(
|
||||
@SessionId private val sessionId: String,
|
||||
// @SessionId private val sessionId: String,
|
||||
@UserId private val myUserId: String,
|
||||
private val olmMachineProvider: OlmMachineProvider
|
||||
) : CrossSigningService {
|
||||
|
||||
val olmMachine = olmMachineProvider.olmMachine
|
||||
|
||||
/**
|
||||
* Is our own device signed by our own cross signing identity
|
||||
*/
|
||||
|
|
|
@ -28,6 +28,7 @@ import org.matrix.android.sdk.internal.crypto.store.IMXCryptoStore
|
|||
import timber.log.Timber
|
||||
import javax.inject.Inject
|
||||
|
||||
@Deprecated("rust")
|
||||
internal class MegolmSessionDataImporter @Inject constructor(private val olmDevice: MXOlmDevice,
|
||||
private val roomDecryptorProvider: RoomDecryptorProvider,
|
||||
private val outgoingGossipingRequestManager: OutgoingGossipingRequestManager,
|
||||
|
|
|
@ -26,6 +26,7 @@ import org.matrix.android.sdk.internal.crypto.keysbackup.DefaultKeysBackupServic
|
|||
/**
|
||||
* An interface for decrypting data
|
||||
*/
|
||||
@Deprecated("rust")
|
||||
internal interface IMXDecrypting {
|
||||
|
||||
/**
|
||||
|
|
|
@ -21,6 +21,7 @@ import org.matrix.android.sdk.api.session.events.model.Content
|
|||
/**
|
||||
* An interface for encrypting data
|
||||
*/
|
||||
@Deprecated("rust")
|
||||
internal interface IMXEncrypting {
|
||||
|
||||
/**
|
||||
|
|
|
@ -16,6 +16,7 @@
|
|||
|
||||
package org.matrix.android.sdk.internal.crypto.algorithms
|
||||
|
||||
@Deprecated("rust")
|
||||
internal interface IMXGroupEncryption {
|
||||
|
||||
/**
|
||||
|
|
|
@ -18,6 +18,7 @@ package org.matrix.android.sdk.internal.crypto.algorithms
|
|||
|
||||
import org.matrix.android.sdk.internal.crypto.model.event.RoomKeyWithHeldContent
|
||||
|
||||
@Deprecated("rust")
|
||||
internal interface IMXWithHeldExtension {
|
||||
fun onRoomKeyWithHeldEvent(withHeldInfo: RoomKeyWithHeldContent)
|
||||
}
|
||||
|
|
|
@ -43,6 +43,7 @@ import org.matrix.android.sdk.internal.util.JsonCanonicalizer
|
|||
import org.matrix.android.sdk.internal.util.convertToUTF8
|
||||
import timber.log.Timber
|
||||
|
||||
@Deprecated("in favour of rust")
|
||||
internal class MXMegolmEncryption(
|
||||
// The id of the room we will be sending to.
|
||||
private val roomId: String,
|
||||
|
|
|
@ -99,6 +99,7 @@ import kotlin.random.Random
|
|||
* to the user's homeserver.
|
||||
*/
|
||||
@SessionScope
|
||||
@Deprecated("use rust")
|
||||
internal class DefaultKeysBackupService @Inject constructor(
|
||||
@UserId private val userId: String,
|
||||
private val credentials: Credentials,
|
||||
|
|
|
@ -38,6 +38,7 @@ import org.matrix.android.sdk.api.session.crypto.keysbackup.KeysBackupStateListe
|
|||
import org.matrix.android.sdk.internal.crypto.MXCRYPTO_ALGORITHM_MEGOLM_BACKUP
|
||||
import org.matrix.android.sdk.internal.crypto.MegolmSessionData
|
||||
import org.matrix.android.sdk.internal.crypto.OlmMachine
|
||||
import org.matrix.android.sdk.internal.crypto.OlmMachineProvider
|
||||
import org.matrix.android.sdk.internal.crypto.RequestSender
|
||||
import org.matrix.android.sdk.internal.crypto.keysbackup.model.KeysBackupVersionTrust
|
||||
import org.matrix.android.sdk.internal.crypto.keysbackup.model.MegolmBackupAuthData
|
||||
|
@ -71,7 +72,7 @@ import kotlin.random.Random
|
|||
*/
|
||||
@SessionScope
|
||||
internal class RustKeyBackupService @Inject constructor(
|
||||
private val olmMachine: OlmMachine,
|
||||
olmMachineProvider: OlmMachineProvider,
|
||||
private val sender: RequestSender,
|
||||
private val coroutineDispatchers: MatrixCoroutineDispatchers,
|
||||
private val cryptoCoroutineScope: CoroutineScope,
|
||||
|
@ -85,6 +86,8 @@ internal class RustKeyBackupService @Inject constructor(
|
|||
|
||||
private val keysBackupStateManager = KeysBackupStateManager(uiHandler)
|
||||
|
||||
private val olmMachine = olmMachineProvider.olmMachine
|
||||
|
||||
// The backup version
|
||||
override var keysBackupVersion: KeysVersionResult? = null
|
||||
private set
|
||||
|
|
Loading…
Reference in a new issue