fix: handle unknown res configs gracefully #4053
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Fixed decoding for #4051.
The only persisting part of a standard 64-byte res config are the first 52 bytes.
The last 12 bytes are expected to be empty; they are later populated by Android.
Some vendors, like Motorola, are using these extra bytes for their own customized aapt, and also a res config size of 76 bytes.
We handle the 52 standard bytes, and everything after that is expected to be empty bytes, otherwise we make a unique config marked as invalid and named
-unk<hash of unknown bytes>. Using a hash ensures resources with the same unknown bytes are grouped together.Resources with these configs can't be rebuilt by any public aapt2 and are normally dropped (with proper logging).
To preserve them for whatever reason,
--keep-broken-rescan be used.With the broken resources excluded, the resulting output can be rebuilt normally.
No changes for APKs with standard res configs.
Example output for the Motorola
framework-res.apkfrom the issue mentioned above: