diff options
Diffstat (limited to 'libs/androidfw/Idmap.cpp')
-rw-r--r-- | libs/androidfw/Idmap.cpp | 15 |
1 files changed, 11 insertions, 4 deletions
diff --git a/libs/androidfw/Idmap.cpp b/libs/androidfw/Idmap.cpp index 5f98b8f8db43..982419059ead 100644 --- a/libs/androidfw/Idmap.cpp +++ b/libs/androidfw/Idmap.cpp @@ -18,8 +18,10 @@ #include "androidfw/Idmap.h" +#include "android-base/file.h" #include "android-base/logging.h" #include "android-base/stringprintf.h" +#include "android-base/utf8.h" #include "androidfw/misc.h" #include "androidfw/ResourceTypes.h" #include "androidfw/Util.h" @@ -250,7 +252,12 @@ std::optional<std::string_view> ReadString(const uint8_t** in_out_data_ptr, size } } // namespace -LoadedIdmap::LoadedIdmap(std::string&& idmap_path, const Idmap_header* header, +// O_PATH is a lightweight way of creating an FD, only exists on Linux +#ifndef O_PATH +#define O_PATH (0) +#endif + +LoadedIdmap::LoadedIdmap(const std::string& idmap_path, const Idmap_header* header, const Idmap_data_header* data_header, const Idmap_target_entry* target_entries, const Idmap_target_entry_inline* target_inline_entries, @@ -267,10 +274,10 @@ LoadedIdmap::LoadedIdmap(std::string&& idmap_path, const Idmap_header* header, configurations_(configs), overlay_entries_(overlay_entries), string_pool_(std::move(string_pool)), - idmap_path_(std::move(idmap_path)), + idmap_fd_(android::base::utf8::open(idmap_path.c_str(), O_RDONLY|O_CLOEXEC|O_BINARY|O_PATH)), overlay_apk_path_(overlay_apk_path), target_apk_path_(target_apk_path), - idmap_last_mod_time_(getFileModDate(idmap_path_.data())) {} + idmap_last_mod_time_(getFileModDate(idmap_fd_.get())) {} std::unique_ptr<LoadedIdmap> LoadedIdmap::Load(StringPiece idmap_path, StringPiece idmap_data) { ATRACE_CALL(); @@ -368,7 +375,7 @@ std::unique_ptr<LoadedIdmap> LoadedIdmap::Load(StringPiece idmap_path, StringPie } bool LoadedIdmap::IsUpToDate() const { - return idmap_last_mod_time_ == getFileModDate(idmap_path_.c_str()); + return idmap_last_mod_time_ == getFileModDate(idmap_fd_.get()); } } // namespace android |