Add wipe options

- wipe system
- wipe data
- wipe cache
- wipe dalvik cache
- wipe system and data
- wipe cache and dalvik cache
This commit is contained in:
garwedgess 2013-05-01 20:41:05 +01:00
parent ff8508f635
commit 84f8428085
5 changed files with 134 additions and 53 deletions

View File

@ -22,14 +22,12 @@
char* MENU_HEADERS[] = { NULL }; char* MENU_HEADERS[] = { NULL };
char* MENU_ITEMS[] = { "reboot system now", char* MENU_ITEMS[] = { "Install Zip",
"install zip from sdcard", "Wipe Options",
"install zip from sideload", "Backup and Restore",
"wipe data/factory reset", "Mounts and Storage",
"wipe cache partition", "Advanced",
"backup and restore", "Reboot Options",
"mounts and storage",
"advanced",
NULL }; NULL };
void device_ui_init(UIParameters* ui_parameters) { void device_ui_init(UIParameters* ui_parameters) {

View File

@ -1473,14 +1473,13 @@ void show_advanced_menu()
static char* list[] = { "Aroma File Manager", static char* list[] = { "Aroma File Manager",
"Wipe Battery Stats", "Wipe Battery Stats",
"wipe dalvik cache", "Report Error",
"report error", "Key Test",
"key test", "Show Log",
"show log", "Fix Permissions",
"fix permissions", "Partition SD card",
"partition sdcard", "Partition External SD card",
"partition external sdcard", "Partition Internal SD card",
"partition internal sdcard",
NULL NULL
}; };
@ -1511,24 +1510,11 @@ void show_advanced_menu()
break; break;
} }
case 2: case 2:
if (0 != ensure_path_mounted("/data"))
break;
ensure_path_mounted("/sd-ext");
ensure_path_mounted("/cache");
if (confirm_selection( "Confirm wipe?", "Yes - Wipe Dalvik Cache")) {
__system("rm -r /data/dalvik-cache");
__system("rm -r /cache/dalvik-cache");
__system("rm -r /sd-ext/dalvik-cache");
ui_print("Dalvik Cache wiped.\n");
}
ensure_path_unmounted("/data");
break;
case 3:
handle_failure(1); handle_failure(1);
break; break;
case 4: case 3:
{ {
ui_print("Outputting key codes.\n"); ui_print("Outputting key codes...\n");
ui_print("Go back to end debugging.\n"); ui_print("Go back to end debugging.\n");
int key; int key;
int action; int action;
@ -1541,29 +1527,121 @@ void show_advanced_menu()
while (action != GO_BACK); while (action != GO_BACK);
break; break;
} }
case 5: case 4:
ui_printlogtail(12); ui_printlogtail(12);
break; break;
case 6: case 5:
ensure_path_mounted("/system"); ensure_path_mounted("/system");
ensure_path_mounted("/data"); ensure_path_mounted("/data");
ui_print("Fixing permissions...\n"); ui_print("Fixing permissions...\n");
__system("fix_permissions"); __system("fix_permissions");
ui_print("Done!\n"); ui_print("Done!\n");
break; break;
case 7: case 6:
partition_sdcard("/sdcard"); partition_sdcard("/sdcard");
break; break;
case 8: case 7:
partition_sdcard("/external_sd"); partition_sdcard("/external_sd");
break; break;
case 9: case 8:
partition_sdcard("/emmc"); partition_sdcard("/emmc");
break; break;
} }
} }
} }
void show_wipeall_menu()
{
static char* headers[] = { "Wipe Options",
"",
NULL
};
static char* list[] = { "Wipe System",
"Wipe Data / Factory Reset",
"Wipe Cache",
"Wipe Dalvik Cache",
"Wipe System and Data",
"Wipe Cache and Dalvik Cache",
NULL
};
int chosen_item = get_menu_selection(headers, list, 0, 0);
// if (chosen_item == GO_BACK)
//break;
switch (chosen_item)
{
case 0:
if (confirm_selection("Confirm wipe System ?", "Yes, I will install a new ROM!")) {
{
ui_print("\n-- Wiping system...\n");
erase_volume("/system");
ui_print("\n==Now flash a new ROM!==\n");
}
}
break;
case 1:
{
wipe_data();
}
break;
case 2:
if (confirm_selection("Confirm wipe?", "Yes - Wipe Cache"))
{
ui_print("\n-- Wiping cache...\n");
erase_volume("/cache");
ui_print("Cache wipe complete.\n");
}
break;
case 3:
if (0 != ensure_path_mounted("/data"))
break;
if (confirm_selection( "Confirm wipe?", "Yes - Wipe Dalvik Cache"))
{
ensure_path_mounted("/sd-ext");
ensure_path_mounted("/cache");
ui_print("\n-- Wiping dalvik cache...\n");
__system("rm -r /data/dalvik-cache");
__system("rm -r /cache/dalvik-cache");
__system("rm -r /sd-ext/dalvik-cache");
ui_print("Dalvik cache wipe complete.\n");
}
ensure_path_unmounted("/data");
break;
case 4:
{
if (confirm_selection("Confirm wipe data & system?", "Yes, I will install a new ROM!")) {
ui_print("\n-- Wiping data...\n");
wipe_data();
ui_print("-- Wiping system...\n");
erase_volume("/system");
ui_print("\n==Now flash a new ROM!==\n");
}
break;
}
case 5:
if (0 != ensure_path_mounted("/data"))
break;
if (confirm_selection( "Confirm Wipe?", "Yes - Wipe Cache and Dalvik Cache"))
{
ui_print("\n-- Wiping cache...\n");
erase_volume("/cache");
ensure_path_mounted("/sd-ext");
ensure_path_mounted("/cache");
ui_print("-- Wiping dalvik cache...\n");
__system("rm -r /data/dalvik-cache");
__system("rm -r /cache/dalvik-cache");
__system("rm -r /sd-ext/dalvik-cache");
ui_print("Cache and Dalvik Cache Wiped.\n");
}
ensure_path_unmounted("/data");
break;
}
}
void write_fstab_root(char *path, FILE *file) void write_fstab_root(char *path, FILE *file)
{ {
Volume *vol = volume_for_path(path); Volume *vol = volume_for_path(path);

View File

@ -28,6 +28,9 @@ show_nandroid_menu();
void void
show_partition_menu(); show_partition_menu();
void
show_wipeall_menu();
void void
show_choose_zip_menu(); show_choose_zip_menu();

View File

@ -303,7 +303,7 @@ finish_recovery(const char *send_intent) {
sync(); // For good measure. sync(); // For good measure.
} }
static int /*static*/int //to be able to call it from wipe options
erase_volume(const char *volume) { erase_volume(const char *volume) {
ui_set_background(BACKGROUND_ICON_INSTALLING); ui_set_background(BACKGROUND_ICON_INSTALLING);
ui_show_indeterminate_progress(); ui_show_indeterminate_progress();
@ -629,10 +629,10 @@ update_directory(const char* path, const char* unmount_when_done) {
return result; return result;
} }
static void /*static*/void
wipe_data(int confirm) { wipe_data(int confirm) {
if (confirm) { if (confirm) {
static char** title_headers = NULL; /*static*/char** title_headers = NULL;
if (title_headers == NULL) { if (title_headers == NULL) {
char* headers[] = { "Confirm wipe of all user data?", char* headers[] = { "Confirm wipe of all user data?",
@ -765,6 +765,10 @@ prompt_and_wait() {
show_install_update_menu(); show_install_update_menu();
break; break;
case ITEM_WIPES_ALL:
show_wipeall_menu();
break;
case ITEM_NANDROID: case ITEM_NANDROID:
show_nandroid_menu(); show_nandroid_menu();
break; break;
@ -776,10 +780,6 @@ prompt_and_wait() {
case ITEM_ADVANCED: case ITEM_ADVANCED:
show_advanced_menu(); show_advanced_menu();
break; break;
case ITEM_POWEROFF:
poweroff = 1;
return;
} }
} }
} }

View File

@ -72,17 +72,19 @@ int device_wipe_data();
#define SELECT_ITEM -4 #define SELECT_ITEM -4
#define GO_BACK -5 #define GO_BACK -5
#define ITEM_REBOOT 0 #define ITEM_APPLY_EXT 0
#define ITEM_APPLY_EXT 1 #define ITEM_APPLY_SDCARD 0 // historical synonym for ITEM_APPLY_EXT
#define ITEM_APPLY_SDCARD 1 // historical synonym for ITEM_APPLY_EXT //#define ITEM_APPLY_SIDELOAD 1
#define ITEM_WIPE_DATA 2 #define ITEM_WIPES_ALL 1
#define ITEM_WIPE_CACHE 3 #define ITEM_NANDROID 2
#define ITEM_PARTITION 3
#define ITEM_ADVANCED 4
#define ITEM_REBOOT 5
#define ITEM_WIPE_DATA 6
#define ITEM_WIPE_CACHE 7
// unused in cwr // unused in cwr
#define ITEM_APPLY_CACHE 3 #define ITEM_APPLY_CACHE 7
#define ITEM_NANDROID 4 #define ITEM_POWEROFF 8
#define ITEM_PARTITION 5
#define ITEM_ADVANCED 6
#define ITEM_POWEROFF 7
// Header text to display above the main menu. // Header text to display above the main menu.
extern char* MENU_HEADERS[]; extern char* MENU_HEADERS[];