GetResourceName used GetPAckageById which only works when the compile
time package id is eqal to the runtime package id. This change resolves
resource names correctly using the ruuntime package id.
Bug: 79666085
Test: libandroidfw_tests
Change-Id: Ic60cb2416329c5cb34e925991cd689ca7574b483
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
Teaches idmap2 to recognize policy restrictions put on overlayable
resources. If overlayable enforcement is turned on for an overlay, then
any resources defined within the overlayable api of the target will have
policy restrictions imposed on them. All resources without overlayable
definitions will continue to be overlayable without policy restrictions.
Bug: 119390857
Test: atest idmap2 and booting
Co-authored-by: Ryan Mitchell <rtmitchell@google.com>
Change-Id: I7e435648eb6e4a87b0b90a7b2a0c3f33c1516ea6
This API will be used by Android Studio layout inspector to
query where a given resource attribute originated from to allow
developers to have an easier way to find what needs to be changed
to affect a given resource attribute.
Test: CTS added in the topic
Bug: 111439551
Change-Id: Ifbb52b39912ed0444030a86164290a1cd4155250
After an AssetManager.FindEntry call is made, either directly or from any of the resource entry calls, a stack of the steps taken to resolve the resource is saved. Those steps can be retrieved as a log later on by calling AssetManager.GetLastResourceResolution, which returns a formatted string of the resource ID/name and path taken, including the configs and package names of each step.
Logging and the saving of the steps to memory can be enabled/disabled with the @hide .setResourceResolutionLoggingEnabled() method on AssetManager.
Bug: 122374289
Test: cases for single and multi ApkAssets loaded
Test: case for no resolution made
Test: made test app to display log on device
Test: added debugging call to source and ran through on-device apps
Change-Id: I6a32b8d4020c3f8510032ff7f431510089fff43f
Replace calls to dup() with fcntl(F_DUPFD_CLOEXEC). The only difference
between the two is that O_CLOEXEC is set on the newly duped file
descriptor. This helps address file descriptor leaks crossing an exec()
boundary.
Test: compiles and boots
Bug: 120983106
Change-Id: Icc2ff2f7f398905aa8283c8797898114d34a9829
Encode the actor and name attributes of <overlayable> elements in the
overlayable chunks. Two chunks cannot have the same name.
Bug: 110869880
Bug: 119390855
Test: aapt2_tests and libandroidfw_tests
Change-Id: I0ed95efef640b3927046b6155d1840f0d96030dd
* 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: Id02c36c24f5708584e317c035cef3ef2762b537e
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
This change defines two new chunks for encoding overlayable information.
RES_TABLE_OVERLAYABLE_POLICY_TYPE contains flags that represent
restrictions enforced on overlays that try to overlay a specific set of
resource ids. The chunk header is followed by ResTable_ref for each id
that belongs to the policy type. A policy chunk will be created for
every unique combination of policies that are defined in overlayable
declarations.
RES_TABLE_OVERLAYABLE_TYPE holds policy blocks. Since <overlayable>
does not currently have any attributes, only one overlayable block is
encoded in an APK.
This change also removes the SPEC_OVERLAYABLE flag because the runtime
does not use the flag, and the overlayable chunk encoding renders it
obsolete.
Bug: 110869880
Bug: 117545186
Test: libandroidfw_tests and aapt2_tests
Change-Id: I45ae9bf4176699f14c85e2b7a2e8560185d8a0b8
Do not include configurations or locales from overlays overriding system
resources when exclude_system is specified in GetResourceConfigurations
or GetResourceLocales.
Bug: 120083032
Test: run cts -m CtsContentTestCases -t
android.content.res.cts.AssetManagerTest#testGetNonSystemLocales
Change-Id: I4ba3b07d3bb9ac72b196ff7ed4d1e853b51f7eea
The problem of creating idmap data consists of three steps:
1. create the mapping overlay resid -> target resid
2. fix the padding between the target resids
3. write the mapping as a binary stream
Because we iterate over the resources in the overlay package, there are
no guarantees on the order in which target resources are processed. This
means we can't fix the padding until after step 1. On the other hand,
after step 2 the mapping should be immutable.
Introduce new data structures that help enforce immutability and
ownership of data, as outlined above.
Bug: 80150169
Test: make libandroidfw_tests
Test: atest OverlayHostTests OverlayDeviceTests
Change-Id: I45689e8003c96d251a63a758f77609972ae963df
Change idmap to iterate over the resources in the overlay package
instead of the target package when scanning for resources defined in
both packages. This cuts down the runtime cost of creating an idmap
considerably since the algorithm now scales with the number of resources
in the overlay package (a handful) and not the number of resources in
the target package (android: 10k, SystemUI: 8k) at a minor cost to code
complexity.
Improvements on the runtime of ResTable::createIdmap (systrace on an
emulator running aosp_x86_64-eng):
- target=android: 12.5 ms -> 3.0 ms
- target=SystemUI: 8.6 ms -> 1.0 ms
The bulk of the cost of creating an idmap from installd is now the fork
and execl to call "idmap --fd ..." which weigh in at 16 ms.
Bug: 80150169
Test: make libandroidfw_tests
Test: atest OverlayHostTests OverlayDeviceTests
Change-Id: I98e18d5958c0cd835a73055b714f5bf0f4f95a09
When themes have two different AssetManagers, we only copy attributes
that exist in both the themes. If the value of the attribute or
reference is equal to 0 (a null reference but not using the TYPE_NULL
type), do not attempt to fix the package id of that null reference.
Bug: 119522708
Test: manual test of broken app
Change-Id: Id615d5a47b7f121b08bbba885d106b9cd3f54afc
Prepare the idmap and asset managers for interfacing with idmap2 instead
of today's installd + idmap pipeline, but don't make the switch just
yet.
Instead, idmap2 runs as its own native daemon with an AIDL interface.
This removes the need for installd to fork and exec on each idmap call,
saving about 50 ms per call.
Bug: 78815803
Test: atest OverlayDeviceTests OverlayHostTests
Change-Id: I60852e15d99329896ff9de6559d1e7cd1c67e33d
The entry pool is encoded in UTF-8 not UTF-16. This would cause stringAt
to return a pointer to a cache that holds the UTF-8 string converted to
UTF-16. If the cache becomes invalidated, the UTF-16 pointer is no
longer valid and causes seg faults when looked up.
Test: libandroidfw_tests
Change-Id: I0f13dbeadd0d148de2805efd6cadb8e220368e3b
Only resolve non-dynamic references and attributes if the package is
loaded as a library or if a shared library is attempting to retrieve
its own resources.
Bug: 116486668
Bug: 116620612
Test: libandroidfw_tests & manual test of broken apps
& atest FieldsClassificationTest#testGetAlgorith
Change-Id: Icb827796a65072a39452dbe577d5e18f085ea4e2
The docuemntation of setTo states that the resources two styles from
different AssetManagers have in common will be set in the destination
theme. This change adds this functionality. The package ids of the
attributes, the package ids of reference values, and the cookie of
attribute values have to be rewritten to match the destination
AssetManager. This change can later be made more generic if rewriting
references between packages is needed elsewhere.
Bug: 115897657
Test: libandroidfw_tests and manual test of app specified in the bug
Change-Id: Iee999ea2cc8473168cac11aaf3c34e14c958e5ae
It will be a global error by default.
Test: make checkbuild
Bug: 112564944
Change-Id: I26616fd50ccf3639fa7c01d850a14d079273ede7
Exempt-From-Owner-Approval: do not block on new warnings
Bug: none
Test: m checkbuild
Exempt-From-Owner-Approval: owner is OOO for another week,
it's a fairly minor change to this repository
Change-Id: If4cf57619034ab98b06115ca60beb2fb26c4cd19