Activation: Implement ActivationProgress interface

This commit implements the ActivationProgress interface, which maintains
a value representing percentage completion of the activation process.
This value is periodically updated throughout the process.

Resolves openbmc/openbmc#1554

Change-Id: I7dafb32995c4c95d86e1cc17ca42065065eee2f4
Signed-off-by: Michael Tritz <mtritz@us.ibm.com>
diff --git a/activation.cpp b/activation.cpp
index 9a19008..428a256 100755
--- a/activation.cpp
+++ b/activation.cpp
@@ -46,6 +46,12 @@
             // RW volumes have not yet been created, we need to start the
             // service files for each of those actions.
 
+            if (!activationProgress)
+            {
+                activationProgress = std::make_unique<ActivationProgress>(bus,
+                        path);
+            }
+
             if (!activationBlocksTransition)
             {
                 activationBlocksTransition =
@@ -78,6 +84,8 @@
             method.append(ubimountServiceFile, "replace");
             bus.call_noreply(method);
 
+            activationProgress->progress(10);
+
             return softwareServer::Activation::activation(value);
         }
         else if (squashfsLoaded == true && rwVolumesCreated == true)
@@ -95,6 +103,8 @@
                 (fs::is_directory(PNOR_RW_PREFIX + versionId)) &&
                 (fs::is_directory(PNOR_RO_PREFIX + versionId)))
             {
+                activationProgress->progress(90);
+
                 if (!fs::is_directory(PNOR_ACTIVE_PATH))
                 {
                     fs::create_directories(PNOR_ACTIVE_PATH);
@@ -133,13 +143,19 @@
                                         *this,
                                         0);
                 }
+
+                activationProgress->progress(100);
+
                 activationBlocksTransition.reset(nullptr);
+                activationProgress.reset(nullptr);
+
                 return softwareServer::Activation::activation(
                         softwareServer::Activation::Activations::Active);
             }
             else
             {
                 activationBlocksTransition.reset(nullptr);
+                activationProgress.reset(nullptr);
                 return softwareServer::Activation::activation(
                         softwareServer::Activation::Activations::Failed);
             }
@@ -155,6 +171,7 @@
     else
     {
         activationBlocksTransition.reset(nullptr);
+        activationProgress.reset(nullptr);
         return softwareServer::Activation::activation(value);
     }
 }
@@ -206,12 +223,14 @@
 
     if(newStateUnit == squashfsMountServiceFile && newStateResult == "done")
     {
-       squashfsLoaded = true;
+        squashfsLoaded = true;
+        activationProgress->progress(activationProgress->progress() + 20);
     }
 
     if(newStateUnit == ubimountServiceFile && newStateResult == "done")
     {
         rwVolumesCreated = true;
+        activationProgress->progress(activationProgress->progress() + 50);
     }
 
     if(squashfsLoaded && rwVolumesCreated)