summaryrefslogtreecommitdiffstats
path: root/updater/commands.cpp
diff options
context:
space:
mode:
authorTao Bao <tbao@google.com>2018-07-09 19:57:58 +0200
committerandroid-build-merger <android-build-merger@google.com>2018-07-09 19:57:58 +0200
commit9c00224fc7f4f25a8e4564af2b4cd254c89fec86 (patch)
treed17cd00549fddc484bdb926f66287ee76cc692cf /updater/commands.cpp
parentMerge "tests: Split unit tests out of component/applypatch_test.cpp." am: cf1f9bdb12 am: cac6932cf4 (diff)
parentMerge "updater: Add ABORT command." am: c059b6c1c6 (diff)
downloadandroid_bootable_recovery-9c00224fc7f4f25a8e4564af2b4cd254c89fec86.tar
android_bootable_recovery-9c00224fc7f4f25a8e4564af2b4cd254c89fec86.tar.gz
android_bootable_recovery-9c00224fc7f4f25a8e4564af2b4cd254c89fec86.tar.bz2
android_bootable_recovery-9c00224fc7f4f25a8e4564af2b4cd254c89fec86.tar.lz
android_bootable_recovery-9c00224fc7f4f25a8e4564af2b4cd254c89fec86.tar.xz
android_bootable_recovery-9c00224fc7f4f25a8e4564af2b4cd254c89fec86.tar.zst
android_bootable_recovery-9c00224fc7f4f25a8e4564af2b4cd254c89fec86.zip
Diffstat (limited to 'updater/commands.cpp')
-rw-r--r--updater/commands.cpp17
1 files changed, 16 insertions, 1 deletions
diff --git a/updater/commands.cpp b/updater/commands.cpp
index fb19ebc9a..e88149678 100644
--- a/updater/commands.cpp
+++ b/updater/commands.cpp
@@ -29,8 +29,16 @@
using namespace std::string_literals;
+bool Command::abort_allowed_ = false;
+
Command::Type Command::ParseType(const std::string& type_str) {
- if (type_str == "bsdiff") {
+ if (type_str == "abort") {
+ if (!abort_allowed_) {
+ LOG(ERROR) << "ABORT disallowed";
+ return Type::LAST;
+ }
+ return Type::ABORT;
+ } else if (type_str == "bsdiff") {
return Type::BSDIFF;
} else if (type_str == "erase") {
return Type::ERASE;
@@ -237,6 +245,13 @@ Command Command::Parse(const std::string& line, size_t index, std::string* err)
src_hash, &source_info, err)) {
return {};
}
+ } else if (op == Type::ABORT) {
+ // No-op, other than sanity checking the input args.
+ if (pos != tokens.size()) {
+ *err = android::base::StringPrintf("invalid number of args: %zu (expected 0)",
+ tokens.size() - pos);
+ return {};
+ }
} else {
*err = "invalid op";
return {};