Skip to content

Commit fad25ab

Browse files
committed
merge with eclair recovery
2 parents ef83d3e + 56606a2 commit fad25ab

18 files changed

+1576
-69
lines changed

Android.mk

+70-14
Original file line numberDiff line numberDiff line change
@@ -8,26 +8,44 @@ commands_recovery_local_path := $(LOCAL_PATH)
88
# LOCAL_CPP_EXTENSION := .c
99

1010
LOCAL_SRC_FILES := \
11-
extendedcommands.c \
12-
nandroid.c \
13-
legacy.c \
14-
commands.c \
15-
recovery.c \
16-
bootloader.c \
17-
firmware.c \
18-
install.c \
19-
roots.c \
20-
ui.c \
21-
verifier.c
11+
extendedcommands.c \
12+
nandroid.c \
13+
legacy.c \
14+
commands.c \
15+
recovery.c \
16+
install.c \
17+
roots.c \
18+
ui.c \
19+
verifier.c
20+
21+
LOCAL_SRC_FILES += \
22+
reboot.c \
23+
setprop.c
24+
25+
ifndef BOARD_HAS_NO_MISC_PARTITION
26+
LOCAL_SRC_FILES += \
27+
firmware.c \
28+
bootloader.c
29+
else
30+
LOCAL_CFLAGS += -DBOARD_HAS_NO_MISC_PARTITION
31+
endif
32+
33+
ifdef BOARD_RECOVERY_IGNORE_BOOTABLES
34+
LOCAL_CFLAGS += -DBOARD_RECOVERY_IGNORE_BOOTABLES
35+
endif
36+
37+
ifdef BOARD_HIJACK_RECOVERY_PATH
38+
LOCAL_CFLAGS += -DBOARD_HIJACK_RECOVERY_PATH=\"$(BOARD_HIJACK_RECOVERY_PATH)\"
39+
endif
2240

2341
LOCAL_SRC_FILES += test_roots.c
2442

2543
LOCAL_MODULE := recovery
2644

2745
LOCAL_FORCE_STATIC_EXECUTABLE := true
2846

29-
RECOVERY_VERSION := ClockworkMod Recovery v2.5.0.1
30-
LOCAL_CFLAGS := -DRECOVERY_VERSION="$(RECOVERY_VERSION)"
47+
RECOVERY_VERSION := ClockworkMod Recovery v2.5.0.8
48+
LOCAL_CFLAGS += -DRECOVERY_VERSION="$(RECOVERY_VERSION)"
3149
RECOVERY_API_VERSION := 3
3250
LOCAL_CFLAGS += -DRECOVERY_API_VERSION=$(RECOVERY_API_VERSION)
3351

@@ -59,6 +77,14 @@ ifdef BOARD_DATA_FILESYSTEM
5977
LOCAL_CFLAGS += -DDATA_FILESYSTEM=\"$(BOARD_DATA_FILESYSTEM)\"
6078
endif
6179

80+
ifdef BOARD_DATADATA_DEVICE
81+
LOCAL_CFLAGS += -DDATADATA_DEVICE=\"$(BOARD_DATADATA_DEVICE)\"
82+
endif
83+
84+
ifdef BOARD_DATADATA_FILESYSTEM
85+
LOCAL_CFLAGS += -DDATADATA_FILESYSTEM=\"$(BOARD_DATADATA_FILESYSTEM)\"
86+
endif
87+
6288
ifdef BOARD_CACHE_DEVICE
6389
LOCAL_CFLAGS += -DCACHE_DEVICE=\"$(BOARD_CACHE_DEVICE)\"
6490
endif
@@ -67,10 +93,38 @@ ifdef BOARD_CACHE_FILESYSTEM
6793
LOCAL_CFLAGS += -DCACHE_FILESYSTEM=\"$(BOARD_CACHE_FILESYSTEM)\"
6894
endif
6995

96+
ifdef BOARD_SYSTEM_DEVICE
97+
LOCAL_CFLAGS += -DSYSTEM_DEVICE=\"$(BOARD_SYSTEM_DEVICE)\"
98+
endif
99+
100+
ifdef BOARD_SYSTEM_FILESYSTEM
101+
LOCAL_CFLAGS += -DSYSTEM_FILESYSTEM=\"$(BOARD_SYSTEM_FILESYSTEM)\"
102+
endif
103+
70104
ifdef BOARD_HAS_DATADATA
71105
LOCAL_CFLAGS += -DHAS_DATADATA
72106
endif
73107

