To make it easier to add the actor policy in a follow up CL,
move most of the policy handling to a central location.
The strings and transformation between strings and flags is
now handled in libidmap2policies, with libandroidfw
containing the single source of policy flags.
This also extracts all the test resource IDs into an R.h
so they can be swapped without having to edit a dozen files
each time.
Bug: 130563563
Test: m aapt2_tests idmapt2_tests and run from host test output
Test: atest libandroidfw_tests
Change-Id: Ie533c9cebf938215df7586f00c38763ae467e606
"aapt2 compile" marks styleables as public instead of preserving
information from <public/> or --visibility options. This behavior can
now be disabled via --preserve-visibility-of-styleables.
Bug: 146649511
Change-Id: Ifb8ab396573d1393df737a59625e79e9cf2494a7
Tested: aapt2_tests
"aapt2 compile" marks styleables as public instead of preserving
information from <public/> or --visibility options. This behavior can
now be disabled via --preserve-visibility-of-styleables.
Bug: 146649511
Change-Id: Ifb8ab396573d1393df737a59625e79e9cf2494a7
Tested: aapt2_tests
If the value of an attribute enum is defined as a hexadecimal integer,
flatten uses of the attribute as with the
android::Res_value::TYPE_INT_HEX type.
This change adds a "type" field to pb::Attribute::Symbol, which if left
unset, will have a default value of android::Res_value::TYPE_INT_DEC
when deserialized by aapt2.
Bug: 124474141
Test: aapt2_tests and manual compilation of files and inspection using
`aapt2 dump chunks`
Change-Id: Ibf12394284fdbe3a8047f7ecf4fe68517dfc3abb
In aapt1, if you specified the value of an attribute in a style as an
empty string (eg. <item name="my_attr"></item>), the encoded value would
be an empty string. In aapt2 currently, @null is encoded instead. This
change restores aapt1 behavior. Use @null explicitly if the desired
value is to be @null.
Bug: 133450400
Test: manual comparison of APK created by aapt1 and aapt2
<attr name="my_attr" format="string|reference" />
<style name="MyName">
<item name="my_attr"></item>
</style>
$ aapt p -M AndroidManifest.xml -F out1.apk -S res -f
$ aapt2 compile --dir res-o compiled.flata
$ aapt2 link --manifest AndroidManifest.xml -o out2.apk compiled.flata
$ aapt2 dump out2.apk
Change-Id: I8aa0ba30379dac0b1229da525abbc5482f40114b
Instead of printing the tag name, print the type name when the type was
unable to be recognized. The type name is initialized to the tag name
and changes when a type attribute is defined..
Bug: 37891551
Test: manual
Change-Id: I9b0e6a6f2d96a8c5af71fbca8e83c947a8e308bf
AAPT does not allow for attributes declared in declare-styleables
that do not have a format to create new attribute resources. AAPT2
does and should not.
Bug: 131100106
Test: aapt2_tests
Change-Id: Id00884dc9ed939672df90f670a7915d4b6d232c1
This change adds parsing, encoding, and validating of odm and oem
overlayable policies to aapt2, libandroidfw, and idmap2.
Bug: 121033532
Test: aapt2_tests, idmap2_tests
Change-Id: Ifc0d4b6c9f9c37e06b2988abade69dbb277c50c2
CDATA blocks were being processed differently in aapt2 so this change
fixes aapt2 to not treat cdata blocks differently and still trime
whitespace.
Also, aapt did not process escapes when compiling xml files. This
change removes over-processing of xml text nodes.
All test strings are what aapt(1) would output.
Test: aapt2_tests
Bug: 124470332
Change-Id: I90ee0c1e5e9208f8a5c60cee93e3ba02712c9b2c
If the inner element of a <plurals> tag fails to parse, aapt2 will seg
fault. Don't do that.
Bug: 123423125
Test: manual
Change-Id: Iff39fa84073da62d85279683ac3d03b7309bc5e3
Add encoding/decoding of new policy for overlays. Signature enforces
that an overlay package is signed with the same key as the actor of
the target resource, so that an overlay can be installed by the user
as a normal app but restricted to those built by the author of the
actor (which can be the same as the target).
This also enforces that a valid policy is specified.
This doesn't implement the actors nor the signature check.
Bug: 119402606
Test: ResourceParserTest ParseOverlayablePolicy
Test: ProtoSerializerTest SerializeAndDeserializeOverlayable
Test: aapt2_tests
Change-Id: I8495ad790c2ebd51759bc6eba81149680c209475
When loading the binary APK, do not set the paths of Source structs to
the path of the binary APK. This causes the merge_zips step of the build
system to fail.
Bug: 124082573
Test: vendor/google/build/build_mainline_modules.sh
Change-Id: I84b8d43c5b6a5835e7ff6bd579c4eb744e02c20f
Sometimes AAPT2 doesn't include the path of the file in the error
message, or just outputs a warning where an error should be printed
(but the overall build still fails without an error message). Let's
always include the file path to make it easier for the users to find out
the source of the failure.
Fixes: 122856772
Test: manual
Change-Id: Ibbbfd21b372792e5eaa40278186eb64cdfb0f60e
Since Q will no longer have a product_services partition, remove instances of
the product_services policy across aapt2, androidfw, and idmap2.
Bug:122745343
Test: aapt2_tests and libandroidfw_tests
Change-Id: I97c223a0bf5a2eab95811e5f738b44af6335e0ea
Add parsing of two overlayable attributes:
name : The unnique identifying name of the overlayable set of resources
actor: The component responsible for enabling and disabling overlays
targeting the specified set of resources
Bug: 110869880
Bug: 119390855
Test: m -j aapt2_tests
Change-Id: Id42463e2b92b69034fb39cd29bc8606affb61ba7
This change removes the ability for an overlayable resource to be
defined in multiple policy blocks within the same overlayable. This
change also changes aapt2 to use a bit mask to keep track of the parsed
policies.
Bug: 110869880
Bug: 120298168
Test: aapt2_tests
Change-Id: Ie26cd913f94a16c0b312f222bccfa48f62feceaa
<overlayable> tags can now have policy elements that indicate which
partition the overlay apk must reside on in order to be allowed to
overlay a resource. This change only adds parsing of <policy> and
encoding of policy in the proto ResourceTable. A later change will add
the encoding of policy and overlayable in the binary APK.
<overlayable>
<policy type="system|vendor|product|product_services|public" >
<item type="string" name="oof" />
</policy>
</overlayable>
Bug: 110869880
Test: make aapt2_tests
Change-Id: I8d4ed7b0e01f981149c6e3190af1681073b79b03
This is to allow idmap2 to access ConfigDescription.
Test: libandroidfw_tests
Test: aapt2_tests
Change-Id: I54210bbbd8dad5903cb7100807df977efa394ad5
Merged-In: I54210bbbd8dad5903cb7100807df977efa394ad5
This change adds support for resources that have CDATA blocks within
their values. The blocks should allow any character to occur without
being escaped. It also should not effect the current state of quote
processing.
Bug: 80326349
Test: Created tests in aapt2_tests
Change-Id: Ie1a00e50cffc877e2eb5f788f8d7a1bda839c0cf
Trim whitespace of raw strings when parsing xml values. This change
trims the whitespace of style items. For example:
<item name="viewInflaterClass">com.helloworld.Inflater
</item>
This will be trimmed to not include a trailing whitespace.
Bug: 109666819
Test: aapt2_tests
Change-Id: I0c1fbb3abdc7e609316c92e59ccaf0573b07e5a7
A previous change, editied the logic for parsing ids to allow for ids to
reference other ids. This change though caused a regression that made
ids in the form '<id name="name" />' cease to parse. This changes fixes
that regression.
Bug: 78513618
Test: Updated tests in ResourceParser_test.cpp
Change-Id: I3608bb764464e951a50910be55e199c6ec575d09
AAPT would allow for ids to be declared in the form:
<item name="name" type="id>@id/other</item>
@id/name should hold a reference to @id/other. When
getResources().getValue() is called on R.id.name with resolveRefs
enabled, the resuling reference should be R.id.other.
Bug: 69445910
Test: Created tests for correct parsing of id references and correct
resolving of deep references
Change-Id: Id1feb37b2565c213dc6a19b4c401906260d7fc14
Change styled string whitespace processing to be like AAPT's was.
Main changes:
- whitespace around tags is preserved.
- tags start exactly where they are supposed to, not off by one.
Bug: 72406283
Test: make aapt2_tests
Change-Id: I4d12728c493efd8c978e2e3d2718b56534ff52ef
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 doesn't actually do anything yet, but makes sure
it is not a syntax error and allows teams to start marking
their resources as overlayable.
The syntax form marking a set of resources as overlayable
looks like:
<overlayable policy="system">
<item type="string" name="foo" />
<item type="style" name="bar" />
</overlayable>
Currently, the only supported policy is "system", meaning only
the system will be able to overlay the resources. Leaving
out the policy attribute defaults to "system".
Bug: 64980941
Test: make aapt2_tests
Change-Id: Ied7a9ddae87a4a0af6a0f4d1c213bfce8a0ed612
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
Move the styled strings to a separate section of the StringPool so
that sorting can never mess up the order of Styles.
Bug: 63570514
Test: make aapt2_tests
Change-Id: Id2ce1355b92be1bb31ce0daa7e54ae9b5b6c2ffe
A resource defined like so:
<item type="drawable" name="foo" />
should be assigned the value @null.
The only exception is for <string> resources, which are given the
empty string value (since <string></string> is ambiguous). The decision
to use "" is based off the fact that old AAPT used to assign "" to all
undefined resources, even non-string ones.
Bug: 38425050
Test: make aapt2_tests
Change-Id: Ib3e0f6f83d16ddd8b279c9fd44a07a37867b85e9
TO bring AAPT2 behavior in-line with AAPT, <item> has a default
format of "any", and only becomes restricted with an explicit format
attribute.
Bug: 62260121
Test: make aapt2_tests
Change-Id: Ife416f520e6c2710bb30e3ba3f2d4463794bfa06