Skip to content
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

refactor: clean up external pull parser and introduce brut.j.xml #3709

Merged
merged 2 commits into from
Oct 15, 2024
Merged

refactor: clean up external pull parser and introduce brut.j.xml #3709

merged 2 commits into from
Oct 15, 2024

Conversation

IgorEisberg
Copy link
Contributor

@IgorEisberg IgorEisberg commented Oct 5, 2024

We have no need for an XML pull parser in the project, it was only used for a test, which is now done with XPath.

The external xpp3 library from org.ogce is obsolete and has the issue of including javax.xml.namespace.QName which conflicts with the JRE implementation that exists for a very long time now. This makes direct usages of QName produce very obscure NPEs that took me hours to figure out. This patch will allow further optimization that is WIP.
The external library was replaced by the basic xmlpull API.

The MXSerializer has been cleaned and the features used by apktool have been integrated into the custom implementation, now part of a separate module called brut.j.xml.
Writing has been optimized by buffering write operations, inspired by KXmlSerializer used by Android itself.

A class XmlPullUtils also written that allows copying from a XmlPullParser into a XmlSerializer with or without an EventHandler. We use it for AndroidManifestPullStreamDecoder (with EventHandler, to allow omitting the uses-sdk tag), and for ResXmlPullStreamDecoder (direct copy, without EventHandler).

saveDocument in ResXmlPatcher was tweaked to output XML matching the input - a new line after declaration and a new line after root element's end tag.

TL;DR mostly behind the scene refactor, no end user changes.

We have no need for an XML pull parser in the project,
it was only used for testing, which is now done with XPath.

The external xpp3 library from org.ogce is obsolete and has
the issue of including javax.xml.namespace.QName which conflicts
with the JRE implementation that exists for a very long time now.
This makes direct usages of QName produce very obscure NPEs that
took me hours to figure out. This patch will allow further
optimization that is WIP.
The external library was replaced by the basic xmlpull API.

The MXSerializer has been cleaned and the features used by apktool
have been integrated into the custom implementation, now part of
a separate module called brut.j.xml.
Writing has been optimized by buffering write operations, inspired
by KXmlSerializer used by Android itself.

A class XmlPullUtils also written that allows copying from a
XmlPullParser into a XmlSerializer with or without an EventHandler.
We use it for AndroidManifestPullStreamDecoder (with EventHandler,
to allow omitting the uses-sdk tag), and for ResXmlPullStreamDecoder
(direct copy, without EventHandler).

saveDocument in ResXmlPatcher was tweaked to output proper output -
a new line after declaration and a new line after root element's
end tag.

TL;DR mostly behind the scene refactor, no end user changes.
@iBotPeaches
Copy link
Owner

This is cool - nice work

@IgorEisberg
Copy link
Contributor Author

You OK bro? You went quiet.

@iBotPeaches
Copy link
Owner

You OK bro? You went quiet.

PXL_20241010_122259137.mp4

@IgorEisberg
Copy link
Contributor Author

You OK bro? You went quiet.

PXL_20241010_122259137.mp4

Oh shit, you live in the US? I heard about that hurricane mess. Such a wild place to live in.
Stay safe man, I hope the authorities are taking care of you.

@iBotPeaches iBotPeaches merged commit b49e770 into iBotPeaches:master Oct 15, 2024
25 checks passed
@iBotPeaches iBotPeaches added this to the v2.11.0 milestone Oct 15, 2024
iBotPeaches added a commit that referenced this pull request Oct 15, 2024
@iBotPeaches
Copy link
Owner

thanks! catching up on things now with internet/power.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants