Fix the progress getting for mapped files
Mapped files don't support querying their loading progress,
so we should simply skip them - they are already a part of
some other file, and will get accounted for loading when
that file's progress get queried
+ a bunch of small improvements
Bug: 180535478
Test: atest service.incremental_test, adb install --incremental
with mapped native libs
Change-Id: Ifc8a402144f2f3669a0419124fb0f35d7002190a
(cherry picked from commit 7731ebd1d8187c92a992d1f53c4114a6c40f7563)
diff --git a/services/incremental/ServiceWrappers.cpp b/services/incremental/ServiceWrappers.cpp
index 36bda49..d613289 100644
--- a/services/incremental/ServiceWrappers.cpp
+++ b/services/incremental/ServiceWrappers.cpp
@@ -287,11 +287,10 @@
auto it = mJobs.begin();
// Always acquire begin(). We can't use it after unlock as mTimedJobs can change.
for (; it != mJobs.end() && it->when <= now; it = mJobs.begin()) {
- auto job = std::move(it->what);
- mJobs.erase(it);
+ auto jobNode = mJobs.extract(it);
lock.unlock();
- job();
+ jobNode.value().what();
lock.lock();
}
nextJobTs = it != mJobs.end() ? it->when : kInfinityTs;
@@ -313,20 +312,20 @@
std::thread mThread;
};
-class RealFsWrapper : public FsWrapper {
+class RealFsWrapper final : public FsWrapper {
public:
RealFsWrapper() = default;
~RealFsWrapper() = default;
- std::vector<std::string> listFilesRecursive(std::string_view directoryPath) const final {
- std::vector<std::string> files;
+ void listFilesRecursive(std::string_view directoryPath, FileCallback onFile) const final {
for (const auto& entry : std::filesystem::recursive_directory_iterator(directoryPath)) {
if (!entry.is_regular_file()) {
continue;
}
- files.push_back(entry.path().c_str());
+ if (!onFile(entry.path().native())) {
+ break;
+ }
}
- return files;
}
};