aboutsummaryrefslogtreecommitdiff
path: root/install/adb_install.cpp
diff options
context:
space:
mode:
authorxunchang <xunchang@google.com>2019-04-22 12:18:14 -0700
committerxunchang <xunchang@google.com>2019-04-26 10:36:48 -0700
commitfedeef6f6d1f7b8f1e5a8b9e77f8dc21ef6b3c95 (patch)
treefaef441afe34374f515635c59af444846c823354 /install/adb_install.cpp
parente645ba5acae703f4728f9bac199119369f1ec4e6 (diff)
downloadrecovery-fedeef6f6d1f7b8f1e5a8b9e77f8dc21ef6b3c95.tar.gz
Support wipe command in rescue mode
Bug: 131037235 Test: unit tests pass, run `adb rescue wipe` Change-Id: I22668f2c98fe2d9195d2561f961c28a7c08e712c
Diffstat (limited to 'install/adb_install.cpp')
-rw-r--r--install/adb_install.cpp23
1 files changed, 15 insertions, 8 deletions
diff --git a/install/adb_install.cpp b/install/adb_install.cpp
index 9dfe0407..4dd1f1b0 100644
--- a/install/adb_install.cpp
+++ b/install/adb_install.cpp
@@ -43,6 +43,7 @@
#include "fuse_sideload.h"
#include "install/install.h"
+#include "install/wipe_data.h"
#include "minadbd_types.h"
#include "otautil/sysutil.h"
#include "recovery_ui/device.h"
@@ -330,7 +331,7 @@ static void CreateMinadbdServiceAndExecuteCommands(
signal(SIGPIPE, SIG_DFL);
}
-int ApplyFromAdb(RecoveryUI* ui, bool rescue_mode, Device::BuiltinAction* reboot_action) {
+int ApplyFromAdb(Device* device, bool rescue_mode, Device::BuiltinAction* reboot_action) {
// Save the usb state to restore after the sideload operation.
std::string usb_state = android::base::GetProperty("sys.usb.state", "none");
// Clean up state and stop adbd.
@@ -339,13 +340,7 @@ int ApplyFromAdb(RecoveryUI* ui, bool rescue_mode, Device::BuiltinAction* reboot
return INSTALL_ERROR;
}
- if (!rescue_mode) {
- ui->Print(
- "\n\nNow send the package you want to apply\n"
- "to the device with \"adb sideload <filename>\"...\n");
- } else {
- ui->Print("\n\nWaiting for rescue commands...\n");
- }
+ RecoveryUI* ui = device->GetUI();
int install_result = INSTALL_ERROR;
std::map<MinadbdCommand, CommandFunction> command_map{
@@ -363,6 +358,18 @@ int ApplyFromAdb(RecoveryUI* ui, bool rescue_mode, Device::BuiltinAction* reboot
std::bind(&AdbRebootHandler, MinadbdCommand::kRebootRescue, &install_result, reboot_action) },
};
+ if (!rescue_mode) {
+ ui->Print(
+ "\n\nNow send the package you want to apply\n"
+ "to the device with \"adb sideload <filename>\"...\n");
+ } else {
+ ui->Print("\n\nWaiting for rescue commands...\n");
+ command_map.emplace(MinadbdCommand::kWipeData, [&device]() {
+ bool result = WipeData(device, false);
+ return std::make_pair(result, true);
+ });
+ }
+
CreateMinadbdServiceAndExecuteCommands(ui, command_map, rescue_mode);
// Clean up before switching to the older state, for example setting the state