Commit Graph

148 Commits

Author SHA1 Message Date
TreeHugger Robot
b0815b80e8 Merge "Add support for /oem/overlay" into qt-dev 2019-04-24 08:33:38 +00:00
Ryan Mitchell
939df096be Add odm and oem policies
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
2019-04-17 16:07:57 -07:00
Mårten Kongstad
eb8a5c0b91 Add support for /oem/overlay
Add support for runtime resource overlay (RRO) APKs in /oem/overlay.

Bug: 121033532
Test: manual (adb push apk to /oem/overlay, reboot, cmd overlay list)
Change-Id: I70b23b11831d57b3241e6057c745aa4ce9f795ef
2019-04-09 06:37:33 -07:00
Mårten Kongstad
48c24cf149 Add support for /odm/overlay
Add support for runtime resource overlay (RRO) APKs in /odm/overlay.

Bug: 121033532
Test: manual (adb push apk to /odm/overlay, reboot, cmd overlay list)
Change-Id: I0918d276dfa6a43054068d3f84ecd0d1639f1d0b
2019-04-02 11:07:10 -07:00
Winson
b0085ce5b6 Fix AssetManager2 isUpToDate check
This logic was lost in the AssetManager1 -> 2 migration.

The old AM1 checked the last modification time of the file
and compared it to a previously stored value. This re-adds the
logic to ApkAssets and fixes the checks in the JNI/Java layer.

Unfortunately I couldn't find a failing/practical case where
this check mattered. It only came up when diagnosing an issue
which ended up being unrelated.

Test: manually ran with other overlay changes

Change-Id: I758e4af1d32a9c03b2204a8a3a26e82b7e83feda
2019-03-29 12:18:18 -07:00
Mårten Kongstad
dbf343becb RRO: remove ability to overlay assets
Target packages use <overlayable> to opt-in to RRO. While this works for
resources, it does not support assets. For security reasons, remove the
ability to overlay assets via RRO for now: a future change may extend
<overlayable> to include assets.

Test: atest OverlayDeviceTests
Bug: 120867881
Change-Id: Ie0b6897f0586ea8b9d75f357e216904e25d4dc7b
2019-03-19 15:40:55 -07:00
Aurimas Liutikas
f9dbd5fed6 Clean up attribute apis based on api council feedback.
Bug: 127714248
Test: None
Change-Id: I40596a88e7e446c6a25f2b9074bb88a0a417ed63
2019-03-07 14:23:59 -08:00
TreeHugger Robot
1f24ccf2f6 Merge changes from topic "display_policy"
* changes:
  DisplayEventDispatcher: add DISPLAY_EVENT_CONFIG_CHANGED
  SurfaceControl: add setAllowedDisplayConfigs
2019-02-27 00:01:45 +00:00
Ady Abraham
a5a21f70e1 DisplayEventDispatcher: add DISPLAY_EVENT_CONFIG_CHANGED
Add a new event for display configuration change. This event
will be sent by SF anytime it changes the display config.

Test: Generate DISPLAY_EVENT_CONFIG_CHANGED and observe the log
Bug: 122905403
Change-Id: Ifa473a34d7b313501e5e4e8a67186fb82754fdcd
2019-02-22 17:54:06 -08:00
Ryan Mitchell
a55dc2ed6b Fix long paths on Windows
util::mkdirs iteratively creates each directory of a specified path. For
windows, Calling mkdir on only the drive letter or on the extended path
prefix (\?\\) will result in an error. Start after the long path prefix
and the drive letter.

This also changes AAPT2 to use AssetMaanager2 to retrieve symbols from
the symbol table. AssetManager2's zip library uses _wopen to open
windows files.

Bug:123251200
Test: aapt2_tests.exe
Change-Id: I26169d83b22d441485de3c49d63a6c4ed710e292
2019-02-20 09:46:00 -08:00
Winson
b2d7f5343d Signature policy for overlayable items
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
2019-02-14 10:07:13 -08:00
Mårten Kongstad
c92c4dd6c6 Surface <overlayable> info in Java AssetManager
Add a new, hidden method to AssetManager to extract a mapping
overlayable name -> overlayable actor for all <overlayable> blocks in a
package. [This will eventually be used to check if the caller of the OMS
AIDL API is the registered actor for a given overlay.]

Also, teach AssetManager2 to not accept packages that re-use the same
overlayable name. [Such packages have always been ill-formed.]

Bug: 123894537
Test: make libandroidfw_tests
Change-Id: I1117fd3503f04fe4c73eb7114901e022508f4d9e
2019-02-07 14:32:16 -08:00
Aurimas Liutikas
86ef44bcc7 Merge "Add helper methods for View attribute debugging" 2019-02-07 19:05:20 +00:00
Aurimas Liutikas
8f004c85a0 Add helper methods for View attribute debugging
Adding abilities to debug:
- Attribute resolution stack (which resources are looked
  at when resolving an attribute)
