Fix root detection for KernelSU

Use libsu's Shell API instead of Runtime.exec("su -c ...") for root
detection. The previous approach assumed su is in PATH, which works
for Magisk but not for KernelSU where su has a different path.
This commit is contained in:
世界
2026-01-14 14:05:07 +08:00
parent 65f6529ff1
commit cd0ae262f1
6 changed files with 10 additions and 26 deletions
@@ -18,16 +18,6 @@ import kotlin.coroutines.resumeWithException
object RootInstaller {
suspend fun checkAccess(): Boolean = withContext(Dispatchers.IO) {
try {
val process = Runtime.getRuntime().exec("su -c echo test")
val exitCode = process.waitFor()
exitCode == 0
} catch (e: Exception) {
false
}
}
suspend fun install(apkFile: File) {
withContext(Dispatchers.IO) {
bindRootService().use { handle ->