Avoid constantly check env

This commit is contained in:
vvb2060 2022-01-09 02:46:37 +08:00 committed by John Wu
parent 6b67902d53
commit dbf45da8ab

View File

@ -80,7 +80,7 @@ class HomeViewModel(
it.bindExtra(BR.viewModel, this)
}
private var shownDialog = false
private var checkedEnv = false
override fun refresh() = viewModelScope.launch {
state = State.LOADING
@ -136,12 +136,12 @@ class HomeViewModel(
}
private suspend fun ensureEnv() {
if (MagiskState.NOT_INSTALLED == stateMagisk || shownDialog) return
if (MagiskState.NOT_INSTALLED == stateMagisk || checkedEnv) return
val cmd = "env_check ${Info.env.versionString} ${Info.env.versionCode}"
if (!Shell.su(cmd).await().isSuccess) {
shownDialog = true
EnvFixDialog(this).publish()
}
checkedEnv = true
}
}