diff options
author | TreeHugger Robot <treehugger-gerrit@google.com> | 2018-03-17 08:03:18 +0000 |
---|---|---|
committer | Android (Google) Code Review <android-gerrit@google.com> | 2018-03-17 08:03:18 +0000 |
commit | 8dca85f0c81e18e73aad914c0c22c111ecfd32bc (patch) | |
tree | 3b46d28034abd6ca8c56fee9d13c192a6f9c6331 | |
parent | 6665d991e1dbe5bce2af47d126ddfbe08b810473 (diff) | |
parent | 45a00fdccefc059112e43be690411ece655f2ed1 (diff) | |
download | core-8dca85f0c81e18e73aad914c0c22c111ecfd32bc.tar.gz core-8dca85f0c81e18e73aad914c0c22c111ecfd32bc.tar.bz2 core-8dca85f0c81e18e73aad914c0c22c111ecfd32bc.zip |
Merge "adb: checks device state when using adb disable-verity for AVB" into pi-dev
-rw-r--r-- | adb/set_verity_enable_state_service.cpp | 13 |
1 files changed, 11 insertions, 2 deletions
diff --git a/adb/set_verity_enable_state_service.cpp b/adb/set_verity_enable_state_service.cpp index 49e0363a1..0fcf89b7c 100644 --- a/adb/set_verity_enable_state_service.cpp +++ b/adb/set_verity_enable_state_service.cpp @@ -98,13 +98,22 @@ static std::string get_ab_suffix() { return android::base::GetProperty("ro.boot.slot_suffix", ""); } +static bool is_avb_device_locked() { + return android::base::GetProperty("ro.boot.vbmeta.device_state", "") == "locked"; +} + /* Use AVB to turn verity on/off */ static bool set_avb_verity_enabled_state(int fd, AvbOps* ops, bool enable_verity) { std::string ab_suffix = get_ab_suffix(); - bool verity_enabled; + + if (is_avb_device_locked()) { + WriteFdFmt(fd, "Device is locked. Please unlock the device first\n"); + return false; + } + if (!avb_user_verity_get(ops, ab_suffix.c_str(), &verity_enabled)) { - WriteFdFmt(fd, "Error getting verity state\n"); + WriteFdFmt(fd, "Error getting verity state. Try adb root first?\n"); return false; } |