summaryrefslogtreecommitdiff
path: root/libs/androidfw/AssetManager.cpp
AgeCommit message (Collapse)Author
2015-08-03Clean up AssetManager::scanAndMergeZipLockedYusuke Sato
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-06-17ZipFileRO: Use precise widths for zip file types.Narayan Kamath
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
2014-12-03Merge "RRO: prevent duplicate system overlays"Adam Lesinski
2014-12-02Merge changes If2c7e09f,Ie21f227cAdam Lesinski
* changes: RRO idmap: pad with 0xffffffff, not 0x00000000 RRO: reintroduce lost ResTable insert of assets
2014-11-07Frameworks/base: Wall Werror in libs/androidfwAndreas Gampe
Turn on -Wall -Werror in libs/androidfw. Fix warnings. Refactor some code. Change-Id: I66fe54ace433c15dee5de328b149ca142f74b2dd
2014-11-07RRO: prevent duplicate system overlaysMårten Kongstad
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-07RRO: reintroduce lost ResTable insert of assetsMårten Kongstad
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-07-17Allow for appending of resources to an AssetManager.Martin Kosiba
BUG: 11505352 Change-Id: Ifa290580a6dc63c2f471d0bbf5f066db14aed4d7
2014-07-07am 10eb3b06: am e0849423: am 501bb0a5: Merge "Fix issue when converting ↵Narayan Kamath
fil->tl." * commit '10eb3b0665dd7c636af5f0d657512c1a2e309e0c': Fix issue when converting fil->tl.
2014-07-07Fix issue when converting fil->tl.Narayan Kamath
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-02resolved conflicts for merge of a8dbd7b4 to masterNick Kralevich
Change-Id: I90f42546c6d0a8f21af3041e59baf6a226247b1c
2014-07-02Fall back to "tl" if "fil" is absent.Narayan Kamath
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-06-18Support multiple resource tables with same packageAdam Lesinski
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-17am f5cb96cf: am 51736de1: am 4c488cca: Merge "[Asset Manager] Fix memory ↵Adam Lesinski
leakage bug" * commit 'f5cb96cfbbd2a7148b4b337097c94bea3f52d5f3': [Asset Manager] Fix memory leakage bug
2014-06-16[Asset Manager] Fix memory leakage bugsean_lu
Symptom: memory leakage Root Cause: new SortedVector but not free it in native cpp Solution: free the SortedVector Project: AOSP Note: Change-Id: Iab5a7f2e8d8509631301e7231427927d4797c856
2014-03-25Shared library resource supportAdam Lesinski
Shared libraries can now export resources for applications to use. Exporting resources works the same way the framework exports resources, by defining the public symbols in res/values/public.xml. Building a shared library requires aapt to be invoked with the --shared-lib option. Shared libraries will be assigned a package ID of 0x00 at build-time. At runtime, all loaded shared libraries will be assigned a new package ID. Currently, shared libraries should not import other shared libraries, as those dependencies will not be loaded at runtime. At runtime, reflection is used to update the package ID of resource symbols in the shared library's R class file. The package name of the R class file is assumed to be the same as the shared library's package name declared in its manifest. This will be customizable in a future commit. See /tests/SharedLibrary/ for examples of a shared library and its client. Bug:12724178 Change-Id: I60c0cb8ab87849f8f8a1a13431562fe8603020a7
2014-02-14Extended locales in AAPT / AssetManager.Narayan Kamath
Support 3 letter language codes, script codes & variants. The bulk of the changes are related to the implementation of command line filtering of locales etc. The previous code assumed that the value of each "axis" (locale, density, size etc.) could be represented by a 4 byte type. This is no longer the case. This change introduces a new class, AaptLocaleValue which holds a (normalized) locale parsed from a directory name or a filter string. This class takes responsibility for parsing locales as well as writing them to ResTable_config structures, which is their representation in the resource table. This includes minor changes at the java / JNI level for AssetManager. We now call locale.toLanguageTag() to give the native layer a well formed BCP-47 tag. I've removed some duplicated parsing code in AssetManager.cpp and replaced them with functions on ResTable_config. The native getLocales function has been changed to return well formed BCP-47 locales as well, so that the corresponding java function can use Locale.forLanguageTag to construct a Locale object out of it. Finally, this change introduces default and copy constructors for ResTable_config to prevent having to memset() the associated memory to 0 on every stack allocation. (cherry-picked from commit 91447d88f2bdf9c2bf8d1a53570efef6172fba74) Change-Id: I1b43086860661012f949fb8e5deb7df44519b854
2014-02-12resolved conflicts for merge of 1cbea39f to masterNick Kralevich
Change-Id: Ib33484546c6a03cbc4cd96e97d9d785d68e10700
2014-02-12resolved conflicts for merge of dd3d95f1 to klp-volantis-devNick Kralevich
Change-Id: I96c0f0da852a0b3cf8aef9158678d38aa30f456f
2014-02-11Use size_t* in AssetManager::createIdmapColin Cross
ResTable::createIdmap takes a size_t*, and the idmap command is passing in a size_t*, make AssetManager::createIdmap take a size_t*. Should fix the mac build. Change-Id: Idc16dedfe2aa7367c75f89a937a8242d494e8f8e
2014-02-11Fix build.Dianne Hackborn
At least part of what is broken. Other stuff still seems to be. Change-Id: I367dc0377bd5b4e59d9d9b68f3506bf1d64aa591 (cherry picked from commit 32bb5fae353b5bb6275e75952e89c514c7369cee)
2014-02-11Fix build.Dianne Hackborn
At least part of what is broken. Other stuff still seems to be. Change-Id: I367dc0377bd5b4e59d9d9b68f3506bf1d64aa591
2014-02-11am be49403a: am 0cd115e1: am 578087e3: Merge "New command line tool \'idmap\'"Dianne Hackborn
* commit 'be49403a0362c18edaeafe59ac09baac14294dee': New command line tool 'idmap'
2014-02-10Extended locales in AAPT / AssetManager.Narayan Kamath
Support 3 letter language codes, script codes & variants. The bulk of the changes are related to the implementation of command line filtering of locales etc. The previous code assumed that the value of each "axis" (locale, density, size etc.) could be represented by a 4 byte type. This is no longer the case. This change introduces a new class, AaptLocaleValue which holds a (normalized) locale parsed from a directory name or a filter string. This class takes responsibility for parsing locales as well as writing them to ResTable_config structures, which is their representation in the resource table. This includes minor changes at the java / JNI level for AssetManager. We now call locale.toLanguageTag() to give the native layer a well formed BCP-47 tag. I've removed some duplicated parsing code in AssetManager.cpp and replaced them with functions on ResTable_config. The native getLocales function has been changed to return well formed BCP-47 locales as well, so that the corresponding java function can use Locale.forLanguageTag to construct a Locale object out of it. Finally, this change introduces default and copy constructors for ResTable_config to prevent having to memset() the associated memory to 0 on every stack allocation. Change-Id: I899a56a9a182ee6be52b9389d1ae59266f5482e9
2014-02-03Runtime resource overlay, iteration 2Mårten Kongstad
Support any number of overlay packages. Support any target package. UPDATED PACKAGE MATCHING ------------------------ In Runtime resource overlay, iteration 1, only a single overlay package was considered. Package matching was based on file paths: /vendor/overlay/system/framework-res.apk corresponded to /system/framework-res.apk. Introduce a more flexible matching scheme where any package is an overlay package if its manifest includes <overlay targetPackage="com.target.package"/> For security reasons, an overlay package must fulfill certain criteria to take effect: see below. THE IDMAP TOOL AND IDMAP FILES ------------------------------ Idmap files are created by the 'idmap' binary; idmap files must be present when loading packages. For the Android system, Zygote calls 'idmap' as part of the resource pre-loading. For application packages, 'idmap' is invoked via 'installd' during package installation (similar to 'dexopt'). UPDATED FLOW ------------ The following is an outline of the start-up sequences for the Android system and Android apps. Steps marked with '+' are introduced by this commit. Zygote initialization Initial AssetManager object created + idmap --scan creates idmaps for overlays targeting 'android', \ stores list of overlays in /data/resource-cache/overlays.list AssetManager caches framework-res.apk + AssetManager caches overlay packages listed in overlays.list Android boot New AssetManager's ResTable acquired AssetManager re-uses cached framework-res.apk + AssetManager re-uses cached 'android' overlays (if any) App boot ActivityThread prepares AssetManager to load app.apk + ActivityThread prepares AssetManager to load app overlays (if any) New AssetManager's ResTable acquired as per Android boot SECURITY -------- Overlay packages are required to be pre-loaded (in /vendor/overlay). These packages are trusted by definition. A future iteration of runtime resource overlay may add support for downloaded overlays, which would likely require target and overlay signatures match for the overlay to be trusted. LOOKUP PRIORITY --------------- During resource lookup, packages are sequentially queried to provide a best match, given the constraints of the current configuration. If any package provide a better match than what has been found so far, it replaces the previous match. The target package is always queried last. When loading a package with more than one overlay, the order in which the overlays are added become significant if several packages overlay the same resource. Had downloaded overlays been supported, the install time could have been used to determine the load order. Regardless, for pre-installed overlays, the install time is randomly determined by the order in which the Package Manager locates the packages during initial boot. To support a well-defined order, pre-installed overlay packages are expected to define an additional 'priority' attribute in their <overlay> tags: <overlay targetPackage="com.target.package" priority="1234"/> Pre-installed overlays are loaded in order of their priority attributes, sorted in ascending order. Assigning the same priority to several overlays targeting the same base package leads to undefined behaviour. It is the responsibility of the vendor to avoid this. The following example shows the ResTable and PackageGroups after loading an application and two overlays. The resource lookup framework will query the packages in the order C, B, A. +------+------+- -+------+------+ | 0x01 | | ... | | 0x7f | +------+------+- -+------+------+ | | "android" Target package A | Pre-installed overlay B (priority 1) | Pre-installed overlay C (priority 2) Change-Id: If49c963149369b1957f7d2303b3dd27f669ed24e
2014-02-03New command line tool 'idmap'Mårten Kongstad
Introduce a new tool 'idmap' to handle generation and verification of idmap files. The tool is modelled on 'dexopt', and is intended to be used similarly, notably by 'installd'. See cmds/idmap/idmap.cpp for further documentation on 'idmap'. Note: this commit is interdependent on a commit in project build/ to add 'idmap' to PRODUCT_PACKAGES. Note: the changes to androidfw are only stubs. The actual implementation will be provided in Runtime resource overlay, iteration 2. Change-Id: I7131b74ece1e46c8a9c0a31d103e686aa07da2bb
2014-01-31Change ResourceType cookies to int32_t.Narayan Kamath
Also change the order of parameters in ResTable constructors to avoid ambiguity. (cherry picked from commit 00b314436f4fdfada4bbf1e79ec12e9fa38aeaf1) Change-Id: I874c5d03c134dc3c331fba423b5280366296287c
2014-01-28Change ResourceType cookies to int32_t.Narayan Kamath
Also change the order of parameters in ResTable constructors to avoid ambiguity. Change-Id: If7bfa1f640dddca39b9f26a3ce84081fa7b6e6e3
2014-01-27AssetManager cookies should be int32_t and not void*.Narayan Kamath
Cookies are really indices into vectors and arrays, so they don't need to be void*. We choose int32_t instead of size_t to allow their width to be well specified. Change-Id: I319f271bd4f102dee7cb9f00df4c75ea697456f5
2014-01-27Reimplement ZipFileRO in terms of libziparchive.Narayan Kamath
This lets us share zip archive processing code with both the runtime (Art, dalvik) and critical java code (StrictJarFile). This change also moves several utility methods to ZipUtils and dedups code across several zip inflation methods. One of the side effects of this change is that several processing loops are now O(n) instead of O(n^2). bug: 10193060 (cherry picked from commit afd31e08299008fdc5c2813f21b2573f29dc53df) Change-Id: Iae67e62f1dc6dfc3f43e29bc38e3ffd1cb14d191
2014-01-27Re-apply androidfw fixes lost by the directory rearrangement.Elliott Hughes
Assignment to wrong variable in libs/androidfw/AssetManager.cpp. https://code.google.com/p/android/issues/detail?id=61560 Missing delete[]s in libs/androidfw/ObbFile.cpp. https://code.google.com/p/android/issues/detail?id=61549 Change-Id: I24e6867284d70a7793d78e62d1a836cbee310fb0
2014-01-27Revert "move libandroidfw to frameworks/native"Adam Lesinski
This reverts commit 84b6292c33d71b5739828d08aa8101d1954577f2.
2014-01-27AssetManager cookies should be int32_t and not void*.Narayan Kamath
Cookies are really indices into vectors and arrays, so they don't need to be void*. We choose int32_t instead of size_t to allow their width to be well specified. (cherry picked from commit ebfdd0f467e39c3af8d92cade78263935340acb7) (cherry picked from commit a7fa2e592e2e579e5acdb903dba83fc074ebc215) (cherry picked from commit a9d5701b034ed2d9771b3f0943e1add00741d7cd) Change-Id: I2aed3db568b6fdc487bf99e2c5dd123206736fda
2013-12-09Reimplement ZipFileRO in terms of libziparchive.Narayan Kamath
This lets us share zip archive processing code with both the runtime (Art, dalvik) and critical java code (StrictJarFile). This change also moves several utility methods to ZipUtils and dedups code across several zip inflation methods. One of the side effects of this change is that several processing loops are now O(n) instead of O(n^2). bug: 10193060 Change-Id: I3c7188496837a47246c4f342e45485a70fef3169
2013-11-22Merge commit 'b873a17ce7be0a9771c24999adca6964431728f6' into HEADThe Android Open Source Project
Change-Id: I938755073e70602cc8f51ce9bd420fdcf870cecd
2013-10-29Fix a variety of small publicly-reported bugs.Elliott Hughes
Possible NULL dereference in cmds/bootanimation/BootAnimation.cpp. https://code.google.com/p/android/issues/detail?id=61556 Missing fclose in core/jni/android_os_Debug.cpp. https://code.google.com/p/android/issues/detail?id=61546 Bad loop guards in core/jni/android_util_Process.cpp. https://code.google.com/p/android/issues/detail?id=61557 Assignment to wrong variable in libs/androidfw/AssetManager.cpp. https://code.google.com/p/android/issues/detail?id=61560 Missing delete[]s in libs/androidfw/ObbFile.cpp. https://code.google.com/p/android/issues/detail?id=61549 Leaks on error in tools/aapt/Images.cpp. https://code.google.com/p/android/issues/detail?id=61552 Two missing fclose calls in tools/aapt/Resource.cpp. https://code.google.com/p/android/issues/detail?id=61553 Missing fclose in tools/aidl/aidl.cpp. https://code.google.com/p/android/issues/detail?id=61554 Change-Id: I5820f3824e72d07a9acb776cf0af3e7443f5694a
2013-10-03move libandroidfw to frameworks/nativeMike Lockwood
Change-Id: Ic5b8a2742c7141156ab0f00ca29097bfe92bce60
2013-05-07libutils clean-upMathias Agopian
Change-Id: I11ee943da23a66828455a9770fc3c5ceb4bbcaa9
2013-04-15Maybe fix issue #8620910: Win_sdk build failed and unable to create...Dianne Hackborn
...the sdk platform repo Change-Id: Ib6cd7c0dfb9b6217ae79af3e2ac25fe0442996e3
2013-04-12Add new resources trace, also trace apk dex loading.Dianne Hackborn
Change-Id: Ia48566efb21ee018659bd976ddb3a0f4997b9a3a
2012-08-05libutils cleanupMathias Agopian
Change-Id: Ic069539338ba4097dba9399904f02bbd0296c20e
2012-03-22frameworks/base: move Zip* from libandroidfw to libutilsColin Cross
ZipUtils is needed by build/tools, move it from libandroidfw (frameworks/base) to libutils (frameworks/native). Change-Id: I2b4b7adcdf68eb25ee7cba5dd3b69eadf0523af3
2012-02-20frameworks/base refactoringMathias Agopian
create the new libandroidfw from parts of libui and libutils Change-Id: I1584995616fff5d527a2aba63921b682a6194d58