Skip to content

Commit

Permalink
Refactor logging for chunks and sparse flags. (#3260)
Browse files Browse the repository at this point in the history
* refactor: log each chunk in verbose mode

* refactor: drop unneeded ":" from log output

* refactor: spit out sparse message once
  • Loading branch information
iBotPeaches committed Aug 9, 2023
1 parent 0d7a1bc commit 1243dd5
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -256,8 +256,10 @@ public void setSharedLibrary(boolean flag) {
}

public void setSparseResources(boolean flag) {
if (mApkInfo.sparseResources != flag) {
LOGGER.info("Sparsely packed resources detected.");
}
mApkInfo.sparseResources = flag;

}

public void clearSdkInfo() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,11 +65,16 @@ private ResPackage[] readResourceTable() throws IOException, AndrolibException {
Set<ResPackage> pkgs = new LinkedHashSet<>();

ResTypeSpec typeSpec;
int chunkNumber = 1;

chunkLoop:
for (;;) {
nextChunk();

LOGGER.fine(String.format(
"Chunk #%d start: type=0x%04x chunkSize=0x%08x", chunkNumber++, mHeader.type, mHeader.chunkSize
));

switch (mHeader.type) {
case ARSCHeader.RES_NULL_TYPE:
readUnknownChunk();
Expand Down Expand Up @@ -266,9 +271,6 @@ private ResType readTableType() throws IOException, AndrolibException {
mHeader.checkForUnreadHeader(mIn);

if ((typeFlags & 0x01) != 0) {
LOGGER.fine("Sparse type flags detected: " + mTypeSpec.getName());

// We've detected sparse resources, lets record this so we can rebuild in that same format
mResTable.setSparseResources(true);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ public void decode(ResResource res, Directory inDir, Directory outDir, Map<Strin
resFileMapping.put(inFilePath, outFilePath);
}

LOGGER.fine("Decoding file: " + inFilePath + " to: " + outFilePath);
LOGGER.fine("Decoding file " + inFilePath + " to " + outFilePath);

try {
if (typeName.equals("raw")) {
Expand Down

0 comments on commit 1243dd5

Please sign in to comment.