summaryrefslogtreecommitdiffstats
path: root/recovery.c
diff options
context:
space:
mode:
authorDoug Zongker <dougz@android.com>2009-06-09 21:22:33 +0200
committerDoug Zongker <dougz@android.com>2009-06-11 23:50:33 +0200
commitddd6a2865db5c73a4bb9d486f71a8c2f1f96ec69 (patch)
treea991238ca9fd1299d295d6229df882585ca0c659 /recovery.c
parentam 9b9c2114: Merge change 3514 into donut (diff)
downloadandroid_bootable_recovery-ddd6a2865db5c73a4bb9d486f71a8c2f1f96ec69.tar
android_bootable_recovery-ddd6a2865db5c73a4bb9d486f71a8c2f1f96ec69.tar.gz
android_bootable_recovery-ddd6a2865db5c73a4bb9d486f71a8c2f1f96ec69.tar.bz2
android_bootable_recovery-ddd6a2865db5c73a4bb9d486f71a8c2f1f96ec69.tar.lz
android_bootable_recovery-ddd6a2865db5c73a4bb9d486f71a8c2f1f96ec69.tar.xz
android_bootable_recovery-ddd6a2865db5c73a4bb9d486f71a8c2f1f96ec69.tar.zst
android_bootable_recovery-ddd6a2865db5c73a4bb9d486f71a8c2f1f96ec69.zip
Diffstat (limited to 'recovery.c')
-rw-r--r--recovery.c71
1 files changed, 29 insertions, 42 deletions
diff --git a/recovery.c b/recovery.c
index 188d4de69..6c13b9f31 100644
--- a/recovery.c
+++ b/recovery.c
@@ -37,6 +37,7 @@
#include "minui/minui.h"
#include "minzip/DirUtil.h"
#include "roots.h"
+#include "recovery_ui.h"
static const struct option OPTIONS[] = {
{ "send_intent", required_argument, NULL, 's' },
@@ -287,25 +288,7 @@ erase_root(const char *root)
static void
prompt_and_wait()
{
- char* headers[] = { "Android system recovery utility",
- "",
- "Use trackball to highlight;",
- "click to select.",
- "",
- NULL };
-
- // these constants correspond to elements of the items[] list.
-#define ITEM_REBOOT 0
-#define ITEM_APPLY_SDCARD 1
-#define ITEM_WIPE_DATA 2
-#define ITEM_WIPE_CACHE 3
- char* items[] = { "reboot system now [Home+Back]",
- "apply sdcard:update.zip [Alt+S]",
- "wipe data/factory reset [Alt+W]",
- "wipe cache partition",
- NULL };
-
- ui_start_menu(headers, items);
+ ui_start_menu(MENU_HEADERS, MENU_ITEMS);
int selected = 0;
int chosen_item = -1;
@@ -313,29 +296,28 @@ prompt_and_wait()
ui_reset_progress();
for (;;) {
int key = ui_wait_key();
- int alt = ui_key_pressed(KEY_LEFTALT) || ui_key_pressed(KEY_RIGHTALT);
int visible = ui_text_visible();
- if (key == KEY_DREAM_BACK && ui_key_pressed(KEY_DREAM_HOME)) {
- // Wait for the keys to be released, to avoid triggering
- // special boot modes (like coming back into recovery!).
- while (ui_key_pressed(KEY_DREAM_BACK) ||
- ui_key_pressed(KEY_DREAM_HOME)) {
- usleep(1000);
+ int action = device_handle_key(key, visible);
+
+ if (action < 0) {
+ switch (action) {
+ case HIGHLIGHT_UP:
+ --selected;
+ selected = ui_menu_select(selected);
+ break;
+ case HIGHLIGHT_DOWN:
+ ++selected;
+ selected = ui_menu_select(selected);
+ break;
+ case SELECT_ITEM:
+ chosen_item = selected;
+ break;
+ case NO_ACTION:
+ break;
}
- chosen_item = ITEM_REBOOT;
- } else if (alt && key == KEY_W) {
- chosen_item = ITEM_WIPE_DATA;
- } else if (alt && key == KEY_S) {
- chosen_item = ITEM_APPLY_SDCARD;
- } else if ((key == KEY_DOWN || key == KEY_VOLUMEDOWN) && visible) {
- ++selected;
- selected = ui_menu_select(selected);
- } else if ((key == KEY_UP || key == KEY_VOLUMEUP) && visible) {
- --selected;
- selected = ui_menu_select(selected);
- } else if (key == BTN_MOUSE && visible) {
- chosen_item = selected;
+ } else {
+ chosen_item = action;
}
if (chosen_item >= 0) {
@@ -343,6 +325,11 @@ prompt_and_wait()
// on the screen.
ui_end_menu();
+ // device-specific code may take some action here. It may
+ // return one of the core actions handled in the switch
+ // statement below.
+ chosen_item = device_perform_action(chosen_item);
+
switch (chosen_item) {
case ITEM_REBOOT:
return;
@@ -372,8 +359,8 @@ prompt_and_wait()
return; // reboot if logs aren't visible
} else {
if (firmware_update_pending()) {
- ui_print("\nReboot via home+back or menu\n"
- "to complete installation.\n");
+ ui_print("\nReboot via menu to complete\n"
+ "installation.\n");
} else {
ui_print("\nInstall from sdcard complete.\n");
}
@@ -383,7 +370,7 @@ prompt_and_wait()
// if we didn't return from this function to reboot, show
// the menu again.
- ui_start_menu(headers, items);
+ ui_start_menu(MENU_HEADERS, MENU_ITEMS);
selected = 0;
chosen_item = -1;