From dbf45da8ab497d317bbc5997b7f0b0d00f387d47 Mon Sep 17 00:00:00 2001 From: vvb2060 Date: Sun, 9 Jan 2022 02:46:37 +0800 Subject: [PATCH] Avoid constantly check env --- .../main/java/com/topjohnwu/magisk/ui/home/HomeViewModel.kt | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) 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 1e8028531..938eb1321 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 @@ -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 } }