* 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
* fix: support API 35 as Vanilla Ice Cream
* feat: update internal framework to API 35 preview (Vanilla Ice Cream)
* chore: SDK_CUR_DEVELOPMENT is 10,000
If th zip entry for resources.arsc is not found an exception is
thrown, but the ZipFile is not closed. Using try-with-resources
means that the ZipFile will always be closed irrespective of how
the code block exits.
* refactor: rename sanitize function
* fix: expose getDir
* fix: safe handling of untrusted resource names
- fixes: GHSA-2hqv-2xv4-5h5w
* test: sample file for GHSA-2hqv-2xv4-5h5w
* refactor: avoid detection of absolute files for resource check
* chore: enable info mode on gradle
* test: skip test on windows
* chore: debug windows handling
* fix: normalize entry with file separators
* fix: normalize filepath after cleansing
* chore: Android paths are not OS specific
* refactor: use java.nio for path traversal checking
* chore: align path separator on Windows for Zip files
* chore: rework towards basic directory traversal
* chore: remove '--info' on build.yml
* perf: process smali code in parallel
Note: backsmali can't be properly multithreaded because of the synchronized methods inside
* perf: start backsmali concurrently with a resources decompiler
* perf: speed up apk building by skipping temp archive creation
Now we're not compressing the same data twice
* refactor: extract duplicated code
* refactor: rename methods and inline some comments
* build: update aapt/aapt2 with win/linux binaries
* docs: add note for specific aapt tag
* test: test for grammatical inflection
* build: update aapt/aapt2 with mac binaries
* build: update aapt/aapt2 with mac binaries (static libstl)
* fix: prevent over-reading config flags
* feat: add grammatical inflection
* fix: add natural requirement for U
* fix: UpsideDownCake is now 34
* test: test for grammatical inflection
* fix: add detection for compact resources
* fix: add detection for offset16 table types
* Revert "test: test for grammatical inflection"
This reverts commit fa08cef9fe6d436176f74152d85a652a771971ad.
* refactor: use enum instead of magic numbers
* 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