mirror of
https://github.com/topjohnwu/Magisk.git
synced 2024-12-25 14:37:38 +00:00
SuRequestViewModel: fix await RootService on the main thread
This commit is contained in:
parent
bcdcfa1104
commit
207d7fd3f6
@ -34,6 +34,7 @@ import com.topjohnwu.magisk.events.BiometricEvent
|
|||||||
import com.topjohnwu.magisk.events.DieEvent
|
import com.topjohnwu.magisk.events.DieEvent
|
||||||
import com.topjohnwu.magisk.events.ShowUIEvent
|
import com.topjohnwu.magisk.events.ShowUIEvent
|
||||||
import com.topjohnwu.magisk.utils.TextHolder
|
import com.topjohnwu.magisk.utils.TextHolder
|
||||||
|
import kotlinx.coroutines.Dispatchers
|
||||||
import kotlinx.coroutines.launch
|
import kotlinx.coroutines.launch
|
||||||
import java.util.concurrent.TimeUnit.SECONDS
|
import java.util.concurrent.TimeUnit.SECONDS
|
||||||
|
|
||||||
@ -71,7 +72,8 @@ class SuRequestViewModel(
|
|||||||
}
|
}
|
||||||
|
|
||||||
private val handler = SuRequestHandler(AppContext.packageManager, policyDB)
|
private val handler = SuRequestHandler(AppContext.packageManager, policyDB)
|
||||||
private lateinit var timer: CountDownTimer
|
private val millis = SECONDS.toMillis(Config.suDefaultTimeout.toLong())
|
||||||
|
private var timer = SuTimer(millis, 1000)
|
||||||
private var initialized = false
|
private var initialized = false
|
||||||
|
|
||||||
fun grantPressed() {
|
fun grantPressed() {
|
||||||
@ -97,7 +99,7 @@ class SuRequestViewModel(
|
|||||||
}
|
}
|
||||||
|
|
||||||
fun handleRequest(intent: Intent) {
|
fun handleRequest(intent: Intent) {
|
||||||
viewModelScope.launch {
|
viewModelScope.launch(Dispatchers.Default) {
|
||||||
if (handler.start(intent))
|
if (handler.start(intent))
|
||||||
showDialog()
|
showDialog()
|
||||||
else
|
else
|
||||||
@ -126,8 +128,7 @@ class SuRequestViewModel(
|
|||||||
selectedItemPosition = timeoutPrefs.getInt(packageName, 0)
|
selectedItemPosition = timeoutPrefs.getInt(packageName, 0)
|
||||||
|
|
||||||
// Set timer
|
// Set timer
|
||||||
val millis = SECONDS.toMillis(Config.suDefaultTimeout.toLong())
|
timer.start()
|
||||||
timer = SuTimer(millis, 1000).apply { start() }
|
|
||||||
|
|
||||||
// Actually show the UI
|
// Actually show the UI
|
||||||
ShowUIEvent(if (Config.suTapjack) EmptyAccessibilityDelegate else null).publish()
|
ShowUIEvent(if (Config.suTapjack) EmptyAccessibilityDelegate else null).publish()
|
||||||
|
Loading…
x
Reference in New Issue
Block a user