Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit dc9e87c4 authored by Doug Zongker's avatar Doug Zongker
Browse files

generalize "install from sdcard" to "install from external storage"

Allow sideloading of OTA packages from USB drives that appear as
/dev/block/sda1.

Change-Id: I1908576c24547cd0088475d8c8917699cd906868
parent b4277c25
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -24,7 +24,7 @@ char* MENU_HEADERS[] = { "Android system recovery utility",
                         NULL };

char* MENU_ITEMS[] = { "reboot system now",
                       "apply update from sdcard",
                       "apply update from external storage",
                       "wipe data/factory reset",
                       "wipe cache partition",
                       NULL };
+6 −4
Original line number Diff line number Diff line
@@ -52,7 +52,7 @@ static const struct option OPTIONS[] = {
static const char *COMMAND_FILE = "CACHE:recovery/command";
static const char *INTENT_FILE = "CACHE:recovery/intent";
static const char *LOG_FILE = "CACHE:recovery/log";
static const char *SDCARD_ROOT = "SDCARD:";
static const char *EXT_ROOT = "EXT:";
static const char *TEMPORARY_LOG_FILE = "/tmp/recovery.log";
static const char *SIDELOAD_TEMP_DIR = "TMP:sideload";

@@ -479,7 +479,7 @@ sdcard_directory(const char* root_path) {
    // Mount the sdcard when the package selection menu is enabled so
    // you can "adb push" packages to the sdcard and immediately
    // install them.
    ensure_root_path_mounted(SDCARD_ROOT);
    ensure_root_path_mounted(EXT_ROOT);

    const char* MENU_HEADERS[] = { "Choose a package to install:",
                                   root_path,
@@ -491,6 +491,7 @@ sdcard_directory(const char* root_path) {
    d = opendir(translate_root_path(root_path, path, sizeof(path)));
    if (d == NULL) {
        LOGE("error opening %s: %s\n", path, strerror(errno));
        ensure_root_path_unmounted(EXT_ROOT);
        return 0;
    }

@@ -588,6 +589,7 @@ sdcard_directory(const char* root_path) {
    free(zips);
    free(headers);

    ensure_root_path_unmounted(EXT_ROOT);
    return result;
}

@@ -661,9 +663,9 @@ prompt_and_wait() {
                if (!ui_text_visible()) return;
                break;

            case ITEM_APPLY_SDCARD:
            case ITEM_APPLY_EXT:
                ;
                int status = sdcard_directory(SDCARD_ROOT);
                int status = sdcard_directory(EXT_ROOT);
                if (status >= 0) {
                    if (status != INSTALL_SUCCESS) {
                        ui_set_background(BACKGROUND_ICON_ERROR);
+2 −1
Original line number Diff line number Diff line
@@ -66,7 +66,8 @@ int device_wipe_data();
#define SELECT_ITEM         -4

#define ITEM_REBOOT          0
#define ITEM_APPLY_SDCARD    1
#define ITEM_APPLY_EXT       1
#define ITEM_APPLY_SDCARD    1  // historical synonym for ITEM_APPLY_EXT
#define ITEM_WIPE_DATA       2
#define ITEM_WIPE_CACHE      3

+2 −3
Original line number Diff line number Diff line
@@ -54,7 +54,6 @@ static RootInfo g_roots[] = {
    { "MISC:", g_mtd_device, NULL, "misc", NULL, g_raw },
    { "PACKAGE:", NULL, NULL, NULL, NULL, g_package_file },
    { "RECOVERY:", g_mtd_device, NULL, "recovery", "/", g_raw },
    { "SDCARD:", "/dev/block/mmcblk0p1", "/dev/block/mmcblk0", NULL, "/sdcard", "vfat" },
    { "SYSTEM:", g_mtd_device, NULL, "system", "/system", "yaffs2" },
    { "MBM:", g_mtd_device, NULL, "mbm", NULL, g_raw },
    { "TMP:", NULL, NULL, NULL, "/tmp", g_ramdisk },
@@ -64,16 +63,16 @@ static RootInfo g_roots[] = {
      "/cache", "ext4" },
    { "DATA:", "/dev/block/platform/sdhci-tegra.3/by-name/userdata", NULL, NULL,
      "/data", "ext4" },
    { "EXT:", "/dev/block/sda1", NULL, NULL, "/sdcard", "vfat" },
#else
    { "CACHE:", g_mtd_device, NULL, "cache", "/cache", "yaffs2" },
    { "DATA:", g_mtd_device, NULL, "userdata", "/data", "yaffs2" },
    { "EXT:", "/dev/block/mmcblk0p1", "/dev/block/mmcblk0", NULL, "/sdcard", "vfat" },
#endif

};
#define NUM_ROOTS (sizeof(g_roots) / sizeof(g_roots[0]))

// TODO: for SDCARD:, try /dev/block/mmcblk0 if mmcblk0p1 fails

static const RootInfo *
get_root_info_for_path(const char *root_path)
{