mirror of
https://github.com/topjohnwu/Magisk.git
synced 2024-12-24 19:27:41 +00:00
ensureEnv even if getRemote fails
Co-authored-by: vvb2060 <vvb2060@gmail.com>
This commit is contained in:
parent
5c42830328
commit
41b701846f
@ -45,30 +45,32 @@ 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
|
||||||
!Info.env.isActive -> MagiskState.NOT_INSTALLED
|
get() = when {
|
||||||
Info.env.magiskVersionCode < BuildConfig.VERSION_CODE -> MagiskState.OBSOLETE
|
!Info.env.isActive -> MagiskState.NOT_INSTALLED
|
||||||
else -> MagiskState.UP_TO_DATE
|
Info.env.magiskVersionCode < BuildConfig.VERSION_CODE -> MagiskState.OBSOLETE
|
||||||
}
|
else -> MagiskState.UP_TO_DATE
|
||||||
|
}
|
||||||
|
|
||||||
@get:Bindable
|
@get:Bindable
|
||||||
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
|
||||||
if (isActive)
|
get() = Info.env.run {
|
||||||
"$magiskVersionString ($magiskVersionCode)".asText()
|
if (isActive)
|
||||||
else
|
"$magiskVersionString ($magiskVersionCode)".asText()
|
||||||
R.string.not_available.asText()
|
else
|
||||||
}
|
R.string.not_available.asText()
|
||||||
|
}
|
||||||
|
|
||||||
@get:Bindable
|
@get:Bindable
|
||||||
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