galaxys
This commit is contained in:
parent
92077c15d6
commit
5aaa8238f7
47
Android.mk
47
Android.mk
@ -13,13 +13,27 @@ LOCAL_SRC_FILES := \
|
||||
legacy.c \
|
||||
commands.c \
|
||||
recovery.c \
|
||||
bootloader.c \
|
||||
firmware.c \
|
||||
install.c \
|
||||
roots.c \
|
||||
ui.c \
|
||||
verifier.c
|
||||
|
||||
ifndef BOARD_HAS_NO_MISC_PARTITION
|
||||
LOCAL_SRC_FILES += \
|
||||
firmware.c \
|
||||
bootloader.c
|
||||
else
|
||||
LOCAL_CFLAGS += -DBOARD_HAS_NO_MISC_PARTITION
|
||||
endif
|
||||
|
||||
ifdef BOARD_USES_FFORMAT
|
||||
LOCAL_CFLAGS += -DBOARD_USES_FFORMAT
|
||||
endif
|
||||
|
||||
ifdef BOARD_RECOVERY_IGNORE_BOOTABLES
|
||||
LOCAL_CLFAGS += -DBOARD_RECOVERY_IGNORE_BOOTABLES
|
||||
endif
|
||||
|
||||
LOCAL_SRC_FILES += test_roots.c
|
||||
|
||||
LOCAL_MODULE := recovery
|
||||
@ -27,7 +41,7 @@ LOCAL_MODULE := recovery
|
||||
LOCAL_FORCE_STATIC_EXECUTABLE := true
|
||||
|
||||
RECOVERY_VERSION := ClockworkMod Recovery v2.5.0.1
|
||||
LOCAL_CFLAGS := -DRECOVERY_VERSION="$(RECOVERY_VERSION)"
|
||||
LOCAL_CFLAGS += -DRECOVERY_VERSION="$(RECOVERY_VERSION)"
|
||||
RECOVERY_API_VERSION := 2
|
||||
LOCAL_CFLAGS += -DRECOVERY_API_VERSION=$(RECOVERY_API_VERSION)
|
||||
|
||||
@ -59,6 +73,14 @@ ifdef BOARD_DATA_FILESYSTEM
|
||||
LOCAL_CFLAGS += -DDATA_FILESYSTEM=\"$(BOARD_DATA_FILESYSTEM)\"
|
||||
endif
|
||||
|
||||
ifdef BOARD_DATADATA_DEVICE
|
||||
LOCAL_CFLAGS += -DDATADATA_DEVICE=\"$(BOARD_DATADATA_DEVICE)\"
|
||||
endif
|
||||
|
||||
ifdef BOARD_DATADATA_FILESYSTEM
|
||||
LOCAL_CFLAGS += -DDATADATA_FILESYSTEM=\"$(BOARD_DATADATA_FILESYSTEM)\"
|
||||
endif
|
||||
|
||||
ifdef BOARD_CACHE_DEVICE
|
||||
LOCAL_CFLAGS += -DCACHE_DEVICE=\"$(BOARD_CACHE_DEVICE)\"
|
||||
endif
|
||||
@ -67,6 +89,14 @@ ifdef BOARD_CACHE_FILESYSTEM
|
||||
LOCAL_CFLAGS += -DCACHE_FILESYSTEM=\"$(BOARD_CACHE_FILESYSTEM)\"
|
||||
endif
|
||||
|
||||
ifdef BOARD_SYSTEM_DEVICE
|
||||
LOCAL_CFLAGS += -DSYSTEM_DEVICE=\"$(BOARD_SYSTEM_DEVICE)\"
|
||||
endif
|
||||
|
||||
ifdef BOARD_SYSTEM_FILESYSTEM
|
||||
LOCAL_CFLAGS += -DSYSTEM_FILESYSTEM=\"$(BOARD_SYSTEM_FILESYSTEM)\"
|
||||
endif
|
||||
|
||||
ifdef BOARD_HAS_DATADATA
|
||||
LOCAL_CFLAGS += -DHAS_DATADATA
|
||||
endif
|
||||
@ -93,6 +123,7 @@ LOCAL_STATIC_LIBRARIES += libstdc++ libc
|
||||
include $(BUILD_EXECUTABLE)
|
||||
|
||||
RECOVERY_LINKS := amend busybox flash_image dump_image mkyaffs2image unyaffs erase_image nandroid
|
||||
|
||||
# nc is provided by external/netcat
|
||||
SYMLINKS := $(addprefix $(TARGET_RECOVERY_ROOT_OUT)/sbin/,$(RECOVERY_LINKS))
|
||||
$(SYMLINKS): RECOVERY_BINARY := $(LOCAL_MODULE)
|
||||
@ -132,6 +163,16 @@ LOCAL_MODULE_PATH := $(TARGET_RECOVERY_ROOT_OUT)/sbin
|
||||
LOCAL_SRC_FILES := killrecovery.sh
|
||||
include $(BUILD_PREBUILT)
|
||||
|
||||
ifdef BOARD_USES_FFORMAT
|
||||
include $(CLEAR_VARS)
|
||||
LOCAL_MODULE := fformat
|
||||
LOCAL_MODULE_TAGS := eng
|
||||
LOCAL_MODULE_CLASS := RECOVERY_EXECUTABLES
|
||||
LOCAL_MODULE_PATH := $(TARGET_RECOVERY_ROOT_OUT)/sbin
|
||||
LOCAL_SRC_FILES := prebuilt/fformat
|
||||
include $(BUILD_PREBUILT)
|
||||
endif
|
||||
|
||||
include $(commands_recovery_local_path)/amend/Android.mk
|
||||
include $(commands_recovery_local_path)/minui/Android.mk
|
||||
include $(commands_recovery_local_path)/minzip/Android.mk
|
||||
|
@ -626,11 +626,13 @@ cmd_write_firmware_image(const char *name, void *cookie,
|
||||
return 1;
|
||||
}
|
||||
|
||||
#ifndef BOARD_HAS_NO_MISC_PARTITION
|
||||
if (remember_firmware_update(type, context.data, context.total_bytes)) {
|
||||
LOGE("Can't store %s image\n", type);
|
||||
free(context.data);
|
||||
return 1;
|
||||
}
|
||||
#endif
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
@ -50,10 +50,12 @@ int device_reboot_now(volatile char* key_pressed, int key_code) {
|
||||
int device_handle_key(int key_code, int visible) {
|
||||
if (visible) {
|
||||
switch (key_code) {
|
||||
case KEY_CAPSLOCK:
|
||||
case KEY_DOWN:
|
||||
case KEY_VOLUMEDOWN:
|
||||
return HIGHLIGHT_DOWN;
|
||||
|
||||
case KEY_LEFTSHIFT:
|
||||
case KEY_UP:
|
||||
case KEY_VOLUMEUP:
|
||||
return HIGHLIGHT_UP;
|
||||
@ -65,6 +67,7 @@ int device_handle_key(int key_code, int visible) {
|
||||
if (!get_allow_toggle_display())
|
||||
return GO_BACK;
|
||||
break;
|
||||
case KEY_LEFTBRACE:
|
||||
case KEY_ENTER:
|
||||
case BTN_MOUSE:
|
||||
case KEY_CENTER:
|
||||
|
@ -61,7 +61,9 @@ void toggle_script_asserts()
|
||||
int install_zip(const char* packagefilepath)
|
||||
{
|
||||
ui_print("\n-- Installing: %s\n", packagefilepath);
|
||||
#ifndef BOARD_HAS_NO_MISC_PARTITION
|
||||
set_sdcard_update_bootloader_message();
|
||||
#endif
|
||||
int status = install_package(packagefilepath);
|
||||
ui_reset_progress();
|
||||
if (status != INSTALL_SUCCESS) {
|
||||
@ -69,9 +71,11 @@ int install_zip(const char* packagefilepath)
|
||||
ui_print("Installation aborted.\n");
|
||||
return 1;
|
||||
}
|
||||
#ifndef BOARD_HAS_NO_MISC_PARTITION
|
||||
if (firmware_update_pending()) {
|
||||
ui_print("\nReboot via menu to complete\ninstallation.\n");
|
||||
}
|
||||
#endif
|
||||
ui_set_background(BACKGROUND_ICON_NONE);
|
||||
ui_print("\nInstall from sdcard complete.\n");
|
||||
return 0;
|
||||
|
@ -90,11 +90,13 @@ handle_firmware_update(char* type, char* filename, ZipArchive* zip) {
|
||||
fclose(f);
|
||||
}
|
||||
|
||||
#ifndef BOARD_HAS_NO_MISC_PARTITION
|
||||
if (remember_firmware_update(type, data, data_size)) {
|
||||
LOGE("Can't store %s image\n", type);
|
||||
free(data);
|
||||
return INSTALL_ERROR;
|
||||
}
|
||||
#endif
|
||||
free(filename);
|
||||
|
||||
return INSTALL_SUCCESS;
|
||||
|
@ -5,4 +5,6 @@ rm /cache/update.zip
|
||||
touch /tmp/.ignorebootmessage
|
||||
kill $(ps | grep /sbin/adbd)
|
||||
kill $(ps | grep /sbin/recovery)
|
||||
|
||||
/sbin/recovery
|
||||
exit 1
|
51
nandroid.c
51
nandroid.c
@ -133,6 +133,7 @@ int nandroid_backup(const char* backup_path)
|
||||
sprintf(tmp, "mkdir -p %s", backup_path);
|
||||
__system(tmp);
|
||||
|
||||
#ifndef BOARD_RECOVERY_IGNORE_BOOTABLES
|
||||
ui_print("Backing up boot...\n");
|
||||
sprintf(tmp, "%s/%s", backup_path, "boot.img");
|
||||
ret = dump_image("boot", tmp, NULL);
|
||||
@ -143,7 +144,8 @@ int nandroid_backup(const char* backup_path)
|
||||
sprintf(tmp, "%s/%s", backup_path, "recovery.img");
|
||||
ret = dump_image("recovery", tmp, NULL);
|
||||
if (0 != ret)
|
||||
return print_and_error("Error while dumping boot image!\n");
|
||||
return print_and_error("Error while dumping recovery image!\n");
|
||||
#endif
|
||||
|
||||
if (0 != (ret = nandroid_backup_partition(backup_path, "SYSTEM:")))
|
||||
return ret;
|
||||
@ -198,13 +200,28 @@ int nandroid_backup(const char* backup_path)
|
||||
|
||||
typedef int (*format_function)(char* root);
|
||||
|
||||
static void ensure_directory(const char* dir) {
|
||||
char tmp[PATH_MAX];
|
||||
sprintf(tmp, "mkdir -p %s", dir);
|
||||
__system(tmp);
|
||||
}
|
||||
|
||||
int nandroid_restore_partition_extended(const char* backup_path, const char* root, int umount_when_finished) {
|
||||
int ret = 0;
|
||||
char mount_point[PATH_MAX];
|
||||
translate_root_path(root, mount_point, PATH_MAX);
|
||||
char* name = basename(mount_point);
|
||||
|
||||
char tmp[PATH_MAX];
|
||||
sprintf(tmp, "%s/%s.img", backup_path, name);
|
||||
struct stat file_info;
|
||||
if (0 != (ret = statfs(tmp, &file_info))) {
|
||||
ui_print("%s.img not found. Skipping restore of /sd-ext.", name);
|
||||
return 0;
|
||||
}
|
||||
|
||||
ensure_directory(mount_point);
|
||||
|
||||
unyaffs_callback callback = NULL;
|
||||
if (0 != stat("/sdcard/clockworkmod/.hidenandroidprogress", &file_info)) {
|
||||
callback = yaffs_callback;
|
||||
@ -225,8 +242,6 @@ int nandroid_restore_partition_extended(const char* backup_path, const char* roo
|
||||
return ret;
|
||||
}
|
||||
|
||||
char tmp[PATH_MAX];
|
||||
sprintf(tmp, "%s/%s.img", backup_path, name);
|
||||
if (0 != (ret = unyaffs(tmp, mount_point, callback))) {
|
||||
ui_print("Error while restoring %s!\n", mount_point);
|
||||
return ret;
|
||||
@ -260,6 +275,7 @@ int nandroid_restore(const char* backup_path, int restore_boot, int restore_syst
|
||||
return print_and_error("MD5 mismatch!\n");
|
||||
|
||||
int ret;
|
||||
#ifndef BOARD_RECOVERY_IGNORE_BOOTABLES
|
||||
if (restore_boot)
|
||||
{
|
||||
ui_print("Erasing boot before restore...\n");
|
||||
@ -272,6 +288,7 @@ int nandroid_restore(const char* backup_path, int restore_boot, int restore_syst
|
||||
return ret;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
if (restore_system && 0 != (ret = nandroid_restore_partition(backup_path, "SYSTEM:")))
|
||||
return ret;
|
||||
@ -284,34 +301,14 @@ int nandroid_restore(const char* backup_path, int restore_boot, int restore_syst
|
||||
return ret;
|
||||
#endif
|
||||
|
||||
if (restore_data)
|
||||
{
|
||||
struct statfs s;
|
||||
sprintf(tmp, "%s/.android_secure.img", backup_path);
|
||||
if (0 != (ret = statfs(tmp, &s)))
|
||||
{
|
||||
ui_print(".android_secure.img not found. Skipping restore of applications on external storage.");
|
||||
}
|
||||
else
|
||||
{
|
||||
__system("mkdir -p /sdcard/.android_secure");
|
||||
if (0 != (ret = nandroid_restore_partition_extended(backup_path, "SDCARD:/.android_secure", 0)))
|
||||
return ret;
|
||||
}
|
||||
}
|
||||
if (restore_data && 0 != (ret = nandroid_restore_partition_extended(backup_path, "SDCARD:/.android_secure", 0)))
|
||||
return ret;
|
||||
|
||||
if (restore_cache && 0 != (ret = nandroid_restore_partition_extended(backup_path, "CACHE:", 0)))
|
||||
return ret;
|
||||
|
||||
if (restore_sdext)
|
||||
{
|
||||
struct statfs s;
|
||||
sprintf(tmp, "%s/sd-ext.img", backup_path);
|
||||
if (0 != (ret = statfs(tmp, &s)))
|
||||
ui_print("sd-ext.img not found. Skipping restore of /sd-ext.");
|
||||
else if (0 != (ret = nandroid_restore_partition(backup_path, "SDEXT:")))
|
||||
return ret;
|
||||
}
|
||||
if (restore_sdext && 0 != (ret = nandroid_restore_partition(backup_path, "SDEXT:")))
|
||||
return ret;
|
||||
|
||||
sync();
|
||||
ui_set_background(BACKGROUND_ICON_NONE);
|
||||
|
18
recovery.c
18
recovery.c
@ -157,7 +157,9 @@ static void
|
||||
get_args(int *argc, char ***argv) {
|
||||
struct bootloader_message boot;
|
||||
memset(&boot, 0, sizeof(boot));
|
||||
#ifndef BOARD_HAS_NO_MISC_PARTITION
|
||||
get_bootloader_message(&boot); // this may fail, leaving a zeroed structure
|
||||
#endif
|
||||
|
||||
if (boot.command[0] != 0 && boot.command[0] != 255) {
|
||||
LOGI("Boot command: %.*s\n", sizeof(boot.command), boot.command);
|
||||
@ -214,9 +216,12 @@ get_args(int *argc, char ***argv) {
|
||||
strlcat(boot.recovery, (*argv)[i], sizeof(boot.recovery));
|
||||
strlcat(boot.recovery, "\n", sizeof(boot.recovery));
|
||||
}
|
||||
#ifndef BOARD_HAS_NO_MISC_PARTITION
|
||||
set_bootloader_message(&boot);
|
||||
#endif
|
||||
}
|
||||
|
||||
#ifndef BOARD_HAS_NO_MISC_PARTITION
|
||||
void
|
||||
set_sdcard_update_bootloader_message()
|
||||
{
|
||||
@ -226,6 +231,7 @@ set_sdcard_update_bootloader_message()
|
||||
strlcpy(boot.recovery, "recovery\n", sizeof(boot.recovery));
|
||||
set_bootloader_message(&boot);
|
||||
}
|
||||
#endif
|
||||
|
||||
// clear the recovery command and prepare to boot a (hopefully working) system,
|
||||
// copy our log file to cache as well (for the system to read), and
|
||||
@ -260,10 +266,12 @@ finish_recovery(const char *send_intent)
|
||||
check_and_fclose(log, LOG_FILE);
|
||||
}
|
||||
|
||||
#ifndef BOARD_HAS_NO_MISC_PARTITION
|
||||
// Reset the bootloader message to revert to a normal main system boot.
|
||||
struct bootloader_message boot;
|
||||
memset(&boot, 0, sizeof(boot));
|
||||
set_bootloader_message(&boot);
|
||||
#endif
|
||||
|
||||
// Remove the command file, so recovery won't repeat indefinitely.
|
||||
char path[PATH_MAX] = "";
|
||||
@ -464,7 +472,9 @@ prompt_and_wait()
|
||||
if (confirm_selection("Confirm install?", "Yes - Install /sdcard/update.zip"))
|
||||
{
|
||||
ui_print("\n-- Install from sdcard...\n");
|
||||
#ifndef BOARD_HAS_NO_MISC_PARTITION
|
||||
set_sdcard_update_bootloader_message();
|
||||
#endif
|
||||
int status = install_package(SDCARD_PACKAGE_FILE);
|
||||
if (status != INSTALL_SUCCESS) {
|
||||
ui_set_background(BACKGROUND_ICON_ERROR);
|
||||
@ -472,12 +482,16 @@ prompt_and_wait()
|
||||
} else if (!ui_text_visible()) {
|
||||
return; // reboot if logs aren't visible
|
||||
} else {
|
||||
#ifndef BOARD_HAS_NO_MISC_PARTITION
|
||||
if (firmware_update_pending()) {
|
||||
ui_print("\nReboot via menu to complete\n"
|
||||
"installation.\n");
|
||||
} else {
|
||||
ui_print("\nInstall from sdcard complete.\n");
|
||||
}
|
||||
#else
|
||||
ui_print("\nInstall from sdcard complete.\n");
|
||||
#endif
|
||||
}
|
||||
}
|
||||
break;
|
||||
@ -524,8 +538,8 @@ main(int argc, char **argv)
|
||||
return nandroid_main(argc, argv);
|
||||
return busybox_driver(argc, argv);
|
||||
}
|
||||
create_fstab();
|
||||
__system("/sbin/postrecoveryboot.sh");
|
||||
create_fstab();
|
||||
|
||||
int is_user_initiated_recovery = 0;
|
||||
time_t start = time(NULL);
|
||||
@ -614,8 +628,10 @@ main(int argc, char **argv)
|
||||
if (status != INSTALL_SUCCESS && !is_user_initiated_recovery) ui_set_background(BACKGROUND_ICON_ERROR);
|
||||
if (status != INSTALL_SUCCESS || ui_text_visible()) prompt_and_wait();
|
||||
|
||||
#ifndef BOARD_HAS_NO_MISC_PARTITION
|
||||
// If there is a radio image pending, reboot now to install it.
|
||||
maybe_install_firmware_update(send_intent);
|
||||
#endif
|
||||
|
||||
// Otherwise, get ready to boot the main system...
|
||||
finish_recovery(send_intent);
|
||||
|
10
roots.c
10
roots.c
@ -50,7 +50,7 @@ static RootInfo g_roots[] = {
|
||||
{ "RECOVERY:", g_mtd_device, NULL, "recovery", "/", g_raw },
|
||||
{ "SDCARD:", SDCARD_DEVICE_PRIMARY, SDCARD_DEVICE_SECONDARY, NULL, "/sdcard", "vfat" },
|
||||
{ "SDEXT:", SDEXT_DEVICE, NULL, NULL, "/sd-ext", SDEXT_FILESYSTEM },
|
||||
{ "SYSTEM:", g_mtd_device, NULL, "system", "/system", "yaffs2" },
|
||||
{ "SYSTEM:", SYSTEM_DEVICE, NULL, "system", "/system", SYSTEM_FILESYSTEM },
|
||||
{ "MBM:", g_mtd_device, NULL, "mbm", NULL, g_raw },
|
||||
{ "TMP:", NULL, NULL, NULL, "/tmp", NULL },
|
||||
};
|
||||
@ -378,5 +378,13 @@ format_root_device(const char *root)
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef BOARD_USES_FFORMAT
|
||||
if (info->filesystem != NULL && strcmp("rfs", info->filesystem) == 0) {
|
||||
char cmd[PATH_MAX];
|
||||
sprintf("/sbin/fformat %s", info->device);
|
||||
return __system(cmd);
|
||||
}
|
||||
#endif
|
||||
|
||||
return format_non_mtd_device(root);
|
||||
}
|
||||
|
8
roots.h
8
roots.h
@ -60,6 +60,14 @@
|
||||
#define CACHE_FILESYSTEM "yaffs2"
|
||||
#endif
|
||||
|
||||
#ifndef SYSTEM_DEVICE
|
||||
#define SYSTEM_DEVICE g_mtd_device
|
||||
#endif
|
||||
|
||||
#ifndef SYSTEM_FILESYSTEM
|
||||
#define SYSTEM_FILESYSTEM "yaffs2"
|
||||
#endif
|
||||
|
||||
/* Any of the "root_path" arguments can be paths with relative
|
||||
* components, like "SYSTEM:a/b/c".
|
||||
*/
|
||||
|
Loading…
Reference in New Issue
Block a user