Commit Graph

835 Commits

Author SHA1 Message Date
Ryan Mitchell
2f5b31db3b Merge "Fail install when resources.arsc is compressed" into rvc-dev am: b8a61d13c2 am: f1c7db061e
Change-Id: Iee221bc5dc6e8870468d4cc1d9801a21e48d3e7a
2020-04-13 15:30:54 +00:00
Ryan Mitchell
b8a61d13c2 Merge "Fail install when resources.arsc is compressed" into rvc-dev 2020-04-13 14:57:19 +00:00
Ryan Mitchell
3c0b8da2c1 Merge changes from topic "invalidate_idmap" into rvc-dev am: 6cb79cdfb7 am: 7cfbff64eb
Change-Id: Ief1e732e3b18738c5c0f62f2fe8c47f66169c85b
2020-04-10 16:17:25 +00:00
Ryan Mitchell
192400cf33 Fail install when resources.arsc is compressed
If an application targets R+, prevent the application from being
installed if the app has a compressed resources.arsc or if the
resources.arsc is not aligned on a 4-byte boundary. Resources tables
that cannot be memory mapped have to be read into a buffer in RAM
and exert unnecessary memory pressure on the system.

Bug: 132742131
Test: manual (adding CTS tests)
Change-Id: Ieef764c87643863de24531fac12cc520fe6d90d0
2020-04-09 11:01:54 -07:00
Ryan Mitchell
a90930528d Invalidate idmap when target updates
When the target package update, check if the idmap file must change.
If so, propagate the idmap changes to the targets overlay paths, and
invalidate cached overlay ApkAssets in ResourcesManager.

Bug: 147794117
Bug: 150877400
Test: OverlayRemountedTest
Test: libandroidfw_tests
Change-Id: I6115c30bae3672b188a5ff270720a0eea15b43b5
2020-04-07 12:14:51 -07:00
Tianjie Xu
b2415d3b32 Merge "Change the parameter type of offset in read" am: 74a5df06af am: eead9e3eda
Change-Id: I4ad529b54e83421488d341d8f25def5d1cc2df54
2020-04-04 20:39:31 +00:00
Ryan Mitchell
d856e14c8d Merge "Begin moving FrameworkResourceLoaderTest to cts" into rvc-dev am: 1b922d56c0
Change-Id: Ia9e28c0697da0f848c9e1996b345e3b18f8ae9b6
2020-04-03 16:09:59 +00:00
Tianjie
01ae3f4157 Change the parameter type of offset in read
As we support zip64 in libziparchive, we change the parameter of
the ReadAtOffset() in zip reader from uin32_t to off64_t. So the
derived class needs to be updated as well.

Bug: 150900468
Test: build
Change-Id: Icbfd2dd54b01ff62da988ba8598c1057f9bb6368
2020-04-02 06:16:21 +00:00
Ryan Mitchell
199b09a1a7 Begin moving FrameworkResourceLoaderTest to cts
This changes removes FrameworkResourceLoaderTest from frameworks/base
before it is moved to CTS.

Bug: 152979463
Test: atest CtsResourcesLoaderTest
Change-Id: I4b899564ab93472cb6d2a5ed0917026753c2827f
2020-04-01 20:09:29 +00:00
Ryan Mitchell
3769911736 Merge changes If7ea17d5,If6364fd6 into rvc-dev am: 8275fb7d66
Change-Id: Iaa34df4fc6cce09177547a11497d28fa1ce9cdb5
2020-03-27 17:49:56 +00:00
Tobias Thierer
0b4d263ca7 Merge "OWNERS: tobiast -> ngeoffray." am: 9c0d26b4cb am: d9b0a60742
Change-Id: I5b781cfc5b6383c61087b796e0e344be084d3dc9
2020-03-27 11:51:34 +00:00
Tobias Thierer
fa82e757dd OWNERS: tobiast -> ngeoffray.
This CL topic was created via:

  find . -name OWNERS | xargs grep -l tobiast | xargs sed \
  -i 's/tobiast/ngeoffray/g'

Plus appropriate repo start, git commit, repo upload commands:

  while read proj; do croot $proj ; repo start OWNERS-tobiast-ngeoffray ; \
  git commit -F ~/commit-message.txt; croot ; done \
  < ~/owners-projects.txt

  repo upload -t --br=OWNERS-tobiast-ngeoffray

No attempt was made to sort the files after the replacement.

Exempt-From-Owner-Approval: Both old and new owner are on this CL.
Test: Manually inspected the result.
Bug: 152399425
Change-Id: I2f100a71d399a7d4d46ea036fff564ff5c5dbda7
2020-03-26 14:10:06 +00:00
Ryan Mitchell
824cc490c5 Assigned package ids to overlays last
Before overlays could reference internal resources, overlays were
added to AssetManagers before shared libraries. Overlays are now
loaded as shared libraries so they must be assigned package ids
after non-overlay shared libraries so enabling and disabling
overlays does not affect the package ids of the non-overlay shared
libraries.

Since overlays are added to the end of the AssetManager by
ResourcesManager, enabling and disabling overlays will not change
the assets cookie of shared libraries loaded through ResourcesManager,
but it will change the apk assets cookie or overlays added through
AssetManager#addAssetPathAsSharedLibrary.

The package ids of shared libraries added through
AssetManager#addAssetPathAsSharedLibrary will not be affected by
overlays since overlay package ids are assigned last.

Bug: 146685730
Test: CtsHostsideWebViewTests
Change-Id: If7ea17d51b18769bf2465e29af3ae6a71004d06c
2020-03-23 18:14:11 -07:00
Ryan Mitchell
b894c274d0 Revert "Assign shared libraries stable package ids"
This change must be reverted because it broke packages with the same
package name but different package ids loaded at once.

Bug: 146685730
Test: MultiSplitInstallTest
This reverts commit fe50d739f7.

Change-Id: If6364fd660c76284452f77e7d4f09a3df9dede1d
2020-03-23 18:05:40 -07:00
Ryan Mitchell
c5f968d58b Merge changes from topic "res_loader_dir" into rvc-dev am: b0544a733c
Change-Id: I18c28c7293a24d712940c9e80e7817f9547512f8
2020-03-20 18:21:20 +00:00
Ryan Mitchell
b0544a733c Merge changes from topic "res_loader_dir" into rvc-dev
* changes:
  Allow using loaders on non-RM Resources instances
  Move AssetsProvider to native layer
  Add ResourcesProvider.loadFromDirectory
  Refactor tests for ApkAsset loading APIs
  Refactor ApkAsset loading APIs
  Fix bugprone-use-after-move warnings
  Fix bugprone-use-after-move warnings
2020-03-20 18:16:30 +00:00
Ryan Mitchell
39cacf2de7 Allow using loaders on non-RM Resources instances
Currently there is a limitation where ResourcesLoaders cannot be  used
on Resources object not created through ResourcesManager. This change
creates an update handler for Resources objects that are not registered
with ResourcesManager.

The handler changes the loaders on the asset manager owned by the
Resources instance.

Bug: 151666644
Test: atest ResourceLoaderValuesTest
Change-Id: I5a89f686386bdb088dc964014e7becc0c2b4770f
2020-03-19 18:33:55 -07:00
Ryan Mitchell
4ea1e42889 Move AssetsProvider to native layer
Querying in the native layer for assets provided through
AssetsProviders does not currently work. This change refactors the
AssetProvider API to return a file descriptor that is read in the
native layer and can bubble up to the java layer.

This change also removes the InputStream API to favor of developers
using memfd_create.

Bug: 142716192
Test: atest ResourceLoaderValuesTest
Change-Id: I1a7eca0994c3b7cc32008d9a72bf91086ff0e816
2020-03-19 18:33:55 -07:00
Ryan Mitchell
c07aa70270 Add ResourcesProvider.loadFromDirectory
This API allows a directory to be loaded as if it was a zipped APK.
This is a substitute for the DirectoryAssetProvider API that
currently does not work in the native layer.

Bug: 142716192
Test: atest FrameworksResourceLoaderTests
Change-Id: Ia13e15653e75b421423dd56f9fe89e183ab4cb9a
2020-03-19 18:33:55 -07:00
Ryan Mitchell
ef40d2e832 Refactor ApkAsset loading APIs
To add the partner requested ResourcesProvider#loadFromDir APIs, this
change adds format type integer that allows us to reduce the number of
ApkAssets loading overrides.

