예제 #1
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;
}
예제 #2
0
void bootmgr_start(int charger)
{
    settings.default_boot_sd = (char*)malloc(256);
    bootmgr_load_settings();
    bootmgr_init_display();

    bootmgr_set_brightness(settings.brightness);

    int key = 0;
    int8_t last_selected = -1;
    int8_t last_phase = -1;
    uint8_t key_pressed = (settings.timeout_seconds == -1);
    int16_t timer = settings.timeout_seconds*10;
    uint16_t x, y;
    uint8_t touch;
    selected = -1;

    pthread_t t_input;
    pthread_create(&t_input, NULL, bootmgr_input_thread, NULL);
    bootmgr_set_time_thread(1);

    bootmgr_selected = settings.default_boot;

    if(charger && (settings.charger_settings & CHARGER_AUTO_START))
    {
        char status[50];
        bootmgr_get_file(battery_status, status, 50);
        if(strstr(status, "Charging") == status)
        {
            key_pressed = 1;
            bootmgr_charger_init();
        }
    }
    disable_lg_charger = (settings.charger_settings & CHARGER_DISABLE_LG);

    while(bootmgr_run)
    {
        if(last_selected != bootmgr_selected)
        {
            bootmgr_draw();
            last_selected = bootmgr_selected;
        }

        if(last_phase != bootmgr_phase)
        {
            bootmgr_setup_touch();
            bootmgr_draw();
            last_phase = bootmgr_phase;
        }

        key = bootmgr_get_last_key();
        touch = bootmgr_get_last_touch(&x, &y);
        if(key != -1 || touch)
        {
            if(!key_pressed)
            {
                bootmgr_erase_text(25);
                bootmgr_draw();
                key_pressed = 1;
            }

            if(bootmgr_handle_key(key))
                break;

            if(touch && !sleep_mode)
            {
                key = bootmgr_check_touch(x, y);
                if(key & TCALL_EXIT_MGR)
                    break;
            }
        }

        usleep(100000);
        if(!key_pressed)
        {
            if(timer%10 == 0)
            {
                bootmgr_printf(-1, 25, WHITE, "Boot from %s in %us", bootmgr_selected == 0 ? "internal mem" : "SD card", timer/10);
                bootmgr_draw();
            }

            if(--timer <= 0)
            {
                bootmgr_erase_text(25);
                if(bootmgr_selected == 0)
                {
                    bootmgr_boot_internal();
                    break;
                }
                else
                {
                    if(bootmgr_boot_sd_auto())
                        break;
                }
                key_pressed = 1;
            }
        }
    }
    bootmgr_exit();
}
예제 #3
0
void bootmgr_start()
{
    bootmgr_load_settings();
    bootmgr_init_display();

    bootmgr_set_brightness(settings.brightness);

    int key = 0;
    int8_t last_selected = -1;
    int8_t last_phase = -1;
    uint8_t key_pressed = (settings.timeout_seconds == -1);
    int16_t timer = settings.timeout_seconds*10;
    uint16_t x, y;
    uint8_t touch;
    selected = -1;

    pthread_t t_input;
    pthread_create(&t_input, NULL, bootmgr_input_thread, NULL);
    bootmgr_set_time_thread(1);

    while(bootmgr_run)
    {
        if(last_selected != bootmgr_selected)
        {
            bootmgr_draw();
            last_selected = bootmgr_selected;
        }

        if(last_phase != bootmgr_phase)
        {
            bootmgr_setup_touch();
            bootmgr_draw();
            last_phase = bootmgr_phase;
        }

        key = bootmgr_get_last_key();
        touch = bootmgr_get_last_touch(&x, &y);
        if(key != -1 || touch)
        {
            if(!key_pressed)
            {
                bootmgr_erase_text(25);
                bootmgr_draw();
                key_pressed = 1;
            }

            if(bootmgr_handle_key(key))
                break;

            if(touch)
            {
                key = bootmgr_check_touch(x, y);
                if(key & TCALL_EXIT_MGR)
                    break;
            }
        }

        usleep(100000);
        if(!key_pressed)
        {
            if(timer%10 == 0)
            {
                bootmgr_printf(-1, 25, WHITE, "Boot from internal mem in %us", timer/10);
                bootmgr_draw();
            }

            if(--timer <= 0)
            {
                bootmgr_boot_internal();
                break;
            }
        }
    }
    bootmgr_exit();
}