Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: remove encrypted proteus storage flag [WPB-15409] #3806

Open
wants to merge 4 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion app/src/main/kotlin/com/wire/android/WireApplication.kt
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
12 changes: 0 additions & 12 deletions app/src/main/kotlin/com/wire/android/datastore/GlobalDataStore.kt
Original file line number Diff line number Diff line change
Expand Up @@ -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")

Expand Down Expand Up @@ -104,16 +102,6 @@ class GlobalDataStore @Inject constructor(@ApplicationContext private val contex
context.dataStore.edit { it[RECORD_AUDIO_EFFECTS_CHECKBOX] = enabled }
}

fun isEncryptedProteusStorageEnabled(): Flow<Boolean> =
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 }
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,23 +21,20 @@ 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
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)
Expand All @@ -55,7 +52,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,
Expand Down
22 changes: 2 additions & 20 deletions app/src/main/kotlin/com/wire/android/ui/debug/DebugDataOptions.kt
Original file line number Diff line number Diff line change
Expand Up @@ -65,11 +65,10 @@ fun DebugDataOptions(
) {
LocalSnackbarHostState.current.collectAndShowSnackbar(snackbarFlow = viewModel.infoMessage)
DebugDataOptionsContent(
state = viewModel.state(),
state = viewModel.state,
appVersion = appVersion,
buildVariant = buildVariant,
onCopyText = onCopyText,
onEnableEncryptedProteusStorageChange = viewModel::enableEncryptedProteusStorage,
onRestartSlowSyncForRecovery = viewModel::restartSlowSyncForRecovery,
onForceUpdateApiVersions = viewModel::forceUpdateApiVersions,
onManualMigrationPressed = { onManualMigrationPressed(viewModel.currentAccount()) },
Expand All @@ -89,7 +88,6 @@ fun DebugDataOptionsContent(
appVersion: String,
buildVariant: String,
onCopyText: (String) -> Unit,
onEnableEncryptedProteusStorageChange: (Boolean) -> Unit,
onDisableEventProcessingChange: (Boolean) -> Unit,
onRestartSlowSyncForRecovery: () -> Unit,
onForceUpdateApiVersions: () -> Unit,
Expand Down Expand Up @@ -198,10 +196,7 @@ fun DebugDataOptionsContent(
)
}
}
ProteusOptions(
isEncryptedStorageEnabled = state.isEncryptedProteusStorageEnabled,
onEncryptedStorageEnabledChange = onEnableEncryptedProteusStorageChange
)

if (BuildConfig.DEBUG) {
MLSOptions(
keyPackagesCount = state.keyPackagesCount,
Expand Down Expand Up @@ -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(
Expand Down Expand Up @@ -539,15 +523,13 @@ fun PreviewOtherDebugOptions() = WireTheme {
buildVariant = "debug",
onCopyText = {},
state = DebugDataOptionsState(
isEncryptedProteusStorageEnabled = true,
keyPackagesCount = 10,
mslClientId = "clientId",
mlsErrorMessage = "error",
isManualMigrationAllowed = true,
debugId = "debugId",
commitish = "commitish"
),
onEnableEncryptedProteusStorageChange = {},
onForceUpdateApiVersions = {},
onDisableEventProcessingChange = {},
onRestartSlowSyncForRecovery = {},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,10 +64,9 @@ import javax.inject.Inject
@ViewModelScopedPreview
interface DebugDataOptionsViewModel {
val infoMessage: SharedFlow<UIText> get() = MutableSharedFlow()
fun state(): DebugDataOptionsState = DebugDataOptionsState()
val state: DebugDataOptionsState get() = DebugDataOptionsState()
fun currentAccount(): UserId = UserId("value", "domain")
fun checkCrlRevocationList() {}
fun enableEncryptedProteusStorage(enabled: Boolean) {}
fun restartSlowSyncForRecovery() {}
fun enrollE2EICertificate() {}
fun handleE2EIEnrollmentResult(result: Either<CoreFailure, E2EIEnrollmentResult>) {}
Expand Down Expand Up @@ -95,15 +94,14 @@ class DebugDataOptionsViewModelImpl
private val getDefaultProtocolUseCase: GetDefaultProtocolUseCase,
) : ViewModel(), DebugDataOptionsViewModel {

var state by mutableStateOf(
override var state by mutableStateOf(
DebugDataOptionsState()
)

private val _infoMessage = MutableSharedFlow<UIText>()
override val infoMessage = _infoMessage.asSharedFlow()

init {
observeEncryptedProteusStorageState()
observeMlsMetadata()
checkIfCanTriggerManualMigration()
setGitHashAndDeviceId()
Expand Down Expand Up @@ -159,7 +157,6 @@ class DebugDataOptionsViewModelImpl
}
}

override fun state() = state
override fun currentAccount(): UserId = currentAccount

override fun checkCrlRevocationList() {
Expand All @@ -170,14 +167,6 @@ class DebugDataOptionsViewModelImpl
}
}

override fun enableEncryptedProteusStorage(enabled: Boolean) {
if (enabled) {
viewModelScope.launch {
globalDataStore.setEncryptedProteusStorageEnabled(true)
}
}
}

override fun restartSlowSyncForRecovery() {
viewModelScope.launch {
restartSlowSyncProcessForRecovery()
Expand Down Expand Up @@ -257,15 +246,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
Expand Down
10 changes: 2 additions & 8 deletions app/src/private/kotlin/com/wire/android/ExternalLoggerManager.kt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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())
}
}
6 changes: 0 additions & 6 deletions default.json
Original file line number Diff line number Diff line change
Expand Up @@ -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/"
Expand All @@ -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",
Expand All @@ -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",
Expand All @@ -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/"
Expand All @@ -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",
Expand Down Expand Up @@ -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,
Expand Down
Loading