Commit 78a444d6 authored by topjohnwu's avatar topjohnwu Committed by John Wu

Wait for root service to bind

parent 37b81ad1
......@@ -111,15 +111,23 @@ class RootUtils(stub: Any?) : RootService() {
}
fun await() {
// We cannot await on the main thread
if (Info.isRooted && !ShellUtils.onMainThread())
if (!Info.isRooted)
return
if (!ShellUtils.onMainThread()) {
acquireSharedInterruptibly(1)
} else if (state != 0) {
throw IllegalStateException("Cannot await on the main thread")
}
}
}
companion object {
var bindTask: Shell.Task? = null
var fs = FileSystemManager.getLocal()
var fs: FileSystemManager = FileSystemManager.getLocal()
get() {
Connection.await()
return field
}
private set
var obj: IRootUtils? = null
get() {
......
......@@ -35,7 +35,7 @@ class ModuleViewModel : AsyncLoadViewModel() {
var loading = true
private set(value) = set(value, field, { field = it }, BR.loading)
init {
private suspend fun init() = withContext(Dispatchers.IO) {
if (Info.env.isActive && LocalModule.loaded()) {
items.insertItem(InstallModule)
.insertList(itemsInstalled)
......@@ -44,6 +44,9 @@ class ModuleViewModel : AsyncLoadViewModel() {
override suspend fun doLoadWork() {
loading = true
if (items.isEmpty()) {
init()
}
loadInstalled()
loading = false
loadUpdateInfo()
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment