bmc: firmware updateCompleted: close(session)

Signed-off-by: Patrick Venture <venture@google.com>
Change-Id: Ief314aeab74101cf57ad49abc4676037de1b312f
diff --git a/firmware_handler.cpp b/firmware_handler.cpp
index 56ad3a2..12147a3 100644
--- a/firmware_handler.cpp
+++ b/firmware_handler.cpp
@@ -637,6 +637,10 @@
     {
         switch (state)
         {
+            case UpdateState::verificationPending:
+                /* They haven't triggered, therefore closing is uninteresting.
+                 */
+                break;
             case UpdateState::verificationStarted:
                 /* TODO: If they close this blob before verification finishes,
                  * that's an abort.
@@ -652,7 +656,6 @@
                 else
                 {
                     /* TODO: Verification failed, what now? */
-                    state = UpdateState::notYetStarted;
                 }
                 break;
             default:
@@ -664,7 +667,29 @@
     }
     else if (item->second->activePath == updateBlobId)
     {
-        /* nothing interesting. */
+        switch (state)
+        {
+            case UpdateState::updatePending:
+                /* They haven't triggered the update, therefore this is
+                 * uninteresting. */
+                break;
+            case UpdateState::updateStarted:
+                /* TODO: handle closing while update is running!. */
+                break;
+            case UpdateState::updateCompleted:
+                if (lastUpdateStatus == ActionStatus::failed)
+                {
+                    /* TODO: lOG something? */
+                }
+
+                state = UpdateState::notYetStarted;
+                removeBlobId(updateBlobId);
+                removeBlobId(activeImageBlobId);
+                removeBlobId(activeHashBlobId);
+                break;
+            default:
+                break;
+        }
     }
     else
     {