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_VERSION = "v20.4"
const val MIN_VERCODE = 20400 const val MIN_VERCODE = 20400
fun atLeast_21_0() = Info.env.magiskVersionCode >= 21000 || isCanary() fun atLeast_21_0() = Info.env.versionCode >= 21000 || isCanary()
fun atLeast_21_2() = Info.env.magiskVersionCode >= 21200 || isCanary() fun atLeast_21_2() = Info.env.versionCode >= 21200 || isCanary()
fun isCanary() = isCanary(Info.env.magiskVersionCode) fun isCanary() = isCanary(Info.env.versionCode)
fun isCanary(ver: Int) = ver > 0 && ver % 100 != 0 fun isCanary(ver: Int) = ver > 0 && ver % 100 != 0
} }

View File

@ -56,14 +56,14 @@ object Info {
) )
class Env( class Env(
val magiskVersionString: String = "", val versionString: String = "",
code: Int = -1 code: Int = -1
) { ) {
val magiskVersionCode = when { val versionCode = when {
code < Const.Version.MIN_VERCODE -> -1 code < Const.Version.MIN_VERCODE -> -1
else -> if (Shell.rootAccess()) code else -1 else -> if (Shell.rootAccess()) code else -1
} }
val isUnsupported = code > 0 && code < Const.Version.MIN_VERCODE 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) CUSTOM_CHANNEL -> fetchCustomUpdate(Config.customChannelUrl)
else -> throw IllegalArgumentException() else -> throw IllegalArgumentException()
} }
if (info.magisk.versionCode < Info.env.magiskVersionCode && if (info.magisk.versionCode < Info.env.versionCode &&
Config.updateChannel == DEFAULT_CHANNEL Config.updateChannel == DEFAULT_CHANNEL
) { ) {
Config.updateChannel = BETA_CHANNEL Config.updateChannel = BETA_CHANNEL

View File

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

View File

@ -75,7 +75,7 @@ class LogViewModel(
FileInputStream("/proc/self/mountinfo").reader().use { it.copyTo(file) } FileInputStream("/proc/self/mountinfo").reader().use { it.copyTo(file) }
file.write("\n---Magisk Logs---\n") 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(consoleText)
file.write("\n---Manager Logs---\n") file.write("\n---Manager Logs---\n")