Skip to content

Commit

Permalink
Remove wipe battery stats garbage.
Browse files Browse the repository at this point in the history
Add support for doing a true ext4 format of /data on /data/media devices.

Change-Id: Ie6706989705e4cf90d0be119c7ffc54b2191d198
  • Loading branch information
chirayudesai authored and koush committed Nov 22, 2012
1 parent a2cac12 commit 1606b8a
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 23 deletions.
49 changes: 27 additions & 22 deletions extendedcommands.c
Original file line number Diff line number Diff line change
Expand Up @@ -594,7 +594,11 @@ int confirm_selection(const char* title, const char* confirm)
return 1;

char* confirm_headers[] = { title, " THIS CAN NOT BE UNDONE.", "", NULL };
if (0 == stat("/sdcard/clockworkmod/.one_confirm", &info)) {
int one_confirm = 0 == stat("/sdcard/clockworkmod/.one_confirm", &info);
#ifdef BOARD_TOUCH_RECOVERY
one_confirm = 1;
#endif
if (one_confirm) {
char* items[] = { "No",
confirm, //" Yes -- wipe partition", // [1]
NULL };
Expand Down Expand Up @@ -897,14 +901,28 @@ void show_partition_menu()
options[mountable_volumes + formatable_volumes + 1] = NULL;
}
else {
options[mountable_volumes + formatable_volumes] = NULL;
options[mountable_volumes + formatable_volumes] = "format /data and /data/media (/sdcard)";
options[mountable_volumes + formatable_volumes + 1] = NULL;
}

int chosen_item = get_menu_selection(headers, &options, 0, 0);
if (chosen_item == GO_BACK)
break;
if (chosen_item == (mountable_volumes+formatable_volumes)) {
show_mount_usb_storage_menu();
if (!is_data_media()) {
show_mount_usb_storage_menu();
}
else {
if (!confirm_selection("format /data and /data/media (/sdcard)", confirm))
continue;
handle_data_media_format(1);
ui_print("Formatting /data...\n");
if (0 != format_volume("/data"))
ui_print("Error formatting /data!\n");
else
ui_print("Done.\n");
handle_data_media_format(0);
}
}
else if (chosen_item < mountable_volumes) {
MountMenuEntry* e = &mount_menu[chosen_item];
Expand Down Expand Up @@ -1187,14 +1205,6 @@ void show_nandroid_menu()
}
}

void wipe_battery_stats()
{
ensure_path_mounted("/data");
remove("/data/system/batterystats.bin");
ensure_path_unmounted("/data");
ui_print("Battery Stats wiped.\n");
}

static void partition_sdcard(const char* volume) {
if (!can_partition(volume)) {
ui_print("Can't partition device: %s\n", volume);
Expand Down Expand Up @@ -1273,7 +1283,6 @@ void show_advanced_menu()

static char* list[] = { "reboot recovery",
"wipe dalvik cache",
"wipe battery stats",
"report error",
"key test",
"show log",
Expand Down Expand Up @@ -1318,13 +1327,9 @@ void show_advanced_menu()
ensure_path_unmounted("/data");
break;
case 2:
if (confirm_selection( "Confirm wipe?", "Yes - Wipe Battery Stats"))
wipe_battery_stats();
break;
case 3:
handle_failure(1);
break;
case 4:
case 3:
{
ui_print("Outputting key codes.\n");
ui_print("Go back to end debugging.\n");
Expand All @@ -1339,23 +1344,23 @@ void show_advanced_menu()
while (action != GO_BACK);
break;
}
case 5:
case 4:
ui_printlogtail(12);
break;
case 6:
case 5:
ensure_path_mounted("/system");
ensure_path_mounted("/data");
ui_print("Fixing permissions...\n");
__system("fix_permissions");
ui_print("Done!\n");
break;
case 7:
case 6:
partition_sdcard("/sdcard");
break;
case 8:
case 7:
partition_sdcard("/external_sd");
break;
case 9:
case 8:
partition_sdcard("/emmc");
break;
}
Expand Down
7 changes: 6 additions & 1 deletion roots.c
Original file line number Diff line number Diff line change
Expand Up @@ -341,6 +341,7 @@ int ensure_path_unmounted(const char* path) {
}

extern struct selabel_handle *sehandle;
static int handle_data_media = 0;

int format_volume(const char* volume) {
Volume* v = volume_for_path(volume);
Expand All @@ -356,7 +357,7 @@ int format_volume(const char* volume) {
}
// check to see if /data is being formatted, and if it is /data/media
// Note: the /sdcard check is redundant probably, just being safe.
if (strstr(volume, "/data") == volume && is_data_media()) {
if (strstr(volume, "/data") == volume && is_data_media() && !handle_data_media) {
return format_unknown_device(NULL, volume, NULL);
}
if (strcmp(v->fs_type, "ramdisk") == 0) {
Expand Down Expand Up @@ -415,3 +416,7 @@ int format_volume(const char* volume) {
#endif
return format_unknown_device(v->device, volume, v->fs_type);
}

void handle_data_media_format(int handle) {
handle_data_media = handle;
}
1 change: 1 addition & 0 deletions roots.h
Original file line number Diff line number Diff line change
Expand Up @@ -46,5 +46,6 @@ Volume* get_device_volumes();
int is_data_media();
void setup_data_media();
int is_data_media_volume_path(const char* path);
void handle_data_media_format(int handle);

#endif // RECOVERY_ROOTS_H_

0 comments on commit 1606b8a

Please sign in to comment.