summaryrefslogtreecommitdiff
path: root/libs/androidfw/Asset.cpp
AgeCommit message (Collapse)Author
2020-12-08Revert^2 "libandroidfw hardening for IncFs"Ryan Mitchell
55ef6167a2c235bd88c7216238b2001b46795b79 Change-Id: I02d4890d181655dfd0a14c188468db512559d27b Merged-In: I02d4890d181655dfd0a14c188468db512559d27b
2020-03-19Refactor ApkAsset loading APIsRyan Mitchell
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
2019-10-10Add ResourceLoader API with .apk and .arsc supportWinson
ResourceLoaders allow inserting another .apk/.arsc into AssetManager's resource resolution search. The effect is similar to overlays, where a entry of >= config later in the path list will return that ApkAsset's resource value instead. Because loading from an .arsc is supported, which doesn't contain any actual files, ResourceLoader exposes loadDrawable and loadXmlResourceParser to allow an application load those files from anywhere or create them in code. The data being loaded is either pushed into an .apk or .arsc that mocks itself as the package being "overlaid" and is passed in through ResourcesProvider, an interface with static methods that supports loading from a readable path on disk or a FileDescriptor. The APIs are accessed through a Context's getResources(), which has been changed to be unique per "Context-scope", which is usually the lifetime of the Java object. The exception is that Activities who get their Resources object persisted across recreations maintain that logic for persisting ResourceLoaders. Bug: 135270223 Test: atest FrameworksResourceLoaderTests Change-Id: I6929f0828629ad39a21fa155e7fec73bd75eec7d
2019-04-03Fix remaining pointer leaks in Asset.cppWinson
Follow up from comment in ag/6761240 Test: none Change-Id: Ib6a52b3fe13b4eb00b363ee720196fe0bfdfbb94
2019-03-18Delete pAsset* when failing to open chunk from FileAssetWinson
Realistically this doesn't matter because FileAsset always returns NO_ERROR. But it's worth being correct, in case that ever changes. Bug: 112146313 Test: none necessary Change-Id: Iaeddc77c78c93394f96b77533cf8ce30cd1dc370
2018-02-23Don't use cutils/Atomic.hSteven Moreland
Test: builds Change-Id: I74485a5cbecb8710714f7bf3e54da61dd787838f
2017-02-15AssetManager2: Various fixesAdam Lesinski
- Use FileMaps to open Assets (prevents closing of ApkAssets underlying zip) - Implement OpenDir and List methods - Fix issue where DynamicRefTable wasn't properly constructed Test: make libandroidfw_tests Change-Id: Ib21a84e1114d028120744aa3bc1c6eb9d9399fa8
2016-10-17Fix race with Asset destruction and printing allocation statsAdam Lesinski
A race could occur when printing the list of Asset allocations for debugging purposes. Each Asset object would insert themselves into a global linked list on construction and remove themselves on destruction. Iterating the list and the insertion/remove operations all acquire a global lock. The race occurs after the Asset subclass destructor runs but before the Asset base class destructor runs, which performs the actual removal from the list. The vtable of the object being destroyed ends up pointing at the base Asset class' vtable, and during the iteration of the global list, a pure virtual method is called leading to an abort, since the wrong vtable is dereferenced. This change moves the insertion/removal of the Asset object into the global list to the concrete class, which adds some maintenance overhead but solves the problem. Bug:31113965 Test: make libandroidfw_tests Change-Id: I1a620897e5e04a8519ee247883bba0719b1fa6f3
2016-03-02Cleanup uses of sprintf so we can deprecate it.George Burgess IV
Change-Id: Ic66abfb547cd5551c47e03d604e65f83c84c597f
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 Change-Id: Iae675a9601db7aae03a8b80b40321d2cc1d97f50
2015-02-23Track removal of refcounts from FileMap.Narayan Kamath
Use delete instead of release. Change-Id: I25c841b368aa9d51e9259399b94cafa2bbb7a076
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-03-19androidfw: resolve 64-bit build issuesMark Salyzyn
- uid_t/gid_t cast to unsigned long - unused argument warnings - tab and space requirements Change-Id: Ib446d8165b9082be02edb55e6b71fd1a03ea3431
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-05-07libutils clean-upMathias Agopian
Change-Id: I11ee943da23a66828455a9770fc3c5ceb4bbcaa9
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