From 76c88a72c616421295643777a64790d65fcd3605 Mon Sep 17 00:00:00 2001 From: tiann Date: Thu, 26 Jan 2023 15:51:59 +0800 Subject: [PATCH] manager: fix ksud installation failed at first boot. --- .../src/main/java/me/weishu/kernelsu/KernelSUApplication.kt | 3 --- .../app/src/main/java/me/weishu/kernelsu/ui/screen/Home.kt | 4 ++++ .../app/src/main/java/me/weishu/kernelsu/ui/util/KsuCli.kt | 1 + 3 files changed, 5 insertions(+), 3 deletions(-) diff --git a/manager/app/src/main/java/me/weishu/kernelsu/KernelSUApplication.kt b/manager/app/src/main/java/me/weishu/kernelsu/KernelSUApplication.kt index 4b6f463d89f6..11084934709c 100644 --- a/manager/app/src/main/java/me/weishu/kernelsu/KernelSUApplication.kt +++ b/manager/app/src/main/java/me/weishu/kernelsu/KernelSUApplication.kt @@ -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() } diff --git a/manager/app/src/main/java/me/weishu/kernelsu/ui/screen/Home.kt b/manager/app/src/main/java/me/weishu/kernelsu/ui/screen/Home.kt index 6c22704c7c46..7cab9155e270 100644 --- a/manager/app/src/main/java/me/weishu/kernelsu/ui/screen/Home.kt +++ b/manager/app/src/main/java/me/weishu/kernelsu/ui/screen/Home.kt @@ -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) diff --git a/manager/app/src/main/java/me/weishu/kernelsu/ui/util/KsuCli.kt b/manager/app/src/main/java/me/weishu/kernelsu/ui/util/KsuCli.kt index d99bcfd924f0..10fb44569960 100644 --- a/manager/app/src/main/java/me/weishu/kernelsu/ui/util/KsuCli.kt +++ b/manager/app/src/main/java/me/weishu/kernelsu/ui/util/KsuCli.kt @@ -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") } }