manager: fix ksud installation failed at first boot.

This commit is contained in:
tiann 2023-01-26 15:51:59 +08:00
parent f6c249bd77
commit 76c88a72c6
No known key found for this signature in database
GPG Key ID: 6D3F65FFD9559C06
3 changed files with 5 additions and 3 deletions

View File

@ -3,7 +3,6 @@ package me.weishu.kernelsu
import android.app.Application
import coil.Coil
import coil.ImageLoader
import me.weishu.kernelsu.ui.util.install
import me.zhanghai.android.appiconloader.coil.AppIconFetcher
import me.zhanghai.android.appiconloader.coil.AppIconKeyer
@ -25,8 +24,6 @@ class KernelSUApplication : Application() {
}
.build()
)
install()
}

View File

@ -36,6 +36,7 @@ import me.weishu.kernelsu.ui.screen.destinations.SettingScreenDestination
import me.weishu.kernelsu.ui.util.LocalSnackbarHost
import me.weishu.kernelsu.ui.util.reboot
import me.weishu.kernelsu.ui.util.getSELinuxStatus
import me.weishu.kernelsu.ui.util.install
@OptIn(ExperimentalMaterial3Api::class)
@RootNavGraph(start = true)
@ -58,6 +59,9 @@ fun HomeScreen(navigator: DestinationsNavigator) {
) {
val kernelVersion = getKernelVersion()
val isManager = Natives.becomeManager(ksuApp.packageName)
SideEffect {
if (isManager) install()
}
val ksuVersion = if (isManager) Natives.getVersion() else null
StatusCard(kernelVersion, ksuVersion)

View File

@ -27,6 +27,7 @@ fun createRootShell(): Shell {
return try {
builder.build(getKsuDaemonPath(), "debug", "su")
} catch (e: Throwable) {
Log.e(TAG, "su failed: ", e)
builder.build("sh")
}
}