108+
ifdef BOARD_DATA_FILESYSTEM_OPTIONS
109+
LOCAL_CFLAGS += -DDATA_FILESYSTEM_OPTIONS=\"$(BOARD_DATA_FILESYSTEM_OPTIONS)\"
110+
endif
111+
112+
ifdef BOARD_DATADATA_FILESYSTEM_OPTIONS
113+
LOCAL_CFLAGS += -DDATADATA_FILESYSTEM_OPTIONS=\"$(BOARD_DATADATA_FILESYSTEM_OPTIONS)\"
114+
endif
115+
116+
ifdef BOARD_CACHE_FILESYSTEM_OPTIONS
117+
LOCAL_CFLAGS += -DCACHE_FILESYSTEM_OPTIONS=\"$(BOARD_CACHE_FILESYSTEM_OPTIONS)\"
118+
endif
119+
120+
ifdef BOARD_SYSTEM_FILESYSTEM_OPTIONS
121+
LOCAL_CFLAGS += -DSYSTEM_FILESYSTEM_OPTIONS=\"$(BOARD_SYSTEM_FILESYSTEM_OPTIONS)\"
122+
endif
123+
124+
ifdef BOARD_HAS_MTD_CACHE
125+
LOCAL_CFLAGS += -DBOARD_HAS_MTD_CACHE
126+
endif
127+
74128
# This binary is in the recovery ramdisk, which is otherwise a copy of root.
75129
# It gets copied there in config/Makefile. LOCAL_MODULE_TAGS suppresses
76130
# a (redundant) copy of the binary in /system/bin for user builds.
@@ -93,7 +147,8 @@ LOCAL_STATIC_LIBRARIES += libstdc++ libc
93147

94148
include $(BUILD_EXECUTABLE)
95149

96-
RECOVERY_LINKS := amend busybox flash_image dump_image mkyaffs2image unyaffs erase_image nandroid
150+
RECOVERY_LINKS := amend busybox flash_image dump_image mkyaffs2image unyaffs erase_image nandroid reboot
151+
97152
# nc is provided by external/netcat
98153
SYMLINKS := $(addprefix $(TARGET_RECOVERY_ROOT_OUT)/sbin/,$(RECOVERY_LINKS))
99154
$(SYMLINKS): RECOVERY_BINARY := $(LOCAL_MODULE)
@@ -156,6 +211,7 @@ include $(commands_recovery_local_path)/tools/Android.mk
156211
include $(commands_recovery_local_path)/edify/Android.mk
157212
include $(commands_recovery_local_path)/updater/Android.mk
158213
include $(commands_recovery_local_path)/applypatch/Android.mk
214+
include $(commands_recovery_local_path)/utilities/Android.mk
159215
commands_recovery_local_path :=
160216

161217
endif # TARGET_ARCH == arm

commands.c

+2
Original file line numberDiff line numberDiff line change
@@ -626,11 +626,13 @@ cmd_write_firmware_image(const char *name, void *cookie,
626626
return 1;
627627
}
628628

629+
#ifndef BOARD_HAS_NO_MISC_PARTITION
629630
if (remember_firmware_update(type, context.data, context.total_bytes)) {
630631
LOGE("Can't store %s image\n", type);
631632
free(context.data);
632633
return 1;
633634
}
635+
#endif
634636

635637
return 0;
636638
}

default_recovery_ui.c

+5-2
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,8 @@ char* MENU_ITEMS[] = { "reboot system now",
2727
"wipe data/factory reset",
2828
"wipe cache partition",
2929
"install zip from sdcard",
30-
"nandroid",
31-
"partitions menu",
30+
"backup and restore",
31+
"mounts and storage",
3232
"advanced",
3333
NULL };
3434

