VintfObject::GetFwkMatrix combine matrices at runtime

... instead of reading /system/compatibility_matrix.xml,
it combines matrices under /system/etc/vintf at run-time. This ensure
GSI gets the correct framework requirements based on Shipping
FCM Version.

Test: `adb shell vintf` shows that fwk comp mat is correctly
      read (even if /system/compatibility_matrix.xml is
      deleted manually).

Test: vintf_object_tests on host/device.

Bug: 64720381
Bug: 70628538
Change-Id: Ie4607e2eb5f7ba97e21b309d369872e91ecb1d74
diff --git a/utils.h b/utils.h
index 5f28b6d..c3dcd53 100644
--- a/utils.h
+++ b/utils.h
@@ -17,8 +17,11 @@
 #ifndef ANDROID_VINTF_UTILS_H
 #define ANDROID_VINTF_UTILS_H
 
+#include <dirent.h>
+
 #include <fstream>
 #include <iostream>
+#include <memory>
 #include <sstream>
 
 #include <utils/Errors.h>
@@ -58,6 +61,24 @@
     virtual status_t fetch(const std::string& path, std::string& fetched) {
         return fetchInternal(path, fetched, nullptr);
     }
+    virtual status_t listFiles(const std::string& path, std::vector<std::string>* out,
+                               std::string* error) {
+        std::unique_ptr<DIR, decltype(&closedir)> dir(opendir(path.c_str()), closedir);
+        if (!dir) {
+            if (error) {
+                *error = "Cannot open " + path;
+            }
+            return NAME_NOT_FOUND;
+        }
+
+        dirent* dp;
+        while ((dp = readdir(dir.get())) != nullptr) {
+            if (dp->d_type != DT_DIR) {
+                out->push_back(dp->d_name);
+            }
+        }
+        return OK;
+    }
 };
 
 extern FileFetcher* gFetcher;