SDK 0.1.49: notification decryption is now fully handled by the Rust SDK. (#1231)

* Revert "Ensure the sync is started when receiving a Push, to ensure that the encryption loop is running."

This reverts commit 82f6f358a7.

* Integrate SDK from https://github.com/matrix-org/matrix-rust-sdk/pull/2505

* Enable retryDecryption() on the NotificationClient.

* SDK 0.1.49 - Encryption Sync is enabled by default now, and retryDecryption is the default too.

* Remove feature flag `UseEncryptionSync`

* Fix sample project build

* Exclude `DeveloperSettingsPresenter` from kover verification.

* Add changelog

---------

Co-authored-by: Jorge Martín <jorgem@element.io>
This commit is contained in:
Benoit Marty 2023-09-06 11:33:36 +02:00 committed by GitHub
parent 26573f4892
commit 128c4a7b09
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
17 changed files with 35 additions and 104 deletions

View file

@ -65,6 +65,7 @@ import kotlinx.coroutines.withContext
import kotlinx.coroutines.withTimeout
import org.matrix.rustcomponents.sdk.Client
import org.matrix.rustcomponents.sdk.ClientDelegate
import org.matrix.rustcomponents.sdk.NotificationProcessSetup
import org.matrix.rustcomponents.sdk.Room
import org.matrix.rustcomponents.sdk.RoomListItem
import org.matrix.rustcomponents.sdk.use
@ -98,9 +99,13 @@ class RustMatrixClient constructor(
client = client,
dispatchers = dispatchers,
)
private val notificationClient = client.notificationClient().use { builder ->
builder.filterByPushRules().finish()
}
private val notificationProcessSetup = NotificationProcessSetup.SingleProcess(syncService)
private val notificationClient = client.notificationClient(notificationProcessSetup)
.use { builder ->
builder
.filterByPushRules()
.finish()
}
private val notificationService = RustNotificationService(sessionId, notificationClient, dispatchers, clock)
@ -279,6 +284,7 @@ class RustMatrixClient constructor(
syncService.destroy()
innerRoomListService.destroy()
notificationClient.destroy()
notificationProcessSetup.destroy()
client.destroy()
}
@ -316,6 +322,7 @@ class RustMatrixClient constructor(
client.accountUrl()
}
}
override suspend fun loadUserDisplayName(): Result<String> = withContext(sessionDispatcher) {
runCatching {
client.displayName()

View file

@ -19,8 +19,6 @@ package io.element.android.libraries.matrix.impl
import android.content.Context
import io.element.android.libraries.core.coroutine.CoroutineDispatchers
import io.element.android.libraries.di.ApplicationContext
import io.element.android.libraries.featureflag.api.FeatureFlagService
import io.element.android.libraries.featureflag.api.FeatureFlags
import io.element.android.libraries.network.useragent.UserAgentProvider
import io.element.android.libraries.sessionstorage.api.SessionData
import io.element.android.libraries.sessionstorage.api.SessionStore
@ -41,7 +39,6 @@ class RustMatrixClientFactory @Inject constructor(
private val sessionStore: SessionStore,
private val userAgentProvider: UserAgentProvider,
private val clock: SystemClock,
private val featureFlagsService: FeatureFlagService,
) {
suspend fun create(sessionData: SessionData): RustMatrixClient = withContext(coroutineDispatchers.io) {
@ -56,11 +53,7 @@ class RustMatrixClientFactory @Inject constructor(
client.restoreSession(sessionData.toSession())
val syncService = client.syncService().apply {
if (featureFlagsService.isFeatureEnabled(FeatureFlags.UseEncryptionSync)) {
withEncryptionSync(withCrossProcessLock = false, appIdentifier = null)
}
}
val syncService = client.syncService()
.finish()
RustMatrixClient(

View file

@ -126,6 +126,7 @@ private fun RoomListLoadingState.toLoadingState(): RoomList.LoadingState {
private fun RoomListServiceState.toRoomListState(): RoomListService.State {
return when (this) {
RoomListServiceState.INITIAL,
RoomListServiceState.RECOVERING,
RoomListServiceState.SETTING_UP -> RoomListService.State.Idle
RoomListServiceState.RUNNING -> RoomListService.State.Running
RoomListServiceState.ERROR -> RoomListService.State.Error

View file

@ -16,7 +16,6 @@
package io.element.android.libraries.matrix.impl.sync
import io.element.android.libraries.matrix.api.sync.StartSyncReason
import io.element.android.libraries.matrix.api.sync.SyncService
import io.element.android.libraries.matrix.api.sync.SyncState
import kotlinx.coroutines.CoroutineScope
@ -26,8 +25,6 @@ import kotlinx.coroutines.flow.distinctUntilChanged
import kotlinx.coroutines.flow.map
import kotlinx.coroutines.flow.onEach
import kotlinx.coroutines.flow.stateIn
import kotlinx.coroutines.sync.Mutex
import kotlinx.coroutines.sync.withLock
import org.matrix.rustcomponents.sdk.SyncServiceInterface
import org.matrix.rustcomponents.sdk.SyncServiceState
import timber.log.Timber
@ -36,36 +33,19 @@ class RustSyncService(
private val innerSyncService: SyncServiceInterface,
sessionCoroutineScope: CoroutineScope
) : SyncService {
private val mutex = Mutex()
private val startSyncReasonSet = mutableSetOf<StartSyncReason>()
override suspend fun startSync(reason: StartSyncReason): Result<Unit> {
return mutex.withLock {
startSyncReasonSet.add(reason)
runCatching {
Timber.d("Start sync")
innerSyncService.start()
}.onFailure {
Timber.e("Start sync failed: $it")
}
}
override suspend fun startSync() = runCatching {
Timber.i("Start sync")
innerSyncService.start()
}.onFailure {
Timber.d("Start sync failed: $it")
}
override suspend fun stopSync(reason: StartSyncReason): Result<Unit> {
return mutex.withLock {
startSyncReasonSet.remove(reason)
if (startSyncReasonSet.isEmpty()) {
runCatching {
Timber.d("Stop sync")
innerSyncService.stop()
}.onFailure {
Timber.e("Stop sync failed: $it")
}
} else {
Timber.d("Stop sync skipped, still $startSyncReasonSet")
Result.success(Unit)
}
}
override suspend fun stopSync() = runCatching {
Timber.i("Stop sync")
innerSyncService.stop()
}.onFailure {
Timber.d("Stop sync failed: $it")
}
override val syncState: StateFlow<SyncState> =