From f67f16733f90b77ff345ae17aec71ba343d6ed85 Mon Sep 17 00:00:00 2001 From: ShirkNeko <109797057+ShirkNeko@users.noreply.github.com> Date: Mon, 31 Mar 2025 23:22:03 +0800 Subject: [PATCH 1/3] =?UTF-8?q?=E4=BC=98=E5=8C=96KPM=E6=A8=A1=E5=9D=97?= =?UTF-8?q?=E5=8A=A0=E8=BD=BD=E9=80=BB=E8=BE=91=EF=BC=8C=E6=9B=B4=E6=96=B0?= =?UTF-8?q?=E7=9B=B8=E5=85=B3=E5=AD=97=E7=AC=A6=E4=B8=B2=E8=B5=84=E6=BA=90?= =?UTF-8?q?=EF=BC=8C=E8=B0=83=E6=95=B4KPM=E7=89=88=E6=9C=AC=E6=98=BE?= =?UTF-8?q?=E7=A4=BA=E6=9D=A1=E4=BB=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/shirkneko/zako/sukisu/ui/screen/Home.kt | 13 ++++++------- .../java/shirkneko/zako/sukisu/ui/screen/kpm.kt | 16 +++++++++++----- .../app/src/main/res/values-zh-rCN/strings.xml | 10 +++++----- manager/app/src/main/res/values/strings.xml | 10 +++++----- 4 files changed, 27 insertions(+), 22 deletions(-) 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 de7fe75b..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 @@ -347,13 +347,6 @@ private fun StatusCard( style = MaterialTheme.typography.bodyMedium ) } - Spacer(modifier = Modifier.height(4.dp)) - - val kpmVersion = getKpmVersion() - Text( - text = stringResource(R.string.home_kpm_version, kpmVersion), - style = MaterialTheme.typography.bodyMedium - ) } } @@ -555,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/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 From 408c3be67590bc11c528125495919a5df742775e Mon Sep 17 00:00:00 2001 From: ShirkNeko <109797057+ShirkNeko@users.noreply.github.com> Date: Tue, 1 Apr 2025 02:40:58 +0800 Subject: [PATCH 2/3] =?UTF-8?q?=E4=BC=98=E5=8C=96Kpm=E6=A8=A1=E5=9D=97?= =?UTF-8?q?=E7=9B=B8=E5=85=B3=E5=87=BD=E6=95=B0=E7=9A=84=E8=BF=94=E5=9B=9E?= =?UTF-8?q?=E7=B1=BB=E5=9E=8B=EF=BC=8C=E6=94=B9=E4=B8=BABoolean=E6=88=96In?= =?UTF-8?q?t=E4=BB=A5=E6=8F=90=E9=AB=98=E5=8F=AF=E8=AF=BB=E6=80=A7?= =?UTF-8?q?=E5=92=8C=E5=87=86=E7=A1=AE=E6=80=A7?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../shirkneko/zako/sukisu/ui/util/KsuCli.kt | 22 +++++++++---------- 1 file changed, 11 insertions(+), 11 deletions(-) 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() } From e9d0526e1b8a881c9b49facc9ba30716fb08d437 Mon Sep 17 00:00:00 2001 From: liankong Date: Tue, 1 Apr 2025 12:28:59 +0800 Subject: [PATCH 3/3] 1 --- kernel/kpm/Makefile | 4 +--- userspace/kpmmgr/jni/kpmmgr.c | 2 +- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/kernel/kpm/Makefile b/kernel/kpm/Makefile index e0a8ce1a..10cf7d44 100644 --- a/kernel/kpm/Makefile +++ b/kernel/kpm/Makefile @@ -1,4 +1,2 @@ obj-y += kpm.o -obj-y += compact.o - -ccflags-y += -flto=thin \ No newline at end of file +obj-y += compact.o \ No newline at end of file diff --git a/userspace/kpmmgr/jni/kpmmgr.c b/userspace/kpmmgr/jni/kpmmgr.c index 7fce2f4a..7c4d9a7f 100644 --- a/userspace/kpmmgr/jni/kpmmgr.c +++ b/userspace/kpmmgr/jni/kpmmgr.c @@ -70,7 +70,7 @@ int main(int argc, char *argv[]) { if (strcmp(argv[1], "load") == 0 && argc >= 3) { // 加载 KPM 模块 ret = prctl(KSU_OPTIONS, CONTROL_CODE(SUKISU_KPM_LOAD), argv[2], (argc > 3 ? argv[3] : NULL), &out); - if(out == 0) { + if(out > 0) { printf("Success"); } } else if (strcmp(argv[1], "unload") == 0 && argc >= 3) {