refactor: new BinaryXmlResourceParser, ResXmlSerializer and more#4077
Merged
Conversation
iBotPeaches
approved these changes
Jan 28, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Describing this PR fully is like writing a novel, so I'll sum up the main changes. Most of the code has comments and notes anyway, especially on sensitive/confusing parts.
BinaryXmlResourceParserfully powered byResChunkPullParser. Some obfuscated APKs that couldn't be decoded properly are now easily decoded.ResXmlSerializerreplacesMXSerializer. It's a stripped-down and customized version ofKXmlSerializer(used in AOSP) that's made specifically for safely writing resource XML files.ResStringEncoder(accompanied bybrut.util.TextUtils) handles most of the encoding and escaping of strings. The value ofResStringcan now beStyledStringas well, andResStringEncoderhandles the spans properly according toStyledStringrules. The encoder uses the same StringBuilder through the whole process without allocating any substrings, much lower overhead than prior methods.literals.xmlhas been expanded to demonstrate the new capabilities of the smart escaping algorithm.--ignore-raw-valuesadvanced option. The only APK that uses the--keep-raw-valuesaapt2 option that I know of isCarrierConfig.apkthat preserves MCC/MNC raw values. Not used much in normal production.android.*code removed, most of it was unused. The used parts merged into code where they are relevant. This will prevent breaking conflicts for people who use Apktool as a library along with AOSP code.Tested on large scale. Let me know if there are any questions.