From fd1579b7c015cc22584a4d9608a11214f5ca540c Mon Sep 17 00:00:00 2001 From: Koushik Dutta Date: Sat, 1 May 2010 12:46:55 -0700 Subject: [PATCH] add Wipe Battery stats. Generate fstab dynamically. --- Android.mk | 10 +++++++++- extendedcommands.c | 11 +++++++++++ extendedcommands.h | 4 ++++ mkfstab.sh | 35 +++++++++++++++++++++++++++++++++++ recovery.c | 2 ++ 5 files changed, 61 insertions(+), 1 deletion(-) create mode 100755 mkfstab.sh diff --git a/Android.mk b/Android.mk index 72e286a..b619675 100644 --- a/Android.mk +++ b/Android.mk @@ -26,7 +26,7 @@ LOCAL_MODULE := recovery LOCAL_FORCE_STATIC_EXECUTABLE := true -RECOVERY_VERSION := ClockworkMod Recovery v1.8.1.2 +RECOVERY_VERSION := ClockworkMod Recovery v1.8.1.3 LOCAL_CFLAGS := -DRECOVERY_VERSION="$(RECOVERY_VERSION)" RECOVERY_API_VERSION := 2 LOCAL_CFLAGS += -DRECOVERY_API_VERSION=$(RECOVERY_API_VERSION) @@ -84,6 +84,14 @@ LOCAL_MODULE_PATH := $(TARGET_RECOVERY_ROOT_OUT)/sbin LOCAL_SRC_FILES := nandroid-md5.sh include $(BUILD_PREBUILT) +include $(CLEAR_VARS) +LOCAL_MODULE := mkfstab.sh +LOCAL_MODULE_TAGS := eng +LOCAL_MODULE_CLASS := RECOVERY_EXECUTABLES +LOCAL_MODULE_PATH := $(TARGET_RECOVERY_ROOT_OUT)/sbin +LOCAL_SRC_FILES := mkfstab.sh +include $(BUILD_PREBUILT) + include $(commands_recovery_local_path)/amend/Android.mk include $(commands_recovery_local_path)/minui/Android.mk include $(commands_recovery_local_path)/minzip/Android.mk diff --git a/extendedcommands.c b/extendedcommands.c index 949b767..3b32c12 100644 --- a/extendedcommands.c +++ b/extendedcommands.c @@ -736,6 +736,13 @@ void show_nandroid_menu() } } +void wipe_battery_stats() +{ + ensure_root_path_mounted("DATA:"); + remove("/data/system/batterystats.bin"); + ensure_root_path_unmounted("DATA:"); +} + void show_advanced_menu() { static char* headers[] = { "Advanced and Debugging Menu", @@ -744,6 +751,7 @@ void show_advanced_menu() }; static char* list[] = { "Reboot Recovery", + "Wipe Battery Stats", "Key Test", NULL }; @@ -759,6 +767,9 @@ void show_advanced_menu() __reboot(LINUX_REBOOT_MAGIC1, LINUX_REBOOT_MAGIC2, LINUX_REBOOT_CMD_RESTART2, "recovery"); break; case 1: + wipe_battery_stats(); + break; + case 2: { ui_print("Outputting key codes.\n"); ui_print("Go back to end debugging.\n"); diff --git a/extendedcommands.h b/extendedcommands.h index 0f958dd..83e5213 100644 --- a/extendedcommands.h +++ b/extendedcommands.h @@ -39,3 +39,7 @@ show_advanced_menu(); int format_non_mtd_device(const char* root); + +void +wipe_battery_stats(); + diff --git a/mkfstab.sh b/mkfstab.sh new file mode 100755 index 0000000..e18c726 --- /dev/null +++ b/mkfstab.sh @@ -0,0 +1,35 @@ +#!/sbin/sh + +rm -f /etc/fstab +cat /proc/mtd | while read mtdentry +do + mtd=$(echo $mtdentry | awk '{print $1}') + mtd=$(echo $mtd | sed s/mtd//) + mtd=$(echo $mtd | sed s/://) + exist=$(ls -l /dev/block/mtdblock$mtd) 2> /dev/null + if [ -z "$exist" ] + then + continue + fi + partition=$(echo $mtdentry | awk '{print $4}') + partition=$(echo $partition | sed s/\"//g) + mount=$partition + type= + if [ "$partition" = "system" ] + then + type=yaffs2 + elif [ "$partition" = "userdata" ] + then + type=yaffs2 + mount=data + elif [ "$partition" == "cache" ] + then + type=yaffs2 + else + continue + fi + + echo "/dev/block/mtdblock$mtd /$mount $type rw" >> /etc/fstab +done +echo "/dev/block/mmcblk0p1" /sdcard vfat rw >> /etc/fstab +echo "/dev/block/mmbblk0p2" /sd-ext vfat rw >> /etc/fstab diff --git a/recovery.c b/recovery.c index 6972564..70d165c 100644 --- a/recovery.c +++ b/recovery.c @@ -483,6 +483,8 @@ main(int argc, char **argv) return amend_main(argc, argv); return busybox_driver(argc, argv); } + __system("/sbin/mkfstab.sh"); + int is_user_initiated_recovery = 0; time_t start = time(NULL);