Skip to content

Commit

Permalink
feat: add a crl revocation list to debug screen (#2804)
Browse files Browse the repository at this point in the history
Co-authored-by: Mohamad Jaara <[email protected]>
  • Loading branch information
AndroidBob and MohamadJaara authored Apr 12, 2024
1 parent 1f2734d commit ca15e59
Show file tree
Hide file tree
Showing 3 changed files with 61 additions and 8 deletions.
5 changes: 5 additions & 0 deletions app/src/main/kotlin/com/wire/android/di/CoreLogicModule.kt
Original file line number Diff line number Diff line change
Expand Up @@ -246,6 +246,11 @@ class UseCaseModule {
@CurrentAccount currentAccount: UserId
) = coreLogic.getSessionScope(currentAccount).getPersistentWebSocketStatus

@ViewModelScoped
@Provides
fun provideCheckCrlRevocationListUseCase(@KaliumCoreLogic coreLogic: CoreLogic, @CurrentAccount currentAccount: UserId) =
coreLogic.getSessionScope(currentAccount).checkCrlRevocationList

@ViewModelScoped
@Provides
fun provideIsMLSEnabledUseCase(@KaliumCoreLogic coreLogic: CoreLogic, @CurrentAccount currentAccount: UserId) =
Expand Down
60 changes: 54 additions & 6 deletions app/src/main/kotlin/com/wire/android/ui/debug/DebugDataOptions.kt
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ import com.wire.kalium.logic.CoreFailure
import com.wire.kalium.logic.E2EIFailure
import com.wire.kalium.logic.data.user.UserId
import com.wire.kalium.logic.feature.debug.DisableEventProcessingUseCase
import com.wire.kalium.logic.feature.e2ei.CheckCrlRevocationListUseCase
import com.wire.kalium.logic.feature.e2ei.usecase.E2EIEnrollmentResult
import com.wire.kalium.logic.feature.keypackage.MLSKeyPackageCountResult
import com.wire.kalium.logic.feature.keypackage.MLSKeyPackageCountUseCase
Expand Down Expand Up @@ -103,7 +104,8 @@ class DebugDataOptionsViewModel
private val updateApiVersions: UpdateApiVersionsScheduler,
private val mlsKeyPackageCountUseCase: MLSKeyPackageCountUseCase,
private val restartSlowSyncProcessForRecovery: RestartSlowSyncProcessForRecoveryUseCase,
private val disableEventProcessingUseCase: DisableEventProcessingUseCase
private val disableEventProcessingUseCase: DisableEventProcessingUseCase,
private val checkCrlRevocationListUseCase: CheckCrlRevocationListUseCase
) : ViewModel() {

var state by mutableStateOf(
Expand Down Expand Up @@ -138,6 +140,14 @@ class DebugDataOptionsViewModel
}
}

fun checkCrlRevocationList() {
viewModelScope.launch {
checkCrlRevocationListUseCase(
forceUpdate = true
)
}
}

fun enableEncryptedProteusStorage(enabled: Boolean) {
if (enabled) {
viewModelScope.launch {
Expand Down Expand Up @@ -272,7 +282,8 @@ fun DebugDataOptions(
onDisableEventProcessingChange = viewModel::disableEventProcessing,
enrollE2EICertificate = viewModel::enrollE2EICertificate,
handleE2EIEnrollmentResult = viewModel::handleE2EIEnrollmentResult,
dismissCertificateDialog = viewModel::dismissCertificateDialog
dismissCertificateDialog = viewModel::dismissCertificateDialog,
checkCrlRevocationList = viewModel::checkCrlRevocationList
)
}

Expand All @@ -290,7 +301,8 @@ fun DebugDataOptionsContent(
onManualMigrationPressed: () -> Unit,
enrollE2EICertificate: () -> Unit,
handleE2EIEnrollmentResult: (Either<CoreFailure, E2EIEnrollmentResult>) -> Unit,
dismissCertificateDialog: () -> Unit
dismissCertificateDialog: () -> Unit,
checkCrlRevocationList: () -> Unit
) {
Column {

Expand Down Expand Up @@ -327,6 +339,16 @@ fun DebugDataOptionsContent(
)
if (BuildConfig.PRIVATE_BUILD) {

SettingsItem(
title = stringResource(R.string.debug_id),
text = state.debugId,
trailingIcon = R.drawable.ic_copy,
onIconPressed = Clickable(
enabled = true,
onClick = { }
)
)

SettingsItem(
title = stringResource(R.string.debug_id),
text = state.debugId,
Expand Down Expand Up @@ -377,7 +399,8 @@ fun DebugDataOptionsContent(
onDisableEventProcessingChange = onDisableEventProcessingChange,
onRestartSlowSyncForRecovery = onRestartSlowSyncForRecovery,
onForceUpdateApiVersions = onForceUpdateApiVersions,
dependenciesMap = state.dependencies
dependenciesMap = state.dependencies,
checkCrlRevocationList = checkCrlRevocationList
)
}

Expand Down Expand Up @@ -546,7 +569,8 @@ private fun DebugToolsOptions(
onDisableEventProcessingChange: (Boolean) -> Unit,
onRestartSlowSyncForRecovery: () -> Unit,
onForceUpdateApiVersions: () -> Unit,
dependenciesMap: ImmutableMap<String, String?>
dependenciesMap: ImmutableMap<String, String?>,
checkCrlRevocationList: () -> Unit
) {
FolderHeader(stringResource(R.string.label_debug_tools_title))
Column {
Expand Down Expand Up @@ -574,6 +598,29 @@ private fun DebugToolsOptions(
)
}
)

// checkCrlRevocationList
RowItemTemplate(
modifier = Modifier.wrapContentWidth(),
title = {
Text(
style = MaterialTheme.wireTypography.body01,
color = MaterialTheme.wireColorScheme.onBackground,
text = "CRL revocation check",
modifier = Modifier.padding(start = dimensions().spacing8x)
)
},
actions = {
WirePrimaryButton(
minSize = MaterialTheme.wireDimensions.buttonMediumMinSize,
minClickableSize = MaterialTheme.wireDimensions.buttonMinClickableSize,
onClick = checkCrlRevocationList,
text = stringResource(R.string.debug_settings_force_api_versioning_update_button_text),
fillMaxWidth = false
)
}
)

RowItemTemplate(
modifier = Modifier.wrapContentWidth(),
title = {
Expand Down Expand Up @@ -670,6 +717,7 @@ fun PreviewOtherDebugOptions() {
onManualMigrationPressed = {},
enrollE2EICertificate = {},
handleE2EIEnrollmentResult = {},
dismissCertificateDialog = {}
dismissCertificateDialog = {},
checkCrlRevocationList = {}
)
}
4 changes: 2 additions & 2 deletions app/src/main/kotlin/com/wire/android/ui/debug/DebugScreen.kt
Original file line number Diff line number Diff line change
Expand Up @@ -70,9 +70,9 @@ fun DebugScreen(navigator: Navigator) {
private fun UserDebugContent(
onNavigationPressed: () -> Unit,
onManualMigrationPressed: (currentAccount: UserId) -> Unit,
) {
userDebugViewModel: UserDebugViewModel = hiltViewModel(),

val userDebugViewModel: UserDebugViewModel = hiltViewModel()
) {
val debugContentState: DebugContentState = rememberDebugContentState(userDebugViewModel.logPath)

WireScaffold(
Expand Down

0 comments on commit ca15e59

Please sign in to comment.