AU: Include a bit flag (bit 31) in error codes to indicate non-normal boot mode.

BUG=chromium-os:10320
TEST=unit test, tested on device in normal and dev mode

Change-Id: I67d695bc167a4cc1a638711f047e2b86f8eaa8f1

Review URL: http://codereview.chromium.org/6098008
diff --git a/utils.cc b/utils.cc
index 95b5ec9..7206171 100644
--- a/utils.cc
+++ b/utils.cc
@@ -25,6 +25,7 @@
 #include <base/rand_util.h>
 #include <base/string_util.h>
 #include <base/logging.h>
+#include <cros_boot_mode/boot_mode.h>
 #include <rootdev/rootdev.h>
 
 #include "update_engine/file_writer.h"
@@ -50,6 +51,15 @@
   return file_util::PathExists(FilePath(kOOBECompletedMarker));
 }
 
+bool IsNormalBootMode() {
+  cros_boot_mode::BootMode mode;
+  mode.Initialize(false,  // unsupported_is_developer
+                  true);  // use_bootloader
+  bool normal = mode.mode() == cros_boot_mode::BootMode::kNormal;
+  LOG_IF(INFO, !normal) << "Boot mode not normal: " << mode.mode_text();
+  return normal;
+}
+
 bool WriteFile(const char* path, const char* data, int data_len) {
   DirectFileWriter writer;
   TEST_AND_RETURN_FALSE_ERRNO(0 == writer.Open(path,