Refactor: Make createActivation() common
The function is almost the same for ubi and static layout, except a few
differences that creates the ubi objects.
Add below pure virtual functions for ubi to create ubi specific objects
* createActivationObject()
* createVersionObject()
Then it is possible to move most of the code in createActivation() into
the commone one.
Tested: On the last commit of the patch series, run code update and
factory reset on Witherspoon and all work fine.
Change-Id: Ieb3e783bc5b251529a55909f9e9f644230b274e7
Signed-off-by: Lei YU <mine260309@gmail.com>
diff --git a/ubi/item_updater_ubi.hpp b/ubi/item_updater_ubi.hpp
index ec9d05c..5de51d3 100644
--- a/ubi/item_updater_ubi.hpp
+++ b/ubi/item_updater_ubi.hpp
@@ -48,12 +48,22 @@
static std::string determineId(const std::string& symlinkPath);
private:
- /** @brief Callback function for Software.Version match.
- * @details Creates an Activation D-Bus object.
- *
- * @param[in] msg - Data associated with subscribed signal
- */
- void createActivation(sdbusplus::message::message& msg) override;
+ std::unique_ptr<Activation> createActivationObject(
+ const std::string& path, const std::string& versionId,
+ const std::string& extVersion,
+ sdbusplus::xyz::openbmc_project::Software::server::Activation::
+ Activations activationStatus,
+ AssociationList& assocs) override;
+
+ std::unique_ptr<Version>
+ createVersionObject(const std::string& objPath,
+ const std::string& versionId,
+ const std::string& versionString,
+ sdbusplus::xyz::openbmc_project::Software::server::
+ Version::VersionPurpose versionPurpose,
+ const std::string& filePath) override;
+
+ bool validateImage(const std::string& path) override;
/** @brief Host factory reset - clears PNOR partitions for each
* Activation D-Bus object */