Skip to content

Commit

Permalink
Add more debug information (WPB-14930)
Browse files Browse the repository at this point in the history
  • Loading branch information
sbakhtiarov committed Dec 10, 2024
1 parent 062f329 commit 5f5acff
Show file tree
Hide file tree
Showing 4 changed files with 79 additions and 1 deletion.
15 changes: 15 additions & 0 deletions app/src/main/kotlin/com/wire/android/ui/debug/DebugDataOptions.kt
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,21 @@ fun DebugDataOptionsContent(
)
)

Column {
SettingsItem(
title = "Federation Enabled",
text = state.isFederationEnabled.toString(),
)
SettingsItem(
title = "Default Backend Protocol",
text = state.defaultProtocol,
)
SettingsItem(
title = "Current API Version",
text = state.currentApiVersion.toString(),
)
}

if (BuildConfig.DEBUG) {
GetE2EICertificateSwitch(
enrollE2EI = enrollE2EICertificate
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,5 +29,8 @@ data class DebugDataOptionsState(
val certificate: String = "null",
val showCertificate: Boolean = false,
val startGettingE2EICertificate: Boolean = false,
val analyticsTrackingId: String = "null"
val analyticsTrackingId: String = "null",
val isFederationEnabled: Boolean = false,
val currentApiVersion: Int = 0,
val defaultProtocol: String = "null",
)
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ import com.wire.android.util.getGitBuildId
import com.wire.android.util.ui.UIText
import com.wire.kalium.logic.CoreFailure
import com.wire.kalium.logic.E2EIFailure
import com.wire.kalium.logic.data.user.SupportedProtocol
import com.wire.kalium.logic.data.user.UserId
import com.wire.kalium.logic.feature.analytics.GetCurrentAnalyticsTrackingIdentifierUseCase
import com.wire.kalium.logic.feature.e2ei.CheckCrlRevocationListUseCase
Expand All @@ -42,6 +43,8 @@ import com.wire.kalium.logic.feature.keypackage.MLSKeyPackageCountResult
import com.wire.kalium.logic.feature.keypackage.MLSKeyPackageCountUseCase
import com.wire.kalium.logic.feature.notificationToken.SendFCMTokenError
import com.wire.kalium.logic.feature.notificationToken.SendFCMTokenUseCase
import com.wire.kalium.logic.feature.user.GetDefaultProtocolUseCase
import com.wire.kalium.logic.feature.user.SelfServerConfigUseCase
import com.wire.kalium.logic.functional.Either
import com.wire.kalium.logic.functional.fold
import com.wire.kalium.logic.sync.periodic.UpdateApiVersionsScheduler
Expand Down Expand Up @@ -87,6 +90,8 @@ class DebugDataOptionsViewModelImpl
private val getCurrentAnalyticsTrackingIdentifier: GetCurrentAnalyticsTrackingIdentifierUseCase,
private val sendFCMToken: SendFCMTokenUseCase,
private val dispatcherProvider: DispatcherProvider,
private val selfServerConfigUseCase: SelfServerConfigUseCase,
private val getDefaultProtocolUseCase: GetDefaultProtocolUseCase,
) : ViewModel(), DebugDataOptionsViewModel {

var state by mutableStateOf(
Expand All @@ -102,6 +107,31 @@ class DebugDataOptionsViewModelImpl
checkIfCanTriggerManualMigration()
setGitHashAndDeviceId()
setAnalyticsTrackingId()
setServerConfigData()
setDefaultProtocol()
}

private fun setDefaultProtocol() {
viewModelScope.launch {
state = state.copy(
defaultProtocol = when (getDefaultProtocolUseCase()) {
SupportedProtocol.PROTEUS -> "Proteus"
SupportedProtocol.MLS -> "MLS"
}
)
}
}

private fun setServerConfigData() {
viewModelScope.launch {
val result = selfServerConfigUseCase()
if (result is SelfServerConfigUseCase.Result.Success) {
state = state.copy(
isFederationEnabled = result.serverLinks.metaData.federation,
currentApiVersion = result.serverLinks.metaData.commonApiVersion.version,
)
}
}
}

private fun setAnalyticsTrackingId() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,21 +31,27 @@ import com.wire.android.ui.debug.DebugDataOptionsViewModelImpl
import com.wire.android.util.getDeviceIdString
import com.wire.android.util.getGitBuildId
import com.wire.android.util.ui.UIText
import com.wire.kalium.logic.configuration.server.CommonApiVersionType
import com.wire.kalium.logic.configuration.server.ServerConfig
import com.wire.kalium.logic.data.conversation.ClientId
import com.wire.kalium.logic.data.user.SupportedProtocol
import com.wire.kalium.logic.data.user.UserId
import com.wire.kalium.logic.feature.analytics.GetCurrentAnalyticsTrackingIdentifierUseCase
import com.wire.kalium.logic.feature.e2ei.CheckCrlRevocationListUseCase
import com.wire.kalium.logic.feature.keypackage.MLSKeyPackageCountResult
import com.wire.kalium.logic.feature.keypackage.MLSKeyPackageCountUseCase
import com.wire.kalium.logic.feature.notificationToken.SendFCMTokenError
import com.wire.kalium.logic.feature.notificationToken.SendFCMTokenUseCase
import com.wire.kalium.logic.feature.user.GetDefaultProtocolUseCase
import com.wire.kalium.logic.feature.user.SelfServerConfigUseCase
import com.wire.kalium.logic.functional.Either
import com.wire.kalium.logic.sync.periodic.UpdateApiVersionsScheduler
import com.wire.kalium.logic.sync.slow.RestartSlowSyncProcessForRecoveryUseCase
import io.mockk.MockKAnnotations
import io.mockk.coEvery
import io.mockk.every
import io.mockk.impl.annotations.MockK
import io.mockk.mockk
import io.mockk.mockkStatic
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.ExperimentalCoroutinesApi
Expand Down Expand Up @@ -155,6 +161,12 @@ internal class DebugDataOptionsHiltArrangement {
@MockK
lateinit var getCurrentAnalyticsTrackingIdentifier: GetCurrentAnalyticsTrackingIdentifierUseCase

@MockK
lateinit var selfServerConfigUseCase: SelfServerConfigUseCase

@MockK
lateinit var getDefaultProtocolUseCase: GetDefaultProtocolUseCase

@MockK
lateinit var sendFCMToken: SendFCMTokenUseCase

Expand All @@ -170,6 +182,8 @@ internal class DebugDataOptionsHiltArrangement {
getCurrentAnalyticsTrackingIdentifier = getCurrentAnalyticsTrackingIdentifier,
sendFCMToken = sendFCMToken,
dispatcherProvider = TestDispatcherProvider(),
selfServerConfigUseCase = selfServerConfigUseCase,
getDefaultProtocolUseCase = getDefaultProtocolUseCase,
)
}

Expand All @@ -196,6 +210,22 @@ internal class DebugDataOptionsHiltArrangement {
coEvery {
globalDataStore.getUserMigrationStatus(TestUser.SELF_USER_ID.value)
} returns flowOf(UserMigrationStatus.NoNeed)
coEvery {
selfServerConfigUseCase()
} returns SelfServerConfigUseCase.Result.Success(
ServerConfig(
id = "id",
links = mockk(),
metaData = ServerConfig.MetaData(
federation = true,
commonApiVersion = CommonApiVersionType.Unknown,
domain = null,
)
)
)
every {
getDefaultProtocolUseCase()
} returns SupportedProtocol.PROTEUS
}

fun arrange() = this to viewModel
Expand Down

0 comments on commit 5f5acff

Please sign in to comment.