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

View File

@@ -3,6 +3,7 @@ package io.nekohasekai.sfa.vendor
import android.content.Context
import io.nekohasekai.sfa.Application
import io.nekohasekai.sfa.bg.BoxService
import io.nekohasekai.sfa.bg.RootClient
import io.nekohasekai.sfa.database.Settings
import io.nekohasekai.sfa.utils.HookStatusClient
import io.nekohasekai.sfa.xposed.XposedActivation
@@ -62,7 +63,7 @@ object ApkInstaller {
return when (method) {
InstallMethod.PACKAGE_INSTALLER -> canSystemSilentInstall()
InstallMethod.SHIZUKU -> ShizukuInstaller.isAvailable() && ShizukuInstaller.checkPermission()
InstallMethod.ROOT -> RootInstaller.checkAccess()
InstallMethod.ROOT -> RootClient.checkRootAvailable()
}
}
}

View File

@@ -8,6 +8,7 @@ import androidx.camera.core.ImageAnalysis
import com.google.android.material.dialog.MaterialAlertDialogBuilder
import io.nekohasekai.sfa.Application
import io.nekohasekai.sfa.R
import io.nekohasekai.sfa.bg.RootClient
import io.nekohasekai.sfa.database.Settings
import io.nekohasekai.sfa.compose.screen.qrscan.QRCodeCropArea
import io.nekohasekai.sfa.update.UpdateCheckException
@@ -135,7 +136,7 @@ object Vendor : VendorInterface {
}
true
}
"ROOT" -> RootInstaller.checkAccess()
"ROOT" -> RootClient.checkRootAvailable()
else -> false
}
}