summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorElliott Hughes <enh@google.com>2015-03-24 22:43:42 +0100
committerGerrit Code Review <noreply-gerritcodereview@google.com>2015-03-24 22:43:42 +0100
commit47733eafdc37203d59a8a0a17ccfb936d2920e31 (patch)
treef7fdd21da3942576ad9b8eac59dd2187acdaded0
parentMerge "Make the recovery menus wrap." (diff)
parentFix wipe command when using sideload in recovery (diff)
downloadandroid_bootable_recovery-47733eafdc37203d59a8a0a17ccfb936d2920e31.tar
android_bootable_recovery-47733eafdc37203d59a8a0a17ccfb936d2920e31.tar.gz
android_bootable_recovery-47733eafdc37203d59a8a0a17ccfb936d2920e31.tar.bz2
android_bootable_recovery-47733eafdc37203d59a8a0a17ccfb936d2920e31.tar.lz
android_bootable_recovery-47733eafdc37203d59a8a0a17ccfb936d2920e31.tar.xz
android_bootable_recovery-47733eafdc37203d59a8a0a17ccfb936d2920e31.tar.zst
android_bootable_recovery-47733eafdc37203d59a8a0a17ccfb936d2920e31.zip
-rw-r--r--recovery.cpp99
1 files changed, 47 insertions, 52 deletions
diff --git a/recovery.cpp b/recovery.cpp
index 641f36f3e..51c131d9b 100644
--- a/recovery.cpp
+++ b/recovery.cpp
@@ -825,6 +825,30 @@ static void choose_recovery_file(Device* device) {
}
}
+static int apply_from_sdcard(Device* device, int* wipe_cache) {
+ if (ensure_path_mounted(SDCARD_ROOT) != 0) {
+ ui->Print("\n-- Couldn't mount %s.\n", SDCARD_ROOT);
+ return INSTALL_ERROR;
+ }
+
+ char* path = browse_directory(SDCARD_ROOT, device);
+ if (path == NULL) {
+ ui->Print("\n-- No package file selected.\n", path);
+ return INSTALL_ERROR;
+ }
+
+ ui->Print("\n-- Install %s ...\n", path);
+ set_sdcard_update_bootloader_message();
+ void* token = start_sdcard_fuse(path);
+
+ int status = install_package(FUSE_SIDELOAD_HOST_PATHNAME, wipe_cache,
+ TEMPORARY_INSTALL_FILE, false);
+
+ finish_sdcard_fuse(token);
+ ensure_path_unmounted(SDCARD_ROOT);
+ return status;
+}
+
// Return REBOOT, SHUTDOWN, or REBOOT_BOOTLOADER. Returning NO_ACTION
// means to take the default, which is to reboot or shutdown depending
// on if the --shutdown_after flag was passed to recovery.
@@ -876,49 +900,35 @@ prompt_and_wait(Device* device, int status) {
if (!ui->IsTextVisible()) return Device::NO_ACTION;
break;
- case Device::APPLY_EXT: {
- if (ensure_path_mounted(SDCARD_ROOT) != 0) {
- ui->Print("\n-- Couldn't mount %s.\n", SDCARD_ROOT);
- break;
- }
-
- char* path = browse_directory(SDCARD_ROOT, device);
- if (path == NULL) {
- ui->Print("\n-- No package file selected.\n", path);
- break;
- }
-
- ui->Print("\n-- Install %s ...\n", path);
- set_sdcard_update_bootloader_message();
- void* token = start_sdcard_fuse(path);
-
- int status = install_package(FUSE_SIDELOAD_HOST_PATHNAME, &wipe_cache,
- TEMPORARY_INSTALL_FILE, false);
-
- finish_sdcard_fuse(token);
- ensure_path_unmounted(SDCARD_ROOT);
-
- if (status == INSTALL_SUCCESS && wipe_cache) {
- ui->Print("\n-- Wiping cache (at package request)...\n");
- if (erase_volume("/cache")) {
- ui->Print("Cache wipe failed.\n");
+ case Device::APPLY_ADB_SIDELOAD:
+ case Device::APPLY_EXT:
+ {
+ bool adb = (chosen_action == Device::APPLY_ADB_SIDELOAD);
+ if (adb) {
+ status = apply_from_adb(ui, &wipe_cache, TEMPORARY_INSTALL_FILE);
} else {
- ui->Print("Cache wipe complete.\n");
+ status = apply_from_sdcard(device, &wipe_cache);
}
- }
- if (status >= 0) {
- if (status != INSTALL_SUCCESS) {
- ui->SetBackground(RecoveryUI::ERROR);
- ui->Print("Installation aborted.\n");
- } else if (!ui->IsTextVisible()) {
- return Device::NO_ACTION; // reboot if logs aren't visible
- } else {
- ui->Print("\nInstall from SD card complete.\n");
+ if (status == INSTALL_SUCCESS && wipe_cache) {
+ ui->Print("\n-- Wiping cache (at package request)...\n");
+ bool okay = erase_volume("/cache");
+ ui->Print("Cache wipe %s.\n", okay ? "succeeded" : "failed");
+ }
+
+ if (status >= 0) {
+ 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 from %s complete.\n", adb ? "ADB" : "SD card");
+ }
}
}
break;
- }
case Device::APPLY_CACHE:
ui->Print("\nAPPLY_CACHE is deprecated.\n");
@@ -927,21 +937,6 @@ prompt_and_wait(Device* device, int status) {
case Device::READ_RECOVERY_LASTLOG:
choose_recovery_file(device);
break;
-
- case Device::APPLY_ADB_SIDELOAD:
- status = apply_from_adb(ui, &wipe_cache, TEMPORARY_INSTALL_FILE);
- if (status >= 0) {
- 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 from ADB complete.\n");
- }
- }
- break;
}
}
}