Skip to content

Commit

Permalink
feat(res): support compact resource entries (#2268)
Browse files Browse the repository at this point in the history
  • Loading branch information
skylot committed Sep 6, 2024
1 parent 937dd20 commit 0938351
Showing 1 changed file with 7 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -308,7 +308,7 @@ private void parseTypeChunk(long start, PackageChunk pkg) throws IOException {
entryOffsetMap.put(i, is.readInt32());
}
}
is.checkPos(entriesStart, "Expected first entry start");
is.skipToPos(entriesStart, "Failed to skip to entries start");
int processed = 0;
for (int index : entryOffsetMap.keySet()) {
int offset = entryOffsetMap.get(index);
Expand Down Expand Up @@ -365,16 +365,11 @@ private void parseStagedAliasChunk(long chunkStart) throws IOException {

private void parseEntry(PackageChunk pkg, int typeId, int entryId, String config) throws IOException {
int size = is.readInt16();

int flags = is.readInt16();
boolean isComplex = (flags & FLAG_COMPLEX) != 0;
boolean isCompact = (flags & FLAG_COMPACT) != 0;

if (isCompact) {
throw new JadxRuntimeException("Compact resource entries are not supported yet");
}

int key = is.readInt32();
int key = isCompact ? size : is.readInt32();
if (key == -1) {
return;
}
Expand All @@ -384,7 +379,11 @@ private void parseEntry(PackageChunk pkg, int typeId, int entryId, String config
String origKeyName = pkg.getKeyStrings().get(key);

ResourceEntry newResEntry = buildResourceEntry(pkg, config, resRef, typeName, origKeyName);
if (isComplex || size == 16) {
if (isCompact) {
int dataType = flags >> 8;
int data = is.readInt32();
newResEntry.setSimpleValue(new RawValue(dataType, data));
} else if (isComplex || size == 16) {
int parentRef = is.readInt32();
int count = is.readInt32();
newResEntry.setParentRef(parentRef);
Expand Down

0 comments on commit 0938351

Please # to comment.