From 1144bcaee5c28ce4261865af197990b7b77f8e28 Mon Sep 17 00:00:00 2001 From: Yurii Zubrytskyi Date: Thu, 17 Apr 2025 16:31:27 -0700 Subject: [res] Fix a crash for the apps doing a bad thing Some apps started crashing after the CL that changed one of the parameters of ZipAssetsProvider constructor from time_t to timespec. Apparently they dlsym() and call that constructor, even when it's not a public or somehow supported API. This CL puts one back for them so they at least don't stop working all at once, and instead it just logs an error so the developers could at least know they're doing a BAD THING. + fix the timespec operator== to actually compare nanoseconds. Bug: 406670650 Test: run the app and ensure it launches Flag: EXEMPT bugfix - a dummy symbol that's unflaggable (cherry picked from https://googleplex-android-review.googlesource.com/q/commit:481f13eaff6a88cbe9b8b9da65f52bc26ba440bd) Merged-In: I85e03985d7303f4e0f943441da57cf0f50230db6 Change-Id: I85e03985d7303f4e0f943441da57cf0f50230db6 --- libs/androidfw/AssetsProvider.cpp | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) (limited to 'libs/androidfw/AssetsProvider.cpp') diff --git a/libs/androidfw/AssetsProvider.cpp b/libs/androidfw/AssetsProvider.cpp index 808509120462..13456fbadbc7 100644 --- a/libs/androidfw/AssetsProvider.cpp +++ b/libs/androidfw/AssetsProvider.cpp @@ -104,7 +104,14 @@ void ZipAssetsProvider::ZipCloser::operator()(ZipArchive* a) const { } ZipAssetsProvider::ZipAssetsProvider(ZipArchiveHandle handle, PathOrDebugName&& path, - package_property_t flags, ModDate last_mod_time) + package_property_t flags, time_t last_mod_time) + : zip_handle_(handle), name_(std::move(path)), flags_(flags), last_mod_time_(last_mod_time) { + LOG(ERROR) << "This function is not supported and will result in " + "poor performance and/or crashes. Stop calling it."; +} + +ZipAssetsProvider::ZipAssetsProvider(ZipArchiveHandle handle, PathOrDebugName&& path, + ModDate last_mod_time, package_property_t flags) : zip_handle_(handle), name_(std::move(path)), flags_(flags), last_mod_time_(last_mod_time) { } @@ -132,7 +139,7 @@ std::unique_ptr ZipAssetsProvider::Create(std::string path, } return std::unique_ptr( - new ZipAssetsProvider(handle, PathOrDebugName::Path(std::move(path)), flags, mod_date)); + new ZipAssetsProvider(handle, PathOrDebugName::Path(std::move(path)), mod_date, flags)); } std::unique_ptr ZipAssetsProvider::Create(base::unique_fd fd, @@ -166,7 +173,7 @@ std::unique_ptr ZipAssetsProvider::Create(base::unique_fd fd, } return std::unique_ptr(new ZipAssetsProvider( - handle, PathOrDebugName::DebugName(std::move(friendly_name)), flags, mod_date)); + handle, PathOrDebugName::DebugName(std::move(friendly_name)), mod_date, flags)); } std::unique_ptr ZipAssetsProvider::OpenInternal(const std::string& path, -- cgit v1.2.3-59-g8ed1b