From 0ddec0984ca5068fa408d2d2fa3886cef3a3ca17 Mon Sep 17 00:00:00 2001 From: Mohamad Jaara Date: Mon, 20 Jan 2025 09:48:16 +0100 Subject: [PATCH 1/4] chore: remove encrypted proteus storage flag [WPB-15409] --- .../com/wire/android/WireApplication.kt | 2 +- .../wire/android/datastore/GlobalDataStore.kt | 12 ----------- .../wire/android/di/KaliumConfigsModule.kt | 6 ++---- .../wire/android/ui/debug/DebugDataOptions.kt | 20 +------------------ .../android/ui/debug/DebugDataOptionsState.kt | 1 - .../ui/debug/DebugDataOptionsViewModel.kt | 19 ------------------ .../com/wire/android/ExternalLoggerManager.kt | 10 ++-------- default.json | 6 ------ 8 files changed, 6 insertions(+), 70 deletions(-) diff --git a/app/src/main/kotlin/com/wire/android/WireApplication.kt b/app/src/main/kotlin/com/wire/android/WireApplication.kt index b1feeee16fe..f181ae3f23a 100644 --- a/app/src/main/kotlin/com/wire/android/WireApplication.kt +++ b/app/src/main/kotlin/com/wire/android/WireApplication.kt @@ -182,7 +182,7 @@ class WireApplication : BaseApp() { private suspend fun initializeApplicationLoggingFrameworks() { // 1. Datadog should be initialized first - ExternalLoggerManager.initDatadogLogger(applicationContext, globalDataStore.get()) + ExternalLoggerManager.initDatadogLogger(applicationContext) // 2. Initialize our internal logging framework val isLoggingEnabled = globalDataStore.get().isLoggingEnabled().first() val config = if (isLoggingEnabled) { diff --git a/app/src/main/kotlin/com/wire/android/datastore/GlobalDataStore.kt b/app/src/main/kotlin/com/wire/android/datastore/GlobalDataStore.kt index b9fa7463f57..7c06a72d2d9 100644 --- a/app/src/main/kotlin/com/wire/android/datastore/GlobalDataStore.kt +++ b/app/src/main/kotlin/com/wire/android/datastore/GlobalDataStore.kt @@ -53,8 +53,6 @@ class GlobalDataStore @Inject constructor(@ApplicationContext private val contex private val MIGRATION_COMPLETED = booleanPreferencesKey("migration_completed") private val WELCOME_SCREEN_PRESENTED = booleanPreferencesKey("welcome_screen_presented") private val IS_LOGGING_ENABLED = booleanPreferencesKey("is_logging_enabled") - private val IS_ENCRYPTED_PROTEUS_STORAGE_ENABLED = - booleanPreferencesKey("is_encrypted_proteus_storage_enabled") private val APP_LOCK_PASSCODE = stringPreferencesKey("app_lock_passcode") private val APP_LOCK_SOURCE = intPreferencesKey("app_lock_source") @@ -104,16 +102,6 @@ class GlobalDataStore @Inject constructor(@ApplicationContext private val contex context.dataStore.edit { it[RECORD_AUDIO_EFFECTS_CHECKBOX] = enabled } } - fun isEncryptedProteusStorageEnabled(): Flow = - getBooleanPreference( - IS_ENCRYPTED_PROTEUS_STORAGE_ENABLED, - BuildConfig.ENCRYPT_PROTEUS_STORAGE - ) - - suspend fun setEncryptedProteusStorageEnabled(enabled: Boolean) { - context.dataStore.edit { it[IS_ENCRYPTED_PROTEUS_STORAGE_ENABLED] = enabled } - } - suspend fun setMigrationCompleted() { context.dataStore.edit { it[MIGRATION_COMPLETED] = true } } diff --git a/app/src/main/kotlin/com/wire/android/di/KaliumConfigsModule.kt b/app/src/main/kotlin/com/wire/android/di/KaliumConfigsModule.kt index 9be6af3cae7..fd337f17ea1 100644 --- a/app/src/main/kotlin/com/wire/android/di/KaliumConfigsModule.kt +++ b/app/src/main/kotlin/com/wire/android/di/KaliumConfigsModule.kt @@ -29,15 +29,13 @@ import dagger.Module import dagger.Provides import dagger.hilt.InstallIn import dagger.hilt.components.SingletonComponent -import kotlinx.coroutines.flow.first -import kotlinx.coroutines.runBlocking @Module @InstallIn(SingletonComponent::class) class KaliumConfigsModule { @Provides - fun provideKaliumConfigs(globalDataStore: GlobalDataStore, context: Context): KaliumConfigs { + fun provideKaliumConfigs(context: Context): KaliumConfigs { val fileRestriction: BuildFileRestrictionState = if (BuildConfig.FILE_RESTRICTION_ENABLED) { BuildConfig.FILE_RESTRICTION_LIST.split(",").map { it.trim() }.let { BuildFileRestrictionState.AllowSome(it) @@ -55,7 +53,7 @@ class KaliumConfigsModule { lowerKeyingMaterialsUpdateThreshold = BuildConfig.PRIVATE_BUILD, developmentApiEnabled = BuildConfig.DEVELOPMENT_API_ENABLED, ignoreSSLCertificatesForUnboundCalls = BuildConfig.IGNORE_SSL_CERTIFICATES, - encryptProteusStorage = runBlocking { globalDataStore.isEncryptedProteusStorageEnabled().first() }, + encryptProteusStorage = true, guestRoomLink = BuildConfig.ENABLE_GUEST_ROOM_LINK, selfDeletingMessages = BuildConfig.SELF_DELETING_MESSAGES, wipeOnCookieInvalid = BuildConfig.WIPE_ON_COOKIE_INVALID, diff --git a/app/src/main/kotlin/com/wire/android/ui/debug/DebugDataOptions.kt b/app/src/main/kotlin/com/wire/android/ui/debug/DebugDataOptions.kt index 165da415254..49de12cbce0 100644 --- a/app/src/main/kotlin/com/wire/android/ui/debug/DebugDataOptions.kt +++ b/app/src/main/kotlin/com/wire/android/ui/debug/DebugDataOptions.kt @@ -69,7 +69,6 @@ fun DebugDataOptions( appVersion = appVersion, buildVariant = buildVariant, onCopyText = onCopyText, - onEnableEncryptedProteusStorageChange = viewModel::enableEncryptedProteusStorage, onRestartSlowSyncForRecovery = viewModel::restartSlowSyncForRecovery, onForceUpdateApiVersions = viewModel::forceUpdateApiVersions, onManualMigrationPressed = { onManualMigrationPressed(viewModel.currentAccount()) }, @@ -89,7 +88,6 @@ fun DebugDataOptionsContent( appVersion: String, buildVariant: String, onCopyText: (String) -> Unit, - onEnableEncryptedProteusStorageChange: (Boolean) -> Unit, onDisableEventProcessingChange: (Boolean) -> Unit, onRestartSlowSyncForRecovery: () -> Unit, onForceUpdateApiVersions: () -> Unit, @@ -198,10 +196,7 @@ fun DebugDataOptionsContent( ) } } - ProteusOptions( - isEncryptedStorageEnabled = state.isEncryptedProteusStorageEnabled, - onEncryptedStorageEnabledChange = onEnableEncryptedProteusStorageChange - ) + if (BuildConfig.DEBUG) { MLSOptions( keyPackagesCount = state.keyPackagesCount, @@ -337,17 +332,6 @@ private fun MLSOptions( //endregion //region Proteus Options -@Composable -private fun ProteusOptions( - isEncryptedStorageEnabled: Boolean, - onEncryptedStorageEnabledChange: (Boolean) -> Unit, -) { - FolderHeader(stringResource(R.string.label_proteus_option_title)) - EnableEncryptedProteusStorageSwitch( - isEnabled = isEncryptedStorageEnabled, - onCheckedChange = onEncryptedStorageEnabledChange - ) -} @Composable private fun EnableEncryptedProteusStorageSwitch( @@ -539,7 +523,6 @@ fun PreviewOtherDebugOptions() = WireTheme { buildVariant = "debug", onCopyText = {}, state = DebugDataOptionsState( - isEncryptedProteusStorageEnabled = true, keyPackagesCount = 10, mslClientId = "clientId", mlsErrorMessage = "error", @@ -547,7 +530,6 @@ fun PreviewOtherDebugOptions() = WireTheme { debugId = "debugId", commitish = "commitish" ), - onEnableEncryptedProteusStorageChange = {}, onForceUpdateApiVersions = {}, onDisableEventProcessingChange = {}, onRestartSlowSyncForRecovery = {}, diff --git a/app/src/main/kotlin/com/wire/android/ui/debug/DebugDataOptionsState.kt b/app/src/main/kotlin/com/wire/android/ui/debug/DebugDataOptionsState.kt index 3f7387e53d3..5f35f0e4473 100644 --- a/app/src/main/kotlin/com/wire/android/ui/debug/DebugDataOptionsState.kt +++ b/app/src/main/kotlin/com/wire/android/ui/debug/DebugDataOptionsState.kt @@ -18,7 +18,6 @@ package com.wire.android.ui.debug data class DebugDataOptionsState( - val isEncryptedProteusStorageEnabled: Boolean = false, val isEventProcessingDisabled: Boolean = false, val keyPackagesCount: Int = 0, val mslClientId: String = "null", diff --git a/app/src/main/kotlin/com/wire/android/ui/debug/DebugDataOptionsViewModel.kt b/app/src/main/kotlin/com/wire/android/ui/debug/DebugDataOptionsViewModel.kt index 27fdf191eb9..8df44a4752b 100644 --- a/app/src/main/kotlin/com/wire/android/ui/debug/DebugDataOptionsViewModel.kt +++ b/app/src/main/kotlin/com/wire/android/ui/debug/DebugDataOptionsViewModel.kt @@ -67,7 +67,6 @@ interface DebugDataOptionsViewModel { fun state(): DebugDataOptionsState = DebugDataOptionsState() fun currentAccount(): UserId = UserId("value", "domain") fun checkCrlRevocationList() {} - fun enableEncryptedProteusStorage(enabled: Boolean) {} fun restartSlowSyncForRecovery() {} fun enrollE2EICertificate() {} fun handleE2EIEnrollmentResult(result: Either) {} @@ -103,7 +102,6 @@ class DebugDataOptionsViewModelImpl override val infoMessage = _infoMessage.asSharedFlow() init { - observeEncryptedProteusStorageState() observeMlsMetadata() checkIfCanTriggerManualMigration() setGitHashAndDeviceId() @@ -170,14 +168,6 @@ class DebugDataOptionsViewModelImpl } } - override fun enableEncryptedProteusStorage(enabled: Boolean) { - if (enabled) { - viewModelScope.launch { - globalDataStore.setEncryptedProteusStorageEnabled(true) - } - } - } - override fun restartSlowSyncForRecovery() { viewModelScope.launch { restartSlowSyncProcessForRecovery() @@ -257,15 +247,6 @@ class DebugDataOptionsViewModelImpl } } - //region Private - private fun observeEncryptedProteusStorageState() { - viewModelScope.launch { - globalDataStore.isEncryptedProteusStorageEnabled().collect { - state = state.copy(isEncryptedProteusStorageEnabled = it) - } - } - } - // If status is NoNeed, it means that the user has already been migrated in and older app version, // or it is a new install // this is why we check the existence of the database file diff --git a/app/src/private/kotlin/com/wire/android/ExternalLoggerManager.kt b/app/src/private/kotlin/com/wire/android/ExternalLoggerManager.kt index cf0fe327944..f25fdd6ecc0 100644 --- a/app/src/private/kotlin/com/wire/android/ExternalLoggerManager.kt +++ b/app/src/private/kotlin/com/wire/android/ExternalLoggerManager.kt @@ -10,18 +10,15 @@ import com.datadog.android.rum.GlobalRum import com.datadog.android.rum.RumMonitor import com.datadog.android.rum.tracking.ActivityViewTrackingStrategy import com.datadog.android.rum.tracking.ComponentPredicate -import com.wire.android.datastore.GlobalDataStore import com.wire.android.ui.WireActivity import com.wire.android.util.sha256 -import kotlinx.coroutines.flow.first -import kotlinx.coroutines.runBlocking import com.wire.android.util.getDeviceIdString private const val LONG_TASK_THRESH_HOLD_MS = 1000L object ExternalLoggerManager { - fun initDatadogLogger(context: Context, globalDataStore: GlobalDataStore) { + fun initDatadogLogger(context: Context) { val clientToken = BuildConfig.DATADOG_CLIENT_TOKEN val applicationId = BuildConfig.DATADOG_APP_ID @@ -59,12 +56,9 @@ object ExternalLoggerManager { .build() val credentials = Credentials(clientToken, environmentName, appVariantName, applicationId) - val extraInfo = mapOf( - "encrypted_proteus_storage_enabled" to runBlocking { globalDataStore.isEncryptedProteusStorageEnabled().first() } - ) Datadog.initialize(context, credentials, configuration, TrackingConsent.GRANTED) - Datadog.setUserInfo(id = context.getDeviceIdString()?.sha256(), extraInfo = extraInfo) + Datadog.setUserInfo(id = context.getDeviceIdString()?.sha256(), extraInfo = emptyMap()) GlobalRum.registerIfAbsent(RumMonitor.Builder().build()) } } diff --git a/default.json b/default.json index 3f0e58c7457..8d9ca499de9 100644 --- a/default.json +++ b/default.json @@ -7,7 +7,6 @@ "application_is_private_build": false, "development_api_enabled": false, "paginated_conversation_list_enabled": true, - "encrypt_proteus_storage": true, "analytics_enabled": true, "analytics_app_key": "4483f7a58ae3e70b3780319c4ccb5c88a037be49", "analytics_server_url": "https://countly.wire.com/" @@ -30,7 +29,6 @@ "default_backend_url_blacklist": "https://clientblacklist.wire.com/staging", "default_backend_url_website": "https://wire.com", "default_backend_title": "wire-staging", - "encrypt_proteus_storage": false, "analytics_enabled": false, "picture_in_picture_enabled": true, "analytics_app_key": "8ffae535f1836ed5f58fd5c8a11c00eca07c5438", @@ -53,7 +51,6 @@ "default_backend_url_blacklist": "https://clientblacklist.wire.com/staging", "default_backend_url_website": "https://wire.com", "default_backend_title": "wire-staging", - "encrypt_proteus_storage": true, "analytics_enabled": true, "picture_in_picture_enabled": true, "analytics_app_key": "8ffae535f1836ed5f58fd5c8a11c00eca07c5438", @@ -65,7 +62,6 @@ "logging_enabled": true, "application_is_private_build": true, "development_api_enabled": false, - "encrypt_proteus_storage": true, "analytics_enabled": true, "analytics_app_key": "8ffae535f1836ed5f58fd5c8a11c00eca07c5438", "analytics_server_url": "https://countly.wire.com/" @@ -76,7 +72,6 @@ "logging_enabled": true, "application_is_private_build": true, "development_api_enabled": false, - "encrypt_proteus_storage": true, "analytics_enabled": true, "picture_in_picture_enabled": true, "analytics_app_key": "8ffae535f1836ed5f58fd5c8a11c00eca07c5438", @@ -107,7 +102,6 @@ "force_constant_bitrate_calls": false, "ignore_ssl_certificates": false, "lower_keypackage_limit": false, - "encrypt_proteus_storage": false, "self_deleting_messages": true, "wipe_on_cookie_invalid": false, "wipe_on_device_removal": false, From 8678444246c63da13faa7c6f93dab28cfb35477a Mon Sep 17 00:00:00 2001 From: Mohamad Jaara Date: Mon, 20 Jan 2025 10:25:57 +0100 Subject: [PATCH 2/4] set debug state as var instead of a function --- .../main/kotlin/com/wire/android/ui/debug/DebugDataOptions.kt | 2 +- .../com/wire/android/ui/debug/DebugDataOptionsViewModel.kt | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/app/src/main/kotlin/com/wire/android/ui/debug/DebugDataOptions.kt b/app/src/main/kotlin/com/wire/android/ui/debug/DebugDataOptions.kt index 49de12cbce0..b0dc3665d5b 100644 --- a/app/src/main/kotlin/com/wire/android/ui/debug/DebugDataOptions.kt +++ b/app/src/main/kotlin/com/wire/android/ui/debug/DebugDataOptions.kt @@ -65,7 +65,7 @@ fun DebugDataOptions( ) { LocalSnackbarHostState.current.collectAndShowSnackbar(snackbarFlow = viewModel.infoMessage) DebugDataOptionsContent( - state = viewModel.state(), + state = viewModel.state, appVersion = appVersion, buildVariant = buildVariant, onCopyText = onCopyText, diff --git a/app/src/main/kotlin/com/wire/android/ui/debug/DebugDataOptionsViewModel.kt b/app/src/main/kotlin/com/wire/android/ui/debug/DebugDataOptionsViewModel.kt index 8df44a4752b..e62881265ad 100644 --- a/app/src/main/kotlin/com/wire/android/ui/debug/DebugDataOptionsViewModel.kt +++ b/app/src/main/kotlin/com/wire/android/ui/debug/DebugDataOptionsViewModel.kt @@ -64,7 +64,7 @@ import javax.inject.Inject @ViewModelScopedPreview interface DebugDataOptionsViewModel { val infoMessage: SharedFlow get() = MutableSharedFlow() - fun state(): DebugDataOptionsState = DebugDataOptionsState() + val state: DebugDataOptionsState fun currentAccount(): UserId = UserId("value", "domain") fun checkCrlRevocationList() {} fun restartSlowSyncForRecovery() {} @@ -94,7 +94,7 @@ class DebugDataOptionsViewModelImpl private val getDefaultProtocolUseCase: GetDefaultProtocolUseCase, ) : ViewModel(), DebugDataOptionsViewModel { - var state by mutableStateOf( + override var state by mutableStateOf( DebugDataOptionsState() ) From a72a4a99f0e650f9e96cbdf8cb9c4bb0c30242d2 Mon Sep 17 00:00:00 2001 From: Mohamad Jaara Date: Mon, 20 Jan 2025 10:30:57 +0100 Subject: [PATCH 3/4] set debug state as var instead of a function --- .../com/wire/android/ui/debug/DebugDataOptionsViewModel.kt | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/app/src/main/kotlin/com/wire/android/ui/debug/DebugDataOptionsViewModel.kt b/app/src/main/kotlin/com/wire/android/ui/debug/DebugDataOptionsViewModel.kt index e62881265ad..344d1cffa61 100644 --- a/app/src/main/kotlin/com/wire/android/ui/debug/DebugDataOptionsViewModel.kt +++ b/app/src/main/kotlin/com/wire/android/ui/debug/DebugDataOptionsViewModel.kt @@ -64,7 +64,7 @@ import javax.inject.Inject @ViewModelScopedPreview interface DebugDataOptionsViewModel { val infoMessage: SharedFlow get() = MutableSharedFlow() - val state: DebugDataOptionsState + val state: DebugDataOptionsState get() = DebugDataOptionsState() fun currentAccount(): UserId = UserId("value", "domain") fun checkCrlRevocationList() {} fun restartSlowSyncForRecovery() {} @@ -157,7 +157,6 @@ class DebugDataOptionsViewModelImpl } } - override fun state() = state override fun currentAccount(): UserId = currentAccount override fun checkCrlRevocationList() { From 50f82555abc4f70114319441fb8fa0a7787aeb48 Mon Sep 17 00:00:00 2001 From: Mohamad Jaara Date: Mon, 20 Jan 2025 10:31:09 +0100 Subject: [PATCH 4/4] detekt --- app/src/main/kotlin/com/wire/android/di/KaliumConfigsModule.kt | 1 - 1 file changed, 1 deletion(-) diff --git a/app/src/main/kotlin/com/wire/android/di/KaliumConfigsModule.kt b/app/src/main/kotlin/com/wire/android/di/KaliumConfigsModule.kt index fd337f17ea1..bcf905cd05e 100644 --- a/app/src/main/kotlin/com/wire/android/di/KaliumConfigsModule.kt +++ b/app/src/main/kotlin/com/wire/android/di/KaliumConfigsModule.kt @@ -21,7 +21,6 @@ package com.wire.android.di import android.content.Context import android.os.Build import com.wire.android.BuildConfig -import com.wire.android.datastore.GlobalDataStore import com.wire.android.util.isWebsocketEnabledByDefault import com.wire.kalium.logic.featureFlags.BuildFileRestrictionState import com.wire.kalium.logic.featureFlags.KaliumConfigs