Changed FlashTask and RebootTask to take in FlashingPlan
Test: tested flash {partition} on raven and reboot {target} on raven
Change-Id: I26f4723474c3a142b086c1ac361578f8487ec3b9
Bug: 194686221
diff --git a/fastboot/task.cpp b/fastboot/task.cpp
index 94dd5c3..a4aa637 100644
--- a/fastboot/task.cpp
+++ b/fastboot/task.cpp
@@ -20,20 +20,16 @@
#include "fastboot.h"
#include "util.h"
-FlashTask::FlashTask(const std::string& _slot) : slot_(_slot){};
-FlashTask::FlashTask(const std::string& _slot, bool _force_flash)
- : slot_(_slot), force_flash_(_force_flash) {}
-FlashTask::FlashTask(const std::string& _slot, bool _force_flash, const std::string& _pname)
- : pname_(_pname), fname_(find_item(_pname)), slot_(_slot), force_flash_(_force_flash) {
+FlashTask::FlashTask(const std::string& _slot, const std::string& _pname)
+ : pname_(_pname), fname_(find_item(_pname)), slot_(_slot) {
if (fname_.empty()) die("cannot determine image filename for '%s'", pname_.c_str());
}
-FlashTask::FlashTask(const std::string& _slot, bool _force_flash, const std::string& _pname,
- const std::string& _fname)
- : pname_(_pname), fname_(_fname), slot_(_slot), force_flash_(_force_flash) {}
+FlashTask::FlashTask(const std::string& _slot, const std::string& _pname, const std::string& _fname)
+ : pname_(_pname), fname_(_fname), slot_(_slot) {}
void FlashTask::Run() {
auto flash = [&](const std::string& partition) {
- if (should_flash_in_userspace(partition) && !is_userspace_fastboot() && !force_flash_) {
+ if (should_flash_in_userspace(partition) && !is_userspace_fastboot()) {
die("The partition you are trying to flash is dynamic, and "
"should be flashed via fastbootd. Please run:\n"
"\n"
@@ -47,25 +43,25 @@
do_for_partitions(pname_, slot_, flash, true);
}
-RebootTask::RebootTask(fastboot::FastBootDriver* _fb) : fb_(_fb){};
-RebootTask::RebootTask(fastboot::FastBootDriver* _fb, std::string _reboot_target)
- : reboot_target_(std::move(_reboot_target)), fb_(_fb){};
+RebootTask::RebootTask(FlashingPlan* _fp) : fp_(_fp){};
+RebootTask::RebootTask(FlashingPlan* _fp, const std::string& _reboot_target)
+ : reboot_target_(_reboot_target), fp_(_fp){};
void RebootTask::Run() {
if ((reboot_target_ == "userspace" || reboot_target_ == "fastboot")) {
if (!is_userspace_fastboot()) {
reboot_to_userspace_fastboot();
- fb_->WaitForDisconnect();
+ fp_->fb->WaitForDisconnect();
}
} else if (reboot_target_ == "recovery") {
- fb_->RebootTo("recovery");
- fb_->WaitForDisconnect();
+ fp_->fb->RebootTo("recovery");
+ fp_->fb->WaitForDisconnect();
} else if (reboot_target_ == "bootloader") {
- fb_->RebootTo("bootloader");
- fb_->WaitForDisconnect();
+ fp_->fb->RebootTo("bootloader");
+ fp_->fb->WaitForDisconnect();
} else if (reboot_target_ == "") {
- fb_->Reboot();
- fb_->WaitForDisconnect();
+ fp_->fb->Reboot();
+ fp_->fb->WaitForDisconnect();
} else {
syntax_error("unknown reboot target %s", reboot_target_.c_str());
}