Example #1
0
int bootmgr_touch_sd_up()
{
    if(!total_backups)
        return TCALL_NONE;
    if(selected == 2 || (!backups_has_active && selected == 5))
        bootmgr_select(total_backups+4);
    else if(selected == 5)
        bootmgr_select(2);
    else
        bootmgr_select(selected-1);
    bootmgr_draw();
    return TCALL_NONE;
}
Example #2
0
int bootmgr_touch_sd_down(void)
{
    if(!total_backups)
        return TCALL_NONE;
    if(selected == 2 || (!backups_has_active && selected == total_backups+4))
        bootmgr_select(5);
    else if(selected == total_backups+4)
            bootmgr_select(2);
    else
        bootmgr_select(selected+1);
    bootmgr_draw();
    return TCALL_NONE;
}
Example #3
0
uint8_t bootmgr_show_rom_list(void)
{
    bootmgr_set_time_thread(0);
    bootmgr_phase = BOOTMGR_SD_SEL;
    bootmgr_display->bg_img = 0;
    bootmgr_printf(-1, 20, WHITE, "Mounting sd-ext...");
    bootmgr_draw();

    if(!backups_loaded)
    {
        // mknod
        mknod(SD_EXT_BLOCK, (0666 | S_IFBLK), makedev(179, 2));

        //mkdir
        mkdir("/sdroot", (mode_t)0775);
        uid_t uid = decode_uid("system");
        gid_t gid = decode_uid("system");
        chown("/sdroot", uid, gid);

        //mount
        static const char *mount_args[] = { NULL, "ext4", SD_EXT_BLOCK, "/sdroot" };
        int res = do_mount(4, mount_args);
        if(res < 0)
        {
            bootmgr_printf(-1, 20, WHITE, "Failed to mount sd-ext!");
            bootmgr_printf(-1, 21, WHITE, "Press back to return.");
            return 0;
        }

        DIR *dir = opendir("/sdroot/multirom/backup");
        if(dir)
        {
            struct dirent * de = NULL;
            while ((de = readdir(dir)) != NULL)
            {
                if (de->d_name[0] == '.')
                    continue;
                backups[total_backups] = (char*)malloc(128);
                strcpy(backups[total_backups++], de->d_name);

                if(total_backups >= BOOTMGR_BACKUPS_MAX-1)
                    break;
            }
            closedir(dir);
            backups[total_backups] = NULL;
        }
        dir = opendir("/sdroot/multirom/rom");
        if(dir)
            backups_has_active = 1;
    }

    backups_loaded = 1;

    bootmgr_printf(0, 0, (0x3F << 11), "Select ROM to boot. Press back to return");
    if(backups_has_active)
    {
        bootmgr_printf(0, 2, WHITE, "Current active ROM");
        bootmgr_select(2);
    }
    bootmgr_printf(0, 4, (0x3F << 11), "Backup folder:");

    uint16_t i = 0;
    for(; i <= 25 && i < total_backups; ++i)
        bootmgr_printf(0, i + 5, WHITE, "%s", backups[i]);

    if(total_backups)
    {
        if(!backups_has_active)
        {
            bootmgr_printf(-1, 2, WHITE, "No active ROM");
            bootmgr_select(5);
        }
        bootmgr_erase_text(20);
    }
    // Useless to print this, because it will be deleted immediately
    //else if(backups_has_active)
    //    bootmgr_printf(-1, 19, WHITE, "No backups present.");
    else
    {
        bootmgr_printf(-1, 20, WHITE, "No active ROM nor backups present.");
        bootmgr_printf(-1, 21, WHITE, "Press \"back\" to return");
    }

    while(bootmgr_get_last_key() != -1); // clear key queue
    while(bootmgr_get_last_touch(&i, &i));     // clear touch queue
    if(!total_backups && backups_has_active)
        return bootmgr_boot_sd();
    bootmgr_draw();
    return 0;
}