79 Commits

Author SHA1 Message Date
Jason Monk
cc5a731fd7 Remove "Allow persistent changes to the vendor overlay theme"
This reverts commit 2dc804be11444565e3d1d151c2a693db3ade94c0.
It also removes the related calls from UiModeManager.

Fixes: 32721178
Test: make & flash
Change-Id: Id371bccec611155cc6910e46b3277c3d27fc1c79
2017-03-23 11:25:59 -04:00
Jaekyun Seok
7de2f9c73f Reinstate codes to enable RRO on system server
Test: building succeeded and tested with sailfish
Bug: 35742444
Change-Id: I99d0f1d097525d3eb46255d6cf823f6ae2a02385
2017-03-03 07:23:23 +09:00
Mårten Kongstad
2e0d0f3111 OMS: integrate OverlayManagerService into framework
Hand over ownership of overlays to OverlayManagerService.

Changes to a package's overlays are propagated using the activity life
cycle. Affected activities will be recreated as needed. This provides a
well-defined point to modify an application's assets while the
application is paused.

Consolidate how overlays targeting the system and overlays targeting
regular applications are handled. Previously, system overlays were
handled as a special case. Now, everything is handled identically. As a
side effect, the call to idmap --scan during Zygote boot has become
obsolete and is removed.

Information on what overlays to use is recorded in
ApplicationInfo.resourceDirs. The PackageManagerService is responsible
for the creation of ApplicationInfo objects. The OverlayManagerService
is responsible for informing the PackageManagerService in advance about
what resourceDirs to use.

When launching an application, the ApplicationInfo is already populated
with up-to-date information about overlays.

When enabling or disabling an overlay for a running application, the
OverlayManagerService first notifies the PackageManagerService about the
updated resourceDirs. It then tells the ActivityManagerService to push
the new ApplicationInfo object to the application's ActivityThread.
Finally the application requests its ResourcesManager to create new
ResourcesImpl objects based on the updated paths.

Change-Id: Ib8afa05ccab4e2db558f89ce4423983c086bb61a
Co-authored-by: Martin Wallgren <martin.wallgren@sonymobile.com>
Signed-off-by: Zoran Jovanovic <zoran.jovanovic@sonymobile.com>
Bug: 31052947
Test: run tests from 'OMS: tests for OverlayManagerService'
2017-02-23 14:01:38 -08:00
Guang Zhu
9545980692 Revert "OMS: integrate OverlayManagerService into framework"
Bug: 31052947
Bug: 35697944

This reverts commit 21a3d1ad686dee97b9cf0ed80389ee2ab0d48013.

Change-Id: I2d86931020301524c26cf8c8e80d557c97fdd6c3
2017-02-23 07:35:39 +00:00
Mårten Kongstad
21a3d1ad68 OMS: integrate OverlayManagerService into framework
Hand over ownership of overlays to OverlayManagerService.

Changes to a package's overlays are propagated using the activity life
cycle. Affected activities will be recreated as needed. This provides a
well-defined point to modify an application's assets while the
application is paused.

Consolidate how overlays targeting the system and overlays targeting
regular applications are handled. Previously, system overlays were
handled as a special case. Now, everything is handled identically. As a
side effect, the call to idmap --scan during Zygote boot has become
obsolete and is removed.

Information on what overlays to use is recorded in
ApplicationInfo.resourceDirs. The PackageManagerService is responsible
for the creation of ApplicationInfo objects. The OverlayManagerService
is responsible for informing the PackageManagerService in advance about
what resourceDirs to use.

When launching an application, the ApplicationInfo is already populated
with up-to-date information about overlays.

When enabling or disabling an overlay for a running application, the
OverlayManagerService first notifies the PackageManagerService about the
updated resourceDirs. It then tells the ActivityManagerService to push
the new ApplicationInfo object to the application's ActivityThread.
Finally the application requests its ResourcesManager to create new
ResourcesImpl objects based on the updated paths.

Co-authored-by: Martin Wallgren <martin.wallgren@sonymobile.com>
Signed-off-by: Zoran Jovanovic <zoran.jovanovic@sonymobile.com>
Bug: 31052947
Test: run tests from 'OMS: tests for OverlayManagerService'
Change-Id: Idc96dae6fc075d5373aa055bbf50e919136d7353
2017-02-21 14:29:43 -08:00
Mårten Kongstad
6bb13da278 Fix memory leak during idmap creation
Plug a memory leak in AssetManager::createIdmap.

Bug: 31052947
Test: use Valgrind and dummy native app
Change-Id: I83af3a40516ed2d50d5a7c8ee175ed960fde9933
2017-01-24 20:26:51 -08:00
Jason Monk
2dc804be11 Allow persistent changes to the vendor overlay theme
This allows the overlay being used to be changed without a new build
but still will require a reboot to take effect. Should no longer be
needed once hierarchical resources are in place, and can be removed.

Also fix check in fd_utils to point at correct location.

Test: Manual
Bug: 32721178
Change-Id: I2a63aea0c87791c8eb845d735cb1182716c8174d
2016-11-07 20:46:07 -05:00
neo.chae
6c8b93cf54 Merge "Fix idmap leak in zygote process" am: f5ad44b60a am: 4720125a3c am: 3e15d09ed4
am: d3a209399a

Change-Id: I2c7272b5f79e029ac88fa6b6acb598bdf68f28e2
2016-11-02 21:30:36 +00:00
neo.chae
3e15d09ed4 Merge "Fix idmap leak in zygote process" am: f5ad44b60a
am: 4720125a3c

Change-Id: If66e9476583ec50d2dca5a15376a4b84ae2a2885
2016-11-02 21:21:32 +00:00
neo.chae
4720125a3c Merge "Fix idmap leak in zygote process"
am: f5ad44b60a

Change-Id: Ia9977c8166f797ad716284eda03076e282a9fde7
2016-11-02 21:16:33 +00:00
neo.chae
6a742a3850 Fix idmap leak in zygote process
Fix a idmap leak in AssetManager::addSystemOverlays.
And, The fix could also prevent fd leak of idmap.

Test: none

Change-Id: Iff8831e1951a1ca103821f64a612a8b28d2c14e7
Signed-off-by: Hyangseok Chae <neo.chae@lge.com>
2016-11-01 08:53:35 +09:00
Jakub Adamek
93bbe47d65 Change name of overlay subdir 'sku'->'theme' am: 54dcaaba4f
am: 6bbb63ad91

Change-Id: I71dfaafbebaa7bd61d182405c734eef1ea7ff1eb
2016-10-21 07:16:07 +00:00
Jakub Adamek
54dcaaba4f Change name of overlay subdir 'sku'->'theme'
The name 'sku' does not fit well as we recommend to use the same
value for different SKUs if vendors wish to have the same colors
on those SKUs.

Bug: 32268656
Change-Id: Ib5e5a3386676453dafeb13a6a6bf91f81bb48a11
2016-10-19 14:06:32 +01:00
Martin Wallgren
85dd1b8594 RRO: Synchronize access to overlays.list am: 0fbb608110 am: dce79f10ba
am: 3970c44547

Change-Id: I4c9eecad4c2d935a1f1840fed6d70685b82b7e65
2016-10-12 21:15:58 +00:00
Martin Wallgren
dce79f10ba RRO: Synchronize access to overlays.list
am: 0fbb608110

Change-Id: I44a716df3954b6d2d58d7c9784f8b55cf041b10b
2016-10-12 21:03:11 +00:00
Martin Wallgren
0fbb608110 RRO: Synchronize access to overlays.list
idmap --scan is executed as a part of the pre-loading in ZygoteInit.
The pre loading is executed in parallel for each supported architecture
(32/64 bit). This will cause a race condition in the creation of the
overlays.list file and the idmap files for the system overlays.

Apply flock on overlays.list to prevent the file from being thrown away
and recreated when it is in use by another Zygote.

Cherry-picked from AOSP.

Bug: 28032298
Test: manual
Change-Id: I51d39f121d207b11181340b68b164b60020f0c61
2016-10-12 14:56:31 +00:00
Martin Wallgren
f12af5e907 RRO: Synchronize access to overlays.list
idmap --scan is executed as a part of the pre-loading in ZygoteInit.
The pre loading is executed in parallel for each supported architecture
(32/64 bit). This will cause a race condition in the creation of the
overlays.list file and the idmap files for the system overlays.

Apply flock on overlays.list to prevent the file from being thrown away
and recreated when it is in use by another Zygote.

Bug: 28032298

Change-Id: I51d39f121d207b11181340b68b164b60020f0c61
2016-10-12 15:42:04 +09:00
songjinshi
09901f3bc9 Fix thread race caused double free issue.
am: 5754b41c20

Change-Id: Ic9dd6e9c6d216753d997da99158816682d5464d1
2016-10-06 20:13:00 +00:00
Adam Lesinski
fe90eaf528 AssetManager: Remove more methods, fix comments
Remove a few vendor-related methods and fix comments
to no longer reference legacy concepts like vendor.

Change-Id: I61dbe53b6b305d8fb3468423462f5de2925b78bd
Test: dead-code removal, if builds, it works
2016-10-04 13:37:31 -07:00
Adam Lesinski
a77685fa59 Remove unused methods from AssetManager.cpp
A lot of the vendor/locale specific code existed pre-1.0
and was reworked into the current system.

Test: refactoring CL, all code except setLocale() was not being executed.
Test: setLocale() change tested manually
Change-Id: Ifb098f9808763a6cf5fb4336e089430adc09e198
2016-10-03 16:33:12 -07:00
Adam Lesinski
dbfd183fdc Merge "[AssetManager]:Fix thread race caused double free issue." am: 126e022095 am: f48d0b8f19 am: 73b91c63ad
am: 224ffd3cb2

Change-Id: Id06724e9d44464d1599743741d73b5bd9c282ff2
2016-10-03 20:31:15 +00:00
Adam Lesinski
224ffd3cb2 Merge "[AssetManager]:Fix thread race caused double free issue." am: 126e022095 am: f48d0b8f19
am: 73b91c63ad

Change-Id: I27f5cc6106f0a8f0a58721e1e8ed836144347b6a
2016-10-03 20:26:41 +00:00
songjinshi
5754b41c20 Fix thread race caused double free issue.
The SharedZip's Asset is not thread-safety,the getResourceTableAsset()
and setResourceTableAsset(Asset* asset) function of the SharedZip is
not sync with a same lock.

Consider the following sequence of events:
Thread A calls setResourceTableAsset(Asset* asset),it will set
mResourceTableAsset = asset; then to calls getBuffer() of the asset.
Thread B calls getResourceTableAsset(),which return mResourceTableAsset,
then to calls getBuffer() of the mResourceTableAsset,the asset and
mResourceTableAsset is same one object.
Thread A to delete mZipInflater in getBuffer().
Thread B to delete mZipInflater in getBuffer().

It will cause crash becuase double delete mZipInflater in getBuffer().

https://code.google.com/p/android/issues/detail?id=211941

Bug:31734545
Change-Id: I5a7d67fdf64c4aa03f505b37a2fa840f4443d158
Signed-off-by: songjinshi <songjinshi@xiaomi.com>
2016-10-03 20:13:12 +00:00
Jakub Adamek
1c527915f7 Change name of overlay subdir property to sku. am: c03d9483f0
am: e60842aba3

Change-Id: Ifda5c5a7fc7eaff49aa2f65671d543e285b7f8a4
2016-10-03 10:38:13 +00:00
Jakub Adamek
c03d9483f0 Change name of overlay subdir property to sku.
Also move the SKU subdirectories directly under /vendor/overlay.

Bug: 31692079
Change-Id: I68c712b13918cc99629534580ee4f77d9e5b3823
2016-10-03 10:14:12 +01:00
Jakub Adamek
bfc891c25c Search for runtime resource overlays in subdir. am: 1c15c63578
am: ff5cb98888

Change-Id: I726b08026ceb250cc95669d3b5a5c35e15bf82e4
2016-09-28 10:33:16 +00:00
Jakub Adamek
1c15c63578 Search for runtime resource overlays in subdir.
See go/sku-colors. This changes the directory to search for framework
overlays if the right system property is defined. This allows
OEMs to specify different resources based on device SKUs.

Bug: 31692079
Change-Id: I9cb121b286b7f52aa26de1757fde1f3110cd47fd
2016-09-28 10:09:20 +01:00
songjinshi
49921f2c05 [AssetManager]:Fix thread race caused double free issue.
The SharedZip's Asset is not thread-safety,the getResourceTableAsset()
and setResourceTableAsset(Asset* asset) function of the SharedZip is
not sync with a same lock.

Consider the following sequence of events:
Thread A calls setResourceTableAsset(Asset* asset),it will set
mResourceTableAsset = asset; then to calls getBuffer() of the asset.
Thread B calls getResourceTableAsset(),which return mResourceTableAsset,
then to calls getBuffer() of the mResourceTableAsset,the asset and
mResourceTableAsset is same one object.
Thread A to delete mZipInflater in getBuffer().
Thread B to delete mZipInflater in getBuffer().

It will cause crash becuase double delete mZipInflater in getBuffer().

https://code.google.com/p/android/issues/detail?id=211941

Change-Id: I5a7d67fdf64c4aa03f505b37a2fa840f4443d158
Signed-off-by: songjinshi <songjinshi@xiaomi.com>
2016-09-20 01:31:19 +00:00
Roozbeh Pournader
7e5f96f1a3 Move matching Tagalog and Filipino to ResourceTypes.cpp
Previously, if a mix of "fil" and "tl" resources existed in Resources
(from mixing resources from libraries for example), only resources
from one or the other would be chosen, resulting in default resources
getting surprisingly used. Now, we resolve the equivalent languages
at a per-resource levels (breaking ties for the identical code).

Also, previously if both "tl" and "fil" resources were present in
assets, getLocales() could return a list with duplicate locales.
This change removes Filipino duplicates in the return value of
AssetManager::getLocales().

Finally, there was a bug in the replacement of "tl" with "fil" that
considered any locale starting with the letter "tl" to be Tagalog.
This failed in case of various languages, including Klingon ("tlh")
and Tlingit ("tli"). It's now fixed.

Bug: 29073000
Change-Id: I0e8b9ae337ced2e640a2575897948c4c5ca307d3
2016-06-15 11:45:58 -07:00
Adam Lesinski
76da37e1cf Performance improvements in AssetManager
Change the implementation of getLocales() to iterate the set of
configurations using a templated method, instead of using the result
of getConfigurations().

Also remove the check for AndroidManifest.xml when adding an asset path.
This is unneccessary.

Bug:28625993
Change-Id: I16de5da598d0c371421d1dc8eee054dce9baf53a
2016-05-20 15:04:09 -07:00
Adam Lesinski
b7e1ce0775 Optimize ResTable::getLocales() to improve bindApplication performance
Change from linear searching for uniqueness to binary search.

Bug:27198799
Change-Id: I1ccb6e93cc213810848f07d631d9d8de7c719803
2016-04-18 15:06:50 -07:00
Tim Murray
98e80076c6 Revert "Optimize ResTable::getLocales() to improve bindApplication performance"
This reverts commit 5520581b5f043fb858b5b2044ff33ad8545a6d38.

bug 28189634

Change-Id: I2d2b859f6d9bd44434fa901cce990583f514980c
2016-04-14 16:06:29 -07:00
Adam Lesinski
5520581b5f Optimize ResTable::getLocales() to improve bindApplication performance
Change from linear searching for uniqueness to binary search.

Bug:27198799
Change-Id: Ifa4672929df286c4693ab1f77716f08945941b0c
2016-04-13 13:25:09 -07:00
Roozbeh Pournader
1c686f2ce6 Avoid matching system locales in locale negotiation
Also:
1. Add AssetManager method for finding non-system locales: This is
used in per-app locale negotiation. (Normally,
AssetManager#getLocales() returns both system and non-system
locales.)

2. Match pseudolocales correctly in locale negotiation.

Bug: 25800576
Bug: 26236938
Change-Id: I116caf3a91c290deb4ad68b291c65b7035b18dd4
2016-01-04 13:53:54 -08:00
Tao Bai
a6d7e3fb9c Load app resource as shared library.
- Added aapt command line flag --app-as-shared-lib to build app resources
  that could be loaded as shared lib at runtime.
- Added new method AssetManager.addAssetPathAsSharedLibrary() to load an
  app resource as shared library.

Bug 22487604

Change-Id: Ib9b33c35f9c2b7129f3ba205de03d4564623ea39
2015-09-08 18:48:42 -07:00
Elliott Hughes
ba3fe56edc Lose HAVE_ANDROID_OS from frameworks/base.
Change-Id: I713881fdbaec7cbbb5e7f2f4be6f9b8be3d2ca4e
2015-08-12 14:49:53 -07:00
Yusuke Sato
05f648e1d3 Clean up AssetManager::scanAndMergeZipLocked
Now that ZipFileRO::startIteration supports prefix/suffix matching,
we can pass dirName to the function for simpler code and slightly
better performance.

(cherry-pick of c796ad0a8be6df4a3b354690dfe5ce1df8136c09)

Change-Id: I0e2ac58de28020c2af8d8e569a97592b09596185
2015-08-03 17:24:42 -07:00
Narayan Kamath
407753c456 ZipFileRO: Use precise widths for zip file types.
getEntryInfo crashes on 64-bit devices because "long" types
were being passed int pointers (that pointed to a stack frame)
that were reinterpret_cast'ed to long* (sigh.). To fix this issue
once and for all, use types with explicitly defined widths.

This change also removes some dead invariant checking from
Asset.cpp instead of cleaning it up.

Note that we've introduced a wart in NativeLibraryHelper, where
we need to deal with zlib's uLong type, which is "at least 32 bits
wide".

bug: 21622286

