From 242e60fcaaf0b1c9343987090369da5bfb6e1eb4 Mon Sep 17 00:00:00 2001 From: Benoit Marty Date: Thu, 5 Sep 2019 16:14:34 +0200 Subject: [PATCH] Rename CryptoManager to DefaultCryptoService --- .../matrix/android/internal/crypto/CryptoModule.kt | 2 +- .../{CryptoManager.kt => DefaultCryptoService.kt} | 4 ++-- .../android/internal/session/DefaultSession.kt | 4 ++-- .../internal/session/sync/CryptoSyncHandler.kt | 10 +++++----- .../android/internal/session/sync/RoomSyncHandler.kt | 8 ++++---- .../internal/session/sync/SyncResponseHandler.kt | 12 ++++++------ 6 files changed, 20 insertions(+), 20 deletions(-) rename matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/crypto/{CryptoManager.kt => DefaultCryptoService.kt} (99%) diff --git a/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/crypto/CryptoModule.kt b/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/crypto/CryptoModule.kt index 5ed0c0e29f..4272dbd340 100644 --- a/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/crypto/CryptoModule.kt +++ b/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/crypto/CryptoModule.kt @@ -105,7 +105,7 @@ internal abstract class CryptoModule { } @Binds - abstract fun bindCryptoService(cryptoManager: CryptoManager): CryptoService + abstract fun bindCryptoService(cryptoService: DefaultCryptoService): CryptoService @Binds abstract fun bindDeleteDeviceTask(deleteDeviceTask: DefaultDeleteDeviceTask): DeleteDeviceTask diff --git a/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/crypto/CryptoManager.kt b/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/crypto/DefaultCryptoService.kt similarity index 99% rename from matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/crypto/CryptoManager.kt rename to matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/crypto/DefaultCryptoService.kt index 96d337bd2d..a3786d481d 100755 --- a/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/crypto/CryptoManager.kt +++ b/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/crypto/DefaultCryptoService.kt @@ -93,7 +93,7 @@ import kotlin.math.max * Specially, it tracks all room membership changes events in order to do keys updates. */ @SessionScope -internal class CryptoManager @Inject constructor( +internal class DefaultCryptoService @Inject constructor( // Olm Manager private val olmManager: OlmManager, // The credentials, @@ -1067,6 +1067,6 @@ internal class CryptoManager @Inject constructor( * ========================================================================================== */ override fun toString(): String { - return "CryptoManager of " + credentials.userId + " (" + credentials.deviceId + ")" + return "DefaultCryptoService of " + credentials.userId + " (" + credentials.deviceId + ")" } } diff --git a/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/session/DefaultSession.kt b/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/session/DefaultSession.kt index 2922b7d6de..a18c339b47 100644 --- a/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/session/DefaultSession.kt +++ b/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/session/DefaultSession.kt @@ -40,7 +40,7 @@ import im.vector.matrix.android.api.session.sync.FilterService import im.vector.matrix.android.api.session.sync.SyncState import im.vector.matrix.android.api.session.user.UserService import im.vector.matrix.android.api.util.MatrixCallbackDelegate -import im.vector.matrix.android.internal.crypto.CryptoManager +import im.vector.matrix.android.internal.crypto.DefaultCryptoService import im.vector.matrix.android.internal.database.LiveEntityObserver import im.vector.matrix.android.internal.session.sync.job.SyncThread import im.vector.matrix.android.internal.session.sync.job.SyncWorker @@ -63,7 +63,7 @@ internal class DefaultSession @Inject constructor(override val sessionParams: Se private val signOutService: Lazy, private val pushRuleService: Lazy, private val pushersService: Lazy, - private val cryptoService: Lazy, + private val cryptoService: Lazy, private val fileService: Lazy, private val syncThreadProvider: Provider, private val contentUrlResolver: ContentUrlResolver, diff --git a/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/session/sync/CryptoSyncHandler.kt b/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/session/sync/CryptoSyncHandler.kt index 013fc3ca52..945f344036 100644 --- a/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/session/sync/CryptoSyncHandler.kt +++ b/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/session/sync/CryptoSyncHandler.kt @@ -22,7 +22,7 @@ import im.vector.matrix.android.api.session.events.model.Event import im.vector.matrix.android.api.session.events.model.EventType import im.vector.matrix.android.api.session.events.model.toModel import im.vector.matrix.android.api.session.room.model.message.MessageContent -import im.vector.matrix.android.internal.crypto.CryptoManager +import im.vector.matrix.android.internal.crypto.DefaultCryptoService import im.vector.matrix.android.internal.crypto.MXEventDecryptionResult import im.vector.matrix.android.internal.crypto.algorithms.olm.OlmDecryptionResult import im.vector.matrix.android.internal.crypto.verification.DefaultSasVerificationService @@ -33,7 +33,7 @@ import timber.log.Timber import javax.inject.Inject -internal class CryptoSyncHandler @Inject constructor(private val cryptoManager: CryptoManager, +internal class CryptoSyncHandler @Inject constructor(private val cryptoService: DefaultCryptoService, private val sasVerificationService: DefaultSasVerificationService) { fun handleToDevice(toDevice: ToDeviceSyncResponse, initialSyncProgressService: DefaultInitialSyncProgressService? = null) { @@ -47,13 +47,13 @@ internal class CryptoSyncHandler @Inject constructor(private val cryptoManager: Timber.e("## handleToDeviceEvent() : Warning: Unable to decrypt to-device event : " + event.content) } else { sasVerificationService.onToDeviceEvent(event) - cryptoManager.onToDeviceEvent(event) + cryptoService.onToDeviceEvent(event) } } } fun onSyncCompleted(syncResponse: SyncResponse) { - cryptoManager.onSyncCompleted(syncResponse) + cryptoService.onSyncCompleted(syncResponse) } @@ -68,7 +68,7 @@ internal class CryptoSyncHandler @Inject constructor(private val cryptoManager: if (event.getClearType() == EventType.ENCRYPTED) { var result: MXEventDecryptionResult? = null try { - result = cryptoManager.decryptEvent(event, timelineId ?: "") + result = cryptoService.decryptEvent(event, timelineId ?: "") } catch (exception: MXCryptoError) { event.mCryptoError = (exception as? MXCryptoError.Base)?.errorType //setCryptoError(exception.cryptoError) } diff --git a/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/session/sync/RoomSyncHandler.kt b/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/session/sync/RoomSyncHandler.kt index 74b56e774c..0ebca5e130 100644 --- a/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/session/sync/RoomSyncHandler.kt +++ b/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/session/sync/RoomSyncHandler.kt @@ -23,7 +23,7 @@ import im.vector.matrix.android.api.session.events.model.EventType import im.vector.matrix.android.api.session.events.model.toModel import im.vector.matrix.android.api.session.room.model.Membership import im.vector.matrix.android.api.session.room.model.tag.RoomTagContent -import im.vector.matrix.android.internal.crypto.CryptoManager +import im.vector.matrix.android.internal.crypto.DefaultCryptoService import im.vector.matrix.android.internal.database.helper.* import im.vector.matrix.android.internal.database.model.ChunkEntity import im.vector.matrix.android.internal.database.model.EventEntityFields @@ -50,7 +50,7 @@ internal class RoomSyncHandler @Inject constructor(private val monarchy: Monarch private val readReceiptHandler: ReadReceiptHandler, private val roomSummaryUpdater: RoomSummaryUpdater, private val roomTagHandler: RoomTagHandler, - private val cryptoManager: CryptoManager, + private val cryptoService: DefaultCryptoService, private val tokenStore: SyncTokenStore, private val pushRuleService: DefaultPushRuleService, private val processForPushTask: ProcessEventForPushTask, @@ -141,7 +141,7 @@ internal class RoomSyncHandler @Inject constructor(private val monarchy: Monarch roomSync.state.events.forEach { event -> roomEntity.addStateEvent(event, filterDuplicates = true, stateIndex = untimelinedStateIndex) // Give info to crypto module - cryptoManager.onStateEvent(roomId, event) + cryptoService.onStateEvent(roomId, event) UserEntityFactory.createOrNull(event)?.also { realm.insertOrUpdate(it) } @@ -214,7 +214,7 @@ internal class RoomSyncHandler @Inject constructor(private val monarchy: Monarch event.eventId?.also { eventIds.add(it) } chunkEntity.add(roomEntity.roomId, event, PaginationDirection.FORWARDS, stateIndexOffset) // Give info to crypto module - cryptoManager.onLiveEvent(roomEntity.roomId, event) + cryptoService.onLiveEvent(roomEntity.roomId, event) // Try to remove local echo event.unsignedData?.transactionId?.also { val sendingEventEntity = roomEntity.sendingTimelineEvents.find(it) diff --git a/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/session/sync/SyncResponseHandler.kt b/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/session/sync/SyncResponseHandler.kt index 991e5a9a1a..584e84c2ae 100644 --- a/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/session/sync/SyncResponseHandler.kt +++ b/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/session/sync/SyncResponseHandler.kt @@ -18,7 +18,7 @@ package im.vector.matrix.android.internal.session.sync import arrow.core.Try import im.vector.matrix.android.R -import im.vector.matrix.android.internal.crypto.CryptoManager +import im.vector.matrix.android.internal.crypto.DefaultCryptoService import im.vector.matrix.android.internal.session.DefaultInitialSyncProgressService import im.vector.matrix.android.internal.session.reportSubtask import im.vector.matrix.android.internal.session.sync.model.SyncResponse @@ -30,7 +30,7 @@ internal class SyncResponseHandler @Inject constructor(private val roomSyncHandl private val userAccountDataSyncHandler: UserAccountDataSyncHandler, private val groupSyncHandler: GroupSyncHandler, private val cryptoSyncHandler: CryptoSyncHandler, - private val cryptoManager: CryptoManager, + private val cryptoService: DefaultCryptoService, private val initialSyncProgressService: DefaultInitialSyncProgressService) { fun handleResponse(syncResponse: SyncResponse, fromToken: String?, isCatchingUp: Boolean): Try { @@ -40,12 +40,12 @@ internal class SyncResponseHandler @Inject constructor(private val roomSyncHandl val reporter = initialSyncProgressService.takeIf { isInitialSync } measureTimeMillis { - if (!cryptoManager.isStarted()) { - Timber.v("Should start cryptoManager") - cryptoManager.start(isInitialSync) + if (!cryptoService.isStarted()) { + Timber.v("Should start cryptoService") + cryptoService.start(isInitialSync) } }.also { - Timber.v("Finish handling start cryptoManager in $it ms") + Timber.v("Finish handling start cryptoService in $it ms") } val measure = measureTimeMillis { // Handle the to device events before the room ones