manager: Fix crash when no root

This commit is contained in:
tiann
2023-01-01 23:11:13 +08:00
parent 4fc8a62374
commit 6d2762b1e1
3 changed files with 41 additions and 39 deletions

View File

@@ -1,14 +1,11 @@
package me.weishu.kernelsu
import android.app.Application
import android.util.Log
import coil.Coil
import coil.ImageLoader
import com.topjohnwu.superuser.Shell
import com.topjohnwu.superuser.ShellUtils
import me.weishu.kernelsu.ui.util.install
import me.zhanghai.android.appiconloader.coil.AppIconFetcher
import me.zhanghai.android.appiconloader.coil.AppIconKeyer
import java.io.File
lateinit var ksuApp: KernelSUApplication
@@ -32,17 +29,5 @@ class KernelSUApplication : Application() {
install()
}
fun createRootShell(): Shell {
Shell.enableVerboseLogging = BuildConfig.DEBUG
val su = applicationInfo.nativeLibraryDir + File.separator + "libksu.so"
val builder = Shell.Builder.create()
return builder.build(su)
}
fun install() {
val shell = createRootShell()
val ksduLib = ksuApp.applicationInfo.nativeLibraryDir + File.separator + "libksud.so"
val result = ShellUtils.fastCmdResult(shell, "$ksduLib install")
Log.w("KernelSU", "install ksud result: $result")
}
}