More debug indication in UI

Close #5874
This commit is contained in:
topjohnwu
2022-05-30 01:53:07 -07:00
parent 5e6eb8dd01
commit 50e2f33d1c
4 changed files with 22 additions and 8 deletions

View File

@@ -52,13 +52,17 @@ object Info {
}
}
private fun loadState() = Env(
fastCmd("magisk -v").split(":".toRegex())[0],
runCatching { fastCmd("magisk -V").toInt() }.getOrDefault(-1)
)
private fun loadState(): Env {
val v = fastCmd("magisk -v").split(":".toRegex())
return Env(
v[0], v.size >= 3 && v[2] == "D",
runCatching { fastCmd("magisk -V").toInt() }.getOrDefault(-1)
)
}
class Env(
val versionString: String = "",
val isDebug: Boolean = false,
code: Int = -1
) {
val versionCode = when {

View File

@@ -57,7 +57,7 @@ class HomeViewModel(
val magiskInstalledVersion
get() = Info.env.run {
if (isActive)
"$versionString ($versionCode)".asText()
("$versionString ($versionCode)" + if (isDebug) " (D)" else "").asText()
else
R.string.not_available.asText()
}
@@ -93,8 +93,10 @@ class HomeViewModel(
else -> MagiskState.UP_TO_DATE
}
val isDebug = Config.updateChannel == Config.Value.DEBUG_CHANNEL
managerRemoteVersion =
"${magisk.version} (${magisk.versionCode}) (${stub.versionCode})".asText()
("${magisk.version} (${magisk.versionCode}) (${stub.versionCode})" +
if (isDebug) " (D)" else "").asText()
} ?: run {
state = State.LOADING_FAILED
managerRemoteVersion = R.string.not_available.asText()