diff options
author | David Anderson <dvander@google.com> | 2019-01-15 14:38:20 -0800 |
---|---|---|
committer | David Anderson <dvander@google.com> | 2019-01-17 18:33:14 +0000 |
commit | 1d504e3342b2960066739ea66fac6625b07560fb (patch) | |
tree | 0efac4787a95a99f95c0125765da6a3bc3c33cf8 /fastboot | |
parent | 0e330f12bc7f693933b96ad729d296a92ffd80b7 (diff) | |
download | system_core-1d504e3342b2960066739ea66fac6625b07560fb.tar.gz system_core-1d504e3342b2960066739ea66fac6625b07560fb.tar.bz2 system_core-1d504e3342b2960066739ea66fac6625b07560fb.zip |
fastbootd: Add command to remove GSI installs
Note: this only removes the bootable marker, since we're unable to
remove the userdata files within recovery.
Bug: 121210348
Test: fastboot gsi wipe
fastboot gsi disable
Change-Id: I64fe848c787d426ae9d18a1557a9d6b340bfc2cf
Diffstat (limited to 'fastboot')
-rw-r--r-- | fastboot/Android.bp | 1 | ||||
-rw-r--r-- | fastboot/constants.h | 1 | ||||
-rw-r--r-- | fastboot/device/commands.cpp | 20 | ||||
-rw-r--r-- | fastboot/device/commands.h | 1 | ||||
-rw-r--r-- | fastboot/device/fastboot_device.cpp | 1 | ||||
-rw-r--r-- | fastboot/fastboot.cpp | 11 |
6 files changed, 35 insertions, 0 deletions
diff --git a/fastboot/Android.bp b/fastboot/Android.bp index ead21054c..716fe9558 100644 --- a/fastboot/Android.bp +++ b/fastboot/Android.bp @@ -132,6 +132,7 @@ cc_binary { "libext2_uuid", "libext4_utils", "libfs_mgr", + "libgsi", "libhidlbase", "libhidltransport", "libhwbinder", diff --git a/fastboot/constants.h b/fastboot/constants.h index 81f0560e7..8a72627a9 100644 --- a/fastboot/constants.h +++ b/fastboot/constants.h @@ -33,6 +33,7 @@ #define FB_CMD_RESIZE_PARTITION "resize-logical-partition" #define FB_CMD_UPDATE_SUPER "update-super" #define FB_CMD_OEM "oem" +#define FB_CMD_GSI "gsi" #define RESPONSE_OKAY "OKAY" #define RESPONSE_FAIL "FAIL" diff --git a/fastboot/device/commands.cpp b/fastboot/device/commands.cpp index e91598d01..a2336bf7b 100644 --- a/fastboot/device/commands.cpp +++ b/fastboot/device/commands.cpp @@ -28,6 +28,7 @@ #include <cutils/android_reboot.h> #include <ext4_utils/wipe.h> #include <fs_mgr.h> +#include <libgsi/libgsi.h> #include <liblp/builder.h> #include <liblp/liblp.h> #include <uuid/uuid.h> @@ -460,3 +461,22 @@ bool UpdateSuperHandler(FastbootDevice* device, const std::vector<std::string>& bool wipe = (args.size() >= 3 && args[2] == "wipe"); return UpdateSuper(device, args[1], wipe); } + +bool GsiHandler(FastbootDevice* device, const std::vector<std::string>& args) { + if (!android::gsi::IsGsiInstalled()) { + return device->WriteStatus(FastbootResult::FAIL, "No GSI is installed"); + } + if (args.size() != 2) { + return device->WriteFail("Invalid arguments"); + } + if (args[1] == "wipe") { + if (!android::gsi::UninstallGsi()) { + return device->WriteStatus(FastbootResult::FAIL, strerror(errno)); + } + } else if (args[1] == "disable") { + if (!android::gsi::DisableGsi()) { + return device->WriteStatus(FastbootResult::FAIL, strerror(errno)); + } + } + return device->WriteStatus(FastbootResult::OKAY, "Success"); +} diff --git a/fastboot/device/commands.h b/fastboot/device/commands.h index bb1f988c3..afd6d0806 100644 --- a/fastboot/device/commands.h +++ b/fastboot/device/commands.h @@ -48,3 +48,4 @@ bool DeletePartitionHandler(FastbootDevice* device, const std::vector<std::strin bool ResizePartitionHandler(FastbootDevice* device, const std::vector<std::string>& args); bool UpdateSuperHandler(FastbootDevice* device, const std::vector<std::string>& args); bool OemCmdHandler(FastbootDevice* device, const std::vector<std::string>& args); +bool GsiHandler(FastbootDevice* device, const std::vector<std::string>& args); diff --git a/fastboot/device/fastboot_device.cpp b/fastboot/device/fastboot_device.cpp index 7be721a67..56fafab04 100644 --- a/fastboot/device/fastboot_device.cpp +++ b/fastboot/device/fastboot_device.cpp @@ -53,6 +53,7 @@ FastbootDevice::FastbootDevice() {FB_CMD_RESIZE_PARTITION, ResizePartitionHandler}, {FB_CMD_UPDATE_SUPER, UpdateSuperHandler}, {FB_CMD_OEM, OemCmdHandler}, + {FB_CMD_GSI, GsiHandler}, }), transport_(std::make_unique<ClientUsbTransport>()), boot_control_hal_(IBootControl::getService()), diff --git a/fastboot/fastboot.cpp b/fastboot/fastboot.cpp index 0b8d9b22e..d753f0f82 100644 --- a/fastboot/fastboot.cpp +++ b/fastboot/fastboot.cpp @@ -387,6 +387,7 @@ static int show_help() { " Format a flash partition.\n" " set_active SLOT Set the active slot.\n" " oem [COMMAND...] Execute OEM-specific command.\n" + " gsi wipe|disable Wipe or disable a GSI installation (fastbootd only).\n" "\n" "boot image:\n" " boot KERNEL [RAMDISK [SECOND]]\n" @@ -1926,6 +1927,16 @@ int FastBootTool::Main(int argc, char* argv[]) { std::string partition = next_arg(&args); std::string size = next_arg(&args); fb->ResizePartition(partition, size); + } else if (command == "gsi") { + if (args.empty()) { + syntax_error("missing 'wipe' or 'disable' argument"); + } else if (args.size() == 1 && args[0] == "wipe") { + fb->RawCommand("gsi:wipe", "wiping GSI"); + } else if (args.size() == 1 && args[0] == "disable") { + fb->RawCommand("gsi:disable", "disabling GSI"); + } else { + syntax_error("expected 'wipe' or 'disable'"); + } } else { syntax_error("unknown command %s", command.c_str()); } |