Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 12a5a03a authored by Yurii Zubrytskyi's avatar Yurii Zubrytskyi Committed by Android (Google) Code Review
Browse files

Merge "[res] Fix a crash for the apps doing a bad thing" into main

parents 42733b04 481f13ea
Loading
Loading
Loading
Loading
+10 −3
Original line number Diff line number Diff line
@@ -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> ZipAssetsProvider::Create(std::string path,
  }

  return std::unique_ptr<ZipAssetsProvider>(
      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> ZipAssetsProvider::Create(base::unique_fd fd,
@@ -166,7 +173,7 @@ std::unique_ptr<ZipAssetsProvider> ZipAssetsProvider::Create(base::unique_fd fd,
  }

  return std::unique_ptr<ZipAssetsProvider>(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<Asset> ZipAssetsProvider::OpenInternal(const std::string& path,
+7 −1
Original line number Diff line number Diff line
@@ -110,8 +110,14 @@ struct ZipAssetsProvider : public AssetsProvider {

 private:
  struct PathOrDebugName;

  // There are applications that decided to dlsym and call this constructor somehow, so we
  // have to keep it for backwards compatibility.
  ZipAssetsProvider(ZipArchive* handle, PathOrDebugName&& path, package_property_t flags,
                    ModDate last_mod_time);
                    time_t last_mod_time);
  // ModTime is time_t on Win32, need to change the parameter order to make it overloadable.
  ZipAssetsProvider(ZipArchive* handle, PathOrDebugName&& path, ModDate last_mod_time,
                    package_property_t flags);

  struct PathOrDebugName {
    static PathOrDebugName Path(std::string value) {
+3 −1
Original line number Diff line number Diff line
@@ -77,4 +77,6 @@ bool isKnownWritablePath(const char* path);
}  // namespace android

// Whoever uses getFileModDate() will need this as well
bool operator==(const timespec& l, const timespec& r);
inline bool operator==(const timespec& l, const timespec& r) {
  return l.tv_sec == r.tv_sec && l.tv_nsec == r.tv_nsec;
}
+0 −5
Original line number Diff line number Diff line
@@ -31,7 +31,6 @@
#include <array>
#include <cstdio>
#include <cstring>
#include <tuple>

namespace android {

@@ -143,7 +142,3 @@ bool isKnownWritablePath(const char* path) {
#endif  // __linux__

}  // namespace android

bool operator==(const timespec& l, const timespec& r) {
  return std::tie(l.tv_sec, l.tv_nsec) == std::tie(r.tv_sec, l.tv_nsec);
}