summaryrefslogtreecommitdiffstats
path: root/recovery.cpp
diff options
context:
space:
mode:
authorChristian Poetzsch <christian.potzsch@imgtec.com>2015-02-19 11:42:39 +0100
committerElliott Hughes <enh@google.com>2015-03-24 19:26:42 +0100
commit4ec58a4ee5d025deeb83ce8322aa8a65b16d8a9c (patch)
treef7fdd21da3942576ad9b8eac59dd2187acdaded0 /recovery.cpp
parentMerge "Make the recovery menus wrap." (diff)
downloadandroid_bootable_recovery-4ec58a4ee5d025deeb83ce8322aa8a65b16d8a9c.tar
android_bootable_recovery-4ec58a4ee5d025deeb83ce8322aa8a65b16d8a9c.tar.gz
android_bootable_recovery-4ec58a4ee5d025deeb83ce8322aa8a65b16d8a9c.tar.bz2
android_bootable_recovery-4ec58a4ee5d025deeb83ce8322aa8a65b16d8a9c.tar.lz
android_bootable_recovery-4ec58a4ee5d025deeb83ce8322aa8a65b16d8a9c.tar.xz
android_bootable_recovery-4ec58a4ee5d025deeb83ce8322aa8a65b16d8a9c.tar.zst
android_bootable_recovery-4ec58a4ee5d025deeb83ce8322aa8a65b16d8a9c.zip
Diffstat (limited to '')
-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;
}
}
}