Files
KsuWebUIStandalone/app/src/main/java/io/github/a13e300/ksuwebui/Util.kt
2024-10-04 15:11:11 +08:00

20 lines
478 B
Kotlin

package io.github.a13e300.ksuwebui
import com.topjohnwu.superuser.Shell
inline fun <T> withNewRootShell(
globalMnt: Boolean = false,
block: Shell.() -> T
): T {
return createRootShell(globalMnt).use(block)
}
fun createRootShell(globalMnt: Boolean = false): Shell {
Shell.enableVerboseLogging = BuildConfig.DEBUG
val builder = Shell.Builder.create()
if (globalMnt) {
builder.setFlags(Shell.FLAG_MOUNT_MASTER)
}
return builder.build()
}