diff options
author | Scott Lobdell <slobdell@google.com> | 2021-07-27 17:02:32 +0000 |
---|---|---|
committer | Scott Lobdell <slobdell@google.com> | 2021-07-27 17:02:32 +0000 |
commit | cb84bc77bfeb89a940d8439f7458fe5d9bef7bef (patch) | |
tree | d6e70908803e918eb485e058341ce55d0a957188 /cmds/idmap2/idmap2d/Idmap2Service.cpp | |
parent | dc5ea9d31ab76ba378da9c550813e6b7d8be1e69 (diff) | |
parent | 6aa393b52cd7362100a2b3e9b0b1dece473cf6dd (diff) |
Merge SP1A.210723.002
Change-Id: I220cdfc5cb9db40162fd33f400a54591018d54cf
Diffstat (limited to 'cmds/idmap2/idmap2d/Idmap2Service.cpp')
-rw-r--r-- | cmds/idmap2/idmap2d/Idmap2Service.cpp | 35 |
1 files changed, 29 insertions, 6 deletions
diff --git a/cmds/idmap2/idmap2d/Idmap2Service.cpp b/cmds/idmap2/idmap2d/Idmap2Service.cpp index 2cfbac3f2c26..a8d648917b08 100644 --- a/cmds/idmap2/idmap2d/Idmap2Service.cpp +++ b/cmds/idmap2/idmap2d/Idmap2Service.cpp @@ -297,17 +297,40 @@ Status Idmap2Service::createFabricatedOverlay( return ok(); } -Status Idmap2Service::getFabricatedOverlayInfos( +Status Idmap2Service::acquireFabricatedOverlayIterator() { + if (frro_iter_.has_value()) { + LOG(WARNING) << "active ffro iterator was not previously released"; + } + frro_iter_ = std::filesystem::directory_iterator(kIdmapCacheDir); + return ok(); +} + +Status Idmap2Service::releaseFabricatedOverlayIterator() { + if (!frro_iter_.has_value()) { + LOG(WARNING) << "no active ffro iterator to release"; + } + return ok(); +} + +Status Idmap2Service::nextFabricatedOverlayInfos( std::vector<os::FabricatedOverlayInfo>* _aidl_return) { - for (const auto& entry : std::filesystem::directory_iterator(kIdmapCacheDir)) { - if (!android::IsFabricatedOverlay(entry.path())) { + constexpr size_t kMaxEntryCount = 100; + if (!frro_iter_.has_value()) { + return error("no active frro iterator"); + } + + size_t count = 0; + auto& entry_iter = *frro_iter_; + auto entry_iter_end = end(*frro_iter_); + for (; entry_iter != entry_iter_end && count < kMaxEntryCount; ++entry_iter) { + auto& entry = *entry_iter; + if (!entry.is_regular_file() || !android::IsFabricatedOverlay(entry.path())) { continue; } const auto overlay = FabricatedOverlayContainer::FromPath(entry.path()); if (!overlay) { - // This is a sign something went wrong. - LOG(ERROR) << "Failed to open '" << entry.path() << "': " << overlay.GetErrorMessage(); + LOG(WARNING) << "Failed to open '" << entry.path() << "': " << overlay.GetErrorMessage(); continue; } @@ -319,8 +342,8 @@ Status Idmap2Service::getFabricatedOverlayInfos( out_info.targetOverlayable = info.target_name; out_info.path = entry.path(); _aidl_return->emplace_back(std::move(out_info)); + count++; } - return ok(); } |