* refactor: clean up external pull parser and introduce brut.j.xml
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.
* refactor: ApkDecoder & ApkBuilder overhaul
A major rewrite of ApkDecoder and ApkBuilder classes to make them managable.
Removed many instances of redundancy and improved syntaxed and indentation.
Modifying the stock Apktool source to our needs have become too difficult,
so I'm pushing the general (not specific to our needs) changes upstream.
I'd change a lot more, but I wanted to make sure all tests pass as expected,
despite some of them being wierd, outdated or unnecessary.
This also fixes certain files in META-INF being lost during recompile
when the -c/--copy-original option isn't used.
This has been tweaked and tested for several days and I vouch for its stablity.
* style: fix more redundancy
* style: fix more redundancy
* tweak: consistent case-sensitivity for cmd and options
* refactor: tracking unknownFiles via apkInfo is redundant
1) We take advantage of the fact that doNotCompress already tracks uncompressed files,
including those separated into "unknown".
With this change the "unknownFiles" is simply ignored, so it's backward-compatible
with existing decoded APK dirs.
Tweaked a few tests to match the removal of "unknownFiles".
2) Passing doNotCompress to AAPT is redundant, Apktool extracts the temp APK packed by
AAPT to build/apk and then repackages it anyway, so it serves no purpose.
* refactor: fix minSdkVersion from baksmali + clean up more redundancy
* Regression: minSdkVersion inferred from baksmali was not stored properly.
* The arsc extension can be generalized for simplicity as seen in AOSP source.
https://cs.android.com/android/platform/superproject/main/+/main:external/deqp/scripts/android/build_apk.py;l=644?q=apk%20pack&ss=android%2Fplatform%2Fsuperproject%2Fmain:external%2F
Note:
NO_COMPRESS_EXT_PATTERN only collapses paths to a common extension.
It does NOT force these extensions to be always uncompressed.
doNotCompress is the one determining files/extensions that should be uncompressed.
(no funcionality was changed)
* resourcesAreCompressed in apkInfo is redundant. It was only used in invokeAapt,
but not ApkBuilder. Its value is also never set by Apktool, only read.
Like with doNotCompress, passing any kind of compression rules to AAPT is pointless,
since we don't use the temp APK packed by AAPT directly - it's extracted and repacked
by ApkBuilder, where doNotCompress already determines whether resources.arsc should
or should not be compressed in the final APK.
(no funcionality was changed)
* style: optional args come after required args
* style: optional args come after required args
* style: sdkInfo as a normal field for consistency
* style: some formatting tweaks
* Revert "Remove Apktool Dummys. (#3258)"
This reverts commit 0e226928ce428077aa3177b11c7da62b3c1aef27.
* feat: properly add dummys
* refactor: shorten ResTypeSpec
* style: remove extra space
* refactor: extract FlagItem into own class
* refactor: notate which type is null
* fix: only add dummys if enabled
* feat: skip unknown (if enabled)
* feat: introduce "res-mode"
* feat: expose config on res table
* feat: add method to base attr for res skips
* fix: ensure autobuild doesn't choke
* refactor: remove java17 enhanced switch
* refactor: rename methods
* refactor: cleanup res-mode param
* test: introduction of test/sample apk
* refactor: make ResXmlPatcher public for loading XML
* test: assertions for dummy|leave|retain
* fix: prevent using `@null` as a name
* refactor: shorten long param for 'resm'
* refactor: leave for preserve
* feat: initial migration to kotlin
* feat: initial migration to kotlin
* fix: wire up dependencies
* fix: Deprecated tag for kotlin detection
* refactor: put all modules into sub-projects
* fix: include jar file (android framework)
* fix: add version message/info
* fix: wire up version/gitrev to properties
* fix: wire up proguard on cli
* fix: wire up proguard
* fix: wire up output cleaning command
* fix: drop license header on gradle files
- fully rewritten from scratch by myself
- no longer including license header on build files
* fix: add compile utf8/flags for java8
* refactor: remove unneeded curly braces
* feat: progress towards maven-publish
* build: publish to maven
* docs: update documentation
* refactor: prevent implicit order by removal of afterEvaluate
* build: remove unused license plugin
* Simple straitforward yaml serialization with minimal needed functionality
* Consolidate ApkInfo tests in the package brut.androlib.apk, unify interface YamlReader and add ApkInfoSerializationTest read -> write -> read test
* remove dependencies from snakeyaml
* remove unused methods
* correct indent test value
* correct style with curly braces
* add test item with hieroglyph
* extract AaptInvoker and rename MetaFile to ApkInfo, all decode methods from AndrolibResources moved to the ApkDecoder
* extract ARSCData and FlagsOffset from ARSCDecoder and remove unused imports
* rebase to master
* move decodeManifest and decodeResources to the ResourceDecoder
* remove commented old code
* added option to include permissive network security config file during build
* added tests for app with existing network config and for app without
* minor fixes for pull 2791
* refactor: slim down test app for network config
* style: remove extra newlines
* refactor: moved network tests to aapt2
* refactor: remove unused exceptions
* test (aapt2): ensure aapt2 is used for net-sec-conf
* fix (cli): block use of net-sec-conf on aapt1
* fix conflict
Co-authored-by: Connor Tumbleson <connor@sourcetoad.com>
Co-authored-by: Connor Tumbleson <connor.tumbleson@gmail.com>