Add a debug slash command to crash the application from the timeline screen.

This commit is contained in:
Benoit Marty 2023-01-27 13:29:00 +01:00
parent 3ab465ea93
commit 25a09bc446
3 changed files with 10 additions and 1 deletions

View File

@ -10,6 +10,8 @@
<!-- onboarding english only word play -->
<string name="cut_the_slack_from_teams" translatable="false">Cut the slack from teams.</string>
<string name="command_description_crash_application" translatable="false">Crash the application.</string>
<!-- WIP -->
<string name="location_map_view_copyright" translatable="false">© MapTiler © OpenStreetMap contributors</string>
</resources>

View File

@ -32,6 +32,7 @@ enum class Command(
val isDevCommand: Boolean,
val isThreadCommand: Boolean
) {
CRASH_APP("/crash", null, "", R.string.command_description_crash_application, true, true),
EMOTE("/me", null, "<message>", R.string.command_description_emote, false, true),
BAN_USER("/ban", null, "<user-id> [reason]", R.string.command_description_ban_user, false, false),
UNBAN_USER("/unban", null, "<user-id> [reason]", R.string.command_description_unban_user, false, false),

View File

@ -20,13 +20,16 @@ import im.vector.app.core.extensions.isEmail
import im.vector.app.core.extensions.isMsisdn
import im.vector.app.core.extensions.orEmpty
import im.vector.app.features.home.room.detail.ChatEffect
import im.vector.app.features.settings.VectorPreferences
import org.matrix.android.sdk.api.MatrixPatterns
import org.matrix.android.sdk.api.MatrixUrls.isMxcUrl
import org.matrix.android.sdk.api.session.identity.ThreePid
import timber.log.Timber
import javax.inject.Inject
class CommandParser @Inject constructor() {
class CommandParser @Inject constructor(
private val vectorPreferences: VectorPreferences
) {
/**
* Convert the text message into a Slash command.
@ -404,6 +407,9 @@ class CommandParser @Inject constructor() {
ParsedCommand.ErrorSyntax(Command.UPGRADE_ROOM)
}
}
Command.CRASH_APP.matches(slashCommand) && vectorPreferences.developerMode() -> {
throw RuntimeException("Application crashed from user demand")
}
else -> {
// Unknown command
ParsedCommand.ErrorUnknownSlashCommand(slashCommand)