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 7731ebd1d8)
This commit is contained in:
Yurii Zubrytskyi
2021-02-19 00:08:36 -08:00
parent a5946f7056
commit 3fde572afc
4 changed files with 37 additions and 27 deletions

View File

@@ -1936,25 +1936,33 @@ IncrementalService::LoadingProgress IncrementalService::getLoadingProgress(
}
IncrementalService::LoadingProgress IncrementalService::getLoadingProgressFromPath(
const IncFsMount& ifs, std::string_view storagePath, bool stopOnFirstIncomplete) const {
ssize_t totalBlocks = 0, filledBlocks = 0;
const auto filePaths = mFs->listFilesRecursive(storagePath);
for (const auto& filePath : filePaths) {
const IncFsMount& ifs, std::string_view storagePath,
const bool stopOnFirstIncomplete) const {
ssize_t totalBlocks = 0, filledBlocks = 0, error = 0;
mFs->listFilesRecursive(storagePath, [&, this](auto filePath) {
const auto [filledBlocksCount, totalBlocksCount] =
mIncFs->countFilledBlocks(ifs.control, filePath);
if (filledBlocksCount == -EOPNOTSUPP || filledBlocksCount == -ENOTSUP ||
filledBlocksCount == -ENOENT) {
// a kind of a file that's not really being loaded, e.g. a mapped range
// an older IncFS used to return ENOENT in this case, so handle it the same way
return true;
}
if (filledBlocksCount < 0) {
LOG(ERROR) << "getLoadingProgress failed to get filled blocks count for: " << filePath
<< " errno: " << filledBlocksCount;
return {filledBlocksCount, filledBlocksCount};
error = filledBlocksCount;
return false;
}
totalBlocks += totalBlocksCount;
filledBlocks += filledBlocksCount;
if (stopOnFirstIncomplete && filledBlocks < totalBlocks) {
break;
return false;
}
}
return true;
});
return {filledBlocks, totalBlocks};
return error ? LoadingProgress{error, error} : LoadingProgress{filledBlocks, totalBlocks};
}
bool IncrementalService::updateLoadingProgress(