diff --git a/manager/app/src/main/java/shirkneko/zako/sukisu/ui/screen/Home.kt b/manager/app/src/main/java/shirkneko/zako/sukisu/ui/screen/Home.kt index 4b34f607..364c2584 100644 --- a/manager/app/src/main/java/shirkneko/zako/sukisu/ui/screen/Home.kt +++ b/manager/app/src/main/java/shirkneko/zako/sukisu/ui/screen/Home.kt @@ -51,7 +51,6 @@ import androidx.compose.animation.shrinkVertically import androidx.compose.runtime.saveable.rememberSaveable import shirkneko.zako.sukisu.ui.theme.CardConfig import androidx.core.content.edit -import shirkneko.zako.sukisu.ui.util.KernelConfigUtils.isKpmEnabled @OptIn(ExperimentalMaterial3Api::class) @Destination(start = true) @@ -156,11 +155,10 @@ fun HomeScreen(navigator: DestinationsNavigator) { } InfoCard() if (!isSimpleMode) { + ContributionCard() DonateCard() LearnMoreCard() - ContributionCard() } - Spacer(Modifier) } } @@ -349,15 +347,6 @@ private fun StatusCard( style = MaterialTheme.typography.bodyMedium ) } - Spacer(modifier = Modifier.height(4.dp)) - - if (isKpmEnabled()) { - val kpmVersion = getKpmVersion() - Text( - text = stringResource(R.string.home_kpm_version, kpmVersion), - style = MaterialTheme.typography.bodyMedium - ) - } } } @@ -559,6 +548,12 @@ private fun InfoCard() { InfoCardItem(stringResource(R.string.home_selinux_status), getSELinuxStatus()) + if (!isSimpleMode) { + Spacer(Modifier.height(16.dp)) + InfoCardItem(stringResource(R.string.home_kpm_version), getKpmVersion()) + } + + if (!isSimpleMode) { Spacer(modifier = Modifier.height(16.dp)) diff --git a/manager/app/src/main/java/shirkneko/zako/sukisu/ui/screen/kpm.kt b/manager/app/src/main/java/shirkneko/zako/sukisu/ui/screen/kpm.kt index 7054a447..6c7729ba 100644 --- a/manager/app/src/main/java/shirkneko/zako/sukisu/ui/screen/kpm.kt +++ b/manager/app/src/main/java/shirkneko/zako/sukisu/ui/screen/kpm.kt @@ -102,19 +102,25 @@ fun KpmScreen( if (confirmResult == ConfirmResult.Confirmed) { val success = loadingDialog.withLoading { - loadKpmModule(tempFile.absolutePath) + try { + val process = ProcessBuilder("nsenter", "-t", "1", "-m").start() + process.waitFor() + loadKpmModule(tempFile.absolutePath) + } catch (e: Exception) { + Log.e("KsuCli", "Failed to execute nsenter command: ${e.message}") + "failed" + } } Log.d("KsuCli", "loadKpmModule result: $success") - if (success == "success") { + if (success.contains("Success", ignoreCase = true)) { viewModel.fetchModuleList() snackBarHost.showSnackbar( message = kpmInstallSuccess, duration = SnackbarDuration.Long ) } else { - // 修正为显示安装失败的消息 snackBarHost.showSnackbar( message = kpmInstallFailed, duration = SnackbarDuration.Long @@ -157,7 +163,7 @@ fun KpmScreen( onClick = { selectPatchLauncher.launch( Intent(Intent.ACTION_GET_CONTENT).apply { - type = "application/*" + type = "*/*" } ) }, @@ -238,7 +244,7 @@ fun KpmScreen( unloadKpmModule(module.id) } Log.d("KsuCli", "unloadKpmModule result: $success") - if (success == "success") { + if (success.contains("Success", ignoreCase = true)) { viewModel.fetchModuleList() snackBarHost.showSnackbar( message = kpmUninstallSuccess, diff --git a/manager/app/src/main/java/shirkneko/zako/sukisu/ui/util/KernelConfigUtils.kt b/manager/app/src/main/java/shirkneko/zako/sukisu/ui/util/KernelConfigUtils.kt deleted file mode 100644 index ba32d3df..00000000 --- a/manager/app/src/main/java/shirkneko/zako/sukisu/ui/util/KernelConfigUtils.kt +++ /dev/null @@ -1,15 +0,0 @@ -package shirkneko.zako.sukisu.ui.util - -import java.io.File - -object KernelConfigUtils { - - fun isKpmEnabled(): Boolean { - return try { - val config = File("/proc/config.gz").readText() - config.contains("CONFIG_KPM=y") - } catch (e: Exception) { - false - } - } -} \ No newline at end of file diff --git a/manager/app/src/main/java/shirkneko/zako/sukisu/ui/util/KsuCli.kt b/manager/app/src/main/java/shirkneko/zako/sukisu/ui/util/KsuCli.kt index cf4c4c01..1b5df7db 100644 --- a/manager/app/src/main/java/shirkneko/zako/sukisu/ui/util/KsuCli.kt +++ b/manager/app/src/main/java/shirkneko/zako/sukisu/ui/util/KsuCli.kt @@ -486,51 +486,51 @@ private fun getKpmmgrPath(): String { } -fun loadKpmModule(path: String, args: String? = null): String { +fun loadKpmModule(path: String, args: String? = null): Boolean { val shell = getRootShell() val cmd = "${getKpmmgrPath()} load $path ${args ?: ""}" val result = ShellUtils.fastCmd(shell, cmd) - return result + return result.contains("Success") } -fun unloadKpmModule(name: String): String { +fun unloadKpmModule(name: String): Boolean { val shell = getRootShell() val cmd = "${getKpmmgrPath()} unload $name" val result = ShellUtils.fastCmd(shell, cmd) - return result + return result.trim().toIntOrNull() == 0 } -fun getKpmModuleCount(): String { +fun getKpmModuleCount(): Int { val shell = getRootShell() val cmd = "${getKpmmgrPath()} num" val result = ShellUtils.fastCmd(shell, cmd) - return result + return result.trim().toIntOrNull() ?: 0 } fun listKpmModules(): String { val shell = getRootShell() val cmd = "${getKpmmgrPath()} list" val result = ShellUtils.fastCmd(shell, cmd) - return result + return result.trim() } fun getKpmModuleInfo(name: String): String { val shell = getRootShell() val cmd = "${getKpmmgrPath()} info $name" val result = ShellUtils.fastCmd(shell, cmd) - return result + return result.trim() } -fun controlKpmModule(name: String, args: String? = null): String { +fun controlKpmModule(name: String, args: String? = null): Int { val shell = getRootShell() val cmd = "${getKpmmgrPath()} control $name ${args ?: ""}" val result = ShellUtils.fastCmd(shell, cmd) - return result + return result.trim().toIntOrNull() ?: -1 } fun getKpmVersion(): String { val shell = getRootShell() val cmd = "${getKpmmgrPath()} version" val result = ShellUtils.fastCmd(shell, cmd) - return result + return result.trim() } diff --git a/manager/app/src/main/res/values-zh-rCN/strings.xml b/manager/app/src/main/res/values-zh-rCN/strings.xml index 7a345adc..08e3f5be 100644 --- a/manager/app/src/main/res/values-zh-rCN/strings.xml +++ b/manager/app/src/main/res/values-zh-rCN/strings.xml @@ -230,11 +230,11 @@ 确定要卸载内核模块 %1$s 吗? 卸载成功 卸载失败 - 安装kpm模块 - 确认安装吗? - 安装kpm模块成功 - 安装kpm模块失败 - KPM 版本: %s + 加载kpm模块 + 确认加载吗? + 加载kpm模块成功 + 加载kpm模块失败 + KPM 版本 关闭 以下内核模块功能由KernelPatch开发,经过修改后加入SukiSU Ultra的内核模块功能 SukiSU Ultra展望 diff --git a/manager/app/src/main/res/values/strings.xml b/manager/app/src/main/res/values/strings.xml index 861e94c3..c24c465c 100644 --- a/manager/app/src/main/res/values/strings.xml +++ b/manager/app/src/main/res/values/strings.xml @@ -232,13 +232,13 @@ Determine the kernel module to uninstall: %1$s ? Uninstalled successfully Failed to uninstall - Installing the kpm module - Confirm installation? - Installation of kpm module successful - Installation of kpm module failed + Load the kpm module + Confirm Load? + Load of kpm module successful + Load of kpm module failed kpm parameters kpm control - KPM Version: %s + KPM Version close The following kernel module functions were developed by KernelPatch and modified to include the kernel module functions of SukiSU Ultra SukiSU Ultra Look forward to