summaryrefslogtreecommitdiffstats
path: root/recovery.c
diff options
context:
space:
mode:
Diffstat (limited to 'recovery.c')
-rw-r--r--recovery.c82
1 files changed, 16 insertions, 66 deletions
diff --git a/recovery.c b/recovery.c
index 9ad075d74..fd7ce42f1 100644
--- a/recovery.c
+++ b/recovery.c
@@ -23,7 +23,6 @@
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
-#include <sys/reboot.h>
#include <sys/stat.h>
#include <sys/types.h>
#include <time.h>
@@ -33,19 +32,18 @@
#include "bootloader.h"
#include "common.h"
#include "cutils/properties.h"
+#include "cutils/android_reboot.h"
#include "install.h"
#include "minui/minui.h"
#include "minzip/DirUtil.h"
#include "roots.h"
#include "recovery_ui.h"
-#include "encryptedfs_provisioning.h"
static const struct option OPTIONS[] = {
{ "send_intent", required_argument, NULL, 's' },
{ "update_package", required_argument, NULL, 'u' },
{ "wipe_data", no_argument, NULL, 'w' },
{ "wipe_cache", no_argument, NULL, 'c' },
- { "set_encrypted_filesystems", required_argument, NULL, 'e' },
{ "show_text", no_argument, NULL, 't' },
{ NULL, 0, NULL, 0 },
};
@@ -58,6 +56,8 @@ static const char *SDCARD_ROOT = "/sdcard";
static const char *TEMPORARY_LOG_FILE = "/tmp/recovery.log";
static const char *SIDELOAD_TEMP_DIR = "/tmp/sideload";
+extern UIParameters ui_parameters; // from ui.c
+
/*
* The recovery tool communicates with the main system through /cache files.
* /cache/recovery/command - INPUT - command line for tool, one arg per line
@@ -114,26 +114,6 @@ static const char *SIDELOAD_TEMP_DIR = "/tmp/sideload";
* 8g. finish_recovery() erases BCB
* -- after this, rebooting will (try to) restart the main system --
* 9. main() calls reboot() to boot main system
- *
- * SECURE FILE SYSTEMS ENABLE/DISABLE
- * 1. user selects "enable encrypted file systems"
- * 2. main system writes "--set_encrypted_filesystems=on|off" to
- * /cache/recovery/command
- * 3. main system reboots into recovery
- * 4. get_args() writes BCB with "boot-recovery" and
- * "--set_encrypted_filesystems=on|off"
- * -- after this, rebooting will restart the transition --
- * 5. read_encrypted_fs_info() retrieves encrypted file systems settings from /data
- * Settings include: property to specify the Encrypted FS istatus and
- * FS encryption key if enabled (not yet implemented)
- * 6. erase_volume() reformats /data
- * 7. erase_volume() reformats /cache
- * 8. restore_encrypted_fs_info() writes required encrypted file systems settings to /data
- * Settings include: property to specify the Encrypted FS status and
- * FS encryption key if enabled (not yet implemented)
- * 9. finish_recovery() erases BCB
- * -- after this, rebooting will restart the main system --
- * 10. main() calls reboot() to boot main system
*/
static const int MAX_ARG_LENGTH = 4096;
@@ -446,6 +426,16 @@ get_menu_selection(char** headers, char** items, int menu_only,
int key = ui_wait_key();
int visible = ui_text_visible();
+ if (key == -1) { // ui_wait_key() timed out
+ if (ui_text_ever_visible()) {
+ continue;
+ } else {
+ LOGI("timed out waiting for key input; rebooting.\n");
+ ui_end_menu();
+ return ITEM_REBOOT;
+ }
+ }
+
int action = device_handle_key(key, visible);
if (action < 0) {
@@ -700,6 +690,7 @@ main(int argc, char **argv) {
freopen(TEMPORARY_LOG_FILE, "a", stderr); setbuf(stderr, NULL);
printf("Starting recovery on %s", ctime(&start));
+ device_ui_init(&ui_parameters);
ui_init();
ui_set_background(BACKGROUND_ICON_INSTALLING);
load_volume_table();
@@ -708,10 +699,7 @@ main(int argc, char **argv) {
int previous_runs = 0;
const char *send_intent = NULL;
const char *update_package = NULL;
- const char *encrypted_fs_mode = NULL;
int wipe_data = 0, wipe_cache = 0;
- int toggle_secure_fs = 0;
- encrypted_fs_info encrypted_fs_data;
int arg;
while ((arg = getopt_long(argc, argv, "", OPTIONS, NULL)) != -1) {
@@ -721,7 +709,6 @@ main(int argc, char **argv) {
case 'u': update_package = optarg; break;
case 'w': wipe_data = wipe_cache = 1; break;
case 'c': wipe_cache = 1; break;
- case 'e': encrypted_fs_mode = optarg; toggle_secure_fs = 1; break;
case 't': ui_show_text(1); break;
case '?':
LOGE("Invalid command argument\n");
@@ -758,43 +745,7 @@ main(int argc, char **argv) {
int status = INSTALL_SUCCESS;
- if (toggle_secure_fs) {
- if (strcmp(encrypted_fs_mode,"on") == 0) {
- encrypted_fs_data.mode = MODE_ENCRYPTED_FS_ENABLED;
- ui_print("Enabling Encrypted FS.\n");
- } else if (strcmp(encrypted_fs_mode,"off") == 0) {
- encrypted_fs_data.mode = MODE_ENCRYPTED_FS_DISABLED;
- ui_print("Disabling Encrypted FS.\n");
- } else {
- ui_print("Error: invalid Encrypted FS setting.\n");
- status = INSTALL_ERROR;
- }
-
- // Recovery strategy: if the data partition is damaged, disable encrypted file systems.
- // This preventsthe device recycling endlessly in recovery mode.
- if ((encrypted_fs_data.mode == MODE_ENCRYPTED_FS_ENABLED) &&
- (read_encrypted_fs_info(&encrypted_fs_data))) {
- ui_print("Encrypted FS change aborted, resetting to disabled state.\n");
- encrypted_fs_data.mode = MODE_ENCRYPTED_FS_DISABLED;
- }
-
- if (status != INSTALL_ERROR) {
- if (erase_volume("/data")) {
- ui_print("Data wipe failed.\n");
- status = INSTALL_ERROR;
- } else if (erase_volume("/cache")) {
- ui_print("Cache wipe failed.\n");
- status = INSTALL_ERROR;
- } else if ((encrypted_fs_data.mode == MODE_ENCRYPTED_FS_ENABLED) &&
- (restore_encrypted_fs_info(&encrypted_fs_data))) {
- ui_print("Encrypted FS change aborted.\n");
- status = INSTALL_ERROR;
- } else {
- ui_print("Successfully updated Encrypted FS.\n");
- status = INSTALL_SUCCESS;
- }
- }
- } else if (update_package != NULL) {
+ if (update_package != NULL) {
status = install_package(update_package);
if (status != INSTALL_SUCCESS) ui_print("Installation aborted.\n");
} else if (wipe_data) {
@@ -817,7 +768,6 @@ main(int argc, char **argv) {
// Otherwise, get ready to boot the main system...
finish_recovery(send_intent);
ui_print("Rebooting...\n");
- sync();
- reboot(RB_AUTOBOOT);
+ android_reboot(ANDROID_RB_RESTART, 0, 0);
return EXIT_SUCCESS;
}