Skip to content

Commit 5aaa823

Browse files
committed
galaxys
1 parent 92077c1 commit 5aaa823

10 files changed

+115
-32
lines changed

Android.mk

+44-3
Original file line numberDiff line numberDiff line change
@@ -13,21 +13,35 @@ LOCAL_SRC_FILES := \
1313
legacy.c \
1414
commands.c \
1515
recovery.c \
16-
bootloader.c \
17-
firmware.c \
1816
install.c \
1917
roots.c \
2018
ui.c \
2119
verifier.c
2220

21+
ifndef BOARD_HAS_NO_MISC_PARTITION
22+
LOCAL_SRC_FILES += \
23+
firmware.c \
24+
bootloader.c
25+
else
26+
LOCAL_CFLAGS += -DBOARD_HAS_NO_MISC_PARTITION
27+
endif
28+
29+
ifdef BOARD_USES_FFORMAT
30+
LOCAL_CFLAGS += -DBOARD_USES_FFORMAT
31+
endif
32+
33+
ifdef BOARD_RECOVERY_IGNORE_BOOTABLES
34+
LOCAL_CLFAGS += -DBOARD_RECOVERY_IGNORE_BOOTABLES
35+
endif
36+
2337
LOCAL_SRC_FILES += test_roots.c
2438

2539
LOCAL_MODULE := recovery
2640

2741
LOCAL_FORCE_STATIC_EXECUTABLE := true
2842

2943
RECOVERY_VERSION := ClockworkMod Recovery v2.5.0.1
30-
LOCAL_CFLAGS := -DRECOVERY_VERSION="$(RECOVERY_VERSION)"
44+
LOCAL_CFLAGS += -DRECOVERY_VERSION="$(RECOVERY_VERSION)"
3145
RECOVERY_API_VERSION := 2
3246
LOCAL_CFLAGS += -DRECOVERY_API_VERSION=$(RECOVERY_API_VERSION)
3347

@@ -59,6 +73,14 @@ ifdef BOARD_DATA_FILESYSTEM
5973
LOCAL_CFLAGS += -DDATA_FILESYSTEM=\"$(BOARD_DATA_FILESYSTEM)\"
6074
endif
6175

76+
ifdef BOARD_DATADATA_DEVICE
77+
LOCAL_CFLAGS += -DDATADATA_DEVICE=\"$(BOARD_DATADATA_DEVICE)\"
78+
endif
79+
80+
ifdef BOARD_DATADATA_FILESYSTEM
81+
LOCAL_CFLAGS += -DDATADATA_FILESYSTEM=\"$(BOARD_DATADATA_FILESYSTEM)\"
82+
endif
83+
6284
ifdef BOARD_CACHE_DEVICE
6385
LOCAL_CFLAGS += -DCACHE_DEVICE=\"$(BOARD_CACHE_DEVICE)\"
6486
endif
@@ -67,6 +89,14 @@ ifdef BOARD_CACHE_FILESYSTEM
6789
LOCAL_CFLAGS += -DCACHE_FILESYSTEM=\"$(BOARD_CACHE_FILESYSTEM)\"
6890
endif
6991

92+
ifdef BOARD_SYSTEM_DEVICE
93+
LOCAL_CFLAGS += -DSYSTEM_DEVICE=\"$(BOARD_SYSTEM_DEVICE)\"
94+
endif
95+
96+
ifdef BOARD_SYSTEM_FILESYSTEM
97+
LOCAL_CFLAGS += -DSYSTEM_FILESYSTEM=\"$(BOARD_SYSTEM_FILESYSTEM)\"
98+
endif
99+
70100
ifdef BOARD_HAS_DATADATA
71101
LOCAL_CFLAGS += -DHAS_DATADATA
72102
endif
@@ -93,6 +123,7 @@ LOCAL_STATIC_LIBRARIES += libstdc++ libc
93123
include $(BUILD_EXECUTABLE)
94124

95125
RECOVERY_LINKS := amend busybox flash_image dump_image mkyaffs2image unyaffs erase_image nandroid
126+
96127
# nc is provided by external/netcat
97128
SYMLINKS := $(addprefix $(TARGET_RECOVERY_ROOT_OUT)/sbin/,$(RECOVERY_LINKS))
98129
$(SYMLINKS): RECOVERY_BINARY := $(LOCAL_MODULE)
@@ -132,6 +163,16 @@ LOCAL_MODULE_PATH := $(TARGET_RECOVERY_ROOT_OUT)/sbin
132163
LOCAL_SRC_FILES := killrecovery.sh
133164
include $(BUILD_PREBUILT)
134165

