[incfs] Use a more efficient getBlockCount() for incfs v2

v2 IncFS driver gives a very lightweight function to check the
loading progress on a file, use it instead of counting the
filled ranges

+ remove the unused mockable toString(IncFsFileId)

Bug: 183067554
Test: atest IncrementalServiceTest
Change-Id: Icd3bd891d671b27654f4194787a15a00cba1eb80
diff --git a/services/incremental/ServiceWrappers.cpp b/services/incremental/ServiceWrappers.cpp
index eb204c5..7e85f9d 100644
--- a/services/incremental/ServiceWrappers.cpp
+++ b/services/incremental/ServiceWrappers.cpp
@@ -134,6 +134,10 @@
     } mLooper;
 };
 
+std::string IncFsWrapper::toString(FileId fileId) {
+    return incfs::toString(fileId);
+}
+
 class RealIncFs final : public IncFsWrapper {
 public:
     RealIncFs() = default;
@@ -173,9 +177,16 @@
     FileId getFileId(const Control& control, std::string_view path) const final {
         return incfs::getFileId(control, path);
     }
-    std::string toString(FileId fileId) const final { return incfs::toString(fileId); }
     std::pair<IncFsBlockIndex, IncFsBlockIndex> countFilledBlocks(
             const Control& control, std::string_view path) const final {
+        if (incfs::features() & Features::v2) {
+            const auto counts = incfs::getBlockCount(control, path);
+            if (!counts) {
+                return {-errno, -errno};
+            }
+            return {counts->filledDataBlocks + counts->filledHashBlocks,
+                    counts->totalDataBlocks + counts->totalHashBlocks};
+        }
         const auto fileId = incfs::getFileId(control, path);
         const auto fd = incfs::openForSpecialOps(control, fileId);
         int res = fd.get();