aboutsummaryrefslogtreecommitdiffstats
path: root/recovery.cpp
diff options
context:
space:
mode:
authorTom Marshall <tdm@cyngn.com>2015-11-05 21:30:40 -0800
committerTom Marshall <tdm@cyngn.com>2015-11-25 15:34:35 -0800
commitffc8a8702d9e1568995ce155c648fd029909cdac (patch)
tree3dcf3d34ebb03c3ac8d140d249e55838a90e2e14 /recovery.cpp
parent3381ac447175af3252c79c3e066cbbc38c400c85 (diff)
downloadbootable_recovery-ffc8a8702d9e1568995ce155c648fd029909cdac.zip
bootable_recovery-ffc8a8702d9e1568995ce155c648fd029909cdac.tar.gz
bootable_recovery-ffc8a8702d9e1568995ce155c648fd029909cdac.tar.bz2
recovery: Provide sideload cancellation
Change-Id: I13f0c9ae5444652a2141442ef24258679a78d320
Diffstat (limited to 'recovery.cpp')
-rw-r--r--recovery.cpp38
1 files changed, 26 insertions, 12 deletions
diff --git a/recovery.cpp b/recovery.cpp
index 3cd2764..5c482e0 100644
--- a/recovery.cpp
+++ b/recovery.cpp
@@ -616,8 +616,8 @@ get_menu_selection(const char* const * headers, const char* const * items,
ui->EndMenu();
return 0; // XXX fixme
}
- } else if (key == -2) { // we are returning from ui_cancel_wait_key(): trigger a GO_BACK
- return Device::kGoBack;
+ } else if (key == -2) { // we are returning from ui_cancel_wait_key(): no action
+ return Device::kNoAction;
}
else if (key == -6) {
return Device::kRefresh;
@@ -918,7 +918,18 @@ refresh:
break;
}
if (chosen == item_sideload) {
- status = apply_from_adb(ui, &wipe_cache, TEMPORARY_INSTALL_FILE);
+ static const char* headers[] = { "ADB Sideload",
+ "",
+ NULL
+ };
+ static const char* list[] = { "Cancel sideload", NULL };
+
+ start_sideload(ui, &wipe_cache, TEMPORARY_INSTALL_FILE);
+ int item = get_menu_selection(headers, list, 0, 0, device);
+ if (item != Device::kNoAction) {
+ stop_sideload();
+ }
+ status = wait_sideload();
}
else {
std::string id = volumes[chosen - 1].mId;
@@ -991,14 +1002,16 @@ prompt_and_wait(Device* device, int status) {
}
}
- if (status != INSTALL_SUCCESS) {
- ui->SetBackground(RecoveryUI::ERROR);
- ui->Print("Installation aborted.\n");
- copy_logs();
- } else if (!ui->IsTextVisible()) {
- return Device::NO_ACTION; // reboot if logs aren't visible
- } else {
- ui->Print("\nInstall complete.\n");
+ if (status >= 0 && status != INSTALL_NONE) {
+ if (status != INSTALL_SUCCESS) {
+ ui->SetBackground(RecoveryUI::ERROR);
+ ui->Print("Installation aborted.\n");
+ copy_logs();
+ } else if (!ui->IsTextVisible()) {
+ return Device::NO_ACTION; // reboot if logs aren't visible
+ } else {
+ ui->Print("\nInstall complete.\n");
+ }
}
break;
}
@@ -1338,7 +1351,8 @@ main(int argc, char **argv) {
if (!sideload_auto_reboot) {
ui->ShowText(true);
}
- status = apply_from_adb(ui, &should_wipe_cache, TEMPORARY_INSTALL_FILE);
+ start_sideload(ui, &should_wipe_cache, TEMPORARY_INSTALL_FILE);
+ status = wait_sideload();
if (status == INSTALL_SUCCESS && should_wipe_cache) {
if (!wipe_cache(false, device)) {
status = INSTALL_ERROR;