166+
ifdef BOARD_USES_FFORMAT
167+
include $(CLEAR_VARS)
168+
LOCAL_MODULE := fformat
169+
LOCAL_MODULE_TAGS := eng
170+
LOCAL_MODULE_CLASS := RECOVERY_EXECUTABLES
171+
LOCAL_MODULE_PATH := $(TARGET_RECOVERY_ROOT_OUT)/sbin
172+
LOCAL_SRC_FILES := prebuilt/fformat
173+
include $(BUILD_PREBUILT)
174+
endif
175+
135176
include $(commands_recovery_local_path)/amend/Android.mk
136177
include $(commands_recovery_local_path)/minui/Android.mk
137178
include $(commands_recovery_local_path)/minzip/Android.mk

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

+3
Original file line numberDiff line numberDiff line change
@@ -50,10 +50,12 @@ int device_reboot_now(volatile char* key_pressed, int key_code) {
5050
int device_handle_key(int key_code, int visible) {
5151
if (visible) {
5252
switch (key_code) {
53+
case KEY_CAPSLOCK:
5354
case KEY_DOWN:
5455
case KEY_VOLUMEDOWN:
5556
return HIGHLIGHT_DOWN;
5657

58+
case KEY_LEFTSHIFT:
5759
case KEY_UP:
5860
case KEY_VOLUMEUP:
5961
return HIGHLIGHT_UP;
@@ -65,6 +67,7 @@ int device_handle_key(int key_code, int visible) {
6567
if (!get_allow_toggle_display())
6668
return GO_BACK;
6769
break;
70+
case KEY_LEFTBRACE:
6871
case KEY_ENTER:
6972
case BTN_MOUSE:
7073
case KEY_CENTER:

extendedcommands.c

+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;

install.c

+2
Original file line numberDiff line numberDiff line change
@@ -90,11 +90,13 @@ handle_firmware_update(char* type, char* filename, ZipArchive* zip) {
9090
fclose(f);
9191
}
9292

93+
#ifndef BOARD_HAS_NO_MISC_PARTITION
9394
if (remember_firmware_update(type, data, data_size)) {
9495
LOGE("Can't store %s image\n", type);
9596
free(data);
9697
return INSTALL_ERROR;
9798
}
99+
#endif
98100
free(filename);
99101

100102
return INSTALL_SUCCESS;

killrecovery.sh

+2
Original file line numberDiff line numberDiff line change
@@ -5,4 +5,6 @@ rm /cache/update.zip
55
touch /tmp/.ignorebootmessage
66
kill $(ps | grep /sbin/adbd)
77
kill $(ps | grep /sbin/recovery)
8+
9+
/sbin/recovery
810
exit 1

nandroid.c

+24-27
Original file line numberDiff line numberDiff line change
@@ -133,6 +133,7 @@ int nandroid_backup(const char* backup_path)
133133
sprintf(tmp, "mkdir -p %s", backup_path);
134134
__system(tmp);
135135

136+
#ifndef BOARD_RECOVERY_IGNORE_BOOTABLES
136137
ui_print("Backing up boot...\n");
137138
sprintf(tmp, "%s/%s", backup_path, "boot.img");
138139
ret = dump_image("boot", tmp, NULL);
@@ -143,7 +144,8 @@ int nandroid_backup(const char* backup_path)
143144
sprintf(tmp, "%s/%s", backup_path, "recovery.img");
144145
ret = dump_image("recovery", tmp, NULL);
145146
if (0 != ret)
146-
return print_and_error("Error while dumping boot image!\n");
147+
return print_and_error("Error while dumping recovery image!\n");
148+
#endif
147149

148150
if (0 != (ret = nandroid_backup_partition(backup_path, "SYSTEM:")))
149151
return ret;
@@ -198,13 +200,28 @@ int nandroid_backup(const char* backup_path)
198200

199201
typedef int (*format_function)(char* root);
200202

203+
static void ensure_directory(const char* dir) {
204+
char tmp[PATH_MAX];
205+
sprintf(tmp, "mkdir -p %s", dir);
206+
__system(tmp);
207+
}
208+
201209
int nandroid_restore_partition_extended(const char* backup_path, const char* root, int umount_when_finished) {
202210
int ret = 0;
203211
char mount_point[PATH_MAX];
204212
translate_root_path(root, mount_point, PATH_MAX);
205213
char* name = basename(mount_point);
206214

215+
char tmp[PATH_MAX];
216+
sprintf(tmp, "%s/%s.img", backup_path, name);
207217
struct stat file_info;
218+
if (0 != (ret = statfs(tmp, &file_info))) {
219+
ui_print("%s.img not found. Skipping restore of /sd-ext.", name);
220+
return 0;
221+
}
222+
223+
ensure_directory(mount_point);
224+
208225
unyaffs_callback callback = NULL;
209226
if (0 != stat("/sdcard/clockworkmod/.hidenandroidprogress", &file_info)) {
210227
callback = yaffs_callback;
@@ -225,8 +242,6 @@ int nandroid_restore_partition_extended(const char* backup_path, const char* roo
225242
return ret;
226243
}
227244

228-
char tmp[PATH_MAX];
229-
sprintf(tmp, "%s/%s.img", backup_path, name);
230245
if (0 != (ret = unyaffs(tmp, mount_point, callback))) {
231246
ui_print("Error while restoring %s!\n", mount_point);
232247
return ret;
@@ -260,6 +275,7 @@ int nandroid_restore(const char* backup_path, int restore_boot, int restore_syst
260275
return print_and_error("MD5 mismatch!\n");
261276

262277
int ret;
278+
#ifndef BOARD_RECOVERY_IGNORE_BOOTABLES
263279
if (restore_boot)
264280
{
265281
ui_print("Erasing boot before restore...\n");
@@ -272,6 +288,7 @@ int nandroid_restore(const char* backup_path, int restore_boot, int restore_syst
272288
return ret;
273289
}
274290
}
291+
#endif
275292

276293
if (restore_system && 0 != (ret = nandroid_restore_partition(backup_path, "SYSTEM:")))
277294
return ret;
@@ -284,34 +301,14 @@ int nandroid_restore(const char* backup_path, int restore_boot, int restore_syst
284301
return ret;
285302
#endif
286303

287-
if (restore_data)
288-
{
289-
struct statfs s;
290-
sprintf(tmp, "%s/.android_secure.img", backup_path);
291-
if (0 != (ret = statfs(tmp, &s)))
292-
{
293-
ui_print(".android_secure.img not found. Skipping restore of applications on external storage.");
294-
}
295-
else
296-
{
297-
__system("mkdir -p /sdcard/.android_secure");
298-
if (0 != (ret = nandroid_restore_partition_extended(backup_path, "SDCARD:/.android_secure", 0)))
299-
return ret;
300-
}
301-
}
304+
if (restore_data && 0 != (ret = nandroid_restore_partition_extended(backup_path, "SDCARD:/.android_secure", 0)))
305+
return ret;
302306

303307
if (restore_cache && 0 != (ret = nandroid_restore_partition_extended(backup_path, "CACHE:", 0)))
304308
return ret;
305309

306-
if (restore_sdext)
307-
{
308-
struct statfs s;
309-
sprintf(tmp, "%s/sd-ext.img", backup_path);
310-
if (0 != (ret = statfs(tmp, &s)))
311-
ui_print("sd-ext.img not found. Skipping restore of /sd-ext.");
312-
else if (0 != (ret = nandroid_restore_partition(backup_path, "SDEXT:")))
313-
return ret;
314-
}
310+
if (restore_sdext && 0 != (ret = nandroid_restore_partition(backup_path, "SDEXT:")))
311+
return ret;
315312

316313
sync();
317314
ui_set_background(BACKGROUND_ICON_NONE);

recovery.c

+17-1
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,9 @@ static void
157157
get_args(int *argc, char ***argv) {
158158
struct bootloader_message boot;
159159
memset(&boot, 0, sizeof(boot));
160+
#ifndef BOARD_HAS_NO_MISC_PARTITION
160161
get_bootloader_message(&boot); // this may fail, leaving a zeroed structure
162+
#endif
161163

162164
if (boot.command[0] != 0 && boot.command[0] != 255) {
163165
LOGI("Boot command: %.*s\n", sizeof(boot.command), boot.command);
@@ -214,9 +216,12 @@ get_args(int *argc, char ***argv) {
214216
strlcat(boot.recovery, (*argv)[i], sizeof(boot.recovery));
215217
strlcat(boot.recovery, "\n", sizeof(boot.recovery));
216218
}
219+
#ifndef BOARD_HAS_NO_MISC_PARTITION
217220
set_bootloader_message(&boot);
221+
#endif
218222
}
219223

224+
#ifndef BOARD_HAS_NO_MISC_PARTITION
220225
void
221226
set_sdcard_update_bootloader_message()
222227
{
@@ -226,6 +231,7 @@ set_sdcard_update_bootloader_message()
226231
strlcpy(boot.recovery, "recovery\n", sizeof(boot.recovery));
227232
set_bootloader_message(&boot);
228233
}
234+
#endif
229235

230236
// clear the recovery command and prepare to boot a (hopefully working) system,
231237
// copy our log file to cache as well (for the system to read), and
@@ -260,10 +266,12 @@ finish_recovery(const char *send_intent)
260266
check_and_fclose(log, LOG_FILE);
261267
}
262268

269+
#ifndef BOARD_HAS_NO_MISC_PARTITION
263270
// Reset the bootloader message to revert to a normal main system boot.
264271
struct bootloader_message boot;
265272
memset(&boot, 0, sizeof(boot));
266273
set_bootloader_message(&boot);
274+
#endif
267275

268276
// Remove the command file, so recovery won't repeat indefinitely.
269277
char path[PATH_MAX] = "";
@@ -464,20 +472,26 @@ prompt_and_wait()
464472
if (confirm_selection("Confirm install?", "Yes - Install /sdcard/update.zip"))
465473
{
466474
ui_print("\n-- Install from sdcard...\n");
475+
#ifndef BOARD_HAS_NO_MISC_PARTITION
467476
set_sdcard_update_bootloader_message();
477+
#endif
468478
int status = install_package(SDCARD_PACKAGE_FILE);
469479
if (status != INSTALL_SUCCESS) {
470480
ui_set_background(BACKGROUND_ICON_ERROR);
471481
ui_print("Installation aborted.\n");
472482
} else if (!ui_text_visible()) {
473483
return; // reboot if logs aren't visible
474484
} else {
485+
#ifndef BOARD_HAS_NO_MISC_PARTITION
475486
if (firmware_update_pending()) {
476487
ui_print("\nReboot via menu to complete\n"
477488
"installation.\n");
478489
} else {
479490
ui_print("\nInstall from sdcard complete.\n");
480491
}
492+
#else
493+
ui_print("\nInstall from sdcard complete.\n");
494+
#endif
481495
}
482496
}
483497
break;
@@ -524,8 +538,8 @@ main(int argc, char **argv)
524538
return nandroid_main(argc, argv);
525539
return busybox_driver(argc, argv);
526540
}
527-
create_fstab();
528541
__system("/sbin/postrecoveryboot.sh");
542+
create_fstab();
529543

530544
int is_user_initiated_recovery = 0;
531545
time_t start = time(NULL);
@@ -614,8 +628,10 @@ main(int argc, char **argv)
614628
if (status != INSTALL_SUCCESS && !is_user_initiated_recovery) ui_set_background(BACKGROUND_ICON_ERROR);
615629
if (status != INSTALL_SUCCESS || ui_text_visible()) prompt_and_wait();
616630

631+
#ifndef BOARD_HAS_NO_MISC_PARTITION
617632
// If there is a radio image pending, reboot now to install it.
618633
maybe_install_firmware_update(send_intent);
634+
#endif
619635

620636
// Otherwise, get ready to boot the main system...
621637
finish_recovery(send_intent);

roots.c

+9-1
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ static RootInfo g_roots[] = {
5050
{ "RECOVERY:", g_mtd_device, NULL, "recovery", "/", g_raw },
5151
{ "SDCARD:", SDCARD_DEVICE_PRIMARY, SDCARD_DEVICE_SECONDARY, NULL, "/sdcard", "vfat" },
5252
{ "SDEXT:", SDEXT_DEVICE, NULL, NULL, "/sd-ext", SDEXT_FILESYSTEM },
53-
{ "SYSTEM:", g_mtd_device, NULL, "system", "/system", "yaffs2" },
53+
{ "SYSTEM:", SYSTEM_DEVICE, NULL, "system", "/system", SYSTEM_FILESYSTEM },
5454
{ "MBM:", g_mtd_device, NULL, "mbm", NULL, g_raw },
5555
{ "TMP:", NULL, NULL, NULL, "/tmp", NULL },
5656
};
@@ -378,5 +378,13 @@ format_root_device(const char *root)
378378
}
379379
}
380380

381+
#ifdef BOARD_USES_FFORMAT
382+
if (info->filesystem != NULL && strcmp("rfs", info->filesystem) == 0) {
383+
char cmd[PATH_MAX];
384+
sprintf("/sbin/fformat %s", info->device);
385+
return __system(cmd);
386+
}
387+
#endif
388+
381389
return format_non_mtd_device(root);
382390
}

0 commit comments

Comments
 (0)