mirror of
https://github.com/revanced/Apktool.git
synced 2025-01-08 11:05:52 +01:00
AndrolibResources: added possibility to decode resources.arsc from InputStream.
This commit is contained in:
parent
51e1a28bda
commit
3fdde30939
@ -35,8 +35,8 @@ import org.xmlpull.v1.XmlSerializer;
|
|||||||
final public class AndrolibResources {
|
final public class AndrolibResources {
|
||||||
public ResTable getResTable(File apkFile) throws AndrolibException {
|
public ResTable getResTable(File apkFile) throws AndrolibException {
|
||||||
ResTable resTable = new ResTable();
|
ResTable resTable = new ResTable();
|
||||||
loadApk(resTable, getAndroidResourcesFile(), false);
|
decodeArsc(resTable, getAndroidResourcesFile(), false);
|
||||||
loadApk(resTable, apkFile, true);
|
decodeArsc(resTable, apkFile, true);
|
||||||
return resTable;
|
return resTable;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -202,25 +202,29 @@ final public class AndrolibResources {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void loadApk(ResTable resTable, File apkFile, boolean main)
|
private void decodeArsc(ResTable resTable, File apkFile, boolean main)
|
||||||
throws AndrolibException {
|
throws AndrolibException {
|
||||||
ResPackage[] groups;
|
|
||||||
try {
|
try {
|
||||||
groups = ARSCDecoder.decode(
|
loadArsc(resTable, new ZipRODirectory(apkFile)
|
||||||
new ZipRODirectory(apkFile).getFileInput("resources.arsc"),
|
.getFileInput("resources.arsc"), main);
|
||||||
resTable);
|
|
||||||
} catch (DirectoryException ex) {
|
} catch (DirectoryException ex) {
|
||||||
throw new AndrolibException("Could not decode res table", ex);
|
throw new AndrolibException(
|
||||||
|
"Could not load resources.arsc from file: " + apkFile, ex);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
private void loadArsc(ResTable resTable, InputStream arscStream,
|
||||||
|
boolean main) throws AndrolibException {
|
||||||
|
ResPackage[] groups = ARSCDecoder.decode(arscStream, resTable);
|
||||||
|
|
||||||
if (groups.length == 0) {
|
if (groups.length == 0) {
|
||||||
throw new AndrolibException(
|
throw new AndrolibException(
|
||||||
"Apk with zero package groups: " + apkFile.getPath());
|
"Arsc file with zero package groups");
|
||||||
}
|
}
|
||||||
if (groups.length > 1) {
|
if (groups.length > 1) {
|
||||||
System.err.println(
|
System.err.println(
|
||||||
"warning: apk with multiple package groups: "
|
"warning: arsc file with multiple package groups");
|
||||||
+ apkFile.getPath());
|
|
||||||
}
|
}
|
||||||
for (int i = 0; i < groups.length; i++) {
|
for (int i = 0; i < groups.length; i++) {
|
||||||
if (groups.length != 1 && i == 0
|
if (groups.length != 1 && i == 0
|
||||||
|
Loading…
Reference in New Issue
Block a user