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

Unverified Commit f7edb35e authored by Michael Bestas's avatar Michael Bestas Committed by Michael Bestas
Browse files

fixup! idmap2: Cache Lineage resources

Change-Id: I21cbc3ab3df0d1c705371751a131c206498063f6
parent f01abdb2
Loading
Loading
Loading
Loading
+3 −13
Original line number Diff line number Diff line
@@ -60,7 +60,7 @@ using PolicyBitmask = android::ResTable_overlayable_policy_header::PolicyBitmask
namespace {

constexpr std::string_view kFrameworkPath = "/system/framework/framework-res.apk";
constexpr const char* kLineagePath = "/system/framework/org.lineageos.platform-res.apk";
constexpr std::string_view kLineagePath = "/system/framework/org.lineageos.platform-res.apk";

Status ok() {
  return Status::ok();
@@ -209,9 +209,10 @@ Status Idmap2Service::createIdmap(const std::string& target_path, const std::str
idmap2::Result<Idmap2Service::TargetResourceContainerPtr> Idmap2Service::GetTargetContainer(
    const std::string& target_path) {
  const bool is_framework = target_path == kFrameworkPath;
  const bool is_lineage_framework = target_path == kLineagePath;
  bool use_cache;
  struct stat st = {};
  if (is_framework || !::stat(target_path.c_str(), &st)) {
  if (is_framework || is_lineage_framework || !::stat(target_path.c_str(), &st)) {
    use_cache = true;
  } else {
    LOG(WARNING) << "failed to stat target path '" << target_path << "' for the cache";
@@ -230,17 +231,6 @@ idmap2::Result<Idmap2Service::TargetResourceContainerPtr> Idmap2Service::GetTarg
      container_cache_.erase(cache_it);
    }
  }
  if (target_path == kLineagePath) {
    if (lineage_apk_cache_ == nullptr) {
      // Initialize the lineage APK cache.
      auto target = TargetResourceContainer::FromPath(target_path);
      if (!target) {
        return target.GetError();
      }
      lineage_apk_cache_ = std::move(*target);
    }
    return {lineage_apk_cache_.get()};
  }

  auto target = TargetResourceContainer::FromPath(target_path);
  if (!target) {
+0 −1
Original line number Diff line number Diff line
@@ -75,7 +75,6 @@ class Idmap2Service : public BinderService<Idmap2Service>, public BnIdmap2 {
 private:
  // idmap2d is killed after a period of inactivity, so any information stored on this class should
  // be able to be recalculated if idmap2 dies and restarts.
  std::unique_ptr<idmap2::TargetResourceContainer> lineage_apk_cache_;

  // A cache item for the resource containers (apks or frros), with all information needed to
  // detect if it has changed since it was parsed: