Refactor: Move determinId to ubi
The function determinId is used only in ubi case, move it to ubi.
Tested: On the last commit of the patch series, run code update and
factory reset on Witherspoon and all work fine.
Change-Id: I8974d25bf904a5202b913fc185790c5ecf8eca90
Signed-off-by: Lei YU <mine260309@gmail.com>
diff --git a/item_updater.hpp b/item_updater.hpp
index 96ef29c..7a67d69 100644
--- a/item_updater.hpp
+++ b/item_updater.hpp
@@ -139,14 +139,6 @@
*/
virtual void freeSpace() = 0;
- /** @brief Determine the software version id
- * from the symlink target (e.g. /media/ro-2a1022fe).
- *
- * @param[in] symlinkPath - The path of the symlink.
- * @param[out] id - The version id as a string.
- */
- static std::string determineId(const std::string& symlinkPath);
-
/** @brief Creates an active association to the
* newly active software image
*
diff --git a/ubi/item_updater_ubi.cpp b/ubi/item_updater_ubi.cpp
index 1c2926a..354610b 100644
--- a/ubi/item_updater_ubi.cpp
+++ b/ubi/item_updater_ubi.cpp
@@ -487,7 +487,7 @@
}
}
-std::string ItemUpdater::determineId(const std::string& symlinkPath)
+std::string ItemUpdaterUbi::determineId(const std::string& symlinkPath)
{
if (!fs::exists(symlinkPath))
{
diff --git a/ubi/item_updater_ubi.hpp b/ubi/item_updater_ubi.hpp
index af330a8..dfc8e53 100644
--- a/ubi/item_updater_ubi.hpp
+++ b/ubi/item_updater_ubi.hpp
@@ -41,6 +41,14 @@
bool isVersionFunctional(const std::string& versionId) override;
+ /** @brief Determine the software version id
+ * from the symlink target (e.g. /media/ro-2a1022fe).
+ *
+ * @param[in] symlinkPath - The path of the symlink.
+ * @param[out] id - The version id as a string.
+ */
+ static std::string determineId(const std::string& symlinkPath);
+
private:
/** @brief Callback function for Software.Version match.
* @details Creates an Activation D-Bus object.
diff --git a/ubi/watch.cpp b/ubi/watch.cpp
index 192d3d9..60d0014 100644
--- a/ubi/watch.cpp
+++ b/ubi/watch.cpp
@@ -2,7 +2,7 @@
#include "watch.hpp"
-#include "item_updater.hpp"
+#include "item_updater_ubi.hpp"
#include <sys/inotify.h>
#include <unistd.h>
@@ -93,7 +93,7 @@
path /= event->name;
if (fs::equivalent(path, PNOR_RO_ACTIVE_PATH))
{
- auto id = ItemUpdater::determineId(path);
+ auto id = ItemUpdaterUbi::determineId(path);
static_cast<Watch*>(userdata)->functionalCallback(id);
}
offset += offsetof(inotify_event, name) + event->len;