Add PropertyFetcher.

This is a mockable / replacable class for getting sysprops.
On host, sysprops may be provided via ADB or command line
arguments.
On device, default behavior is to use android-base/properties.h.

Bug: 72722951
Test: libvintf_test
Test: vintf_object_test

Change-Id: I752c4336dacd4c5f3254f32e4caf8dc743c636d9
Merged-In: I752c4336dacd4c5f3254f32e4caf8dc743c636d9
diff --git a/utils.cpp b/utils.cpp
index 2b0cb37..5b2bb7d 100644
--- a/utils.cpp
+++ b/utils.cpp
@@ -16,6 +16,10 @@
 
 #include "utils.h"
 
+#ifdef LIBVINTF_TARGET
+#include <android-base/properties.h>
+#endif
+
 namespace android {
 namespace vintf {
 namespace details {
@@ -29,6 +33,32 @@
 static ObjectFactory<RuntimeInfo> runtimeInfoFactory;
 ObjectFactory<RuntimeInfo>* gRuntimeInfoFactory = &runtimeInfoFactory;
 
+#ifdef LIBVINTF_TARGET
+class DevicePropertyFetcher : public PropertyFetcher {
+   public:
+    std::string getProperty(const std::string& key,
+                            const std::string& defaultValue) const override {
+        return android::base::GetProperty(key, defaultValue);
+    }
+    uint64_t getUintProperty(const std::string& key, uint64_t defaultValue,
+                             uint64_t max) const override {
+        return android::base::GetUintProperty(key, defaultValue, max);
+    }
+    bool getBoolProperty(const std::string& key, bool defaultValue) const override {
+        return android::base::GetBoolProperty(key, defaultValue);
+    }
+};
+const PropertyFetcher& getPropertyFetcher() {
+    static DevicePropertyFetcher fetcher;
+    return fetcher;
+}
+#else
+const PropertyFetcher& getPropertyFetcher() {
+    static PropertyFetcher fetcher;
+    return fetcher;
+}
+#endif
+
 }  // namespace details
 }  // namespace vintf
 }  // namespace android