diff options
author | xunchang <xunchang@google.com> | 2019-04-22 21:18:14 +0200 |
---|---|---|
committer | Tianjie Xu <xunchang@google.com> | 2019-04-30 00:21:23 +0200 |
commit | 5a1916b9bedce04fb79f64b61def1bc53fffb11d (patch) | |
tree | 9844b1d1524f153ff3903b2b0bba86956d514438 /install | |
parent | Parse BCB command to enter rescue mode. (diff) | |
download | android_bootable_recovery-5a1916b9bedce04fb79f64b61def1bc53fffb11d.tar android_bootable_recovery-5a1916b9bedce04fb79f64b61def1bc53fffb11d.tar.gz android_bootable_recovery-5a1916b9bedce04fb79f64b61def1bc53fffb11d.tar.bz2 android_bootable_recovery-5a1916b9bedce04fb79f64b61def1bc53fffb11d.tar.lz android_bootable_recovery-5a1916b9bedce04fb79f64b61def1bc53fffb11d.tar.xz android_bootable_recovery-5a1916b9bedce04fb79f64b61def1bc53fffb11d.tar.zst android_bootable_recovery-5a1916b9bedce04fb79f64b61def1bc53fffb11d.zip |
Diffstat (limited to '')
-rw-r--r-- | install/adb_install.cpp | 23 | ||||
-rw-r--r-- | install/include/install/adb_install.h | 3 |
2 files changed, 16 insertions, 10 deletions
diff --git a/install/adb_install.cpp b/install/adb_install.cpp index 9dfe0407f..4dd1f1b09 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 diff --git a/install/include/install/adb_install.h b/install/include/install/adb_install.h index 49b32b54f..3a0a81747 100644 --- a/install/include/install/adb_install.h +++ b/install/include/install/adb_install.h @@ -17,9 +17,8 @@ #pragma once #include <recovery_ui/device.h> -#include <recovery_ui/ui.h> // Applies a package via `adb sideload` or `adb rescue`. Returns the install result (in `enum // InstallResult`). When a reboot has been requested, INSTALL_REBOOT will be the return value, with // the reboot target set in reboot_action. -int ApplyFromAdb(RecoveryUI* ui, bool rescue_mode, Device::BuiltinAction* reboot_action); +int ApplyFromAdb(Device* device, bool rescue_mode, Device::BuiltinAction* reboot_action); |