refactor: modernize --res-resolve-mode and dummies #4044
Merged
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.
--res-resolve-modehas a new name in 3.x we can afford to update the modes to better describe their meaning.default: Adds dummy entries only for resources that cannot be resolved.(this is done after ARSC parsing, during resolution and res file decoding stages)
greedy: Adds dummy entries for all missing resources in the resource table.(this is done during ARSC parsing, at the end of each package)
lazy: Ignores resources that are missing or cannot be resolved.(Docs will be updated after merge.)
APKTOOL_MISSING_is now alsoAPKTOOL_DUMMY_(they are the same thing, just were added at different stages).Improve dummy serialization based on each item/bag type's default value.
Case study:
aapt2 dump resources:
We learn that:
array,attr,plurals,style) is an empty bag of the given type.idtype is a special placeholder (we already handled that).stringtype is the empty string ("").@null.Use that to serialize them accordingly and add dummies with the appropriate default value.
The result is avoiding unnecessary
<item>tags and unnecessary@nulls where empty tags mean the same.Much cleaner output,
<item>tags are used only when it's unavoidable.Also added a few test cases for this.