Snap for 6864616 from 5b433a5e691ee0d49d31d057a12a58df6215a14c to rvc-qpr1-release

Change-Id: Ib4b19cc40d0d5607252949a9ee3c717b4945bda5
diff --git a/Android.bp b/Android.bp
index 074b9b5..d7c075e 100644
--- a/Android.bp
+++ b/Android.bp
@@ -83,6 +83,32 @@
     ],
 }
 
+// A special target to be statically linkeed into fastboot hal.
+cc_library_static {
+    name: "libnos_for_fastboot",
+    recovery: true,
+    cflags: [
+        "-Wall",
+        "-Wextra",
+        "-Werror",
+        "-Wno-zero-length-array",
+    ],
+    export_include_dirs: [
+        "nugget/include",
+        "libnos/include",
+        "libnos_datagram/include",
+        "libnos_transport/include",
+    ],
+    srcs: [
+        "libnos/debug.cpp",
+        "libnos_transport/transport.c",
+        "libnos_transport/crc16.c",
+    ],
+    static_libs: [
+        "libbase",
+    ],
+}
+
 // A special target to be statically linkeed into recovery which is a system
 // (not vendor) component.
 cc_library_static {
@@ -101,6 +127,24 @@
     ],
 }
 
+// A special target to be statically linkeed into fastboot hal.
+cc_library_static {
+    name: "libnos_citadel_for_fastboot",
+    recovery: true,
+    cflags: [
+        "-Wall",
+        "-Wextra",
+        "-Werror",
+    ],
+    srcs: [
+        ":libnos_client",
+        "libnos_datagram/citadel.c",
+    ],
+    static_libs: [
+        "libnos_for_fastboot",
+    ],
+}
+
 // Language and vendor related defaults
 cc_defaults {
     name: "nos_cc_defaults",
diff --git a/nugget/include/application.h b/nugget/include/application.h
index ef70754..de771f0 100644
--- a/nugget/include/application.h
+++ b/nugget/include/application.h
@@ -314,6 +314,7 @@
   APP_ERROR_CHECKSUM,   /* checksum failed, only used within protocol */
   APP_ERROR_BUSY,       /* the app is already working on a commnad */
   APP_ERROR_TIMEOUT,    /* the app took too long to respond */
+  APP_ERROR_NOT_READY,  /* some required condition is not satisfied */
   /* more? */
 
   /*
diff --git a/nugget/include/citadel_events.h b/nugget/include/citadel_events.h
index 02653b0..314ca41 100644
--- a/nugget/include/citadel_events.h
+++ b/nugget/include/citadel_events.h
@@ -66,6 +66,14 @@
   EVENT_ALERT_V2 = 4,  // Globalsec Alertv2 fired
 };
 
+/*
+ * Upgrade state definition.
+ */
+enum upgrade_state_def {
+  UPGRADE_SUCCESS = 0,
+  UPGRADE_PW_MISMATCH = 1,
+};
+
 /* Please do not change the size of this struct */
 #define EVENT_RECORD_SIZE 64
 struct event_record {
@@ -85,6 +93,9 @@
       uint32_t which1;
     } rebooted;
     struct {
+      uint32_t upgrade_state;
+    } upgraded;
+    struct {
       uint32_t alert_grp[4];
       uint16_t camo_breaches[2];
       uint16_t temp_min;