This change also adds hidden offset and length based ResourcesProvider
APIs that could not make R.

Bug: 142716192
Test: atest FrameworksResourceLoaderTests
Change-Id: I926fde257cae701901dcd4ca408024feae8c90a6
Merged-In: I926fde257cae701901dcd4ca408024feae8c90a6
2020-03-19 18:33:55 -07:00
Ryan Mitchell
e35e87f514 Fix bugprone-use-after-move warnings
Bug: 150783499
Test: WITH_TIDY=1 make
Change-Id: I185cb21521676ddbc4f2b7f098611a2efc7275e6
(cherry picked from commit c658184d36)
Merged-In: I185cb21521676ddbc4f2b7f098611a2efc7275e6
2020-03-19 16:57:50 -07:00
Automerger Merge Worker
a4e3d254b5 Merge "Fix bugprone-copy-constructor-init warnings" am: 4dc2f8f773 am: 87158910b0
Change-Id: I6845ad403b8b7c4572053fc49998ed5e7c01c6be
2020-03-17 19:55:19 +00:00
Treehugger Robot
4dc2f8f773 Merge "Fix bugprone-copy-constructor-init warnings" 2020-03-17 19:26:33 +00:00
Chih-hung Hsieh
0dbbb661cf Merge "Fix bugprone-use-after-move warnings" 2020-03-17 18:34:53 +00:00
Nikita Iashchenko
93a9e785ea Regenerate LocaleDataTables.cpp wtih Unicode 13 update
LocaleDataTables.cpp is regenerated with Unicode 13 updates from CLDR.

Bug: 149845726
Test: ./tools/localedata/extract_icu_data.py $ANDROID_BUILD_TOP
Test: m droid
Merged-In: Id2d023723b50c1c2f73fe07f46fb9b3cae990752
Change-Id: Id2d023723b50c1c2f73fe07f46fb9b3cae990752
2020-03-16 12:39:27 +00:00
Automerger Merge Worker
61c63c35f4 Regenerate LocaleDataTables.cpp wtih Unicode 13 update am: 7ea3b2164d am: 92ea9b82fc
Change-Id: I244c9ab135705cafbc492d5d98d238eb31168ac7
2020-03-11 20:32:14 +00:00
Chih-Hung Hsieh
3fb38f7fe2 Fix bugprone-copy-constructor-init warnings
* normally a copy constructor should call base copy constructor

Bug: 151109313
Test: WITH_TIDY=1 make
Change-Id: I9677889973178c26cd787a457333877619956b51
2020-03-10 12:58:29 -07:00
Chih-Hung Hsieh
933c7a612e Fix bugprone-use-after-move warnings
Bug: 150783499
Test: WITH_TIDY=1 make
Change-Id: I185cb21521676ddbc4f2b7f098611a2efc7275e6
Merged-In: I185cb21521676ddbc4f2b7f098611a2efc7275e6
(cherry picked from commit c658184d36)
2020-03-09 19:08:27 +00:00
Chih-Hung Hsieh
243bc1929b Fix bugprone-use-after-move warnings
Bug: 150783499
Test: WITH_TIDY=1 make
Change-Id: I185cb21521676ddbc4f2b7f098611a2efc7275e6
(cherry picked from commit c658184d36)
Merged-In: I185cb21521676ddbc4f2b7f098611a2efc7275e6
2020-03-06 14:00:53 -08:00
Nikita Iashchenko
7ea3b2164d Regenerate LocaleDataTables.cpp wtih Unicode 13 update
LocaleDataTables.cpp is regenerated with Unicode 13 updates from CLDR.

Bug: 149845726
Test: ./tools/localedata/extract_icu_data.py $ANDROID_BUILD_TOP
Test: m droid
Change-Id: Id2d023723b50c1c2f73fe07f46fb9b3cae990752
2020-03-06 11:34:51 +00:00
Automerger Merge Worker
5908c4f02c Merge "Use String8 ostream from String8.h" am: a9117815ed am: 1257bc0b9d
Change-Id: I2d6799c5022878a7d813b25b6ca05d92e87f0478
2020-02-27 23:34:15 +00:00
Winson
f56ade365a Actor signature overlayable policy
There are cases where an app can ship overlays for itself,
but the "signature" policy as described would open up
a vulnerability by allowing the system actor to create
and sign any arbitrary overlay that will apply to the target.

