mirror of
https://github.com/wgtunnel/android.git
synced 2026-07-03 14:07:49 +02:00
24 lines
602 B
Kotlin
24 lines
602 B
Kotlin
package com.zaneschepke.wireguardautotunnel.util
|
|
|
|
import com.wireguard.android.util.RootShell
|
|
import kotlinx.coroutines.CoroutineDispatcher
|
|
import kotlinx.coroutines.withContext
|
|
|
|
class RootShellUtils(
|
|
private val rootShell: RootShell,
|
|
private val ioDispatcher: CoroutineDispatcher,
|
|
) {
|
|
|
|
suspend fun requestRoot(): Boolean =
|
|
withContext(ioDispatcher) {
|
|
val accepted =
|
|
try {
|
|
rootShell.start()
|
|
true
|
|
} catch (_: Exception) {
|
|
false
|
|
}
|
|
accepted
|
|
}
|
|
}
|