-
-
Notifications
You must be signed in to change notification settings - Fork 3.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix: redesign StyledString decoding #2816
Conversation
Somewhat inspired by this: But using recursion allows for cleaner code and easy handling of self-closing tags which neatly outputs pairs like |
Interesting the only test failing in Isolation in some setups is the test that was added that led to these regressions. Thanks for PR. Slowly going through w/ debugger to understand. |
Yeah I'm not sure what's going on with that test, tried compiling/decompiling with all of the strings in that XML and the output was identical, both with aapt1 and aapt2. Very strange. |
Looks like an issue with aapt1. When the APK is compiled with it, spans are not stored in the same order as with aapt2. Spans when compiled with AAPT1:
Spans when compiled with AAPT2:
|
Due to the above span ordering discrepancy between aapt1/2 I had to write a simple sorting function. |
Thanks for the large investigation and fix. Will try and visit again tomorrow to step through it as well for my own understanding. |
By the way, I tried with Google's own ProtoStyledStringDecoder, and it also just handles AAPT2's spans (ordered by opening tag?) properly, while AAPT1's spans (ordered by closing tag?) are heavily misplaced. I don't even know of a single piece of code that decodes AAPT1's spans properly, let alone code that supports both orderings... |
My guess is Google can just always depend on aapt2 in Studio prior to bundletool being used. I think every month we see less and less applications being disassembled via aapt1. Of course ignoring legacy apps. |
Fixes #2815 by using recursive writing of nested tags instead of relying on questionable sorting methods.