mirror of
https://github.com/revanced/Apktool.git
synced 2025-01-07 10:35: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) {
|
public boolean isFrameworkApk(ResTable resTable) {
|
||||||
for (ResPackage pkg : resTable.listMainPackages()) {
|
for (ResPackage pkg : resTable.listMainPackages()) {
|
||||||
if (pkg.getId() < 64) {
|
if (pkg.getId() > 0 && pkg.getId() < 64) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -30,7 +30,7 @@ import java.io.*;
|
|||||||
import java.nio.charset.StandardCharsets;
|
import java.nio.charset.StandardCharsets;
|
||||||
|
|
||||||
public class SmaliMod {
|
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 {
|
boolean printTokens) throws IOException, RecognitionException {
|
||||||
|
|
||||||
CommonTokenStream tokens;
|
CommonTokenStream tokens;
|
||||||
|
@ -66,7 +66,7 @@ final public class AndrolibResources {
|
|||||||
|
|
||||||
switch (pkgs.length) {
|
switch (pkgs.length) {
|
||||||
case 0:
|
case 0:
|
||||||
pkg = null;
|
pkg = new ResPackage(resTable, 0, null);
|
||||||
break;
|
break;
|
||||||
case 1:
|
case 1:
|
||||||
pkg = pkgs[0];
|
pkg = pkgs[0];
|
||||||
@ -80,10 +80,6 @@ final public class AndrolibResources {
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (pkg == null) {
|
|
||||||
throw new AndrolibException("arsc files with zero packages or no arsc file found.");
|
|
||||||
}
|
|
||||||
|
|
||||||
resTable.addPackage(pkg, true);
|
resTable.addPackage(pkg, true);
|
||||||
return pkg;
|
return pkg;
|
||||||
}
|
}
|
||||||
@ -168,9 +164,11 @@ final public class AndrolibResources {
|
|||||||
resTable.setPackageId(resPackage.getId());
|
resTable.setPackageId(resPackage.getId());
|
||||||
resTable.setPackageOriginal(pkgOriginal);
|
resTable.setPackageOriginal(pkgOriginal);
|
||||||
|
|
||||||
// 1) Check if pkgOriginal === mPackageRenamed
|
// 1) Check if pkgOriginal is null (empty resources.arsc)
|
||||||
// 2) Check if pkgOriginal is ignored via IGNORED_PACKAGES
|
// 2) Check if pkgOriginal === mPackageRenamed
|
||||||
if (pkgOriginal.equalsIgnoreCase(mPackageRenamed) || (Arrays.asList(IGNORED_PACKAGES).contains(pkgOriginal))) {
|
// 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...");
|
LOGGER.info("Regular manifest package...");
|
||||||
} else {
|
} else {
|
||||||
LOGGER.info("Renamed manifest package found! Replacing " + mPackageRenamed + " with " + pkgOriginal);
|
LOGGER.info("Renamed manifest package found! Replacing " + mPackageRenamed + " with " + pkgOriginal);
|
||||||
@ -708,7 +706,7 @@ final public class AndrolibResources {
|
|||||||
if (withResources) {
|
if (withResources) {
|
||||||
axmlParser.setAttrDecoder(new ResAttrDecoder());
|
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);
|
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 {
|
throws AndrolibException {
|
||||||
try {
|
try {
|
||||||
Directory dir = apkFile.getDirectory();
|
Directory dir = apkFile.getDirectory();
|
||||||
|
Loading…
Reference in New Issue
Block a user