Re-enable SyncService.withEncryptionSync to improve decryption of notifications (#1199)
* Re-enable `SyncService.withEncryptionSync` to improve decryption of notifications. * Add feature flag
This commit is contained in:
parent
1c4eb45a60
commit
e4124e93b8
8 changed files with 30 additions and 4 deletions
1
changelog.d/1198.bugfix
Normal file
1
changelog.d/1198.bugfix
Normal file
|
|
@ -0,0 +1 @@
|
||||||
|
Re-enable `SyncService.withEncryptionSync` to improve decryption of notifications.
|
||||||
|
|
@ -83,7 +83,8 @@ class DeveloperSettingsPresenter @Inject constructor(
|
||||||
features,
|
features,
|
||||||
enabledFeatures,
|
enabledFeatures,
|
||||||
event.feature,
|
event.feature,
|
||||||
event.isEnabled
|
event.isEnabled,
|
||||||
|
triggerClearCache = { handleEvents(DeveloperSettingsEvents.ClearCache) }
|
||||||
)
|
)
|
||||||
DeveloperSettingsEvents.ClearCache -> coroutineScope.clearCache(clearCacheAction)
|
DeveloperSettingsEvents.ClearCache -> coroutineScope.clearCache(clearCacheAction)
|
||||||
}
|
}
|
||||||
|
|
@ -122,12 +123,17 @@ class DeveloperSettingsPresenter @Inject constructor(
|
||||||
features: SnapshotStateMap<String, Feature>,
|
features: SnapshotStateMap<String, Feature>,
|
||||||
enabledFeatures: SnapshotStateMap<String, Boolean>,
|
enabledFeatures: SnapshotStateMap<String, Boolean>,
|
||||||
featureUiModel: FeatureUiModel,
|
featureUiModel: FeatureUiModel,
|
||||||
enabled: Boolean
|
enabled: Boolean,
|
||||||
|
triggerClearCache: () -> Unit,
|
||||||
) = launch {
|
) = launch {
|
||||||
val feature = features[featureUiModel.key] ?: return@launch
|
val feature = features[featureUiModel.key] ?: return@launch
|
||||||
if (featureFlagService.setFeatureEnabled(feature, enabled)) {
|
if (featureFlagService.setFeatureEnabled(feature, enabled)) {
|
||||||
enabledFeatures[featureUiModel.key] = enabled
|
enabledFeatures[featureUiModel.key] = enabled
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (featureUiModel.key == FeatureFlags.UseEncryptionSync.key) {
|
||||||
|
triggerClearCache()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun CoroutineScope.computeCacheSize(cacheSize: MutableState<Async<String>>) = launch {
|
private fun CoroutineScope.computeCacheSize(cacheSize: MutableState<Async<String>>) = launch {
|
||||||
|
|
|
||||||
|
|
@ -31,5 +31,11 @@ enum class FeatureFlags(
|
||||||
title = "Polls",
|
title = "Polls",
|
||||||
description = "Create poll and render poll events in the timeline",
|
description = "Create poll and render poll events in the timeline",
|
||||||
defaultValue = false,
|
defaultValue = false,
|
||||||
|
),
|
||||||
|
UseEncryptionSync(
|
||||||
|
key = "feature.useencryptionsync",
|
||||||
|
title = "Use encryption sync",
|
||||||
|
description = "Use the encryption sync API for decrypting notifications.",
|
||||||
|
defaultValue = true,
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -31,6 +31,7 @@ class BuildtimeFeatureFlagProvider @Inject constructor() :
|
||||||
when (feature) {
|
when (feature) {
|
||||||
FeatureFlags.LocationSharing -> true
|
FeatureFlags.LocationSharing -> true
|
||||||
FeatureFlags.Polls -> false
|
FeatureFlags.Polls -> false
|
||||||
|
FeatureFlags.UseEncryptionSync -> true
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
false
|
false
|
||||||
|
|
|
||||||
|
|
@ -35,6 +35,7 @@ dependencies {
|
||||||
implementation(projects.libraries.androidutils)
|
implementation(projects.libraries.androidutils)
|
||||||
implementation(projects.libraries.network)
|
implementation(projects.libraries.network)
|
||||||
implementation(projects.services.toolbox.api)
|
implementation(projects.services.toolbox.api)
|
||||||
|
implementation(projects.libraries.featureflag.api)
|
||||||
api(projects.libraries.matrix.api)
|
api(projects.libraries.matrix.api)
|
||||||
implementation(libs.dagger)
|
implementation(libs.dagger)
|
||||||
implementation(projects.libraries.core)
|
implementation(projects.libraries.core)
|
||||||
|
|
|
||||||
|
|
@ -19,6 +19,8 @@ package io.element.android.libraries.matrix.impl
|
||||||
import android.content.Context
|
import android.content.Context
|
||||||
import io.element.android.libraries.core.coroutine.CoroutineDispatchers
|
import io.element.android.libraries.core.coroutine.CoroutineDispatchers
|
||||||
import io.element.android.libraries.di.ApplicationContext
|
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.network.useragent.UserAgentProvider
|
||||||
import io.element.android.libraries.sessionstorage.api.SessionData
|
import io.element.android.libraries.sessionstorage.api.SessionData
|
||||||
import io.element.android.libraries.sessionstorage.api.SessionStore
|
import io.element.android.libraries.sessionstorage.api.SessionStore
|
||||||
|
|
@ -39,6 +41,7 @@ class RustMatrixClientFactory @Inject constructor(
|
||||||
private val sessionStore: SessionStore,
|
private val sessionStore: SessionStore,
|
||||||
private val userAgentProvider: UserAgentProvider,
|
private val userAgentProvider: UserAgentProvider,
|
||||||
private val clock: SystemClock,
|
private val clock: SystemClock,
|
||||||
|
private val featureFlagsService: FeatureFlagService,
|
||||||
) {
|
) {
|
||||||
|
|
||||||
suspend fun create(sessionData: SessionData): RustMatrixClient = withContext(coroutineDispatchers.io) {
|
suspend fun create(sessionData: SessionData): RustMatrixClient = withContext(coroutineDispatchers.io) {
|
||||||
|
|
@ -53,7 +56,12 @@ class RustMatrixClientFactory @Inject constructor(
|
||||||
|
|
||||||
client.restoreSession(sessionData.toSession())
|
client.restoreSession(sessionData.toSession())
|
||||||
|
|
||||||
val syncService = client.syncService().finish()
|
val syncService = client.syncService().apply {
|
||||||
|
if (featureFlagsService.isFeatureEnabled(FeatureFlags.UseEncryptionSync)) {
|
||||||
|
withEncryptionSync(withCrossProcessLock = false, appIdentifier = null)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
.finish()
|
||||||
|
|
||||||
RustMatrixClient(
|
RustMatrixClient(
|
||||||
client = client,
|
client = client,
|
||||||
|
|
|
||||||
|
|
@ -63,6 +63,7 @@ dependencies {
|
||||||
implementation(projects.features.login.impl)
|
implementation(projects.features.login.impl)
|
||||||
implementation(projects.features.networkmonitor.impl)
|
implementation(projects.features.networkmonitor.impl)
|
||||||
implementation(projects.services.toolbox.impl)
|
implementation(projects.services.toolbox.impl)
|
||||||
|
implementation(projects.libraries.featureflag.impl)
|
||||||
implementation(libs.coroutines.core)
|
implementation(libs.coroutines.core)
|
||||||
coreLibraryDesugaring(libs.android.desugar)
|
coreLibraryDesugaring(libs.android.desugar)
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -26,6 +26,7 @@ import androidx.compose.runtime.getValue
|
||||||
import androidx.compose.ui.Modifier
|
import androidx.compose.ui.Modifier
|
||||||
import androidx.compose.ui.platform.LocalContext
|
import androidx.compose.ui.platform.LocalContext
|
||||||
import androidx.core.view.WindowCompat
|
import androidx.core.view.WindowCompat
|
||||||
|
import io.element.android.libraries.featureflag.impl.DefaultFeatureFlagService
|
||||||
import io.element.android.libraries.matrix.api.auth.MatrixAuthenticationService
|
import io.element.android.libraries.matrix.api.auth.MatrixAuthenticationService
|
||||||
import io.element.android.libraries.matrix.impl.RustMatrixClientFactory
|
import io.element.android.libraries.matrix.impl.RustMatrixClientFactory
|
||||||
import io.element.android.libraries.matrix.impl.auth.RustMatrixAuthenticationService
|
import io.element.android.libraries.matrix.impl.auth.RustMatrixAuthenticationService
|
||||||
|
|
@ -54,7 +55,8 @@ class MainActivity : ComponentActivity() {
|
||||||
coroutineDispatchers = Singleton.coroutineDispatchers,
|
coroutineDispatchers = Singleton.coroutineDispatchers,
|
||||||
sessionStore = sessionStore,
|
sessionStore = sessionStore,
|
||||||
userAgentProvider = userAgentProvider,
|
userAgentProvider = userAgentProvider,
|
||||||
clock = DefaultSystemClock()
|
clock = DefaultSystemClock(),
|
||||||
|
featureFlagsService = DefaultFeatureFlagService(emptySet())
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue