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
diff --git a/utils.h b/utils.h
index 305a018..783d40b 100644
--- a/utils.h
+++ b/utils.h
@@ -141,6 +141,18 @@
}
}
+class PropertyFetcher {
+ public:
+ virtual ~PropertyFetcher() = default;
+ virtual std::string getProperty(const std::string& key,
+ const std::string& defaultValue = "") const;
+ virtual uint64_t getUintProperty(const std::string& key, uint64_t defaultValue,
+ uint64_t max = UINT64_MAX) const;
+ virtual bool getBoolProperty(const std::string& key, bool defaultValue) const;
+};
+
+const PropertyFetcher& getPropertyFetcher();
+
} // namespace details
} // namespace vintf
} // namespace android