Commit Graph

590 Commits

Author SHA1 Message Date
Svet Ganov
3f08542208 Fix resource by name lookup
Test: added: '@' cases to ResourceUtilsTest
      pass: ./out/host/darwin-x86/nativetest/libandroidfw_tests/libandroidfw_tests
      pass: ./out/host/darwin-x86/nativetest/aapt2_tests/aapt2_tests
      pass: cts-tradefed run cts-dev -m CtsAppSecurityHostTestCases
                -t android.appsecurity.cts.PermissionsHostTest

Bug: 74612500

Change-Id: I144e4ca1b63b9cce71052fc02089bb6092739889
2018-03-22 20:59:05 -07:00
Adam Lesinski
f3c951fd52 Merge "Change ownership of AAPT2 and libandroidfw" 2018-03-02 22:38:46 +00:00
Adam Lesinski
a95e841846 Change ownership of AAPT2 and libandroidfw
toddke@ is now the new owner of these projects.

Test: none
Change-Id: Ie92b020e0ba063f48ce8a76ebaef768fe0d554f1
2018-03-02 12:11:03 -08:00
Adam Lesinski
bebfcc46a2 Refactor AssetManager
Bug: 64071469
Test: atest CtsContentTestCases
Change-Id: Ia6856157e8813856268fba003e1e591d690cb26e
2018-02-28 19:06:48 -08:00
Steven Moreland
df7675f1cb Merge "Don't use cutils/Atomic.h" am: 07735797a2 am: a272d540d8
am: 0f4ca4a5c0

Change-Id: I4b9798b39d890537f888415b5ac283227970e4de
2018-02-28 14:13:52 +00:00
Steven Moreland
0f4ca4a5c0 Merge "Don't use cutils/Atomic.h" am: 07735797a2
am: a272d540d8

Change-Id: Ie442c255e43f2ebe80ef5423aa4508930d72c44c
2018-02-28 14:01:17 +00:00
Steven Moreland
fb7952f57e Don't use cutils/Atomic.h
Test: builds
Change-Id: I74485a5cbecb8710714f7bf3e54da61dd787838f
2018-02-23 15:02:42 -08:00
Adam Lesinski
bde1df21ad Revert "Replace AssetManager with AssetManager2 implementation"
This reverts commit 1187590da3.

Bug: 73134570
Change-Id: I59b4d714e447478ea124f086356f127f42251fb7
2018-02-09 12:43:24 -08:00
Adam Lesinski
2a447172a5 Revert "libandroidfw: Make sure to set the 'app as lib' flag"
This reverts commit 9ad287c828.

Bug: 73134570
Change-Id: If930d3a7c17fc2f7ffaebd31281ad5a5d120144f
2018-02-09 12:43:17 -08:00
Adam Lesinski
c9a9c1c1c3 Revert "libandroidfw: Add ApplyStyle and SetConfiguration benchmark"
This reverts commit 59f63bd801.

Bug: 73134570
Change-Id: I6ace34b0d6545ff001664792b0bb1bbff5b5cbbe
2018-02-09 12:43:13 -08:00
Adam Lesinski
b8b3a26194 Revert "libandroidfw: Improve performance of AssetManager2"
This reverts commit 88c9959e5b.

Bug: 73134570
Change-Id: I012643d2b4212cef5aef68feb4146add34f9ecfc
2018-02-09 12:43:10 -08:00
Adam Lesinski
dfeb7ceb2a Revert "AssetManager2: Allow out of order type/type spec"
This reverts commit 78695c3543.

Bug: 73134570
Change-Id: I6acc35372d9071d067d2fb7caa775ee9ba689811
2018-02-09 12:43:07 -08:00
Adam Lesinski
ec7f06cc37 Revert "AssetManager2: Fix list function"
This reverts commit adc0b87ec2.