- Attribute value source (where did each attribute value
  get defined)
- Get explicit style id (if a view had it set via style="...")

This feature will be behind Settings.Global flag that Android
Studio will set to the debugged application package ID.

Bug: 111439551
Test: atest CtsViewTestCases:android.view.cts.ViewStyleTest
Change-Id: Ib6f9fc81000bb867b5b94a68953c99b0bc802d6c
2019-02-06 14:46:17 -08:00
Dominik Laskowski
9e7dce3833 Merge "Generalize physical display management" 2019-02-06 22:46:09 +00:00
Ryan Mitchell
198234502b Enforce overlayable API when defined
If a package defines overlayable resources, then do not allow resources
that are not defined as overlayable to be overlaid.

Bug:123600120
Test: idmap2_tests and cts-tradefed run cts -m CtsRROTestCases
Change-Id: I35120a97ccf4650e67c7ba65a60f4f3c51b0e627
2019-02-05 07:56:50 -08:00
Dominik Laskowski
3316a0a08e Generalize physical display management
This CL enables the framework to manage an arbitrary number of physical
displays. It also surfaces physical display IDs, which are stable across
reboots and encode (model, port) information that will be propagated
further up in a follow-up CL.

Bug: 116025192
Test: Boot with more than two displays
Test: Hotplug works with any number of displays
Test: Verify stable display IDs with "dumpsys display"
Change-Id: Idb2eaff66b2e0873be6ad27d337ff18b730d1331
2019-02-04 10:06:15 -08:00
Aurimas Liutikas
949b05dbdc Update TypedArray and TypedValue to store source layouts.
In ag/5859897 we started tracking source styles for each TypedValue.
It is also useful to keep track of source layouts if the attribute
was resolved against a layout (attribute set in XML layout inside
of <View> tag).

Test: atest CtsContentTestCases:android.content.res.cts.TypedArrayTest
Bug: 111439551
Change-Id: Ie6bc6ecd9a22b536a2f3288263b896f9cec67d38
2019-01-31 15:44:51 -08:00
Ryan Mitchell
741e96ff07 Fix GetResourceName for shared libraries
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
2019-01-24 15:45:43 -08:00
Ryan Mitchell
a117526b4a Merge "Remove RRO policy product_services" 2019-01-18 00:41:31 +00:00
Ryan Mitchell
02d9c1e931 Remove RRO policy product_services
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
2019-01-16 11:47:33 -08:00
Aurimas Liutikas
ce7c99c661 Add source style for each TypedValue.
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
2019-01-15 16:11:23 -08:00
Ryan Mitchell
cf9dd94323 Merge "Add encoding of name and actor overlayable fields" 2019-01-15 19:34:30 +00:00
Winson Chiu
55d9a6042b Merge "Add function to return path for last resolved resource" 2019-01-15 18:38:17 +00:00
Chih-Hung Hsieh
bc80706599 Merge "Fix/suppress androidfw google-explicit-constructor warnings" am: 392f0052c2 am: 99a3d72b98
am: cd06f9ee04

Change-Id: I0340acdbd6530f9bd9f67333974bcc65ff97e0e5
2019-01-14 14:58:22 -08:00
Winson
2f3669b767 Add function to return path for last resolved resource
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
2019-01-14 14:52:00 -08:00
Ryan Mitchell
ef5673a4c4 Add encoding of name and actor overlayable fields
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
2019-01-11 14:45:09 -08:00
Chih-Hung Hsieh
c2ace0c694 Fix/suppress androidfw google-explicit-constructor warnings
* 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
2019-01-10 19:53:08 +00:00
Ryan Mitchell
1bb1fe068a Refactor policy parsing
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
2018-12-11 13:48:45 -08:00
Ryan Mitchell
75e20dda2b Encoding of <overlayable> and <policy>
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
2018-12-04 16:45:26 -08:00
Mårten Kongstad
67d5c938e9 idmap: optimize time to create idmap data
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
2018-11-21 06:48:19 -08:00
Aurimas Liutikas
588bdc6719 Merge "Add style value to ResolvedBag in AssetManager2." 2018-11-19 20:48:55 +00:00
Aurimas Liutikas
d42a670ee5 Add style value to ResolvedBag in AssetManager2.
Bug: 117176857
Test: updated AssetManager2Test.MergesStylesWithParentFromSingleApkAssets
Change-Id: I2b79eea8e43431a932756b267b91eb4423c968a5
2018-11-16 10:50:34 -08:00
Mårten Kongstad
06a1ac8229 Prepare for switch to idmap2
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
2018-11-12 13:24:33 -08:00
Ryan Mitchell
c2b0782c37 Fix flaky idmap test
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
2018-11-07 10:28:56 -08:00
Ryan Mitchell
b3ae42e976 Copy common resources between styles
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
2018-11-01 17:01:28 -07:00
Ryan Prichard
559dbd88c7 Merge "Change ZipArchiveHandle from void* to ZipArchive*" am: f79542efd3 am: a34a1e0c97
am: 498357670e