@@ -54,10 +54,12 @@ int device_reboot_now(volatile char* key_pressed, int key_code) {
5454
int device_handle_key(int key_code, int visible) {
5555
if (visible) {
5656
switch (key_code) {
57+
case KEY_CAPSLOCK:
5758
case KEY_DOWN:
5859
case KEY_VOLUMEDOWN:
5960
return HIGHLIGHT_DOWN;
6061

62+
case KEY_LEFTSHIFT:
6163
case KEY_UP:
6264
case KEY_VOLUMEUP:
6365
return HIGHLIGHT_UP;
@@ -69,6 +71,7 @@ int device_handle_key(int key_code, int visible) {
6971
if (!get_allow_toggle_display())
7072
return GO_BACK;
7173
break;
74+
case KEY_LEFTBRACE:
7275
case KEY_ENTER:
7376
case BTN_MOUSE:
7477
case KEY_CENTER:

extendedcommands.c

+71-4
Original file line numberDiff line numberDiff line change
@@ -61,17 +61,21 @@ void toggle_script_asserts()
6161
int install_zip(const char* packagefilepath)
6262
{
6363
ui_print("\n-- Installing: %s\n", packagefilepath);
64+
#ifndef BOARD_HAS_NO_MISC_PARTITION
6465
set_sdcard_update_bootloader_message();
66+
#endif
6567
int status = install_package(packagefilepath);
6668
ui_reset_progress();
6769
if (status != INSTALL_SUCCESS) {
6870
ui_set_background(BACKGROUND_ICON_ERROR);
6971
ui_print("Installation aborted.\n");
7072
return 1;
7173
}
74+
#ifndef BOARD_HAS_NO_MISC_PARTITION
7275
if (firmware_update_pending()) {
7376
ui_print("\nReboot via menu to complete\ninstallation.\n");
7477
}
78+
#endif
7579
ui_set_background(BACKGROUND_ICON_NONE);
7680
ui_print("\nInstall from sdcard complete.\n");
7781
return 0;
@@ -414,6 +418,10 @@ void show_mount_usb_storage_menu()
414418

415419
int confirm_selection(const char* title, const char* confirm)
416420
{
421+
struct stat info;
422+
if (0 == stat("/sdcard/clockworkmod/.no_confirm", &info))
423+
return 1;
424+
417425
char* confirm_headers[] = { title, " THIS CAN NOT BE UNDONE.", "", NULL };
418426
char* items[] = { "No",
419427
"No",
@@ -470,7 +478,7 @@ int format_non_mtd_device(const char* root)
470478

471479
void show_partition_menu()
472480
{
473-
static char* headers[] = { "Mount and unmount partitions",
481+
static char* headers[] = { "Mounts and Storage Menu",
474482
"",
475483
NULL
476484
};
@@ -792,6 +800,8 @@ void show_advanced_menu()
792800
"Wipe Battery Stats",
793801
"Report Error",
794802
"Key Test",
803+
"Partition SD Card",
804+
"Fix Permissions",
795805
NULL
796806
};
797807

@@ -809,9 +819,15 @@ void show_advanced_menu()
809819
{
810820
if (0 != ensure_root_path_mounted("DATA:"))
811821
break;
812-
if (confirm_selection( "Confirm wipe?", "Yes - Wipe Dalvik Cache"))
822+
ensure_root_path_mounted("SDEXT:");
823+
ensure_root_path_mounted("CACHE:");
824+
if (confirm_selection( "Confirm wipe?", "Yes - Wipe Dalvik Cache")) {
813825
__system("rm -r /data/dalvik-cache");
826+
__system("rm -r /cache/dalvik-cache");
827+
__system("rm -r /sd-ext/dalvik-cache");
828+
}
814829
ensure_root_path_unmounted("DATA:");
830+
ui_print("Dalvik Cache wiped.\n");
815831
break;
816832
}
817833
case 2:
@@ -836,6 +852,57 @@ void show_advanced_menu()
836852
ui_print("Key: %d\n", key);
837853
}
838854
while (action != GO_BACK);
855+
break;
856+
}
857+
case 5:
858+
{
859+
static char* ext_sizes[] = { "128M",
860+
"256M",
861+
"512M",
862+
"1024M",
863+
NULL };
864+
865+
static char* swap_sizes[] = { "0M",
866+
"32M",
867+
"64M",
868+
"128M",
869+
"256M",
870+
NULL };
871+
872+
static char* ext_headers[] = { "Ext Size", "", NULL };
873+
static char* swap_headers[] = { "Swap Size", "", NULL };
874+
875+
int ext_size = get_menu_selection(ext_headers, ext_sizes, 0);
876+
if (ext_size == GO_BACK)
877+
continue;
878+
879+
int swap_size = get_menu_selection(swap_headers, swap_sizes, 0);
880+
if (swap_size == GO_BACK)
881+
continue;
882+
883+
char sddevice[256];
884+
const RootInfo *ri = get_root_info_for_path("SDCARD:");
885+
strcpy(sddevice, ri->device);
886+
// we only want the mmcblk, not the partition
887+
sddevice[strlen("/dev/block/mmcblkX")] = NULL;
888+
char cmd[PATH_MAX];
889+
setenv("SDPATH", sddevice, 1);
890+
sprintf(cmd, "sdparted -es %s -ss %s -efs ext3 -s", ext_sizes[ext_size], swap_sizes[swap_size]);
891+
ui_print("Partitioning SD Card... please wait...\n");
892+
if (0 == __system(cmd))
893+
ui_print("Done!\n");
894+
else
895+
ui_print("An error occured while partitioning your SD Card. Please see /tmp/recovery.log for more details.\n");
896+
break;
897+
}
898+
case 6:
899+
{
900+
ensure_root_path_mounted("SYSTEM:");
901+
ensure_root_path_mounted("DATA:");
902+
ui_print("Fixing permissions...\n");
903+
__system("fix_permissions");
904+
ui_print("Done!\n");
905+
break;
839906
}
840907
}
841908
}
@@ -866,7 +933,7 @@ void write_fstab_root(char *root_path, FILE *file)
866933
}
867934

868935
fprintf(file, "%s ", info->mount_point);
869-
fprintf(file, "%s rw\n", info->filesystem);
936+
fprintf(file, "%s %s\n", info->filesystem, info->filesystem_options == NULL ? "rw" : info->filesystem_options);
870937
}
871938

872939
void create_fstab()
@@ -896,5 +963,5 @@ void handle_failure(int ret)
896963
return;
897964
mkdir("/sdcard/clockworkmod", S_IRWXU);
898965
__system("cp /tmp/recovery.log /sdcard/clockworkmod/recovery.log");
899-
ui_print("/tmp/recovery.log was copied to /sdcard/clockworkmod/recovery.log. Please open ROM Manager to report the issue.");
966+
ui_print("/tmp/recovery.log was copied to /sdcard/clockworkmod/recovery.log. Please open ROM Manager to report the issue.\n");
900967
}

install.c

+62
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,68 @@
4242
#define ASSUMED_UPDATE_BINARY_NAME "META-INF/com/google/android/update-binary"
4343
#define PUBLIC_KEYS_FILE "/res/keys"
4444

45+
// The update binary ask us to install a firmware file on reboot. Set
46+
// that up. Takes ownership of type and filename.
47+
static int
48+
handle_firmware_update(char* type, char* filename, ZipArchive* zip) {
49+
unsigned int data_size;
50+
const ZipEntry* entry = NULL;
51+
52+
if (strncmp(filename, "PACKAGE:", 8) == 0) {
53+
entry = mzFindZipEntry(zip, filename+8);
54+
if (entry == NULL) {
55+
LOGE("Failed to find \"%s\" in package", filename+8);
56+
return INSTALL_ERROR;
57+
}
58+
data_size = entry->uncompLen;
59+
} else {
60+
struct stat st_data;
61+
if (stat(filename, &st_data) < 0) {
62+
LOGE("Error stat'ing %s: %s\n", filename, strerror(errno));
63+
return INSTALL_ERROR;
64+
}
65+
data_size = st_data.st_size;
66+
}
67+
68+
LOGI("type is %s; size is %d; file is %s\n",
69+
type, data_size, filename);
70+
71+
char* data = malloc(data_size);
72+
if (data == NULL) {
73+
LOGI("Can't allocate %d bytes for firmware data\n", data_size);
74+
return INSTALL_ERROR;
75+
}
76+
77+
if (entry) {
78+
if (mzReadZipEntry(zip, entry, data, data_size) == false) {
79+
LOGE("Failed to read \"%s\" from package", filename+8);
80+
return INSTALL_ERROR;
81+
}
82+
} else {
83+
FILE* f = fopen(filename, "rb");
84+
if (f == NULL) {
85+
LOGE("Failed to open %s: %s\n", filename, strerror(errno));
86+
return INSTALL_ERROR;
87+
}
88+
if (fread(data, 1, data_size, f) != data_size) {
89+
LOGE("Failed to read firmware data: %s\n", strerror(errno));
90+
return INSTALL_ERROR;
91+
}
92+
fclose(f);
93+
}
94+
95+
#ifndef BOARD_HAS_NO_MISC_PARTITION
96+
if (remember_firmware_update(type, data, data_size)) {
97+
LOGE("Can't store %s image\n", type);
98+
free(data);
99+
return INSTALL_ERROR;
100+
}
101+
#endif
102+
free(filename);
103+
104+
return INSTALL_SUCCESS;
105+
}
106+
45107
// If the package contains an update binary, extract it and run it.
46108
static int
47109
try_update_binary(const char *path, ZipArchive *zip) {

0 commit comments

Comments
 (0)