Bug:73134570
Change-Id: I9e652245e7661eb7a34dadb5f363a08bc8c9e57e
2018-02-09 12:43:04 -08:00
TreeHugger Robot
a9bf9d166a Merge "AssetManager2: Fix list function" 2018-02-09 08:18:16 +00:00
Adam Lesinski
adc0b87ec2 AssetManager2: Fix list function
List was skipping directories. Include them, and add tests to ensure
the order and precedence is correct.

Bug: 72511641
Test: make libandroidfw_tests
Test: atest CtsContentTestCases:AssetManagerTest
Change-Id: Iadf45883283d3e4aae93bd7c3343745912e34fa0
2018-02-08 22:37:48 -08:00
Adam Lesinski
78695c3543 AssetManager2: Allow out of order type/type spec
AssetManager2 assumes that RES_TABLE_TYPE_SPEC_TYPEs must immediately
precede their associated RES_TABLE_TYPE_TYPEs. This is not correct.
RES_TABLE_TYPE_SPEC_TYPEs must precede their associated
RES_TABLE_TYPE_TYPEs, but they do not need to immediately precede them.

For example, this is what we currently expect:

  RES_TABLE_TYPE_SPEC_TYPE id=1
  RES_TABLE_TYPE_TYPE id=1
  RES_TABLE_TYPE_SPEC_TYPE id=2
  RES_TABLE_TYPE_TYPE id=2

but this is also valid:

  RES_TABLE_TYPE_SPEC_TYPE id=1
  RES_TABLE_TYPE_SPEC_TYPE id=2
  RES_TABLE_TYPE_TYPE id=1
  RES_TABLE_TYPE_TYPE id=2

Bug: 73052092
Test: make libandroidfw_tests
Change-Id: I1f3c43760f8108eee24c2c6ed7bc16f70e951c2b
2018-02-08 15:16:32 -08:00
Adam Lesinski
88c9959e5b libandroidfw: Improve performance of AssetManager2
AssetManager2 relied on creating a list of configurations
present in the resource table so as to avoid copying and
converting ResTable_config's from the APK on every
resource retrieval.

ResTable, however, had a better optimization that pruned
the configurations that didn't match the currently set
configuration. This vastly reduced the number of ResTable_configs
to test.

In this CL, AssetManager2 follows suite with this optimization
and only maintains the filtered ResTable_configs, falling back
to the slow path when the configuration is overridden.

Test: mma frameworks/base/libs/androidfw
Test: adb sync system data
Test: adb shell /data/benchmarktest64/libandroidfw_benchmarks/libandroidfw_benchmarks
Change-Id: Ib57b75fbb32e1d310eec146e5a12dfc6de4385f9
2018-02-05 18:38:57 -08:00
Adam Lesinski
59f63bd801 libandroidfw: Add ApplyStyle and SetConfiguration benchmark
Test: mma frameworks/base/libs/androidfw
Test: adb sync system data
Test: adb shell /data/benchmarktest64/libandroidfw_benchmarks/libandroidfw_benchmarks
Change-Id: Ia0e868008a3b32dc8d1c69ed1f2c39f152bb7815
2018-02-05 18:38:57 -08:00
Adam Lesinski
9ad287c828 libandroidfw: Make sure to set the 'app as lib' flag
When an app is loaded as a shared library (eg. monochrome),
make sure to set the bit that it loaded as such, so that
conversions from package ID 7f -> shared library ID are done.

Bug: 72511998
Test: make libandroidfw_tests
Test: out/host/<host_os>/nativetest64/libandroidfw_tests/libandroidfw_tests
Change-Id: Icd11b7a5adff351165ca16d5853fb5a0002c34b1
2018-02-05 18:38:57 -08:00
Adam Lesinski
1187590da3 Replace AssetManager with AssetManager2 implementation
Test: atest CtsContentTestCases:android.content.res.cts
Test: make libandroidfw_tests
Change-Id: I2bb6d7656d2516d371e83e541ed02f91405f6d94
2018-02-05 18:38:49 -08:00
Android Build Merger (Role)
5b46d98a7a Merge changes from topic "am-1ab9514f-fd12-4093-b1cb-a77e9f0419c9" into oc-dev am: 46fc48f57e am: b39e49d52c
am: 1c4ccab92b

