fastboot: Automatically reboot to userspace fastboot.
In order to flash logical partitions, "flashall" must be run against
userspace fastboot. When the bootloader supports the "reboot-fastboot"
command, we now attempt to automatically reboot into userspace fastboot.
We do this by closing the transport, sleeping for one second, and then
polling for a new connection until one is available. FastBootDriver is
then assigned the new transport.
Bug: 78793464
Test: fastboot flashall on device with logical partitions, while booted
into bootloader fastboot
Change-Id: I6949871b93ab5e352784cabe0963c6ecfc0af36d
diff --git a/fastboot/fastboot_driver.h b/fastboot/fastboot_driver.h
index 51be3db..a97ed2c 100644
--- a/fastboot/fastboot_driver.h
+++ b/fastboot/fastboot_driver.h
@@ -66,6 +66,7 @@
FastBootDriver(Transport* transport,
std::function<void(std::string&)> info = [](std::string&) {},
bool no_checks = false);
+ ~FastBootDriver();
RetCode Boot(std::string* response = nullptr, std::vector<std::string>* info = nullptr);
RetCode Continue(std::string* response = nullptr, std::vector<std::string>* info = nullptr);
@@ -87,6 +88,8 @@
RetCode GetVarAll(std::vector<std::string>* response);
RetCode Powerdown(std::string* response = nullptr, std::vector<std::string>* info = nullptr);
RetCode Reboot(std::string* response = nullptr, std::vector<std::string>* info = nullptr);
+ RetCode RebootTo(std::string target, std::string* response = nullptr,
+ std::vector<std::string>* info = nullptr);
RetCode SetActive(const std::string& part, std::string* response = nullptr,
std::vector<std::string>* info = nullptr);
RetCode Upload(const std::string& outfile, std::string* response = nullptr,
@@ -109,6 +112,10 @@
std::string Error();
RetCode WaitForDisconnect();
+ // Note: changing the transport will close and delete the existing one.
+ void set_transport(Transport* transport);
+ Transport* transport() const { return transport_; }
+
// This is temporarily public for engine.cpp
RetCode RawCommand(const std::string& cmd, std::string* response = nullptr,
std::vector<std::string>* info = nullptr, int* dsize = nullptr);
@@ -136,7 +143,7 @@
static const std::string VERIFY;
};
- Transport* const transport;
+ Transport* transport_;
private:
RetCode SendBuffer(int fd, size_t size);