Improve AnyKernel support. Close #138

This commit is contained in:
Fox2Code 2022-04-27 21:50:25 +02:00
parent 8f5751581e
commit 1c3894e35b
2 changed files with 8 additions and 5 deletions

View File

@ -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;
}

View File

@ -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!");
}
}