From 671a2a551a8f40c7d54ff30b148fd79dc8de0053 Mon Sep 17 00:00:00 2001 From: Chun-Wei Wang Date: Wed, 30 Aug 2023 07:55:43 +0000 Subject: [PATCH] Add a fastboot command to show GSI status The command will be used by RMA tool to skip device wiping when it is already in GSI mode. This change also makes it easier to add more gsi commands in the future without needing to update the host side tool (fastboot). Bug: 298130522 Bug: 298138572 Test: 1. reboot into fastboot mode 2. fastboot gsi status Change-Id: Ic81f89a93b854f9ec70aebe2d209bfd1f98e3645 --- fastboot/device/commands.cpp | 11 +++++++++++ fastboot/fastboot.cpp | 12 +++++------- 2 files changed, 16 insertions(+), 7 deletions(-) diff --git a/fastboot/device/commands.cpp b/fastboot/device/commands.cpp index e929f42c2..d60539332 100644 --- a/fastboot/device/commands.cpp +++ b/fastboot/device/commands.cpp @@ -661,6 +661,17 @@ bool GsiHandler(FastbootDevice* device, const std::vector& args) { if (!android::gsi::DisableGsi()) { return device->WriteStatus(FastbootResult::FAIL, strerror(errno)); } + } else if (args[1] == "status") { + std::string active_dsu; + if (!android::gsi::IsGsiRunning()) { + device->WriteInfo("Not running"); + } else if (!android::gsi::GetActiveDsu(&active_dsu)) { + return device->WriteFail(strerror(errno)); + } else { + device->WriteInfo("Running active DSU: " + active_dsu); + } + } else { + return device->WriteFail("Invalid arguments"); } return device->WriteStatus(FastbootResult::OKAY, "Success"); } diff --git a/fastboot/fastboot.cpp b/fastboot/fastboot.cpp index 71a228ea1..f76afba0b 100644 --- a/fastboot/fastboot.cpp +++ b/fastboot/fastboot.cpp @@ -2579,14 +2579,12 @@ int FastBootTool::Main(int argc, char* argv[]) { std::make_unique(fp.get(), partition, size, fp->slot_override); resize_task->Run(); } else if (command == "gsi") { - std::string arg = next_arg(&args); - if (arg == "wipe") { - fb->RawCommand("gsi:wipe", "wiping GSI"); - } else if (arg == "disable") { - fb->RawCommand("gsi:disable", "disabling GSI"); - } else { - syntax_error("expected 'wipe' or 'disable'"); + if (args.empty()) syntax_error("invalid gsi command"); + std::string cmd("gsi"); + while (!args.empty()) { + cmd += ":" + next_arg(&args); } + fb->RawCommand(cmd, ""); } else if (command == "wipe-super") { std::string image; if (args.empty()) {