// runs the program and redirects it's output to the screen using ui_print int graphsh_main(int argc, char** argv) { if (argc>=2) { ui_init(); ui_print(EXPAND(RECOVERY_VERSION)" - script runner\n"); ui_set_show_text(1); FILE* f = popen(argv[1],"r"); char buff[255]; int l; if (!f) { ui_print("Could not open process\n"); sleep(1); gr_exit(); ev_exit(); return -1; } while(fgets(buff,250,f)) { ui_print("%s",buff); } pclose(f); gr_exit(); ev_exit(); return 0; } else { printf("Usage: graphsh command\n command with it's optional parameter(s) must be in quotes.\n"); return -1; } }
int gr_init(void) { gglInit(&gr_context); GGLContext *gl = gr_context; gr_mem_surface.data = NULL; gr_init_font(); gr_vt_fd = open("/dev/tty0", O_RDWR | O_SYNC); if (gr_vt_fd < 0) { gr_vt_fd = open("/dev/tty", O_RDWR | O_SYNC); } if (gr_vt_fd < 0) { // This is non-fatal; post-Cupcake kernels don't have tty0. perror("can't open /dev/tty0"); } else { ioctl(gr_vt_fd, KDGETMODE, &gr_vt_mode); if (ioctl(gr_vt_fd, KDSETMODE, (void*) KD_GRAPHICS)) { // However, if we do open tty0, we expect the ioctl to work. perror("failed KDSETMODE to KD_GRAPHICS on tty0"); gr_exit(); return -1; } } gr_fb_fd = get_framebuffer(gr_framebuffer); if (gr_fb_fd < 0) { perror("unable to get framebuffer"); gr_exit(); return -1; } get_memory_surface(&gr_mem_surface); fprintf(stderr, "framebuffer: fd %d (%d x %d)\n", gr_fb_fd, gr_framebuffer[0].width, gr_framebuffer[0].height); /* start with 0 as front (displayed) and 1 as back (drawing) */ gr_active_fb = 0; set_active_framebuffer(0); gl->colorBuffer(gl, &gr_mem_surface); gl->activeTexture(gl, 0); gl->enable(gl, GGL_BLEND); gl->blendFunc(gl, GGL_SRC_ALPHA, GGL_ONE_MINUS_SRC_ALPHA); gr_fb_blank(true); gr_fb_blank(false); return 0; }
int gr_init(void) { gglInit(&gr_context); GGLContext *gl = gr_context; gr_init_font(); gr_vt_fd = open("/dev/tty0", O_RDWR | O_SYNC); if (gr_vt_fd < 0) { // This is non-fatal; post-Cupcake kernels don't have tty0. } else if (ioctl(gr_vt_fd, KDSETMODE, (void*) KD_GRAPHICS)) { // However, if we do open tty0, we expect the ioctl to work. perror("failed KDSETMODE to KD_GRAPHICS on tty0"); gr_exit(); return -1; } gr_fb_fd = get_framebuffer(gr_framebuffer); if (gr_fb_fd < 0) { perror("Unable to get framebuffer.\n"); gr_exit(); return -1; } get_memory_surface(&gr_mem_surface); fprintf(stderr, "framebuffer: fd %d (%d x %d)\n", gr_fb_fd, gr_framebuffer[0].width, gr_framebuffer[0].height); /* start with 0 as front (displayed) and 1 as back (drawing) */ gr_active_fb = 0; if (!has_overlay) set_active_framebuffer(0); gl->colorBuffer(gl, &gr_mem_surface); gl->activeTexture(gl, 0); gl->enable(gl, GGL_BLEND); gl->blendFunc(gl, GGL_SRC_ALPHA, GGL_ONE_MINUS_SRC_ALPHA); #ifdef TW_SCREEN_BLANK_ON_BOOT printf("TW_SCREEN_BLANK_ON_BOOT := true\n"); gr_fb_blank(true); gr_fb_blank(false); #endif if (!alloc_ion_mem(fi.line_length * vi.yres)) allocate_overlay(gr_fb_fd, gr_framebuffer); return 0; }
// runs the program and redirects it's output to the screen using ui_print int graphchoice_main(int argc, char** argv) { if (argc>=2) { ui_init(); ui_print(EXPAND(RECOVERY_VERSION)" - choice app\n"); ui_set_show_text(1); ui_reset_progress(); ui_clear_key_queue(); char** headers; char** list; headers = malloc(sizeof(char*)*3); headers[0] = argv[1]; headers[1] = ""; headers[2] = NULL; list = malloc(sizeof(char*)*(argc+2)); list[0] = NULL; list[1] = NULL; int i=2; while (argv[i]) { list[i-2] = argv[i]; list[i-1] = NULL; i++; } int chosen_item = GO_BACK; while (chosen_item == GO_BACK) { chosen_item = get_menu_selection(headers,list,0,0); } gr_exit(); ev_exit(); return chosen_item; } else { printf("Usage: graphchoice question [option1] [option2] [option3] [...].\n"); return -1; } }
int lagfixer_main(int argc, char** argv) { ui_init(); ui_print(EXPAND(RECOVERY_VERSION)" - lagfixer\n"); create_fstab(); ui_set_show_text(1); int res; int opts = 0; if ((argc>=2)&&(strcmp(argv[1],"fr")==0)) { opts=2; } else if ((argc>=2)&&(strcmp(argv[1],"b")==0)) { opts=1; } res = do_lagfix(opts); if (res) { ui_print("Something went wrong while doing the lagfix, sorry.\n"); } else { ui_print("Done. Your device will reboot soon or enter recovery mode to debug.\n"); } sleep(5); gr_exit(); ev_exit(); return 0; }
void ui_final(void) { // evt_exit(); ui_show_text(0); gr_exit(); //ui_free_bitmaps(); }
int gr_fb_test(void) { release_framebuffer(gr_framebuffer); gr_fb_fd = get_framebuffer(gr_framebuffer); if (gr_fb_fd < 0) { led_alert("red", 1); gr_exit(); return -1; } return 0; }
// Exercises many of the gr_*() functions; useful for testing. static void gr_test() { GRSurface** images; int frames; int result = res_create_multi_surface("icon_installing", &frames, &images); if (result < 0) { printf("create surface %d\n", result); gr_exit(); return; } time_t start = time(NULL); int x; for (x = 0; x <= 1200; ++x) { if (x < 400) { gr_color(0, 0, 0, 255); } else { gr_color(0, (x-400)%128, 0, 255); } gr_clear(); gr_color(255, 0, 0, 255); gr_surface frame = images[x%frames]; gr_blit(frame, 0, 0, frame->width, frame->height, x, 0); gr_color(255, 0, 0, 128); gr_fill(400, 150, 600, 350); gr_color(255, 255, 255, 255); gr_text(500, 225, "hello, world!", 0); gr_color(255, 255, 0, 128); gr_text(300+x, 275, "pack my box with five dozen liquor jugs", 1); gr_color(0, 0, 255, 128); gr_fill(gr_draw->width - 200 - x, 300, gr_draw->width - x, 500); gr_draw = gr_backend->flip(gr_backend); } printf("getting end time\n"); time_t end = time(NULL); printf("got end time\n"); printf("start %ld end %ld\n", (long)start, (long)end); if (end > start) { printf("%.2f fps\n", ((double)x) / (end-start)); } }
int gr_init(void) { gr_init_font(); gr_vt_fd = open("/dev/tty0", O_RDWR | O_SYNC); if (gr_vt_fd < 0) { // This is non-fatal; post-Cupcake kernels don't have tty0. perror("can't open /dev/tty0"); } else if (ioctl(gr_vt_fd, KDSETMODE, (void*) KD_GRAPHICS)) { // However, if we do open tty0, we expect the ioctl to work. perror("failed KDSETMODE to KD_GRAPHICS on tty0"); gr_exit(); return -1; } gr_backend = open_adf(); if (gr_backend) { gr_draw = gr_backend->init(gr_backend); if (!gr_draw) { gr_backend->exit(gr_backend); } } if (!gr_draw) { gr_backend = open_fbdev(); gr_draw = gr_backend->init(gr_backend); if (gr_draw == NULL) { return -1; } } overscan_offset_x = gr_draw->width * overscan_percent / 100; overscan_offset_y = gr_draw->height * overscan_percent / 100; gr_flip(); gr_flip(); return 0; }
int main(int argc, char **argv) { int key_code = -1; int input = false; int opt; long int timeout = NEXT_TIMEOUT_MS; int64_t start; while ((opt = getopt(argc, argv, "t:")) != -1) { switch (opt) { case 't': timeout = strtol(optarg, NULL, 0); if (timeout < 0 || timeout >= LONG_MAX) { timeout = NEXT_TIMEOUT_MS; LOGE("invalid timeout %s, defaulting to %ld\n", optarg, timeout); } break; default: return usage(); } } if (optind >= argc) { return usage(); } if (gr_init() == -1 || ev_init(input_cb, &key_code) == -1) { LOGE("failed to initialize minui\n"); return EXIT_FAILURE; } /* display all images except the last one, switch to next image after * timeout or user input */ while (optind < argc - 1) { draw(argv[optind++]); start = android::uptimeMillis(); long int timeout_remaining = timeout; do { if (ev_wait(timeout_remaining) == 0) { ev_dispatch(); if (key_code != -1) { input = true; break; } } timeout_remaining -= android::uptimeMillis() - start; } while (timeout_remaining > 0); }; /* if there was user input while showing the images, display the last * image and wait until the power button is pressed or LAST_TIMEOUT_MS * has elapsed */ if (input) { start = android::uptimeMillis(); draw(argv[optind]); do { if (ev_wait(timeout) == 0) { ev_dispatch(); } if (android::uptimeMillis() - start >= LAST_TIMEOUT_MS) { break; } } while (key_code != KEY_POWER); } clear(); gr_exit(); ev_exit(); return EXIT_SUCCESS; }