NUGGET_PARAM_ENABLE_UPDATE tells us whether it worked or not

Giving the wrong password still fails, but now with the correct
password this call now returns a boolean indicating whether the
header was CHANGED to valid. If it was, the AP should request or
force a Citadel reboot to give the new image a chance to run. If
nothing changed, there's no need to do that.

Bug: b/72983372
Test: Manual update, entered PIN, repeat

Change-Id: I6d0644aac6fcbf795c92ee7673971156ef763f51
Signed-off-by: Bill Richardson <wfrichar@google.com>
diff --git a/citadel/updater/updater.cpp b/citadel/updater/updater.cpp
index ecc8c35..3d7fd8c 100644
--- a/citadel/updater/updater.cpp
+++ b/citadel/updater/updater.cpp
@@ -675,6 +675,7 @@
   std::vector<uint8_t> data(sizeof(struct nugget_app_enable_update));
   struct nugget_app_enable_update *s =
     (struct nugget_app_enable_update*)data.data();
+  std::vector<uint8_t> reply;
 
   memset(&s->password, 0xff, sizeof(s->password));
   if (pw && *pw) {
@@ -687,10 +688,12 @@
   s->which_headers = options.enable_ro ? NUGGET_ENABLE_HEADER_RO : 0;
   s->which_headers |= options.enable_rw ? NUGGET_ENABLE_HEADER_RW : 0;
 
-  uint32_t rv = app.Call(NUGGET_PARAM_ENABLE_UPDATE, data, nullptr);
+  reply.reserve(1);
+  uint32_t rv = app.Call(NUGGET_PARAM_ENABLE_UPDATE, data, &reply);
 
   if (is_app_success(rv))
-    printf("Update enabled\n");
+    /* Reply byte is true only if header was CHANGED to valid */
+    printf("Update %s enabled\n", reply[0] ? "changed to" : "is already");
 
   return rv;
 }
diff --git a/nugget/include/app_nugget.h b/nugget/include/app_nugget.h
index f8e8fda..72572b9 100644
--- a/nugget/include/app_nugget.h
+++ b/nugget/include/app_nugget.h
@@ -110,12 +110,13 @@
 #define NUGGET_PARAM_ENABLE_UPDATE 0x0003
 /*
  * Mark the specified image header(s) as valid, if the provided password
- * matches.
+ * matches. Returns true if either header was CHANGED to valid, which is an
+ * indication that the AP should request a reboot so that it can take effect.
  *
  * @param args         struct nugget_app_enable_update
  * @param arg_len      sizeof(struct nugget_app_enable_update)
- * @param reply        <none>
- * @param reply_len    0
+ * @param reply        0 or 1
+ * @param reply_len    1 byte
  *
  * @errors             APP_ERROR_BOGUS_ARGS
  */