Esempio n. 1
0
void multirom_ui_tab_misc_copy_log(int action)
{
    multirom_dump_status(mrom_status);

    int res = multirom_copy_log(NULL);

    static const char *text[] = { "Failed to copy log to sdcard!", "Successfully copied error log!" };

    active_msgbox = fb_create_msgbox(550*DPI_MUL, 260*DPI_MUL, res ? DRED : CLR_PRIMARY);
    fb_msgbox_add_text(-1, 50*DPI_MUL, SIZE_NORMAL, (char*)text[res+1]);
    if(res == 0)
        fb_msgbox_add_text(-1, -1, SIZE_NORMAL, "/sdcard/multirom/error.txt");
    fb_msgbox_add_text(-1, active_msgbox->h-60*DPI_MUL, SIZE_NORMAL, "Touch anywhere to close");

    fb_draw();
    fb_freeze(1);
    set_touch_handlers_mode(HANDLERS_ALL);
}
Esempio n. 2
0
progdots *progdots_create(int x, int y)
{
    progdots *p = mzalloc(sizeof(progdots));
    p->x = x;
    p->y = y;
    p->switch_timer = SWITCH_SPEED;

    int i;
    for(i = 0; i < PROGDOTS_CNT; ++i)
    {
        p->dots[i] = fb_add_rect(x, y, PROGDOTS_H, PROGDOTS_H, (i == 0 ? CLR_PRIMARY : WHITE));
        x += PROGDOTS_H + (PROGDOTS_W - (PROGDOTS_CNT*PROGDOTS_H))/(PROGDOTS_CNT-1);
    }

    workers_add(progdots_animate, p);

    fb_draw();
    return p;
}
Esempio n. 3
0
int multirom_ui(struct multirom_status *s, struct multirom_rom **to_boot)
{
    if(multirom_init_fb(s->rotation) < 0)
        return UI_EXIT_BOOT_ROM;

    fb_freeze(1);

    mrom_status = s;

    exit_ui_code = -1;
    selected_rom = NULL;
    active_msgbox = NULL;

    multirom_ui_setup_colors(s->colors, &CLR_PRIMARY, &CLR_SECONDARY);
    themes_info = multirom_ui_init_themes();
    if((cur_theme = multirom_ui_select_theme(themes_info, fb_width, fb_height)) == NULL)
    {
        fb_freeze(0);

        ERROR("Couldn't find theme for resolution %dx%d!\n", fb_width, fb_height);
        fb_add_text(0, 0, WHITE, SIZE_SMALL, "Couldn't find theme for resolution %dx%d!\nPress POWER to reboot.", fb_width, fb_height);
        fb_draw();
        fb_clear();
        fb_close();

        start_input_thread();
        while(wait_for_key() != KEY_POWER);
        stop_input_thread();
        return UI_EXIT_REBOOT;
    }

    workers_start();

    multirom_ui_init_header();
    multirom_ui_switch(TAB_INTERNAL);

    add_touch_handler(&multirom_ui_touch_handler, NULL);
    start_input_thread();
    keyaction_enable(1);
    keyaction_set_destroy_msgbox_handle(multirom_ui_destroy_msgbox);

    multirom_set_brightness(s->brightness);

    fb_freeze(0);

    if(s->auto_boot_rom && s->auto_boot_seconds > 0)
        multirom_ui_auto_boot();
    else
        fb_draw();

    while(1)
    {
        pthread_mutex_lock(&exit_code_mutex);
        if(exit_ui_code != -1)
        {
            pthread_mutex_unlock(&exit_code_mutex);
            break;
        }

        if(loop_act & LOOP_UPDATE_USB)
        {
            multirom_find_usb_roms(mrom_status);
            if(themes_info->data->selected_tab == TAB_USB)
                multirom_ui_tab_rom_update_usb(themes_info->data->tab_data);
            loop_act &= ~(LOOP_UPDATE_USB);
        }

        if(loop_act & LOOP_START_PONG)
        {
            loop_act &= ~(LOOP_START_PONG);
            keyaction_enable(0);
            input_push_context();
            fb_push_context();

            pong();

            fb_pop_context();
            input_pop_context();
            keyaction_enable(1);
        }

        if(loop_act & LOOP_CHANGE_CLR)
        {
            fb_freeze(1);

            multirom_ui_setup_colors(s->colors, &CLR_PRIMARY, &CLR_SECONDARY);

            // force redraw tab
            int tab = themes_info->data->selected_tab;
            themes_info->data->selected_tab = -1;

            multirom_ui_destroy_tab(tab);
            multirom_ui_switch(tab);

            fb_freeze(0);
            fb_draw();

            loop_act &= ~(LOOP_CHANGE_CLR);
        }

        pthread_mutex_unlock(&exit_code_mutex);

        usleep(100000);
    }

    keyaction_enable(0);
    keyaction_clear();

    rm_touch_handler(&multirom_ui_touch_handler, NULL);

    fb_create_msgbox(500*DPI_MUL, 250*DPI_MUL, CLR_PRIMARY);

    switch(exit_ui_code)
    {
        case UI_EXIT_BOOT_ROM:
            *to_boot = selected_rom;
            fb_msgbox_add_text(-1, 40*DPI_MUL, SIZE_BIG, "Booting ROM...");
            fb_msgbox_add_text(-1, -1, SIZE_NORMAL, selected_rom->name);
            break;
        case UI_EXIT_REBOOT:
        case UI_EXIT_REBOOT_RECOVERY:
        case UI_EXIT_REBOOT_BOOTLOADER:
            fb_msgbox_add_text(-1, -1, SIZE_BIG, "Rebooting...");
            break;
        case UI_EXIT_SHUTDOWN:
            fb_msgbox_add_text(-1, -1, SIZE_BIG, "Shutting down...");
            break;
    }

    fb_draw();
    fb_freeze(1);

    cur_theme->destroy(themes_info->data);

    int i;
    for(i = 0; i < TAB_COUNT; ++i)
    {
        button_destroy(themes_info->data->tab_btns[i]);
        themes_info->data->tab_btns[i] = NULL;
    }

    stop_input_thread();

    multirom_ui_destroy_tab(themes_info->data->selected_tab);
    multirom_ui_free_themes(themes_info);
    themes_info = NULL;

    workers_stop();

    fb_clear();
#if MR_DEVICE_HOOKS >= 2
    mrom_hook_before_fb_close();
#endif
    fb_close();
    return exit_ui_code;
}
Esempio n. 4
0
void multirom_ui_tab_rom_boot_btn(int action)
{
    if(!themes_info->data->tab_data)
        return;

    tab_data_roms *t = (tab_data_roms*)themes_info->data->tab_data;
    if(!t->list->selected)
        return;

    struct multirom_rom *rom = multirom_get_rom_by_id(mrom_status, t->list->selected->id);
    if(!rom)
        return;

    int m = M(rom->type);
    if(m & MASK_UNSUPPORTED)
    {
        active_msgbox = fb_create_msgbox(550*DPI_MUL, 360*DPI_MUL, DRED);
        fb_msgbox_add_text(-1, 30*DPI_MUL, SIZE_BIG, "Error");
        fb_msgbox_add_text(-1, 90*DPI_MUL, SIZE_NORMAL, "Unsupported ROM type.");
        fb_msgbox_add_text(-1, 180*DPI_MUL, SIZE_NORMAL, "See XDA thread for more info.");
        fb_msgbox_add_text(-1, active_msgbox->h-60*DPI_MUL, SIZE_NORMAL, "Touch anywhere to close");

        fb_draw();
        fb_freeze(1);
        set_touch_handlers_mode(HANDLERS_ALL);
        return;
    }

    if (((m & MASK_KEXEC) || ((m & MASK_ANDROID) && rom->has_bootimg)) &&
        multirom_has_kexec() != 0)
    {
        active_msgbox = fb_create_msgbox(550*DPI_MUL, 360*DPI_MUL, DRED);
        fb_msgbox_add_text(-1, 30*DPI_MUL, SIZE_BIG, "Error");
        fb_msgbox_add_text(-1, 90*DPI_MUL, SIZE_NORMAL, "Kexec-hardboot support");
        fb_msgbox_add_text(-1, 125*DPI_MUL, SIZE_NORMAL, "required to boot this ROM.");
        fb_msgbox_add_text(-1, 180*DPI_MUL, SIZE_NORMAL, "Use kernel with");
        fb_msgbox_add_text(-1, 215*DPI_MUL, SIZE_NORMAL, "kexec-hardboot support.");
        fb_msgbox_add_text(-1, active_msgbox->h-60*DPI_MUL, SIZE_NORMAL, "Touch anywhere to close");

        fb_draw();
        fb_freeze(1);
        set_touch_handlers_mode(HANDLERS_ALL);
        return;
    }

    if((m & MASK_KEXEC) && strchr(rom->name, ' '))
    {
        active_msgbox = fb_create_msgbox(550*DPI_MUL, 360*DPI_MUL, DRED);
        fb_msgbox_add_text(-1, 30*DPI_MUL, SIZE_BIG, "Error");
        fb_msgbox_add_text(-1, 90*DPI_MUL, SIZE_NORMAL, "ROM's name contains spaces");
        fb_msgbox_add_text(-1, 180*DPI_MUL, SIZE_NORMAL, "Remove spaces from ROM's name");
        fb_msgbox_add_text(-1, active_msgbox->h-60*DPI_MUL, SIZE_NORMAL, "Touch anywhere to close");

        fb_draw();
        fb_freeze(1);
        set_touch_handlers_mode(HANDLERS_ALL);
        return;
    }

    pthread_mutex_lock(&exit_code_mutex);
    selected_rom = rom;
    exit_ui_code = UI_EXIT_BOOT_ROM;
    pthread_mutex_unlock(&exit_code_mutex);
}