Change-Id: I32ba85cdc40ea77772361ffb399085f7b8a67416
2018-02-01 03:35:27 +00:00
Android Build Merger (Role)
1c4ccab92b Merge changes from topic "am-1ab9514f-fd12-4093-b1cb-a77e9f0419c9" into oc-dev am: 46fc48f57e
am: b39e49d52c

Change-Id: Iaf02c5ebdb656fc79cde201e6df97760283ea4e4
2018-02-01 03:24:13 +00:00
Android Build Merger (Role)
b39e49d52c Merge changes from topic "am-1ab9514f-fd12-4093-b1cb-a77e9f0419c9" into oc-dev
am: 46fc48f57e

Change-Id: I85ba0993926fbd9a61525e35e411887130b3c5aa
2018-02-01 03:13:16 +00:00
Adam Lesinski
f7d01dd7e1 Revert "Replace AssetManager with AssetManager2 implementation"
This reverts commit dcb3c6559b.

Bug:72511998
Change-Id: I665966ca109f66f85d8665db388c71ea2303c3b8
2018-01-25 17:39:40 -08:00
Adam Lesinski
646265cb2a Revert "libandroidfw: Add ApplyStyle and SetConfiguration benchmark"
This reverts commit d9c809c480.

Bug:72511998
Change-Id: I3be2374e3662fc8397c00f1df1bce6de5f5a4549
2018-01-25 17:34:40 -08:00
Adam Lesinski
0dd369912a Revert "libandroidfw: Improve performance of AssetManager2"
This reverts commit 64ee69d0f1.

Bug:72511998
Change-Id: Iab3ce449e60ec2451d391217543528d312089080
2018-01-25 17:34:39 -08:00
Jaekyun Seok
1713d9e97a Support /product partition
This CL will support the followings.
- installing a RRO package for framework from /product/overlay
- installing apps from /product/app
- installing priv-apps from /product/priv-app
- installing permissions from
  /product/etc/[default-permissions|permissions|sysconfig]

Bug: 64195575
Test: `mm` under frameworks/base/tests/[libs|privapp]-permissions
adb sync && adb reboot
adb shell cmd package list libraries
  => confirmed com.android.test.libs.product library
adb shell cmd package dump \
  com.android.framework.permission.privapp.tests.product
  => confirmed that the package is a priv-app

And I moved vendor/overlay/framework-res__auto_generated_rro.apk into
system/product/overlay/ on sailfish, and I confirmed that the RRO was
installed properly.

Change-Id: I16175933cebd9ec665d190cc5d564b5414a91827
2018-01-25 12:44:45 +09:00
Adam Lesinski
64ee69d0f1 libandroidfw: Improve performance of AssetManager2
AssetManager2 relied on creating a list of configurations
present in the resource table so as to avoid copying and
converting ResTable_config's from the APK on every
resource retrieval.

ResTable, however, had a better optimization that pruned
the configurations that didn't match the currently set
configuration. This vastly reduced the number of ResTable_configs
to test.

In this CL, AssetManager2 follows suite with this optimization
and only maintains the filtered ResTable_configs, falling back
to the slow path when the configuration is overridden.

