summaryrefslogtreecommitdiff
path: root/libs/androidfw/ZipFileRO.cpp
AgeCommit message (Collapse)Author
2020-11-17Revert^2 "libandroidfw hardening for IncFs"Ryan Mitchell
55ef6167a2c235bd88c7216238b2001b46795b79 Change-Id: I02d4890d181655dfd0a14c188468db512559d27b
2020-11-13Revert "libandroidfw hardening for IncFs"Ryan Mitchell
Revert "Move map_ptr to incfs namspace" Revert submission 12787270 Reason for revert: b/173250495 Reverted Changes: I5cd1bc8a2:libandroidfw hardening for IncFs Ice5dbcfb2:Move map_ptr to incfs namspace I29ccdc8ed:Do not cache bag parent stack until requested I1e9e9acaa:Cache resolved theme values Change-Id: Ib90ef68339710086df41e9abe0833a542d03a74f
2020-11-12libandroidfw hardening for IncFsRyan Mitchell
Migrate libandroifw to using incfs::util::map_ptr to prevent processes from crashing when parsing the resources.arsc, parsing compiled xml, files, and retrieving resource values. This change propagates incremental failures to the JNI level where they are raised as ResourcesNotFoundException. Performance of ResourcesPerfWorkloads without change (time in nanoseconds): [1/3] com.android.resources.perf.PerfTest#youtube: PASSED (11.883s) youtube_ns_median: 93812805 youtube_ns_standardDeviation: 4387062 youtube_ns_mean: 94455597 [2/3] com.android.resources.perf.PerfTest#maps: PASSED (11.265s) maps_ns_standardDeviation: 2997543 maps_ns_mean: 83480371 maps_ns_median: 82210941 [3/3] com.android.resources.perf.PerfTest#gmail: PASSED (24.963s) gmail_ns_median: 266141091 gmail_ns_standardDeviation: 3492043 gmail_ns_mean: 267472765 With change and verification forcibly enabled for all apks (including the framework-res.apk): [1/3] com.android.resources.perf.PerfTest#youtube: PASSED (11.646s) youtube_ns_median: 101999396 youtube_ns_standardDeviation: 4625782 youtube_ns_mean: 102631770 [2/3] com.android.resources.perf.PerfTest#maps: PASSED (11.286s) maps_ns_standardDeviation: 2692088 maps_ns_mean: 91326538 maps_ns_median: 90519884 [3/3] com.android.resources.perf.PerfTest#gmail: PASSED (24.694s) gmail_ns_median: 290284442 gmail_ns_standardDeviation: 5764632 gmail_ns_mean: 291660464 With change and verification disabled: [1/3] com.android.resources.perf.PerfTest#youtube: PASSED (11.748s) youtube_ns_median: 95490747 youtube_ns_standardDeviation: 7282249 youtube_ns_mean: 98442515 [2/3] com.android.resources.perf.PerfTest#maps: PASSED (10.862s) maps_ns_standardDeviation: 4484213 maps_ns_mean: 87912988 maps_ns_median: 86325549 [3/3] com.android.resources.perf.PerfTest#gmail: PASSED (24.034s) gmail_ns_median: 282175838 gmail_ns_standardDeviation: 6560876 gmail_ns_mean: 282869146 These tests were done on a Pixel 3 and with cpu settings configured by libs/hwui/tests/scripts/prep_generic.sh: Locked CPUs 4,5,6,7 to 1459200 / 2803200 KHz Disabled CPUs 0,1,2,3 Bug: 160635104 Bug: 169423204 Test: boot device && atest ResourcesPerfWorkloads Change-Id: I5cd1bc8a2257bffaba6ca4a1c96f4e6640106866
2019-06-17Move off ZipString and over to std::string/std::string_view as appropriate.Elliott Hughes
Bug: http://b/129068177 Test: treehugger Change-Id: Ib46761d89772d3a3c655a39df573fd305c117d19
2019-05-08Track libziparchive API change.Elliott Hughes
Bug: http://b/129068177 Test: treehugger Change-Id: Id4b202502b07e08102deda49f7d28ba10a63bb0a
2019-05-03Track libziparchive API change.Elliott Hughes
Bug: http://b/129068177 Test: treehugger Change-Id: I88f49a06db416a7c6ec8afe87cc9cca825eb5ccb
2017-10-31Fully implement "install" and "install-write" in PackageManagerShellCommand.Dianne Hackborn
We can use the new mechanism to ask the calling shell to open a file in order to implement the rest of these commands, allowing you to give the path to an apk to install. That API is thus extended to allow you to open readable files, not just opening file for writing. Doing this however means we no longer can pass a file path to AssetManager for the apk to parse, we only have an already open fd for that. Extending AssetManager to allow adding apks from fds is not that hard, however, since the underlying zip library already supports this. This main thing this changes is in AssetManager.cpp where we retrieve the open zip file for a particular apk that has been added. This used to look up the zip file by path every time it was needed, but that won't work anymore now that we can have things added by fd. Instead, we keep track of each opened zip in the AssetManager, so we can just directly retrieve it from the asset_path representing the item that was added. As a side-effect, this means for normal paths we no longer need to look up by name, but just have the opened zip file directly accessible. (This is probably good, but it does mean that we no longer run the logic of seeing if the zip file's timestamp has changed and re-opening it if it has. We probably shouldn't be relying on that for an active AssetManager anyway, and maybe it is even good that we don't allow the zip file to change under it?) A follow-up change will finally remove the Pm.java implementation and turn the pm "command" into a simple shell script that runs cmd package. Test: manual Change-Id: Ie103e3bdaa5b706796cc329254f2638151a3924f
2015-08-05Fix build breakage caused by r.android.com/162907Yusuke Sato
Change-Id: Ifeb7b57ce79f3d8c0edadf03d14853e72840d49e
2015-08-05am 3383b141: am a024acb8: Merge "Let findSupportedAbi and ↵Yusuke Sato
hasRenderscriptBitcode scan only relevant files" * commit '3383b141c3ac4426279e649ebcee535890203c3f': Let findSupportedAbi and hasRenderscriptBitcode scan only relevant files
2015-08-03Let findSupportedAbi and hasRenderscriptBitcode scan only relevant filesYusuke Sato
for better performance. Without the optimization, these two functions may check more than 100k file names in the pre-installed APK files, which can take a few seconds to finish even on a recent device. (cherry-pick of 34fe3df8519523dbb4bc27010fa57f259d5e868d) Bug: 21957428 Change-Id: I5ebe0438019958d883a7fda6bd92ea4484211d23
2015-06-29resolved conflicts for merge of d3d6e9a3 to mnc-dev-plus-aospYusuke Sato
Change-Id: Ie32db11e6c1062df32b16a5cd6fcd219e0bdc017
2015-06-25Rename ZipEntryName to ZipStringYusuke Sato
Also add a 4th parameter to StartIteration(). This is for https://android-review.googlesource.com/#/c/156771/. Bug: 21957428 Change-Id: Ifbf9aec2f04b214b57e99c306282d7c0d39675a9
2015-06-22Let findSupportedAbi and hasRenderscriptBitcode scan only relevant filesYusuke Sato
for better performance. Without the optimization, these two functions may check more than 100k file names in the pre-installed APK files, which can take a few seconds to finish even on a recent device. Bug: 21957428 Change-Id: I315fd3c6d5aa1076b993752525de449a9933de12
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
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-05-12Fix file descriptor leak when opening invalid archives.Narayan Kamath
I've inspected all other callers of OpenArchive and this seems to be the only broken one. The easiest way to reproduce this is by using getPackageArchiveInfo or by adding an asset path that isn't a valid APK. bug: https://code.google.com/p/android/issues/detail?id=171099 Change-Id: I41cd85d20f26ad47968e2a6f1384cc03330b558b
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-08-15Update ziparchive usage to the new API.Piotr Jastrzebski
Bug: 16162465 Change-Id: If3064e2be3e7e85366b07434294a7879b0e5f9bc
2014-08-11Remove memory leak.Piotr Jastrzebski
Call EndIteration in endIteration to free memory allocated for cookie in StartIteration. Change-Id: I3d58a461c2f3676565cfd7922dc6d8d5c35feae9
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-09-11Fix another off-by-one error in ZipFileROKenny Root
Bug: 10424836 Change-Id: I491458bd31ef39e87127d061427b32a3d59ac807
2013-09-11Reconcile differences between zip implementationsKenny Root
Reconcile the difference between ZipFileRO and java.util.ZipFile to have the same behavior. Bug: 10424836 Change-Id: I6bde1bad7e20065ee650945fd43a913c05ce5ac7
2013-09-11Revert "Reconcile differences between zip implementations"Kenny Root
This reverts commit 9ffddc7eb50653cf60ce6b27a0e1945eed5b5ce1. Change-Id: Ifeba63511211bfc2b375f2205e319e91403b7d06
2013-09-11Reconcile differences between zip implementationsKenny Root
Reconcile the difference between ZipFileRO and java.util.ZipFile to have the same behavior. Bug: 10424836 Change-Id: Iff159c9e1a91b59f6c5346dc0278cb9e4bbc1a39
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