Change-Id: I4fe5a70c750328bb67cdc02a08e4f9eeb97ac20d
2018-10-15 22:05:59 -07:00
Ryan Prichard
a34a1e0c97 Merge "Change ZipArchiveHandle from void* to ZipArchive*"
am: f79542efd3

Change-Id: Iebca19f2757ae77c07eca46a721c6966621fea14
2018-10-15 19:06:02 -07:00
Ryan Prichard
3addcd3965 Change ZipArchiveHandle from void* to ZipArchive*
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
2018-10-15 23:22:47 +00:00
Mårten Kongstad
62f3415ea6 Merge "libandroidfw: introduce ExecuteBinary (POSIX only)" am: 120b7fba93 am: 2a656b455d
am: dcef167772

Change-Id: I751a22f6610a103a32bbbb6925e12e5db6e4ca60
2018-10-10 19:12:19 -07:00
Todd Kennedy
c611199baf Merge commit 'c5e694e9549da3911392abd01bae125444f56294' into manual_merge_c5e694e9549da3911392abd01bae125444f56294
Change-Id: Ia48491cbcef8c3696c24619db2c3b7229f5bccc6
2018-10-10 12:48:14 -07:00
Mårten Kongstad
2a656b455d Merge "libandroidfw: introduce ExecuteBinary (POSIX only)"
am: 120b7fba93

Change-Id: I6e0b320e8887e32b8ea3fd1cfcf0804714fe1eb3
2018-10-09 16:08:34 -07:00
Mårten Kongstad
b7c0800fa0 Merge "libandroidfw: move ConfigDescription from aapt2 to libandroidfw"
am: b14c887974

Change-Id: I14be80a2d2c3620919a78da5a42ed56ec1d1737f
2018-10-09 16:04:34 -07:00
Mårten Kongstad
7672daf8e5 Merge changes from topic "idmap2-prerequisites"
am: 62a5d4249f

Change-Id: I8db3f5ba0de6510c3327273c56e9fcc75c836694
2018-10-09 16:00:31 -07:00
Treehugger Robot
120b7fba93 Merge "libandroidfw: introduce ExecuteBinary (POSIX only)" 2018-10-09 21:43:38 +00:00
Treehugger Robot
b14c887974 Merge "libandroidfw: move ConfigDescription from aapt2 to libandroidfw" 2018-10-09 21:43:38 +00:00
Treehugger Robot
62a5d4249f Merge changes from topic "idmap2-prerequisites"
* changes:
  AssetManager2: optionally keep non-matching configs
  AAPT2: optionally keep resources without default value
  libandroidfw: add resource ID iterator
2018-10-09 21:43:38 +00:00
Mårten Kongstad
668ec5bd3b AssetManager2: optionally keep non-matching configs
AssetManager2 maintains a set of configurations [as specified in the
resource blob] compatible with the currently set configuration [as
specified via SetConfiguration]. This helps optimize future resource
lookups by limiting the set of configurations to iterate over.

However, when creating idmaps, all configurations must be considered,
including those not compatible with the currently set configuration. Add
an optional flag to SetApkAssets to disable the optimization described
above.

Test: manual (will be tested by upcoming idmap2 implementation)
Change-Id: I7526a323ddf90e2f2f49c36e8c110a2cec25357e
2018-10-09 20:15:01 +00:00
Mårten Kongstad
5c541f6e36 libandroidfw: move ConfigDescription from aapt2 to libandroidfw
This is to allow idmap2 to access ConfigDescription.

Test: libandroidfw_tests
Test: aapt2_tests
Change-Id: I54210bbbd8dad5903cb7100807df977efa394ad5
Merged-In: I54210bbbd8dad5903cb7100807df977efa394ad5
2018-10-08 09:56:09 -07:00
Mårten Kongstad
24c9aa6541 libandroidfw: move ConfigDescription from aapt2 to libandroidfw
This is to allow idmap2 to access ConfigDescription.

Test: libandroidfw_tests
Test: aapt2_tests
Change-Id: I54210bbbd8dad5903cb7100807df977efa394ad5
2018-10-08 06:50:22 -07:00