To prevent this, redefine "signature" as target package only,
and introduce "actor" for checking against the actor signature.
Any app that wishes to use both can include both policies.

Bug: 130563563

Test: m aapt2_tests idmapt2_tests and run from host test output
Test: atest libandroidfw_tests

Change-Id: I1c583a5b37f4abbeb18fc6a35c502377d8977a41
2020-02-26 15:59:44 -08:00
Winson
62ac8b56a9 Refactor overlayable policy
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
2020-02-26 15:59:43 -08:00
Steven Moreland
4351d26575 Use String8 ostream from String8.h
Bug: N/A
Test: N/A
Change-Id: If2762ec4a9bb84cca41b1752fe005605eb9b2013
2020-02-26 09:14:29 -08:00
Automerger Merge Worker
7cd9daebb1 Merge "Merge "Remove String16 operator<<, now provided in header" am: 35d04c27ee am: f1e6950510" into qt-qpr1-dev-plus-aosp am: 2593e104d5
Change-Id: I5cc3034b3d8ad29a3244ab436325f1f6a5cf243c
2020-02-11 23:26:19 +00:00
Steven Moreland
849ccdeafe Remove String16 operator<<, now provided in header
Bug: N/A
Test: N/A
Change-Id: Ic0418d81d37726dcfc100ce919b6f79be4077c8a
2020-02-10 15:28:41 -08:00
Ryan Mitchell
155d539634 Sort bag by attribute key when using libs
When shared libraries are assigned package ids in a different order
than compile order, bag resources that use attributes from both
multiple libraries will not be sorted in ascending attribute id order.
This change detects when the attribute ids are not in order and sorts
the bag entries accordingly.

The change is designed to be less invasive. Deduping the GetBag logic
should probably be spun off in a separate bug.

Bug: 147674078
Test: libandroidfw_tests
Change-Id: Id8ce8e9c7ef294fcc312b77468136067d392dbd0
2020-02-10 14:12:00 -08:00
Ryan Mitchell
ee4a564d4f Allow for overlaying dynamic shared libraries
Overlays targeting shared libraries should be loaded into the
resources of every target that depends on the shared library.

Static shared libraries are currently not supported because overlays
should override all versions of static shared libraries and there is
not currently support for an overlay targeting multiple APKs.

Also created a test instrumentation and host test suite for testing
overlays and packages on the system image.

Bug: 140790224
Test: atest OverlayRemountedTest
Change-Id: I20a217b6368d6cf92b2b9f46908fd58012933f72
2020-01-10 23:20:19 +00:00
Ryan Mitchell
fe50d739f7 Assign shared libraries stable package ids
When a shared library package is loaded into an AssetManager, the
shared library will be assigned a unique package id. Subsequent
AssetManaagers that load a shared library of the same package name
as the original shared library will use previously assigned package
name. Shared libraries will have stable package ids throughout the
lifetime of application.

Bug: 140790224
Bug: 128496033
Test: libandroidfw_tests
Test: third-party app no longer crashes on open
Test: atest CtsHostsideWebViewTests
Change-Id: Idc0315be21ea00b74d1a918b7083ad655104c008
2020-01-10 23:15:06 +00:00
TreeHugger Robot
5a9109789e Merge "Add tests for layout overlaying" 2019-12-20 21:40:41 +00:00
TreeHugger Robot
548d6dcf77 Merge "idmap2: add debug information to idmap file format" 2019-12-20 14:38:36 +00:00
Automerger Merge Worker
944c611bd7 Merge changes from topic "icu65.1-upgrade" am: ad2026640c am: b1cc7c336b am: 4870a488d4
Change-Id: Ia5343e7e742c844a0b58d3964ec0eac2c3d0b75a
2019-12-20 12:29:42 +00:00
Nikita Iashchenko
ad2026640c Merge changes from topic "icu65.1-upgrade"
* changes:
  Regenerate LocaleDataTables.cpp
  Update API surface for ICU 65.1
