Move isFieldModeEnabled to common utility
This commit moves isFieldModeEnabled API from SingleFab class to common
utility. Field mode check is going to be required by upcoming PST
features, and hence this API needs to be an utility API in order to be
accessed throughout the repository.
Change-Id: I3f0024b81493e3284ea0c9ea070e110dc1ef6375
Signed-off-by: Souvik Roy <souvikroyofficial10@gmail.com>
diff --git a/vpd-manager/include/utility/common_utility.hpp b/vpd-manager/include/utility/common_utility.hpp
index de7a9ae..e1564f8 100644
--- a/vpd-manager/include/utility/common_utility.hpp
+++ b/vpd-manager/include/utility/common_utility.hpp
@@ -274,5 +274,33 @@
return static_cast<size_t>(l_timeStampSeconds);
}
+/**
+ * @brief API to check is field mode enabled.
+ *
+ * @return true, if field mode is enabled. otherwise false.
+ */
+inline bool isFieldModeEnabled() noexcept
+{
+ try
+ {
+ std::vector<std::string> l_cmdOutput =
+ executeCmd("/sbin/fw_printenv fieldmode");
+
+ if (l_cmdOutput.size() > 0)
+ {
+ toLower(l_cmdOutput[0]);
+
+ // Remove the new line character from the string.
+ l_cmdOutput[0].erase(l_cmdOutput[0].length() - 1);
+
+ return l_cmdOutput[0] == "fieldmode=true";
+ }
+ }
+ catch (const std::exception& l_ex)
+ {}
+
+ return false;
+}
+
} // namespace commonUtility
} // namespace vpd