Rename magiskVersion* -> version*

This commit is contained in:
topjohnwu 2021-12-14 02:59:06 -08:00
parent 41b701846f
commit ad47dba064
5 changed files with 11 additions and 11 deletions

View File

@ -31,9 +31,9 @@ object Const {
const val MIN_VERSION = "v20.4"
const val MIN_VERCODE = 20400
fun atLeast_21_0() = Info.env.magiskVersionCode >= 21000 || isCanary()
fun atLeast_21_2() = Info.env.magiskVersionCode >= 21200 || isCanary()
fun isCanary() = isCanary(Info.env.magiskVersionCode)
fun atLeast_21_0() = Info.env.versionCode >= 21000 || isCanary()
fun atLeast_21_2() = Info.env.versionCode >= 21200 || isCanary()
fun isCanary() = isCanary(Info.env.versionCode)
fun isCanary(ver: Int) = ver > 0 && ver % 100 != 0
}

View File

@ -56,14 +56,14 @@ object Info {
)
class Env(
val magiskVersionString: String = "",
val versionString: String = "",
code: Int = -1
) {
val magiskVersionCode = when {
val versionCode = when {
code < Const.Version.MIN_VERCODE -> -1
else -> if (Shell.rootAccess()) code else -1
}
val isUnsupported = code > 0 && code < Const.Version.MIN_VERCODE
val isActive = magiskVersionCode >= 0
val isActive = versionCode >= 0
}
}

View File

@ -26,7 +26,7 @@ class NetworkService(
CUSTOM_CHANNEL -> fetchCustomUpdate(Config.customChannelUrl)
else -> throw IllegalArgumentException()
}
if (info.magisk.versionCode < Info.env.magiskVersionCode &&
if (info.magisk.versionCode < Info.env.versionCode &&
Config.updateChannel == DEFAULT_CHANNEL
) {
Config.updateChannel = BETA_CHANNEL

View File

@ -48,7 +48,7 @@ class HomeViewModel(
val stateMagisk
get() = when {
!Info.env.isActive -> MagiskState.NOT_INSTALLED
Info.env.magiskVersionCode < BuildConfig.VERSION_CODE -> MagiskState.OBSOLETE
Info.env.versionCode < BuildConfig.VERSION_CODE -> MagiskState.OBSOLETE
else -> MagiskState.UP_TO_DATE
}
@ -59,7 +59,7 @@ class HomeViewModel(
val magiskInstalledVersion
get() = Info.env.run {
if (isActive)
"$magiskVersionString ($magiskVersionCode)".asText()
"$versionString ($versionCode)".asText()
else
R.string.not_available.asText()
}
@ -137,7 +137,7 @@ class HomeViewModel(
private suspend fun ensureEnv() {
if (MagiskState.NOT_INSTALLED == stateMagisk || shownDialog) return
val cmd = "env_check ${Info.env.magiskVersionString} ${Info.env.magiskVersionCode}"
val cmd = "env_check ${Info.env.versionString} ${Info.env.versionCode}"
if (!Shell.su(cmd).await().isSuccess) {
shownDialog = true
EnvFixDialog().publish()

View File

@ -75,7 +75,7 @@ class LogViewModel(
FileInputStream("/proc/self/mountinfo").reader().use { it.copyTo(file) }
file.write("\n---Magisk Logs---\n")
file.write("${Info.env.magiskVersionString} (${Info.env.magiskVersionCode})\n\n")
file.write("${Info.env.versionString} (${Info.env.versionCode})\n\n")
file.write(consoleText)
file.write("\n---Manager Logs---\n")