* Add explicit to conversion constructors/operators
* Use NOLINT or NOLINTNEXTLINE to suppress warnings on intended converters
Bug: 28341362
Test: make with WITH_TIDY=1 DEFAULT_GLOBAL_TIDY_CHECKS=-*,google-explicit-constructor
Change-Id: Ie02101ea7c422e8add535c111a30a2f21ead0ace
Teach "aapt2 link" about a new flag --no-resource-removal. When given,
aapt2 will not filter out resources that lack default values. This is
useful mostly when building overlay packages that define resources for
non-default configurations, such as only for values-sv.
Test: manual: build package with resource only in values-vs, verify apk with aapt2 dump
Change-Id: Idc513bcb3f43bbff7f073163562c3dfccdb9bc9b
Merged-In: Idc513bcb3f43bbff7f073163562c3dfccdb9bc9b
This is to allow idmap2 to access ConfigDescription.
Test: libandroidfw_tests
Test: aapt2_tests
Change-Id: I54210bbbd8dad5903cb7100807df977efa394ad5
Merged-In: I54210bbbd8dad5903cb7100807df977efa394ad5
Pre-O, the platform treats negative resource IDs [those with
a package ID of 0x80 or higher] as invalid. In order to work
around this limitation, we allow the use of traditionally
reserved resource IDs [those between 0x02 and 0x7E].
Bug: 78041707
Test: ./out/host/linux-x86/nativetest64/aapt2_tests/aapt2_tests
Test: ./out/host/linux-x86/nativetest/libandroidfw_tests/libandroidfw_tests
Test: Manual. Create a feature split with a package ID of 0x7E and see it runs and can reference base resources.
Change-Id: I3d9782cc05d3a55e1a2467bf39566788847e1160
We automatically pull the compile SDK from the platform. But,
in certain circumstances the platform's SDK codename is
incorrect. Allow the name to be overridden on the command line.
Change-Id: I398f1b00b29db42e4ce202b94cda483c98971a14
Fixes: 78324052
Test: ./out/host/linux-x86/nativetest64/aapt2_tests/aapt2_tests
Test: Tested for normal functionality when string does not exceed
maximum length and tests for detection of string that is too lonhg for
UTF8i
Bug: b/74176037
Change-Id: Ic71d3671a069e7012e8ca107e79e071499eebbf6
(cherry picked from commit a15c2a8957b9883cb293fdacaeabd7f2e037a0a5)
Bug: 74968793
Test: Tested for correct debuggable attribute presense with and without
flag
Change-Id: I0148d1caba62db8cf258926f1d9e87a849aa283f
(cherry picked from commit 444f9bb6a18ff34b69cba504c8658b7013eaa53a)
According to our docs:
https://developer.android.com/guide/topics/resources/localization.html#defaults-r-important
Some resources *require* that there is a default definition. So far,
the pain is felt when doing translations for strings that have been
renamed, etc.
This CL strips out resources that don't have a default value and define
a resource for a locale. This is conservative, but should be expanded
to other configuration properties moving forward.
Bug: 36572857
Test: make aapt2_tests
Change-Id: Ife94a1f8a2ee221f8532ffa856541a9c8c4e7143
When compiling straight to proto from source, the file types
were not set correctly (binary XML or proto XML).
Bug: 73406447
Test: manual
Change-Id: I68c1881a00a2ec1ad58f7ec485af2543d262d076
Currently in the link step ContainerReader is used to read files but the
reader is not checked for errors prior to the read. This can lead to
silent failure when reading invalid resource files.
Change-Id: I6420699ad30b5b84b0b2c696af8eb5a6cbd4111e
If a resource XML file defines two compatible Attributes, they should
be merged without throwing an error. Ex:
<declare-styleable>
<attr name="conflict" format="string" />
</declare-styleable>
<declare-styleable>
<attr name="conflict" format="string|reference" />
</declare-styleable>
In this case, string|reference and string are the same, so these should
merge correctly.
Bug: 65699599
Test: make aapt2_tests
Test: make AaptBasicTest
Change-Id: I7b0f956d2332f7f0b458acd59ca0a606b2cfdf95
Resources can be marked as overlayable, which means they can
be overlaid by runtime resource overlays.
This change propagates this state to the final resource table that
is installed on device.
Future work:
- Have the idmap tool respect the overlayable state and ignore
entries that overlay anything else.
Bug: 64980941
Test: make aapt2_tests
Change-Id: Id45b1e141a281be2ee32a4ac3096fcf1114d523b
This change injects the 'android:compileSdkVersion' and
'android:compileSdkVersionCodename' into an app's AndroidManifest.xml,
whose values are dervied from the version name and version code of the
framework AndroidManifest.xml that is being linked against.
Bug: 63388434
Test: make aapt2_tests
Change-Id: I7b607192ecb337307c4bcb5770e7f716c6d4c9d2
FileOutputStream is safe to use on Windows, as it opens
files using our compatibility API.
Bug: 68262818
Test: make aapt2_tests
Change-Id: Ib0b27e93edd609b49b1327db7d9867a002198ebb
Android Instant Apps in its current iteration does not use namespaces,
but due to limitations on the Android resource runtime, needs to make
it look like it does.
This is due to a bug that treats any package ID that's not 0x01 or 0x7F
as a shared library. Shared libraries require unique package names.
As a workaround, and since Android Instant Apps can not have a feature
depend on another feature, we can alter the resource package name of a
feature split just before writing it out to disk. This avoids using a
unique package name while linking, thereby avoiding namespace issues.
Bug: 68820737
Test: manual
Change-Id: Ic553ed42656436bbb949393d0248ee7bb9d37860
This command allows a developer to convert their proto APK
(generated from the link phase using --proto-format) into
a binary APK suitable for use on device.
aapt2 convert -o output.apk input.apk
Test: manual + make aapt2_tests
Change-Id: I10a7c33bb4b57006d01fe00a8bf92f78e04e7e50
Add the option to produce keep rules that conditional keep based on
usage of R identifiers. This allows Proguard to potentially shrink more
code if resources are not used.
Currently only produces conditional rules for classes referenced in
layout resources because they are the most common and has the easiest
transitive usage chain to analyze.
Bug: 63628451
Test: make aapt2_tests and manual testing
Change-Id: I6c1af7affd64af40c80e004d8506a9463444b2c3
- This will allow the bundle tool to ingest the outputs of the aapt2 link
phase.
Bug: 64143208
Test: manual
Change-Id: I1a4b3ce5c2ffbbdc4bc642c3371a9ef2e7e9ad71
AAPT Container Format (.apc) is a simple container that
enumerates the various intermediate files that AAPT2 generates
during the compile phase.
The format is defined in formats.md.
For now, continue using the .flat extension for the container file,
and keep making use of the .flata zip for storing multiple files.
This will allow easier integration with existing build systems and allow
the evolution of the APC format to better handle arbitrarily large
files.
Test: make aapt2_tests
Change-Id: Id7216e5b76316bdd683f0fa4eaf2d2da273ba815
A few OEM devices have introduced a memory corruption bug
that is only triggered when an application's AndroidManifest.xml
uses UTF8 string pools. Workaround this by only encoding
AndroidManifest.xml with UTF16 strings.
Bug: 64434571
Test: manual
Change-Id: I2ee50d1b2b5942d971ef2a544c878de63f67c652
This proto format is meant to encapsulate more information
that is specific to Android and allows for easier validation
and manipulation across tools.
Test: make aapt2_tests
Change-Id: I13bc34a460671fc0a36246be0d287a3d37d244d6
A few pieces were missing in the namespace mangling implementation.
Namespace aware libraries now work, along with R class generation.
Bug: 64706588
Test: make AaptTestNamespace_App
Change-Id: I12f78d6aa909e782c0faf7ceaa36058f2e6c864a
In preparation for exporting an XML proto format for UAM to consume,
this change brings the XML DOM API more in line with other APIs that
do not make the Namespace a separate node.
Treating Namespace declarations as just properties of an Element
node makes the implementation of algorithms much simpler, as
the constraints that Namespace nodes have only one child
are now built in and traversing to find Element nodes
is much simpler.
Also made a bunch of quality of life improvements, like formatting and
comment style.
Test: make aapt2_tests
Change-Id: Ib97ff1c4252b7907e2cc1f13a448dc4ca3b809a4
Mingw64 was being difficult, so instead of defining a wmain entrypoint,
the command line parameters are parsed manually using built-in Windows
methods that support Unicode. The results are converted to UTF8 and
handled just like the rest of the linux/mac version of the code.
This also removes dependencies on std::istream in favour of a
FileInputStream which calls the appropriate unicode version of
open to read a file.
No speed regressions found on Linux or MacOS.
Bug: 62336414
Bug: 63830502
Test: manual
Change-Id: I597da51e33729ed1b98bf246e7e773337fd3fee8
* Use const reference parameter type to avoid unnecessary copy.
* Use more efficient overloaded string methods.
Bug: 30407689
Bug: 30411878
Test: build with WITH_TIDY=1
Change-Id: Iaa0a6f18f64cf573bee49dd1466281ea4d37b410
Auto version adaptive-icon XML to v26.
This change makes the logic for generating versioned resources
simpler by changing the comparison function of ResTable_config
to evaluate the sdkVersion property last, making configurations
that differ only in sdkVersion next to each other in a sorted vector.
Bug: 62316340
Test: manual (verified output of tools/aapt2/integration-tests/AppOne)
Change-Id: I977d45821722a65d2135efb4693304eacc565c9a
Keep in sync with AAPT. Since gradle is moving to use AAPT2
by default, updates to AAPT will no longer be necessary and
this will be the authoritative list until a more programmatic
solution presents itself.
Bug: 62211148
Test: manual
Change-Id: Id9232c9fb730c50e4850887fa0f5da82574ca900