2019-12-20 11:14:44 +00:00
Automerger Merge Worker
1d4949230e Merge "Add per-file ownership to libs/androidfw/LocaleDataTables.cpp" am: 073b0dad72 am: 36fac337ad am: b43a2e6740
Change-Id: Ib7ebb261de2d7492f0a5d1bd7faef7210b3ffe12
2019-12-19 21:33:05 +00:00
Nikita Iashchenko
7b085ddae0 Regenerate LocaleDataTables.cpp
LocaleDataTables.cpp was regenerated running the following command
(should be run from frameworks/base):

$ ./tools/localedata/extract_icu_data.py $ANDROID_BUILD_TOP > libs/androidfw/LocaleDataTables.cpp

Test: m droid
Change-Id: If180ff22a74b485cc3cca34a3f9ba98c826a2210
2019-12-19 19:36:50 +00:00
Mårten Kongstad
d7e8a534d0 idmap2: add debug information to idmap file format
Add a new variable length string to the idmap file format. This string will
hold debug information like fulfilled policies and any warnings triggered while
generating the file.

Bump the idmap version to 3.

Adjust the idmap header definition in ResourceType.h to take the new string
into account.

Example debug info:

  $ idmap2 create \
        --target-apk-path frameworks/base/cmds/idmap2/tests/data/target/target.apk \
        --overlay-apk-path frameworks/base/cmds/idmap2/tests/data/overlay/overlay.apk \
        --idmap-path /tmp/a.idmap \
        --policy public \
        --policy oem

  $ idmap2 dump --idmap-path /tmp/a.idmap
  target apk path  : frameworks/base/cmds/idmap2/tests/data/target/target.apk
  overlay apk path : frameworks/base/cmds/idmap2/tests/data/overlay/overlay.apk
  I fulfilled_policies=oem|public enforce_overlayable=true
  W failed to find resource "integer/not_in_target" in target resources
  0x7f010000 -> 0x7f010000 integer/int1
  0x7f02000c -> 0x7f020000 string/str1
  [...]

  $ idmap2 dump --idmap-path /tmp/a.idmap --verbose
  00000000: 504d4449  magic
  00000004: 00000003  version
  00000008: 76a20829  target crc
  0000000c: c054fb26  overlay crc
  00000010: ........  target path: frameworks/base/cmds/idmap2/tests/data/target/target.apk
  00000110: ........  overlay path: frameworks/base/cmds/idmap2/tests/data/overlay/overlay.apk
  00000210: ........  debug info: ...
  00000294:       7f  target package id
  00000295:       7f  overlay package id
  [...]

Also, tell cpplint to accept non-const references as function parameters:
they make more sense as out-parameters than pointers that are assumed to
be non-null.

Also, switch to regular expressions in the RawPrintVisitorTests: no more
manual fixups of the stream offsets! Tell cpplint that the <regex>
header is OK to use.

Bug: 140790707
Test: idmap2_tests
Change-Id: Ib94684a3b4001240321801e21af8e132fbcf6609
2019-12-19 16:51:51 +00:00
Victor Chang
dbd6c5e267 Add per-file ownership to libs/androidfw/LocaleDataTables.cpp
Test: treehugger
Change-Id: I61366a576e75137cef2b6607cd860cfd16c23869
2019-12-19 15:55:52 +00:00
Automerger Merge Worker
cfb045a481 Merge "Regenerate LocaleDataTables.cpp" am: 6658c31b4e am: ccc64a5aef am: ffbeb382a2
Change-Id: Ic6beb9b8a0374663babf41431e5f59ad7c18f7d0
2019-12-17 14:45:33 +00:00
Victor Chang
e84c6b50c2 Regenerate LocaleDataTables.cpp
LocaleDataTables.cpp is outdated due to ICU update over the years

Test: ./tools/localedata/extract_icu_data.py $ANDROID_BUILD_TOP
Test: m droid
Change-Id: I21918cc0f50c7347e514dc7b015607e19cffb377
2019-12-16 15:31:09 +00:00
Ryan Mitchell
df9e732962 Add tests for layout overlaying
Add tests to ensure that findViewbyId retrieves the correct view when
an id is overlaid in a RRO.

Also fixes a bug that made strings hardcoded in the overlays.xml
file unable to be retrieved from the string pool.

Bug: 135943783
Test: atest OverlayDeviceTests
Change-Id: I2bf03f151cb696d28f6bb9018eb319af29ba48f4
2019-12-12 10:55:33 -08:00