Beispiel #1
0
uint8_t bootmgr_toggle_ums(void)
{
    bootmgr_printf(-1, 21, WHITE, "%sabling USB mass storage...", ums_enabled ? "dis" : "en");
    bootmgr_draw();

    sync();

    static const char* gadget_files[] =
    {
        "/sys/devices/platform/msm_hsusb/gadget/lun0/file",
        "/sys/devices/platform/usb_mass_storage/lun0/file",
        NULL
    };

    FILE *f = NULL;

    uint8_t i = 0;
    for(; gadget_files[i] != NULL && f == NULL; ++i)
        f = fopen(gadget_files[i], "w+");

    if(!f)
    {
        bootmgr_erase_text(21);
        return 0;
    }

    if(!ums_enabled)
    {
        bootmgr_toggle_sdcard(1, 1);
        fputs(SD_FAT_BLOCK, f);
        bootmgr_printf(-1, 20, WHITE, "USB mass storage enabled");
        bootmgr_printf(-1, 21, WHITE, "Press \"search\" again to exit");
    }
    else
    {
        fputc(0, f);
        bootmgr_erase_text(20);
        bootmgr_erase_text(21);
        bootmgr_toggle_sdcard(0, 1);
    }
    fclose(f);

    bootmgr_display->bg_img = ums_enabled;
    bootmgr_draw();

    ums_enabled = !ums_enabled;
    return 1;
}
int bootmgr_touch_exit_ums(void)
{
    bootmgr_toggle_ums();
    bootmgr_phase = BOOTMGR_MAIN;
    bootmgr_erase_text(24);
    bootmgr_erase_fill(24);
    return TCALL_DELETE;
}
Beispiel #3
0
void tetris_key(int key)
{
    switch(key)
    {
        case KEY_VOLUMEDOWN:
        {
            if(state & TETRIS_PAUSED)
            {
                bootmgr_erase_text(14);
                bootmgr_erase_text(15);
                bootmgr_erase_fill(1);
                state &= ~(TETRIS_PAUSED);
                state |= TETRIS_STARTED;
            }
            else if(state & TETRIS_STARTED)
            {
                bootmgr_print_fill(11, 14*ISO_CHAR_HEIGHT, 219, 32, BLACK, 1);
                bootmgr_printf(10+((220 - 6*8)/2),  14, WHITE, "Paused");
                bootmgr_printf(10+((220 - 25*8)/2), 15, WHITE, "Press \"VolDown\" to resume");
                bootmgr_draw_fills();
                bootmgr_draw_text();
                fb_update(&fb);
                state &= ~(TETRIS_STARTED);
                state |= TETRIS_PAUSED;
            }
            break;
        }
        case KEY_VOLUMEUP:
            tetris_exit();
            bootmgr_set_time_thread(1);
            break;
        case KEY_HOME:
        {
            if(!(state & TETRIS_STARTED))
            {
                if(state & TETRIS_FINISHED)
                {
                    tetris_clear(0);
                    tetris_set_defaults();
                    bootmgr_erase_text(14);
                    bootmgr_erase_fill(1);
                    tetris_print_score();
                }
                bootmgr_erase_text(15);
                state = (TETRIS_STARTED | TETRIS_SPAWN_NEW);
            }
            else
            {
                pthread_mutex_lock(tetris_draw_mutex);
                tetris_move_piece(TETRIS_DOWN_FAST);
                tetris_draw(0);
                pthread_mutex_unlock(tetris_draw_mutex);
            }
            break;
        }
        case KEY_BACK:
        {
            if(state & TETRIS_STARTED)
            {
                pthread_mutex_lock(tetris_draw_mutex);
                tetris_rotate_piece();
                tetris_draw(0);
                pthread_mutex_unlock(tetris_draw_mutex);
            }
            break;
        }
        case KEY_MENU:
        case KEY_SEARCH:
        {
            if(state & TETRIS_STARTED)
            {
                pthread_mutex_lock(tetris_draw_mutex);
                if(tetris_can_move_piece(key == KEY_MENU ? TETRIS_LEFT : TETRIS_RIGHT))
                    tetris_move_piece(key == KEY_MENU ? TETRIS_LEFT : TETRIS_RIGHT);
                tetris_draw(0);
                pthread_mutex_unlock(tetris_draw_mutex);
            }
            break;
        }
    }
}
Beispiel #4
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();
}
Beispiel #5
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;
}
Beispiel #6
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();
}