resolve merge conflicts of b940309ec7 to master.
Change-Id: Icd6daa7385b8cd8c19f52dbc6805142e81b93dc9
diff --git a/fastboot/fastboot.cpp b/fastboot/fastboot.cpp
index ddd0387..0f1d22f 100644
--- a/fastboot/fastboot.cpp
+++ b/fastboot/fastboot.cpp
@@ -281,6 +281,10 @@
" override the fs type and/or size\n"
" the bootloader reports.\n"
" getvar <variable> Display a bootloader variable.\n"
+ " set_active <suffix> Sets the active slot. If slots are\n"
+ " not supported, this does nothing.\n"
+ " note: suffixes starting with a '-'\n"
+ " must use set_active -- <suffix>\n"
" boot <kernel> [ <ramdisk> [ <second> ] ] Download and boot kernel.\n"
" flash:raw boot <kernel> [ <ramdisk> [ <second> ] ]\n"
" Create bootimage and flash it.\n"
@@ -323,7 +327,8 @@
" -a, --set-active[=<suffix>] Sets the active slot. If no suffix is\n"
" provided, this will default to the value\n"
" given by --slot. If slots are not\n"
- " supported, this does nothing.\n"
+ " supported, this does nothing. This will\n"
+ " run after all non-reboot commands.\n"
#if !defined(_WIN32)
" --wipe-and-use-fbe On devices which support it,\n"
" erase userdata and cache, and\n"
@@ -784,9 +789,19 @@
return android::base::Split(suffix_list, ",");
}
-static std::string verify_slot(Transport* transport, const char *slot) {
+static std::string verify_slot(Transport* transport, const char *slot, bool allow_all) {
if (strcmp(slot, "all") == 0) {
- return "all";
+ if (allow_all) {
+ return "all";
+ } else {
+ std::vector<std::string> suffixes = get_suffixes(transport);
+ if (!suffixes.empty()) {
+ return suffixes[0];
+ } else {
+ fprintf(stderr, "No known slots.\n");
+ exit(1);
+ }
+ }
}
std::vector<std::string> suffixes = get_suffixes(transport);
for (const std::string &suffix : suffixes) {
@@ -800,6 +815,10 @@
exit(1);
}
+static std::string verify_slot(Transport* transport, const char *slot) {
+ return verify_slot(transport, slot, true);
+}
+
static void do_for_partition(Transport* transport, const char *part, const char *slot,
std::function<void(const std::string&)> func, bool force_slot) {
std::string has_slot;
@@ -1294,14 +1313,14 @@
if (slot_override != "")
slot_override = verify_slot(transport, slot_override.c_str());
if (next_active != "")
- next_active = verify_slot(transport, next_active.c_str());
+ next_active = verify_slot(transport, next_active.c_str(), false);
if (wants_set_active) {
if (next_active == "") {
if (slot_override == "") {
wants_set_active = false;
} else {
- next_active = slot_override;
+ next_active = verify_slot(transport, slot_override.c_str(), false);
}
}
}
@@ -1460,6 +1479,12 @@
do_update(transport, "update.zip", slot_override.c_str(), erase_first);
skip(1);
}
+ wants_reboot = 1;
+ } else if(!strcmp(*argv, "set_active")) {
+ require(2);
+ std::string slot = verify_slot(transport, argv[1], false);
+ fb_set_active(slot.c_str());
+ skip(2);
wants_reboot = true;
} else if(!strcmp(*argv, "oem")) {
argc = do_oem_command(argc, argv);