summaryrefslogtreecommitdiff
path: root/libs/androidfw/ApkAssets.cpp
diff options
context:
space:
mode:
author Yurii Zubrytskyi <zyy@google.com> 2022-11-10 14:11:05 -0800
committer Yurii Zubrytskyi <zyy@google.com> 2022-11-30 01:00:40 -0800
commitd0c22cc8e51c5297d11f708be706ba1ce0582426 (patch)
tree82f9314d9ed0a698b0a9226e4d6b00f7941ee322 /libs/androidfw/ApkAssets.cpp
parent59dab3ba294e252e85a5bf7fc0926a448111ad19 (diff)
IsFabricatedOverlay() optimization
This function is used mostly to select what type should be parsing the very same file, so instead of opening that file again later make it able to accept an opened fd Bug: 237583012 Test: build + boot Change-Id: I9ca1f44d6fe16fec0dd4732bfc9f0d6272d3b1e7
Diffstat (limited to 'libs/androidfw/ApkAssets.cpp')
-rwxr-xr-xlibs/androidfw/ApkAssets.cpp9
1 files changed, 5 insertions, 4 deletions
diff --git a/libs/androidfw/ApkAssets.cpp b/libs/androidfw/ApkAssets.cpp
index 9aa37872b8de..c0fa63a08fac 100755
--- a/libs/androidfw/ApkAssets.cpp
+++ b/libs/androidfw/ApkAssets.cpp
@@ -83,15 +83,16 @@ std::unique_ptr<ApkAssets> ApkAssets::LoadOverlay(const std::string& idmap_path,
return {};
}
+ std::string overlay_path(loaded_idmap->OverlayApkPath());
+ auto fd = unique_fd(::open(overlay_path.c_str(), O_RDONLY|O_CLOEXEC));
std::unique_ptr<AssetsProvider> overlay_assets;
- const std::string overlay_path(loaded_idmap->OverlayApkPath());
- if (IsFabricatedOverlay(overlay_path)) {
+ if (IsFabricatedOverlay(fd)) {
// Fabricated overlays do not contain resource definitions. All of the overlay resource values
// are defined inline in the idmap.
- overlay_assets = EmptyAssetsProvider::Create(overlay_path);
+ overlay_assets = EmptyAssetsProvider::Create(std::move(overlay_path));
} else {
// The overlay should be an APK.
- overlay_assets = ZipAssetsProvider::Create(overlay_path, flags);
+ overlay_assets = ZipAssetsProvider::Create(std::move(fd), std::move(overlay_path), flags);
}
if (overlay_assets == nullptr) {
return {};