usb mass storage support. user initiated recovery is now user friendly.

This commit is contained in:
Koushik K. Dutta 2010-02-26 14:14:23 -08:00
parent ea2f2428a1
commit 0317378bf6
6 changed files with 43 additions and 7 deletions

View File

@ -29,7 +29,8 @@ char* MENU_ITEMS[] = { "reboot system now",
"install zip from sdcard",
"backup",
"restore",
"mount sdcard",
"mount /sdcard",
"mount USB storage",
NULL };
int device_toggle_display(volatile char* key_pressed, int key_code) {

View File

@ -358,4 +358,26 @@ void show_nandroid_restore_menu()
return;
}
ui_print("Restore complete.\n");
}
void do_mount_usb_storage()
{
system("echo /dev/block/mmcblk0 > /sys/devices/platform/usb_mass_storage/lun0/file");
static char* headers[] = { "USB Mass Storage device",
"Leaving this menu unmount",
"your SD card from your PC.",
"",
NULL
};
static char* list[] = { "Unmount", NULL };
for (;;)
{
int chosen_item = get_menu_selection(headers, list, 0);
if (chosen_item == GO_BACK || chosen_item == 0)
break;
}
system("echo 0 > /sys/devices/platform/usb_mass_storage/lun0/enable");
}

View File

@ -13,11 +13,14 @@ show_choose_zip_menu();
int
get_allow_toggle_display();
int
ui_get_show_menu();
void
ui_set_show_text(int value);
void
do_nandroid_backup();
void
show_nandroid_restore_menu();
show_nandroid_restore_menu();
void
do_mount_usb_storage();

View File

@ -456,6 +456,9 @@ prompt_and_wait()
LOGE ("Can't mount /sdcard\n");
}
break;
case ITEM_MOUNT_USB:
do_mount_usb_storage();
break;
}
}
}
@ -469,6 +472,7 @@ print_property(const char *key, const char *name, void *cookie)
int
main(int argc, char **argv)
{
int is_user_initiated_recovery = 0;
time_t start = time(NULL);
// If these fail, there's not really anywhere to complain...
@ -528,9 +532,14 @@ main(int argc, char **argv)
if (status != INSTALL_SUCCESS) ui_print("Cache wipe failed.\n");
} else {
status = INSTALL_ERROR; // No command specified
// we are starting up in user initiated recovery here
// let's set up some default options
signature_check_enabled = 0;
is_user_initiated_recovery = 1;
ui_set_show_text(1);
}
if (status != INSTALL_SUCCESS) ui_set_background(BACKGROUND_ICON_ERROR);
if (status != INSTALL_SUCCESS && !is_user_initiated_recovery) ui_set_background(BACKGROUND_ICON_ERROR);
if (status != INSTALL_SUCCESS || ui_text_visible()) prompt_and_wait();
// If there is a radio image pending, reboot now to install it.

View File

@ -71,6 +71,7 @@ int device_wipe_data();
#define ITEM_BACKUP 5
#define ITEM_RESTORE 6
#define ITEM_MOUNT_SDCARD 7
#define ITEM_MOUNT_USB 8
// Header text to display above the main menu.
extern char* MENU_HEADERS[];

4
ui.c
View File

@ -553,6 +553,6 @@ void ui_clear_key_queue() {
pthread_mutex_unlock(&key_queue_mutex);
}
void ui_get_show_menu() {
return show_menu;
void ui_set_show_text(int value) {
show_text = value;
}