From 1bf4f695d4784f304d6cac5a1addec31c2f3fdb9 Mon Sep 17 00:00:00 2001 From: Koushik Dutta Date: Wed, 14 Jul 2010 18:37:33 -0700 Subject: [PATCH] allow toggling of software back menu item. add recovery checkpoint file. mount auto now uses busybox mount. --- Android.mk | 2 +- common.h | 3 +++ default_recovery_ui.c | 18 +++++++++--------- extendedcommands.c | 1 + recovery.c | 30 ++++++++++++++++++++++++++---- roots.c | 17 +++++++++++++++-- roots.h | 2 +- ui.c | 30 ++++++++++++++++++++++-------- 8 files changed, 78 insertions(+), 25 deletions(-) diff --git a/Android.mk b/Android.mk index 55f7de7..9ecc2de 100644 --- a/Android.mk +++ b/Android.mk @@ -26,7 +26,7 @@ LOCAL_MODULE := recovery LOCAL_FORCE_STATIC_EXECUTABLE := true -RECOVERY_VERSION := ClockworkMod Recovery v2.0.2.2 +RECOVERY_VERSION := ClockworkMod Recovery v2.0.2.4 LOCAL_CFLAGS := -DRECOVERY_VERSION="$(RECOVERY_VERSION)" RECOVERY_API_VERSION := 2 LOCAL_CFLAGS += -DRECOVERY_API_VERSION=$(RECOVERY_API_VERSION) diff --git a/common.h b/common.h index 81d9029..6c60d07 100644 --- a/common.h +++ b/common.h @@ -47,6 +47,9 @@ int ui_menu_select(int sel); // statements will be displayed. void ui_end_menu(); +int ui_get_showing_back_button(); +void ui_set_showing_back_button(int showBackButton); + // Set the icon (normally the only thing visible besides the progress bar). enum { BACKGROUND_ICON_NONE, diff --git a/default_recovery_ui.c b/default_recovery_ui.c index f189da4..8ee1239 100644 --- a/default_recovery_ui.c +++ b/default_recovery_ui.c @@ -37,11 +37,10 @@ int device_toggle_display(volatile char* key_pressed, int key_code) { if (alt && key_code == KEY_L) return 1; // allow toggling of the display if the correct key is pressed, and the display toggle is allowed or the display is currently off -#ifdef KEY_POWER_IS_SELECT_ITEM - return get_allow_toggle_display() && (key_code == KEY_HOME || key_code == KEY_MENU || key_code == KEY_END); -#else + if (ui_get_showing_back_button()) { + return get_allow_toggle_display() && (key_code == KEY_HOME || key_code == KEY_MENU || key_code == KEY_END); + } return get_allow_toggle_display() && (key_code == KEY_HOME || key_code == KEY_MENU || key_code == KEY_POWER || key_code == KEY_END); -#endif } int device_reboot_now(volatile char* key_pressed, int key_code) { @@ -59,9 +58,13 @@ int device_handle_key(int key_code, int visible) { case KEY_VOLUMEUP: return HIGHLIGHT_UP; -#ifdef KEY_POWER_IS_SELECT_ITEM case KEY_POWER: -#endif + if (ui_get_showing_back_button()) { + return SELECT_ITEM; + } + if (!get_allow_toggle_display()) + return GO_BACK; + break; case KEY_ENTER: case BTN_MOUSE: case KEY_CENTER: @@ -70,9 +73,6 @@ int device_handle_key(int key_code, int visible) { case KEY_SEND: return SELECT_ITEM; -#ifndef KEY_POWER_IS_SELECT_ITEM - case KEY_POWER: -#endif case KEY_END: case KEY_BACKSPACE: case KEY_BACK: diff --git a/extendedcommands.c b/extendedcommands.c index 9310d21..baa72c5 100644 --- a/extendedcommands.c +++ b/extendedcommands.c @@ -627,6 +627,7 @@ int run_and_remove_extendedcommand() char tmp[PATH_MAX]; sprintf(tmp, "cp %s /tmp/%s", EXTENDEDCOMMAND_SCRIPT, basename(EXTENDEDCOMMAND_SCRIPT)); __system(tmp); + __system("rm /sdcard/clockworkmod/.recoverycheckpoint"); remove(EXTENDEDCOMMAND_SCRIPT); int i = 0; for (i = 20; i > 0; i--) { diff --git a/recovery.c b/recovery.c index 344ed46..34e02ab 100644 --- a/recovery.c +++ b/recovery.c @@ -317,12 +317,19 @@ get_menu_selection(char** headers, char** items, int menu_only) { int selected = 0; int chosen_item = -1; + // Some users with dead enter keys need a way to turn on power to select. + // Jiggering across the wrapping menu is one "secret" way to enable it. + // We can't rely on /cache or /sdcard since they may not be available. + int wrap_count = 0; + while (chosen_item < 0 && chosen_item != GO_BACK) { int key = ui_wait_key(); int visible = ui_text_visible(); int action = device_handle_key(key, visible); + int old_selected = selected; + if (action < 0) { switch (action) { case HIGHLIGHT_UP: @@ -335,11 +342,11 @@ get_menu_selection(char** headers, char** items, int menu_only) { break; case SELECT_ITEM: chosen_item = selected; -#ifdef KEY_POWER_IS_SELECT_ITEM - if (chosen_item == item_count) { - chosen_item = GO_BACK; + if (ui_get_showing_back_button()) { + if (chosen_item == item_count) { + chosen_item = GO_BACK; + } } -#endif break; case NO_ACTION: break; @@ -350,6 +357,21 @@ get_menu_selection(char** headers, char** items, int menu_only) { } else if (!menu_only) { chosen_item = action; } + + if (abs(selected - old_selected) > 1) { + wrap_count++; + if (wrap_count == 3) { + wrap_count = 0; + if (ui_get_showing_back_button()) { + ui_print("Back button disabled.\n"); + ui_set_showing_back_button(0); + } + else { + ui_print("Back button enabled.\n"); + ui_set_showing_back_button(1); + } + } + } } ui_end_menu(); diff --git a/roots.c b/roots.c index d54de2d..da10ee7 100644 --- a/roots.c +++ b/roots.c @@ -21,6 +21,8 @@ #include #include +#include + #include "mtdutils/mtdutils.h" #include "mtdutils/mounts.h" #include "minzip/Zip.h" @@ -205,6 +207,18 @@ is_root_path_mounted(const char *root_path) return internal_root_mounted(info) >= 0; } +static int mount_internal(const char* device, const char* mount_point, const char* filesystem) +{ + if (strcmp(filesystem, "auto") != 0) { + return mount(device, mount_point, filesystem, MS_NOATIME | MS_NODEV | MS_NODIRATIME, ""); + } + else { + char mount_cmd[PATH_MAX]; + sprintf(mount_cmd, "mount -onoatime,nodiratime,nodev %s %s", device, mount_point); + return __system(mount_cmd); + } +} + int ensure_root_path_mounted(const char *root_path) { @@ -245,8 +259,7 @@ ensure_root_path_mounted(const char *root_path) } mkdir(info->mount_point, 0755); // in case it doesn't already exist - if (mount(info->device, info->mount_point, info->filesystem, - MS_NOATIME | MS_NODEV | MS_NODIRATIME, "")) { + if (mount_internal(info->device, info->mount_point, info->filesystem)) { if (info->device2 == NULL) { LOGE("Can't mount %s\n(%s)\n", info->device, strerror(errno)); return -1; diff --git a/roots.h b/roots.h index 40aef87..e777093 100644 --- a/roots.h +++ b/roots.h @@ -33,7 +33,7 @@ #endif #ifndef SDEXT_FILESYSTEM -#define SDEXT_FILESYSTEM "ext4" +#define SDEXT_FILESYSTEM "auto" #endif #ifndef DATA_DEVICE diff --git a/ui.c b/ui.c index 2e0ff83..fe56c5d 100644 --- a/ui.c +++ b/ui.c @@ -29,6 +29,12 @@ #include "minui/minui.h" #include "recovery_ui.h" +#ifdef KEY_POWER_IS_SELECT_ITEM +static int gShowBackButton = 1; +#else +static int gShowBackButton = 0; +#endif + #define MAX_COLS 64 #define MAX_ROWS 32 @@ -511,10 +517,11 @@ int ui_start_menu(char** headers, char** items) { strncpy(menu[i] + MENU_ITEM_HEADER_LENGTH, items[i-menu_top], text_cols-1 - MENU_ITEM_HEADER_LENGTH); menu[i][text_cols-1] = '\0'; } -#ifdef KEY_POWER_IS_SELECT_ITEM - strcpy(menu[i], " - +++++Go Back+++++"); - ++i; -#endif + + if (gShowBackButton) { + strcpy(menu[i], " - +++++Go Back+++++"); + ++i; + } menu_items = i - menu_top; show_menu = 1; @@ -522,11 +529,10 @@ int ui_start_menu(char** headers, char** items) { update_screen_locked(); } pthread_mutex_unlock(&gUpdateMutex); -#ifdef KEY_POWER_IS_SELECT_ITEM - return menu_items - 1; -#else + if (gShowBackButton) { + return menu_items - 1; + } return menu_items; -#endif } int ui_menu_select(int sel) { @@ -602,3 +608,11 @@ void ui_clear_key_queue() { void ui_set_show_text(int value) { show_text = value; } + +void ui_set_showing_back_button(int showBackButton) { + gShowBackButton = showBackButton; +} + +int ui_get_showing_back_button() { + return gShowBackButton; +} \ No newline at end of file