@@ -1,4 +1,2 @@
|
|||||||
obj-y += kpm.o
|
obj-y += kpm.o
|
||||||
obj-y += compact.o
|
obj-y += compact.o
|
||||||
|
|
||||||
ccflags-y += -flto=thin
|
|
||||||
@@ -347,13 +347,6 @@ private fun StatusCard(
|
|||||||
style = MaterialTheme.typography.bodyMedium
|
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())
|
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) {
|
if (!isSimpleMode) {
|
||||||
Spacer(modifier = Modifier.height(16.dp))
|
Spacer(modifier = Modifier.height(16.dp))
|
||||||
|
|
||||||
|
|||||||
@@ -102,19 +102,25 @@ fun KpmScreen(
|
|||||||
|
|
||||||
if (confirmResult == ConfirmResult.Confirmed) {
|
if (confirmResult == ConfirmResult.Confirmed) {
|
||||||
val success = loadingDialog.withLoading {
|
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")
|
Log.d("KsuCli", "loadKpmModule result: $success")
|
||||||
|
|
||||||
if (success == "success") {
|
if (success.contains("Success", ignoreCase = true)) {
|
||||||
viewModel.fetchModuleList()
|
viewModel.fetchModuleList()
|
||||||
snackBarHost.showSnackbar(
|
snackBarHost.showSnackbar(
|
||||||
message = kpmInstallSuccess,
|
message = kpmInstallSuccess,
|
||||||
duration = SnackbarDuration.Long
|
duration = SnackbarDuration.Long
|
||||||
)
|
)
|
||||||
} else {
|
} else {
|
||||||
// 修正为显示安装失败的消息
|
|
||||||
snackBarHost.showSnackbar(
|
snackBarHost.showSnackbar(
|
||||||
message = kpmInstallFailed,
|
message = kpmInstallFailed,
|
||||||
duration = SnackbarDuration.Long
|
duration = SnackbarDuration.Long
|
||||||
@@ -157,7 +163,7 @@ fun KpmScreen(
|
|||||||
onClick = {
|
onClick = {
|
||||||
selectPatchLauncher.launch(
|
selectPatchLauncher.launch(
|
||||||
Intent(Intent.ACTION_GET_CONTENT).apply {
|
Intent(Intent.ACTION_GET_CONTENT).apply {
|
||||||
type = "application/*"
|
type = "*/*"
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
},
|
},
|
||||||
@@ -238,7 +244,7 @@ fun KpmScreen(
|
|||||||
unloadKpmModule(module.id)
|
unloadKpmModule(module.id)
|
||||||
}
|
}
|
||||||
Log.d("KsuCli", "unloadKpmModule result: $success")
|
Log.d("KsuCli", "unloadKpmModule result: $success")
|
||||||
if (success == "success") {
|
if (success.contains("Success", ignoreCase = true)) {
|
||||||
viewModel.fetchModuleList()
|
viewModel.fetchModuleList()
|
||||||
snackBarHost.showSnackbar(
|
snackBarHost.showSnackbar(
|
||||||
message = kpmUninstallSuccess,
|
message = kpmUninstallSuccess,
|
||||||
|
|||||||
@@ -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 shell = getRootShell()
|
||||||
val cmd = "${getKpmmgrPath()} load $path ${args ?: ""}"
|
val cmd = "${getKpmmgrPath()} load $path ${args ?: ""}"
|
||||||
val result = ShellUtils.fastCmd(shell, cmd)
|
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 shell = getRootShell()
|
||||||
val cmd = "${getKpmmgrPath()} unload $name"
|
val cmd = "${getKpmmgrPath()} unload $name"
|
||||||
val result = ShellUtils.fastCmd(shell, cmd)
|
val result = ShellUtils.fastCmd(shell, cmd)
|
||||||
return result
|
return result.trim().toIntOrNull() == 0
|
||||||
}
|
}
|
||||||
|
|
||||||
fun getKpmModuleCount(): String {
|
fun getKpmModuleCount(): Int {
|
||||||
val shell = getRootShell()
|
val shell = getRootShell()
|
||||||
val cmd = "${getKpmmgrPath()} num"
|
val cmd = "${getKpmmgrPath()} num"
|
||||||
val result = ShellUtils.fastCmd(shell, cmd)
|
val result = ShellUtils.fastCmd(shell, cmd)
|
||||||
return result
|
return result.trim().toIntOrNull() ?: 0
|
||||||
}
|
}
|
||||||
|
|
||||||
fun listKpmModules(): String {
|
fun listKpmModules(): String {
|
||||||
val shell = getRootShell()
|
val shell = getRootShell()
|
||||||
val cmd = "${getKpmmgrPath()} list"
|
val cmd = "${getKpmmgrPath()} list"
|
||||||
val result = ShellUtils.fastCmd(shell, cmd)
|
val result = ShellUtils.fastCmd(shell, cmd)
|
||||||
return result
|
return result.trim()
|
||||||
}
|
}
|
||||||
|
|
||||||
fun getKpmModuleInfo(name: String): String {
|
fun getKpmModuleInfo(name: String): String {
|
||||||
val shell = getRootShell()
|
val shell = getRootShell()
|
||||||
val cmd = "${getKpmmgrPath()} info $name"
|
val cmd = "${getKpmmgrPath()} info $name"
|
||||||
val result = ShellUtils.fastCmd(shell, cmd)
|
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 shell = getRootShell()
|
||||||
val cmd = "${getKpmmgrPath()} control $name ${args ?: ""}"
|
val cmd = "${getKpmmgrPath()} control $name ${args ?: ""}"
|
||||||
val result = ShellUtils.fastCmd(shell, cmd)
|
val result = ShellUtils.fastCmd(shell, cmd)
|
||||||
return result
|
return result.trim().toIntOrNull() ?: -1
|
||||||
}
|
}
|
||||||
|
|
||||||
fun getKpmVersion(): String {
|
fun getKpmVersion(): String {
|
||||||
val shell = getRootShell()
|
val shell = getRootShell()
|
||||||
val cmd = "${getKpmmgrPath()} version"
|
val cmd = "${getKpmmgrPath()} version"
|
||||||
val result = ShellUtils.fastCmd(shell, cmd)
|
val result = ShellUtils.fastCmd(shell, cmd)
|
||||||
return result
|
return result.trim()
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -230,11 +230,11 @@
|
|||||||
<string name="kpm_uninstall_confirm">确定要卸载内核模块 %1$s 吗?</string>
|
<string name="kpm_uninstall_confirm">确定要卸载内核模块 %1$s 吗?</string>
|
||||||
<string name="kpm_uninstall_success">卸载成功</string>
|
<string name="kpm_uninstall_success">卸载成功</string>
|
||||||
<string name="kpm_uninstall_failed">卸载失败</string>
|
<string name="kpm_uninstall_failed">卸载失败</string>
|
||||||
<string name="kpm_install">安装kpm模块</string>
|
<string name="kpm_install">加载kpm模块</string>
|
||||||
<string name="kpm_install_confirm">确认安装吗?</string>
|
<string name="kpm_install_confirm">确认加载吗?</string>
|
||||||
<string name="kpm_install_success">安装kpm模块成功</string>
|
<string name="kpm_install_success">加载kpm模块成功</string>
|
||||||
<string name="kpm_install_failed">安装kpm模块失败</string>
|
<string name="kpm_install_failed">加载kpm模块失败</string>
|
||||||
<string name="home_kpm_version">KPM 版本: %s</string>
|
<string name="home_kpm_version">KPM 版本</string>
|
||||||
<string name="close_notice">关闭</string>
|
<string name="close_notice">关闭</string>
|
||||||
<string name="kernel_module_notice">以下内核模块功能由KernelPatch开发,经过修改后加入SukiSU Ultra的内核模块功能</string>
|
<string name="kernel_module_notice">以下内核模块功能由KernelPatch开发,经过修改后加入SukiSU Ultra的内核模块功能</string>
|
||||||
<string name="home_ContributionCard_kernelsu">SukiSU Ultra展望</string>
|
<string name="home_ContributionCard_kernelsu">SukiSU Ultra展望</string>
|
||||||
|
|||||||
@@ -232,13 +232,13 @@
|
|||||||
<string name="kpm_uninstall_confirm">Determine the kernel module to uninstall: %1$s ?</string>
|
<string name="kpm_uninstall_confirm">Determine the kernel module to uninstall: %1$s ?</string>
|
||||||
<string name="kpm_uninstall_success">Uninstalled successfully</string>
|
<string name="kpm_uninstall_success">Uninstalled successfully</string>
|
||||||
<string name="kpm_uninstall_failed">Failed to uninstall</string>
|
<string name="kpm_uninstall_failed">Failed to uninstall</string>
|
||||||
<string name="kpm_install">Installing the kpm module</string>
|
<string name="kpm_install">Load the kpm module</string>
|
||||||
<string name="kpm_install_confirm">Confirm installation?</string>
|
<string name="kpm_install_confirm">Confirm Load?</string>
|
||||||
<string name="kpm_install_success">Installation of kpm module successful</string>
|
<string name="kpm_install_success">Load of kpm module successful</string>
|
||||||
<string name="kpm_install_failed">Installation of kpm module failed</string>
|
<string name="kpm_install_failed">Load of kpm module failed</string>
|
||||||
<string name="kpm_args">kpm parameters</string>
|
<string name="kpm_args">kpm parameters</string>
|
||||||
<string name="kpm_control">kpm control</string>
|
<string name="kpm_control">kpm control</string>
|
||||||
<string name="home_kpm_version">KPM Version: %s</string>
|
<string name="home_kpm_version">KPM Version</string>
|
||||||
<string name="close_notice">close</string>
|
<string name="close_notice">close</string>
|
||||||
<string name="kernel_module_notice">The following kernel module functions were developed by KernelPatch and modified to include the kernel module functions of SukiSU Ultra</string>
|
<string name="kernel_module_notice">The following kernel module functions were developed by KernelPatch and modified to include the kernel module functions of SukiSU Ultra</string>
|
||||||
<string name="home_ContributionCard_kernelsu">SukiSU Ultra Look forward to</string>
|
<string name="home_ContributionCard_kernelsu">SukiSU Ultra Look forward to</string>
|
||||||
|
|||||||
@@ -70,7 +70,7 @@ int main(int argc, char *argv[]) {
|
|||||||
if (strcmp(argv[1], "load") == 0 && argc >= 3) {
|
if (strcmp(argv[1], "load") == 0 && argc >= 3) {
|
||||||
// 加载 KPM 模块
|
// 加载 KPM 模块
|
||||||
ret = prctl(KSU_OPTIONS, CONTROL_CODE(SUKISU_KPM_LOAD), argv[2], (argc > 3 ? argv[3] : NULL), &out);
|
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");
|
printf("Success");
|
||||||
}
|
}
|
||||||
} else if (strcmp(argv[1], "unload") == 0 && argc >= 3) {
|
} else if (strcmp(argv[1], "unload") == 0 && argc >= 3) {
|
||||||
|
|||||||
Reference in New Issue
Block a user