Test: mma frameworks/base/libs/androidfw
Test: adb sync system data
Test: adb shell /data/benchmarktest64/libandroidfw_benchmarks/libandroidfw_benchmarks
Change-Id: I5d46f8b005a37b72750d00bd75f090e7b5a36f60
2018-01-24 15:19:09 -08:00
Adam Lesinski
d9c809c480 libandroidfw: Add ApplyStyle and SetConfiguration benchmark
Test: mma frameworks/base/libs/androidfw
Test: adb sync system data
Test: adb shell /data/benchmarktest64/libandroidfw_benchmarks/libandroidfw_benchmarks
Change-Id: Ia6b441f186ccb455acbee15723f0d2d5657b09b5
2018-01-24 15:19:09 -08:00
Adam Lesinski
dcb3c6559b Replace AssetManager with AssetManager2 implementation
Test: atest CtsContentTestCases:android.content.res.cts
Test: make libandroidfw_tests
Change-Id: I572eb13c6a4372c7f656f5912821cececd5bf3d4
2018-01-24 15:19:04 -08:00
Android Build Merger (Role)
163548ed6a [automerger] Check for null-terminator in ResStringPool::string8At am: 5ec65ae909 am: c3d7250b99 am: e2417e6682 am: 0ab4540c41 am: a3f0976937 am: 166aa6e149 am: b7f7f7e14e am: c26b8635b7 am: afac0f46d9 am: 5786491706
Change-Id: I6b2b0c96e716c385045ebddaa1072b9dc1b4a67c
2018-01-24 19:50:14 +00:00
Igor Viarheichyk
7ec28a888c Use numbering system for configuration selection.
Take into account numbering system when selecting a matching
resource configuration. Add numbering system specifier into the
generated BCP 47 language tag.

Test: build and run libandroidfw_tests
Bug: 71873777

Change-Id: I3afda181f36de4b29a7be270b6f7593c2261fd71
2018-01-19 20:25:34 +00:00
Android Build Merger (Role)
5786491706 [automerger] Check for null-terminator in ResStringPool::string8At am: 5ec65ae909 am: c3d7250b99 am: e2417e6682 am: 0ab4540c41 am: a3f0976937 am: 166aa6e149 am: b7f7f7e14e am: c26b8635b7 am: afac0f46d9
Change-Id: I929d36bb57eb15b520d67580a3372b960ecd2495
2018-01-17 22:20:55 +00:00
Android Build Merger (Role)
afac0f46d9 [automerger] Check for null-terminator in ResStringPool::string8At am: 5ec65ae909 am: c3d7250b99 am: e2417e6682 am: 0ab4540c41 am: a3f0976937 am: 166aa6e149 am: b7f7f7e14e am: c26b8635b7
Change-Id: If1ccdb1c778d8f3f605c1091643a6c11f0ffa00e
2018-01-17 22:20:50 +00:00
Android Build Merger (Role)
c26b8635b7 [automerger] Check for null-terminator in ResStringPool::string8At am: 5ec65ae909 am: c3d7250b99 am: e2417e6682 am: 0ab4540c41 am: a3f0976937 am: 166aa6e149 am: b7f7f7e14e
Change-Id: I24714505cc04c722b7d49762ee3e965369fd4d1e
2018-01-17 22:20:46 +00:00
Android Build Merger (Role)
166aa6e149 [automerger] Check for null-terminator in ResStringPool::string8At am: 5ec65ae909 am: c3d7250b99 am: e2417e6682 am: 0ab4540c41 am: a3f0976937
Change-Id: If96dfd76092dc107e75fbc213346eba2cbc0a0c1
2018-01-17 22:20:29 +00:00
Android Build Merger (Role)
c3d7250b99 [automerger] Check for null-terminator in ResStringPool::string8At am: 5ec65ae909
Change-Id: I1ea52e1ccd7bf5467438e3dc2e670cf8f325c629
2018-01-17 22:20:03 +00:00
Adam Lesinski
5ec65ae909 Check for null-terminator in ResStringPool::string8At
All other stringAt methods check for null termination. Be consistent
so that upper levels don't end up with huge corrupt strings.

Bug: 62537081
Test: none
Change-Id: I17bdfb0c1e34507b66c6cad651bbdb12c5d4c417
(cherry picked from commit 3d35a0ea30)
(cherry picked from commit 97f8cb01149b35b1832c7f9efe85ff19edf1083e)
2018-01-17 22:19:39 +00:00
Ivan Lozano
6593d714b6 Disable sanitizer entirely in ResourceTypes.cpp
The unsigned integer overflow sanitizer catches an overflow on
Res_GETPACKAGE usages. This is used in a number of places in
ResourceTypes.cpp in a number of large functions. For now, lets disable
the sanitizer in this source file.