(cherry picked from commit 4600dd053dbdbd4b95f3b11057a1cc55b99f9c77)

Change-Id: I7886cb37a229cc27c625699c80e6a6a6117d2203
2015-06-17 13:13:16 +00:00
Adam Lesinski
a2b5067aee Merge "RRO: prevent duplicate system overlays" 2014-12-03 17:44:18 +00:00
Adam Lesinski
e89a286541 Merge changes If2c7e09f,Ie21f227c
* changes:
  RRO idmap: pad with 0xffffffff, not 0x00000000
  RRO: reintroduce lost ResTable insert of assets
2014-12-02 22:52:37 +00:00
Andreas Gampe
2204f0bf56 Frameworks/base: Wall Werror in libs/androidfw
Turn on -Wall -Werror in libs/androidfw. Fix warnings. Refactor
some code.

Change-Id: I66fe54ace433c15dee5de328b149ca142f74b2dd
2014-11-07 13:35:05 -08:00
Mårten Kongstad
cb7b63d928 RRO: prevent duplicate system overlays
System overlays, ie overlays with targetPackage="android", were loaded
twice, which caused all sorts of issues. Ensure they are only loaded
once, which will be during Zygote initialization.

Bug: 17765434
Change-Id: Ia5064045c77f713c58fb78adc3942f6af1abdc93
2014-11-07 16:08:22 +01:00
Mårten Kongstad
30113131fb RRO: reintroduce lost ResTable insert of assets
With the recent introduction of AssetManager::appendPathToResTable,
overlay packages were not properly added to the AssetManager, and once
added, were not properly inserted into the ResTable.

Bug: 17765434
Change-Id: Ie21f227c654c98730f74a687d0e16ee2b80e747e
2014-11-07 16:07:42 +01:00
Martin Kosiba
7df3625d5b Allow for appending of resources to an AssetManager.
BUG: 11505352
Change-Id: Ifa290580a6dc63c2f471d0bbf5f066db14aed4d7
2014-07-17 18:10:02 +01:00
Narayan Kamath
23902f5f4d am 10eb3b06: am e0849423: am 501bb0a5: Merge "Fix issue when converting fil->tl."
* commit '10eb3b0665dd7c636af5f0d657512c1a2e309e0c':
  Fix issue when converting fil->tl.
2014-07-07 10:26:42 +00:00
Narayan Kamath
fec5106c8e Fix issue when converting fil->tl.
We should call ResourceTable::getLocales directly,
and not AssetManager::getLocales. The latter will convert
"tl" to "fil" so we'll end up thinking we have resources
for "fil" when we don't really have any.

bug: 15873165

Change-Id: I9753e4608aaecede328a40ee1f3ee6b016d0dedc
2014-07-07 09:51:01 +01:00
Nick Kralevich
a00144ca89 resolved conflicts for merge of a8dbd7b4 to master
Change-Id: I90f42546c6d0a8f21af3041e59baf6a226247b1c
2014-07-02 15:41:21 -07:00
Narayan Kamath
e4345dbd2a Fall back to "tl" if "fil" is absent.
For JB-MR1, there was a hack that used "tl" where
we really meant "fil" because ICU didn't have localizations
for "fil". This has now been fixed, and we now support 3 letter
language codes for AAPT so we can use "fil" where required.

For the benefit of apps that need to target older platforms,
we fall back to "tl" if the app has assets for "tl" and the
resource locale is "fil".

See bugs 7291355, 7207176 and 8049507 for more context.

Change-Id: I1ac8502525f99b40f9091d5efd2df33518d47a41
2014-07-02 10:53:43 +01:00
Adam Lesinski
f90f2f8dc3 Support multiple resource tables with same package
In order to support APK split features, the resource
table needs to support loading multiple resource
tables with the same package but potentially new set
of type IDs.

This adds some complexity as the type ID space changes
from dense and ordered to potentially sparse.

A ByteBucketArray is used to store the type IDs in
a memory efficient way that allows for fast retrieval.

In addition, the IDMAP format has changed. We no longer
need random access to the type data, since we store the
types differently. However, random access to entries of
a given type is still required.

Change-Id: If6f5be680b405b368941d9c1f2b5d2ddca964160
2014-06-18 19:20:08 +00:00
Adam Lesinski
7efc0eb163 am f5cb96cf: am 51736de1: am 4c488cca: Merge "[Asset Manager] Fix memory leakage bug"
* commit 'f5cb96cfbbd2a7148b4b337097c94bea3f52d5f3':
  [Asset Manager] Fix memory leakage bug
2014-06-17 19:21:56 +00:00