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

Commit 221e1793 authored by Luca Stefani's avatar Luca Stefani
Browse files

idmap2: Cache Lineage resources

Change-Id: I212e029be783657fec738031db44fdf2aa5f3cdd
parent 78111ea0
Loading
Loading
Loading
Loading
+12 −0
Original line number Diff line number Diff line
@@ -60,6 +60,7 @@ using PolicyBitmask = android::ResTable_overlayable_policy_header::PolicyBitmask
namespace {

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

Status ok() {
  return Status::ok();
@@ -218,6 +219,17 @@ idmap2::Result<Idmap2Service::TargetResourceContainerPtr> Idmap2Service::GetTarg
    }
    return {framework_apk_cache_.get()};
  }
  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) {
+1 −0
Original line number Diff line number Diff line
@@ -73,6 +73,7 @@ class Idmap2Service : public BinderService<Idmap2Service>, public BnIdmap2 {
  // 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> framework_apk_cache_;
  std::unique_ptr<idmap2::TargetResourceContainer> lineage_apk_cache_;

  std::optional<std::filesystem::directory_iterator> frro_iter_;