From 1c3894e35bc9a01e66217bc4aaf6787a8a0a5924 Mon Sep 17 00:00:00 2001 From: Fox2Code Date: Wed, 27 Apr 2022 21:50:25 +0200 Subject: [PATCH] Improve AnyKernel support. Close #138 --- .../com/fox2code/mmm/installer/InstallerActivity.java | 9 +++++++-- app/src/main/java/com/fox2code/mmm/utils/PropUtils.java | 4 +--- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/app/src/main/java/com/fox2code/mmm/installer/InstallerActivity.java b/app/src/main/java/com/fox2code/mmm/installer/InstallerActivity.java index 040ea39..c8a2c0c 100644 --- a/app/src/main/java/com/fox2code/mmm/installer/InstallerActivity.java +++ b/app/src/main/java/com/fox2code/mmm/installer/InstallerActivity.java @@ -159,13 +159,17 @@ public class InstallerActivity extends CompatActivity { Files.fixJavaZipHax(rawModule); boolean noPatch = false; boolean isModule = false; + boolean isAnyKernel = false; errMessage = "File is not a valid zip file"; try (ZipInputStream zipInputStream = new ZipInputStream( new ByteArrayInputStream(rawModule))) { ZipEntry zipEntry; while ((zipEntry = zipInputStream.getNextEntry()) != null) { String entryName = zipEntry.getName(); - if (entryName.equals("module.prop")) { + if (entryName.equals("anykernel.sh")) { + isAnyKernel = true; + break; + } else if (entryName.equals("module.prop")) { noPatch = true; isModule = true; break; @@ -175,7 +179,8 @@ public class InstallerActivity extends CompatActivity { } } if (!isModule) { - this.setInstallStateFinished(false, + this.setInstallStateFinished(false, isAnyKernel ? + "! AnyKernel modules can only be installed on recovery" : "! File is not a valid magisk module", ""); return; } diff --git a/app/src/main/java/com/fox2code/mmm/utils/PropUtils.java b/app/src/main/java/com/fox2code/mmm/utils/PropUtils.java index 8d4e6ea..e680465 100644 --- a/app/src/main/java/com/fox2code/mmm/utils/PropUtils.java +++ b/app/src/main/java/com/fox2code/mmm/utils/PropUtils.java @@ -249,9 +249,7 @@ public class PropUtils { if (readIdSec && local) { // Using the name for module id is not really appropriate, so beautify it a bit moduleInfo.name = makeNameFromId(moduleInfo.id); - } else if (local) { // Allow local module to not declare ids - invalid = true; - } else { + } else if (!local) { // Allow local modules to not declare ids throw new IOException("Didn't read module id at least once!"); } }