Test: Compiles and device boots without runtime errors.
Bug: 30969751
Change-Id: Id9e0776ef819c895a3194a32da5c85459f1af431
Merged-In: Id9e0776ef819c895a3194a32da5c85459f1af431
(cherry picked from commit 02828740da)
2017-12-28 09:14:42 -08:00
Adam Lesinski
a9743826bd IDMAP: Warn when RROs overlay non-overlayable resources
First pass at getting overlays to respect which resources should be
overlaid. First step is to call it out but not enforce.

Bug: 64980941
Test: manual (inspect the warnings at boot)
Change-Id: I40baee1110d4bc1e54e7f2f9d3b73ffabb067f90
2017-12-18 17:25:27 -08:00
Adam Lesinski
71be70507d AAPT2: Propagate SPEC_OVERLAYABLE flag to final APK
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
2017-12-18 14:16:02 -08:00
Adam Lesinski
498f6053da libandroidfw: Remove pre-verification
This added more up-front cost to loading an APK and didn't provide
a significant benefit to resource retrieval.

Test: make libandroidfw_tests
Change-Id: Idbf993abc433fa8c8950d106c66469b310b66f7f
2017-12-05 00:29:38 +00:00
Adam Lesinski
73f6f9daf6 libandroidfw: Add SparseEntry support for LoadedArsc
go/o-restable-sparse-entries

Test: make libandroidfw_tests
Change-Id: Ib1a7d1fc69008390eee53a1de04356dc50e05b45
2017-11-29 22:19:13 +00:00
Adam Lesinski
1c855a0bc8 libandroidfw: Do not clear last resource id in ResolveReference
If the value passed to AssetManager::ResolveReference is not a
reference, the caller may be expecting for the last reference to
not be cleared, as a more appropriate value should most likely be
retained.

This was causing an issue when a caller was manually resolving
references and expecting the last resource ID resolved to be propagated
across calls to ResolveReference.

Test: make libandroidfw_tests
Change-Id: I5b7f586e2cd541059023eaa9ba23e324a21a9a1e
2017-11-29 10:20:26 -08:00
TreeHugger Robot
dbf16295fe Merge "libandroidfw: Support loading ApkAssets from a file descriptor" 2017-11-27 22:26:26 +00:00
Dianne Hackborn
1704e3cf0c The pm command is no more.
It is now just a shell of itself. :)

Also brings in a few fixes to never try to open files from the system
process.

Test: manual
Change-Id: Ia8187196af597046fd2e7092dbf19ce1dc1ea457
2017-11-21 10:17:14 -08:00
Adam Lesinski
441500b23f libandroidfw: Support loading ApkAssets from a file descriptor
Test: make aapt2_tests
Change-Id: I041f9e9e3d3f6a10684cbd8baa49f4dda7d6dc40
2017-11-13 17:53:45 -08:00
Adam Lesinski
917bdb1b8f Merge "Check for null-terminator in ResStringPool::string8At" 2017-11-10 19:00:10 +00:00
Adam Lesinski
3d35a0ea30 Check for null-terminator in ResStringPool::string8At
All other stringAt methods check for null termination. Be consistent
so that upper levels don't end up with huge corrupt strings.

Bug: 62537081
Test: none
Change-Id: I17bdfb0c1e34507b66c6cad651bbdb12c5d4c417
2017-11-09 17:13:40 -08:00
Ivan Lozano
02828740da Disable sanitizer entirely in ResourceTypes.cpp
The unsigned integer overflow sanitizer catches an overflow on
Res_GETPACKAGE usages. This is used in a number of places in
ResourceTypes.cpp in a number of large functions. For now, lets disable
the sanitizer in this source file.

Test: Compiles and device boots without runtime errors.
Bug: 30969751
Change-Id: Id9e0776ef819c895a3194a32da5c85459f1af431
2017-11-07 14:07:17 -08:00