Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1197)

Unified Diff: utils.cc

Issue 6719012: Use crossystem rather than cros_boot_mode. (Closed) Base URL: ssh://git@gitrw.chromium.org:9222/update_engine.git@master
Patch Set: Created 9 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « utils.h ('k') | utils_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: utils.cc
diff --git a/utils.cc b/utils.cc
index 502b0d1ab134092b32411a0695eb1142c2f70159..e1256a7f0fd3cb8127d2bd32c18509ad3ecad05a 100644
--- a/utils.cc
+++ b/utils.cc
@@ -25,7 +25,6 @@
#include <base/rand_util.h>
#include <base/string_util.h>
#include <base/logging.h>
-#include <cros_boot_mode/boot_mode.h>
#include <google/protobuf/stubs/common.h>
#include <rootdev/rootdev.h>
@@ -53,12 +52,18 @@ bool IsOOBEComplete() {
}
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;
+ // TODO(petkov): Convert to a library call once a crossystem library is
+ // available (crosbug.com/13291).
+ int exit_code = 0;
+ vector<string> cmd(1, "/usr/bin/crossystem");
+ cmd.push_back("devsw_boot?1");
+
+ // Assume dev mode if the dev switch is set to 1 and there was no error
+ // executing crossystem. Assume normal mode otherwise.
+ bool success = Subprocess::SynchronousExec(cmd, &exit_code);
+ bool dev_mode = success && exit_code == 0;
+ LOG_IF(INFO, dev_mode) << "Booted in dev mode.";
+ return !dev_mode;
}
bool WriteFile(const char* path, const char* data, int data_len) {
« no previous file with comments | « utils.h ('k') | utils_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698