From a2a7a374d3419e0ad0ff713b72c97ebb3e93e05d Mon Sep 17 00:00:00 2001 From: Wang Han <1701210638@pku.edu.cn> Date: Sat, 27 Jul 2024 13:13:11 +0800 Subject: [PATCH] Make Zygote injection optional for Zygisk modules This is useful when a module has Zygisk features, but also has other features which can work without Zygisk, such as TrickyStore. --- .../main/java/com/topjohnwu/magisk/ui/module/ModuleRvItem.kt | 3 ++- .../java/com/topjohnwu/magisk/core/model/module/LocalModule.kt | 2 ++ native/src/core/module.cpp | 3 ++- 3 files changed, 6 insertions(+), 2 deletions(-) diff --git a/app/apk/src/main/java/com/topjohnwu/magisk/ui/module/ModuleRvItem.kt b/app/apk/src/main/java/com/topjohnwu/magisk/ui/module/ModuleRvItem.kt index a0c6d4535569..62baebaa4bbc 100644 --- a/app/apk/src/main/java/com/topjohnwu/magisk/ui/module/ModuleRvItem.kt +++ b/app/apk/src/main/java/com/topjohnwu/magisk/ui/module/ModuleRvItem.kt @@ -31,10 +31,11 @@ class LocalModuleRvItem( val isZygisk = item.isZygisk val isRiru = item.isRiru val zygiskUnloaded = isZygisk && item.zygiskUnloaded + val isZygiskOptional = item.isZygiskOptional showNotice = zygiskUnloaded || (Info.isZygiskEnabled && isRiru) || - (!Info.isZygiskEnabled && isZygisk) + (!Info.isZygiskEnabled && isZygisk && !isZygiskOptional) noticeText = when { zygiskUnloaded -> CoreR.string.zygisk_module_unloaded.asText() diff --git a/app/core/src/main/java/com/topjohnwu/magisk/core/model/module/LocalModule.kt b/app/core/src/main/java/com/topjohnwu/magisk/core/model/module/LocalModule.kt index 3d966d38049f..df2848cfa897 100644 --- a/app/core/src/main/java/com/topjohnwu/magisk/core/model/module/LocalModule.kt +++ b/app/core/src/main/java/com/topjohnwu/magisk/core/model/module/LocalModule.kt @@ -32,11 +32,13 @@ data class LocalModule( private val riruFolder = RootUtils.fs.getFile(path, "riru") private val zygiskFolder = RootUtils.fs.getFile(path, "zygisk") private val unloaded = RootUtils.fs.getFile(zygiskFolder, "unloaded") + private val zygiskOptional = RootUtils.fs.getFile(zygiskFolder, "optional") val updated: Boolean get() = updateFile.exists() val isRiru: Boolean get() = (id == "riru-core") || riruFolder.exists() val isZygisk: Boolean get() = zygiskFolder.exists() val zygiskUnloaded: Boolean get() = unloaded.exists() + val isZygiskOptional: Boolean get() = zygiskOptional.exists() var enable: Boolean get() = !disableFile.exists() diff --git a/native/src/core/module.cpp b/native/src/core/module.cpp index dfa31da83008..a263945ed9e2 100644 --- a/native/src/core/module.cpp +++ b/native/src/core/module.cpp @@ -428,7 +428,8 @@ static void collect_modules(bool open_zygisk) { } } else { // Ignore zygisk modules when zygisk is not enabled - if (faccessat(modfd, "zygisk", F_OK, 0) == 0) { + if (faccessat(modfd, "zygisk", F_OK, 0) == 0 && + faccessat(modfd, "zygisk/optional", F_OK, 0) != 0) { LOGI("%s: ignore\n", entry->d_name); return; }