mirror of
https://github.com/topjohnwu/Magisk.git
synced 2024-12-25 07:17:38 +00:00
ensureEnv even if getRemote fails
Co-authored-by: vvb2060 <vvb2060@gmail.com>
This commit is contained in:
parent
5c42830328
commit
41b701846f
@ -45,7 +45,8 @@ class HomeViewModel(
|
|||||||
var isNoticeVisible = Config.safetyNotice
|
var isNoticeVisible = Config.safetyNotice
|
||||||
set(value) = set(value, field, { field = it }, BR.noticeVisible)
|
set(value) = set(value, field, { field = it }, BR.noticeVisible)
|
||||||
|
|
||||||
val stateMagisk = when {
|
val stateMagisk
|
||||||
|
get() = when {
|
||||||
!Info.env.isActive -> MagiskState.NOT_INSTALLED
|
!Info.env.isActive -> MagiskState.NOT_INSTALLED
|
||||||
Info.env.magiskVersionCode < BuildConfig.VERSION_CODE -> MagiskState.OBSOLETE
|
Info.env.magiskVersionCode < BuildConfig.VERSION_CODE -> MagiskState.OBSOLETE
|
||||||
else -> MagiskState.UP_TO_DATE
|
else -> MagiskState.UP_TO_DATE
|
||||||
@ -55,7 +56,8 @@ class HomeViewModel(
|
|||||||
var stateManager = MagiskState.LOADING
|
var stateManager = MagiskState.LOADING
|
||||||
set(value) = set(value, field, { field = it }, BR.stateManager)
|
set(value) = set(value, field, { field = it }, BR.stateManager)
|
||||||
|
|
||||||
val magiskInstalledVersion get() = Info.env.run {
|
val magiskInstalledVersion
|
||||||
|
get() = Info.env.run {
|
||||||
if (isActive)
|
if (isActive)
|
||||||
"$magiskVersionString ($magiskVersionCode)".asText()
|
"$magiskVersionString ($magiskVersionCode)".asText()
|
||||||
else
|
else
|
||||||
@ -66,9 +68,9 @@ class HomeViewModel(
|
|||||||
var managerRemoteVersion = R.string.loading.asText()
|
var managerRemoteVersion = R.string.loading.asText()
|
||||||
set(value) = set(value, field, { field = it }, BR.managerRemoteVersion)
|
set(value) = set(value, field, { field = it }, BR.managerRemoteVersion)
|
||||||
|
|
||||||
val managerInstalledVersion = Info.stub?.let {
|
val managerInstalledVersion
|
||||||
"${BuildConfig.VERSION_NAME} (${BuildConfig.VERSION_CODE}) (${it.version})"
|
get() = "${BuildConfig.VERSION_NAME} (${BuildConfig.VERSION_CODE})" +
|
||||||
} ?: "${BuildConfig.VERSION_NAME} (${BuildConfig.VERSION_CODE})"
|
Info.stub?.let { " (${it.version})" }.orEmpty()
|
||||||
|
|
||||||
@get:Bindable
|
@get:Bindable
|
||||||
var stateManagerProgress = 0
|
var stateManagerProgress = 0
|
||||||
@ -92,14 +94,11 @@ class HomeViewModel(
|
|||||||
|
|
||||||
managerRemoteVersion =
|
managerRemoteVersion =
|
||||||
"${magisk.version} (${magisk.versionCode}) (${stub.versionCode})".asText()
|
"${magisk.version} (${magisk.versionCode}) (${stub.versionCode})".asText()
|
||||||
|
|
||||||
launch {
|
|
||||||
ensureEnv()
|
|
||||||
}
|
|
||||||
} ?: run {
|
} ?: run {
|
||||||
state = State.LOADING_FAILED
|
state = State.LOADING_FAILED
|
||||||
managerRemoteVersion = R.string.not_available.asText()
|
managerRemoteVersion = R.string.not_available.asText()
|
||||||
}
|
}
|
||||||
|
ensureEnv()
|
||||||
}
|
}
|
||||||
|
|
||||||
val showTest = false
|
val showTest = false
|
||||||
@ -137,14 +136,9 @@ class HomeViewModel(
|
|||||||
}
|
}
|
||||||
|
|
||||||
private suspend fun ensureEnv() {
|
private suspend fun ensureEnv() {
|
||||||
val invalidStates = listOf(
|
if (MagiskState.NOT_INSTALLED == stateMagisk || shownDialog) return
|
||||||
MagiskState.NOT_INSTALLED,
|
val cmd = "env_check ${Info.env.magiskVersionString} ${Info.env.magiskVersionCode}"
|
||||||
MagiskState.LOADING
|
if (!Shell.su(cmd).await().isSuccess) {
|
||||||
)
|
|
||||||
if (invalidStates.any { it == stateMagisk } || shownDialog) return
|
|
||||||
|
|
||||||
val result = Shell.su("env_check ${Info.env.magiskVersionString} ${Info.env.magiskVersionCode}").await()
|
|
||||||
if (!result.isSuccess) {
|
|
||||||
shownDialog = true
|
shownDialog = true
|
||||||
EnvFixDialog().publish()
|
EnvFixDialog().publish()
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user