From ad47dba06443f31c4f903c9c145908c11a264e85 Mon Sep 17 00:00:00 2001 From: topjohnwu Date: Tue, 14 Dec 2021 02:59:06 -0800 Subject: [PATCH] Rename magiskVersion* -> version* --- app/src/main/java/com/topjohnwu/magisk/core/Const.kt | 6 +++--- app/src/main/java/com/topjohnwu/magisk/core/Info.kt | 6 +++--- .../com/topjohnwu/magisk/data/repository/NetworkService.kt | 2 +- .../main/java/com/topjohnwu/magisk/ui/home/HomeViewModel.kt | 6 +++--- .../main/java/com/topjohnwu/magisk/ui/log/LogViewModel.kt | 2 +- 5 files changed, 11 insertions(+), 11 deletions(-) diff --git a/app/src/main/java/com/topjohnwu/magisk/core/Const.kt b/app/src/main/java/com/topjohnwu/magisk/core/Const.kt index db818caa2..e45b6a918 100644 --- a/app/src/main/java/com/topjohnwu/magisk/core/Const.kt +++ b/app/src/main/java/com/topjohnwu/magisk/core/Const.kt @@ -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 } diff --git a/app/src/main/java/com/topjohnwu/magisk/core/Info.kt b/app/src/main/java/com/topjohnwu/magisk/core/Info.kt index 821253f5f..2fca909ab 100644 --- a/app/src/main/java/com/topjohnwu/magisk/core/Info.kt +++ b/app/src/main/java/com/topjohnwu/magisk/core/Info.kt @@ -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 } } diff --git a/app/src/main/java/com/topjohnwu/magisk/data/repository/NetworkService.kt b/app/src/main/java/com/topjohnwu/magisk/data/repository/NetworkService.kt index 62d7c5c16..88f2dc222 100644 --- a/app/src/main/java/com/topjohnwu/magisk/data/repository/NetworkService.kt +++ b/app/src/main/java/com/topjohnwu/magisk/data/repository/NetworkService.kt @@ -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 diff --git a/app/src/main/java/com/topjohnwu/magisk/ui/home/HomeViewModel.kt b/app/src/main/java/com/topjohnwu/magisk/ui/home/HomeViewModel.kt index b87973929..b4649a24e 100644 --- a/app/src/main/java/com/topjohnwu/magisk/ui/home/HomeViewModel.kt +++ b/app/src/main/java/com/topjohnwu/magisk/ui/home/HomeViewModel.kt @@ -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() diff --git a/app/src/main/java/com/topjohnwu/magisk/ui/log/LogViewModel.kt b/app/src/main/java/com/topjohnwu/magisk/ui/log/LogViewModel.kt index b4a23aab5..3b24e6a11 100644 --- a/app/src/main/java/com/topjohnwu/magisk/ui/log/LogViewModel.kt +++ b/app/src/main/java/com/topjohnwu/magisk/ui/log/LogViewModel.kt @@ -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")