From b9546a8047f5ac3bf0ec8622b391a699e31e87ff Mon Sep 17 00:00:00 2001 From: "Koushik K. Dutta" Date: Sun, 14 Mar 2010 22:42:30 -0700 Subject: [PATCH] Camera and center button now select. Add more mount and unmount options. 1.7.0 --- Android.mk | 2 +- common.h | 1 + default_recovery_ui.c | 5 ++-- extendedcommands.c | 54 ++++++++++++++++++++++++++++++++++++++++++- extendedcommands.h | 8 +------ recovery.c | 5 ++++ recovery_ui.h | 3 +-- 7 files changed, 65 insertions(+), 13 deletions(-) diff --git a/Android.mk b/Android.mk index b08d947..e3cc394 100644 --- a/Android.mk +++ b/Android.mk @@ -26,7 +26,7 @@ LOCAL_MODULE := recovery LOCAL_FORCE_STATIC_EXECUTABLE := true -RECOVERY_API_VERSION := 1.6.9 +RECOVERY_API_VERSION := 1.7.0 LOCAL_CFLAGS += -DRECOVERY_API_VERSION=$(RECOVERY_API_VERSION) # This binary is in the recovery ramdisk, which is otherwise a copy of root. diff --git a/common.h b/common.h index ddc9f68..594f6d6 100644 --- a/common.h +++ b/common.h @@ -34,6 +34,7 @@ void ui_clear_key_queue(); void ui_print(const char *fmt, ...); void ui_reset_text_col(); +void ui_set_show_text(int value); // Display some header text followed by a menu of items, which appears // at the top of the screen (in place of any scrolling ui_print() diff --git a/default_recovery_ui.c b/default_recovery_ui.c index 458c817..0b4bd13 100644 --- a/default_recovery_ui.c +++ b/default_recovery_ui.c @@ -29,8 +29,7 @@ char* MENU_ITEMS[] = { "reboot system now", "install zip from sdcard", "backup", "restore", - "mount /sdcard", - "mount USB storage", + "mount partitions", NULL }; int device_toggle_display(volatile char* key_pressed, int key_code) { @@ -58,6 +57,8 @@ int device_handle_key(int key_code, int visible) { case KEY_ENTER: case BTN_MOUSE: + case KEY_CENTER: + case KEY_CAMERA: return SELECT_ITEM; case KEY_POWER: diff --git a/extendedcommands.c b/extendedcommands.c index c63aa73..e2e2605 100644 --- a/extendedcommands.c +++ b/extendedcommands.c @@ -356,7 +356,7 @@ void show_nandroid_restore_menu() nandroid_restore(file); } -void do_mount_usb_storage() +void show_mount_usb_storage_menu() { system("echo /dev/block/mmcblk0 > /sys/devices/platform/usb_mass_storage/lun0/file"); static char* headers[] = { "USB Mass Storage device", @@ -379,6 +379,58 @@ void do_mount_usb_storage() system("echo 0 > /sys/devices/platform/usb_mass_storage/lun0/enable"); } + +void show_mount_menu() +{ + static char* headers[] = { "Mount and unmount partitions", + "", + NULL + }; + + typedef char* string; + string mounts[3][3] = { + { "mount /system", "unmount /system", "SYSTEM:" }, + { "mount /data", "unmount /data", "DATA:" }, + { "mount /cache", "unmount /cache", "CACHE:" } + }; + + for (;;) + { + int ismounted[3]; + int i; + static string options[5]; + for (i = 0; i < 3; i++) + { + ismounted[i] = is_root_path_mounted(mounts[i][2]); + options[i] = ismounted[i] ? mounts[i][1] : mounts[i][0]; + } + + options[3] = "mount USB storage"; + options[4] = NULL; + + int chosen_item = get_menu_selection(headers, options, 0); + if (chosen_item == GO_BACK) + break; + if (chosen_item == 4) + { + show_mount_usb_storage_menu(); + } + else if (chosen_item < 4) + { + if (ismounted[chosen_item]) + { + if (0 != ensure_root_path_unmounted(mounts[chosen_item][2])) + ui_print("Error unmounting %s!\n", mounts[chosen_item][2]); + } + else + { + if (0 != ensure_root_path_mounted(mounts[chosen_item][2])) + ui_print("Error mounting %s!\n", mounts[chosen_item][2]); + } + } + } +} + #define EXTENDEDCOMMAND_SCRIPT "/cache/recovery/extendedcommand" int extendedcommand_file_exists() diff --git a/extendedcommands.h b/extendedcommands.h index 65b1a7a..d525e65 100644 --- a/extendedcommands.h +++ b/extendedcommands.h @@ -10,12 +10,6 @@ toggle_script_asserts(); void show_choose_zip_menu(); -int -get_allow_toggle_display(); - -void -ui_set_show_text(int value); - int do_nandroid_backup(char* backup_name); @@ -26,7 +20,7 @@ void show_nandroid_restore_menu(); void -do_mount_usb_storage(); +show_mount_menu(); void show_choose_zip_menu(); diff --git a/recovery.c b/recovery.c index a160ce7..cbc2914 100644 --- a/recovery.c +++ b/recovery.c @@ -457,6 +457,10 @@ prompt_and_wait() case ITEM_RESTORE: show_nandroid_restore_menu(); break; + case ITEM_MOUNT: + show_mount_menu(); + break; + /* case ITEM_MOUNT_SDCARD: if (ensure_root_path_mounted("SDCARD:") != 0) { LOGE ("Can't mount /sdcard\n"); @@ -465,6 +469,7 @@ prompt_and_wait() case ITEM_MOUNT_USB: do_mount_usb_storage(); break; + */ } } } diff --git a/recovery_ui.h b/recovery_ui.h index 51f8817..bb22445 100644 --- a/recovery_ui.h +++ b/recovery_ui.h @@ -70,8 +70,7 @@ int device_wipe_data(); #define ITEM_INSTALL_ZIP 4 #define ITEM_BACKUP 5 #define ITEM_RESTORE 6 -#define ITEM_MOUNT_SDCARD 7 -#define ITEM_MOUNT_USB 8 +#define ITEM_MOUNT 7 // Header text to display above the main menu. extern char* MENU_HEADERS[];