mirror of
https://github.com/revanced/Apktool.git
synced 2025-01-05 17:45:52 +01:00
fix: accept empty resources.arsc (#2998)
* fix: accept empty resources.arsc * fix: accept empty resources.arsc (fix isFrameworkApk=true)
This commit is contained in:
parent
0a3c7595eb
commit
120611879c
@ -776,7 +776,7 @@ public class Androlib {
|
||||
|
||||
public boolean isFrameworkApk(ResTable resTable) {
|
||||
for (ResPackage pkg : resTable.listMainPackages()) {
|
||||
if (pkg.getId() < 64) {
|
||||
if (pkg.getId() > 0 && pkg.getId() < 64) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
@ -30,7 +30,7 @@ import java.io.*;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
|
||||
public class SmaliMod {
|
||||
public static boolean assembleSmaliFile(File smaliFile,DexBuilder dexBuilder, int apiLevel, boolean verboseErrors,
|
||||
public static boolean assembleSmaliFile(File smaliFile, DexBuilder dexBuilder, int apiLevel, boolean verboseErrors,
|
||||
boolean printTokens) throws IOException, RecognitionException {
|
||||
|
||||
CommonTokenStream tokens;
|
||||
|
@ -66,7 +66,7 @@ final public class AndrolibResources {
|
||||
|
||||
switch (pkgs.length) {
|
||||
case 0:
|
||||
pkg = null;
|
||||
pkg = new ResPackage(resTable, 0, null);
|
||||
break;
|
||||
case 1:
|
||||
pkg = pkgs[0];
|
||||
@ -80,10 +80,6 @@ final public class AndrolibResources {
|
||||
break;
|
||||
}
|
||||
|
||||
if (pkg == null) {
|
||||
throw new AndrolibException("arsc files with zero packages or no arsc file found.");
|
||||
}
|
||||
|
||||
resTable.addPackage(pkg, true);
|
||||
return pkg;
|
||||
}
|
||||
@ -168,9 +164,11 @@ final public class AndrolibResources {
|
||||
resTable.setPackageId(resPackage.getId());
|
||||
resTable.setPackageOriginal(pkgOriginal);
|
||||
|
||||
// 1) Check if pkgOriginal === mPackageRenamed
|
||||
// 2) Check if pkgOriginal is ignored via IGNORED_PACKAGES
|
||||
if (pkgOriginal.equalsIgnoreCase(mPackageRenamed) || (Arrays.asList(IGNORED_PACKAGES).contains(pkgOriginal))) {
|
||||
// 1) Check if pkgOriginal is null (empty resources.arsc)
|
||||
// 2) Check if pkgOriginal === mPackageRenamed
|
||||
// 3) Check if pkgOriginal is ignored via IGNORED_PACKAGES
|
||||
if (pkgOriginal == null || pkgOriginal.equalsIgnoreCase(mPackageRenamed)
|
||||
|| (Arrays.asList(IGNORED_PACKAGES).contains(pkgOriginal))) {
|
||||
LOGGER.info("Regular manifest package...");
|
||||
} else {
|
||||
LOGGER.info("Renamed manifest package found! Replacing " + mPackageRenamed + " with " + pkgOriginal);
|
||||
@ -708,7 +706,7 @@ final public class AndrolibResources {
|
||||
if (withResources) {
|
||||
axmlParser.setAttrDecoder(new ResAttrDecoder());
|
||||
}
|
||||
decoders.setDecoder("xml", new XmlPullStreamDecoder(axmlParser,getResXmlSerializer()));
|
||||
decoders.setDecoder("xml", new XmlPullStreamDecoder(axmlParser, getResXmlSerializer()));
|
||||
|
||||
return new Duo<>(new ResFileDecoder(decoders), axmlParser);
|
||||
}
|
||||
@ -772,7 +770,7 @@ final public class AndrolibResources {
|
||||
}
|
||||
}
|
||||
|
||||
private ResPackage[] getResPackagesFromApk(ExtFile apkFile,ResTable resTable, boolean keepBroken)
|
||||
private ResPackage[] getResPackagesFromApk(ExtFile apkFile, ResTable resTable, boolean keepBroken)
|
||||
throws AndrolibException {
|
||||
try {
|
||||
Directory dir = apkFile.getDirectory();
|
||||
|
Loading…
Reference in New Issue
Block a user