summaryrefslogtreecommitdiff
path: root/tools/aapt2/cmd/Link_test.cpp
AgeCommit message (Collapse)Author
2021-05-10Add <staging-public-group-final> to aapt2Ryan Mitchell
To allow apps that compiled against a pre-release SDK to continue working for a period of time after API finalization, a new tag, <staging-public-group-final>, has been added to aapt2. When finalizing the framework resource API, converting <staging-public-group> tags to <staging-public-group-final> will cause aapt2 to generate the resource table so that there is a resource entry for the old non-finalized (staged) resource ID and another entry for the finalized resource ID of newly finalized resources. This allows an application that compiled against the pre-release SDK to continue resolving resources using pre-release resource IDs. All references to pre-release resource IDs will be rewritten to their finalized resource IDs through the information stored in the new staged alias chunk. This allows applications compiled against <staging-public-group> resources to use the newly finalized resource ID without re-compilation. When an application is re-compiled against the SDK with <staging-public-group-final> tags, the application will use the finalized resource IDs. This change limits the use of the alias chunk to the framework for S. Bug: 183411356 Test: aapt2_test Change-Id: Iba1c3033c3c2f32de8e4a19b58d3921c971092c4
2021-04-28Add <macro> tag to aapt2Ryan Mitchell
AAPT2 Macros are compile-time resources definitions that are expanded when referenced during the link phase. A macro must be defined in the res/values.xml directory. A macro definition for a macro named "foo" looks like the following: <macro name="foo">contents</macro> When "@macro/foo" is used in the res/values directory or in a compiled XML file, the contents of the macro replace the macro reference and then the substituted contents are compiled and linked. If the macro contents reference xml namespaces from its original definition, the namespaces of the original macro definition will be used to determine which package is being referenced. Macros can be used anywhere resources can be referenced using the @package:type/entry syntax. Macros are not included in the final resource table or the R.java since they are not actual resources. Bug: 175616308 Test: aapt2_tests Change-Id: I48b29ab6564357b32b4b4e32bff7ef06036382bc
2021-03-31Use staging-public-group in framework SDKRyan Mitchell
To make S finalization easier, this changes the framework SDK so that apps linking against it will be able to continue working as expected after the first phase of SDK finalization. During the first phase of SDK finalization, the resource ids of resources that have not been removed are finalized. staging-public-group tags are converted to staging-public-group-final tags in order to encode into the framework what the staged resource id of a finalized resource was. When an app recompiles, it will use the finalized resource id. Then after all apps recompile, phase 2 of finalization begins, in which the staging-public-group-final tags are removed so apps can no longer use the staged resource ids. Apps that link against the SDK (provided they are using a recent version of aapt) will encode references to staged resources as TYPE_DYNAMIC_REFERENCE and TYPE_DYNAMIC_ATTRIBUTE. The values of R fields for staged resources are defined out-of-line to prevent them from being inlined into apps linking agsint the SDK. This allows the resource ids to change during phase 1 of API finalization. Bug: 183413192 Test: `aapt2 diff` and resource ids stayed the same Test: `aapt2 dump` of framework-res.apk and observe staged resources Change-Id: Ie2275c608297a5f63dde8b1cf795415112cbcc24
2021-03-29Add staging-public-group to aapt2Ryan Mitchell
staging-public-group is a tag for putting resources that have been added during platform development, but have not yet been finalized, into a separate resource id namespace. R.java fields of staged resources are non-final, so when the SDK is finalized, applications using the android R.java will automatically use the new finalized resource id without having to recompile. Staged resources can exist either in the same type id as the type's non-staged counterpart or in a separate type id. Multiple staging-public-group tags each with a different type id can exist simultaneously, which allows for multiple versions of the platform to be developed at once. Bug: 183411093 Test: aapt2_tests Change-Id: Ibb6c84c3626751e33c6097f35a03e306bb85616a
2021-03-29Refactor aapt2 tests ResourceTable changesRyan Mitchell
This changes refactors tests to use the NewResourceBuilder class that makes it easier to construct resource entries. Bug: 183102797 Test: aapt2_tests Change-Id: I851f9fb99a003769f8df8c1876997eee0864822a
2021-02-24Use R field directly for shared lib styleable attrsRyan Mitchell
If a shared library exposes an attribute and a client uses the attribute in its own styleable, the value of the lib attribute resource id in the client styleable must be fixed with the correct package id at runtime. Since the client will not have an onResourcesLoaded to call, the client should directly reference the attribute resource field in its styleable. Bug: 147674078 Test: aapt2_tests Change-Id: I8e64bb2d3165a7072e2604fe1730b248545978f4
2019-06-26Allows features to link to other feature splits without namespacing.Udam Saini
Add uses-split dependencies to AppInfo. At link time, this is used and allows features to reference other features, before resource namespacing is implemented in Android Studio. bug:135681292 Test: Link_test, ReferenceLinker_test, and integration tests. Change-Id: Ifdf0067e7370552b6b9d4d6d4713d4484b6ea154
2019-06-12[aapt2] Add "link" option to override styles instead of overlaying.Donald Chai
For normal app development, the desired linking semantics are: * styleables - take union of all definitions * all other resources - take last non-weak definition This differs from the semantics needed in other scenarios, where merging/overlaying styles is desired. Bug: 134525082 Change-Id: Iac0c43ca2ecf1f3fddc9c3367f8914c12c9258e1 Tested: aapt2_tests
2019-06-10Fix asset compression to check name ends with argRyan Mitchell
There exists a discrepancy between how aapt1 and aapt2 prevent the compression of assets using the -0 flag. aapt1 checked if the file name ended with an argument, but aapt2 is checking if the file extension exactly matches the argument. This change makes aapt2 behave the same as aapt1 for asset compression using the -0 flag. Bug: 132823799 Test: aapt2_tests Change-Id: I641b3ebce29e4407b543faea373a5ce516b70cda
2019-01-23Hold data pointer reference to AAPT2 test fileWinson
To try and solve test flakiness, hold the unique_ptr in the method scope to make sure it's cleaned up after we assert on it. Bug: 123079798 Test: gonna merge and check for failures, since it passes locally Change-Id: Id348d1112832cbb82f605a84ef675c25a7488b11
2019-01-03Remove raw values from proto APKRyan Mitchell
Raw attribute values are not included in xml files when building binary APKs but they are when building proto APKs. Remove raw attribute values and create a new convert flag that (--keep-raw-values) that allows raw value to be kept. Also added flag to link to keep raw attribute values. Bug: 115915884 Bug: 116700688 Test: aapt2_tests Change-Id: Id50136b775b3f43d159ca06181282f6a7b8eaf40