int get_menu_selection(char** headers, char** items, int menu_only) { // throw away keys pressed previously, so user doesn't // accidentally trigger menu items. ui_clear_key_queue(); ui_start_menu(headers, items); int selected = 0; int chosen_item = -1; while (chosen_item < 0) { int key = ui_wait_key(); int visible = ui_text_visible(); int action = device_handle_key(key, visible); if (action < 0) { switch (action) { case HIGHLIGHT_UP: --selected; selected = ui_menu_select(selected); break; case HIGHLIGHT_DOWN: ++selected; selected = ui_menu_select(selected); break; case SELECT_ITEM: chosen_item = selected; break; case NO_ACTION: break; } if(action == SELECT_BACK) { chosen_item = action; break; } } else if (!menu_only) { chosen_item = action; } } ui_end_menu(); return chosen_item; }
static void prompt_and_wait() { ui_print("\n" "Home+Back - reboot system now\n" "Alt+L - toggle log text display\n" "Alt+S - apply sdcard:update.zip\n" "Alt+W - wipe data/factory reset\n"); for (;;) { finish_recovery(NULL); ui_reset_progress(); int key = ui_wait_key(); int alt = ui_key_pressed(KEY_LEFTALT) || ui_key_pressed(KEY_RIGHTALT); if (key == KEY_DREAM_BACK && ui_key_pressed(KEY_DREAM_HOME)) { // Wait for the keys to be released, to avoid triggering // special boot modes (like coming back into recovery!). while (ui_key_pressed(KEY_DREAM_BACK) || ui_key_pressed(KEY_DREAM_HOME)) { usleep(1000); } break; } else if (alt && key == KEY_W) { ui_print("\n"); erase_root("DATA:"); erase_root("CACHE:"); ui_print("Data wipe complete.\n"); if (!ui_text_visible()) break; } else if (alt && key == KEY_S) { ui_print("\nInstalling from sdcard...\n"); int status = install_package(SDCARD_PACKAGE_FILE); if (status != INSTALL_SUCCESS) { ui_set_background(BACKGROUND_ICON_ERROR); ui_print("Installation aborted.\n"); } else if (!ui_text_visible()) { break; // reboot if logs aren't visible } ui_print("\nPress Home+Back to reboot\n"); } } }
static void* tp_test_monitor_thread(void* ptr) { TestCase* thiz = (TestCase*)ptr; DECLES_PRIV(priv, thiz); int key = 0; int power_key_count = 0; while(priv->ts_success == 0) { key = ui_wait_key(); if (key == POWER_KEYCODE) { power_key_count++; if (power_key_count > 3) { break; } } } priv->force_quit = 1; return NULL; }
int get_menu_selection(char** headers, char** items, int menu_only, int initial_selection) { // throw away keys pressed previously, so user doesn't // accidentally trigger menu items. ui_clear_key_queue(); ui_start_menu(headers, items, initial_selection); int selected = initial_selection; int chosen_item = -1; while (chosen_item < 0) { int key = ui_wait_key(); int visible = ui_text_visible(); int action = device_handle_key(key, visible); if (action < 0) { switch (action) { case HIGHLIGHT_UP: --selected; selected = ui_menu_select(selected); break; case HIGHLIGHT_DOWN: ++selected; selected = ui_menu_select(selected); break; case KEY_POWER: case SELECT_ITEM: chosen_item = selected; break; case UP_A_LEVEL: if (menu_loc_idx != 0) { chosen_item = menu_loc[menu_loc_idx]; } break; case HOME_MENU: if (menu_loc_idx != 0) { go_home = 1; chosen_item = menu_loc[menu_loc_idx]; } break; case MENU_MENU: if (menu_loc_idx == 0) { return 3; } else { go_home = 1; go_menu = 1; chosen_item = menu_loc[menu_loc_idx]; } break; case NO_ACTION: break; } } else if (!menu_only) { chosen_item = action; } } ui_end_menu(); return chosen_item; }
int get_menu_selection(char** headers, char** items, int menu_only, int initial_selection) { // throw away keys pressed previously, so user doesn't // accidentally trigger menu items. ui_clear_key_queue(); int item_count = ui_start_menu(headers, items, initial_selection); int selected = initial_selection; int chosen_item = -1; while (chosen_item < 0 && chosen_item != GO_BACK) { int key = ui_wait_key(); int visible = ui_text_visible(); if (key == -1) { // ui_wait_key() timed out if (ui_text_ever_visible()) { continue; } else { LOGI("timed out waiting for key input; rebooting.\n"); ui_end_menu(); return ITEM_REBOOT; } } else if (key == -2) { return GO_BACK; } int action = ui_handle_key(key, visible); int old_selected = selected; selected = ui_get_selected_item(); if (action < 0) { switch (action) { case HIGHLIGHT_UP: --selected; selected = ui_menu_select(selected); break; case HIGHLIGHT_DOWN: ++selected; selected = ui_menu_select(selected); break; case SELECT_ITEM: chosen_item = selected; if (ui_is_showing_back_button()) { if (chosen_item == item_count) { chosen_item = GO_BACK; } } break; case NO_ACTION: break; case GO_BACK: chosen_item = GO_BACK; break; } } else if (!menu_only) { chosen_item = action; } } ui_end_menu(); ui_clear_key_queue(); return chosen_item; }
void show_advanced_menu() { static char* headers[] = { "Advanced and Debugging Menu", "", NULL }; static char* list[] = { "Reboot Recovery", "Wipe Dalvik Cache", "Wipe Battery Stats", "Report Error", "Key Test", #ifndef BOARD_HAS_SMALL_RECOVERY "Partition SD Card", "Fix Permissions", #ifdef BOARD_HAS_SDCARD_INTERNAL "Partition Internal SD Card", #endif #endif NULL }; for (;;) { int chosen_item = get_menu_selection(headers, list, 0, 0); if (chosen_item == GO_BACK) break; switch (chosen_item) { case 0: __reboot(LINUX_REBOOT_MAGIC1, LINUX_REBOOT_MAGIC2, LINUX_REBOOT_CMD_RESTART2, "recovery"); break; case 1: { if (0 != ensure_path_mounted("/data")) break; ensure_path_mounted("/sd-ext"); ensure_path_mounted("/cache"); if (confirm_selection( "Confirm wipe?", "Yes - Wipe Dalvik Cache")) { __system("rm -r /data/dalvik-cache"); __system("rm -r /cache/dalvik-cache"); __system("rm -r /sd-ext/dalvik-cache"); } ensure_path_unmounted("/data"); ui_print("Dalvik Cache wiped.\n"); break; } case 2: { if (confirm_selection( "Confirm wipe?", "Yes - Wipe Battery Stats")) wipe_battery_stats(); break; } case 3: handle_failure(1); break; case 4: { ui_print("Outputting key codes.\n"); ui_print("Go back to end debugging.\n"); int key; int action; do { key = ui_wait_key(); action = device_handle_key(key, 1); ui_print("Key: %d\n", key); } while (action != GO_BACK); break; } case 5: { static char* ext_sizes[] = { "128M", "256M", "512M", "1024M", "2048M", "4096M", NULL }; static char* swap_sizes[] = { "0M", "32M", "64M", "128M", "256M", NULL }; static char* ext_headers[] = { "Ext Size", "", NULL }; static char* swap_headers[] = { "Swap Size", "", NULL }; int ext_size = get_menu_selection(ext_headers, ext_sizes, 0, 0); if (ext_size == GO_BACK) continue; int swap_size = get_menu_selection(swap_headers, swap_sizes, 0, 0); if (swap_size == GO_BACK) continue; char sddevice[256]; Volume *vol = volume_for_path("/sdcard"); strcpy(sddevice, vol->device); // we only want the mmcblk, not the partition sddevice[strlen("/dev/block/mmcblkX")] = NULL; char cmd[PATH_MAX]; setenv("SDPATH", sddevice, 1); sprintf(cmd, "sdparted -es %s -ss %s -efs ext3 -s", ext_sizes[ext_size], swap_sizes[swap_size]); ui_print("Partitioning SD Card... please wait...\n"); if (0 == __system(cmd)) ui_print("Done!\n"); else ui_print("An error occured while partitioning your SD Card. Please see /tmp/recovery.log for more details.\n"); break; } case 6: { ensure_path_mounted("/system"); ensure_path_mounted("/data"); ui_print("Fixing permissions...\n"); __system("fix_permissions"); ui_print("Done!\n"); break; } case 7: { static char* ext_sizes[] = { "128M", "256M", "512M", "1024M", "2048M", "4096M", NULL }; static char* swap_sizes[] = { "0M", "32M", "64M", "128M", "256M", NULL }; static char* ext_headers[] = { "Data Size", "", NULL }; static char* swap_headers[] = { "Swap Size", "", NULL }; int ext_size = get_menu_selection(ext_headers, ext_sizes, 0, 0); if (ext_size == GO_BACK) continue; int swap_size = 0; if (swap_size == GO_BACK) continue; char sddevice[256]; Volume *vol = volume_for_path("/emmc"); strcpy(sddevice, vol->device); // we only want the mmcblk, not the partition sddevice[strlen("/dev/block/mmcblkX")] = NULL; char cmd[PATH_MAX]; setenv("SDPATH", sddevice, 1); sprintf(cmd, "sdparted -es %s -ss %s -efs ext3 -s", ext_sizes[ext_size], swap_sizes[swap_size]); ui_print("Partitioning Internal SD Card... please wait...\n"); if (0 == __system(cmd)) ui_print("Done!\n"); else ui_print("An error occured while partitioning your Internal SD Card. Please see /tmp/recovery.log for more details.\n"); break; } } } }
int get_menu_selection(char** headers, char** items, int menu_only, int initial_selection) { // throw away keys pressed previously, so user doesn't // accidentally trigger menu items. ui_clear_key_queue(); int item_count = ui_start_menu(headers, items, initial_selection); int selected = initial_selection; int chosen_item = -1; // Some users with dead enter keys need a way to turn on power to select. // Jiggering across the wrapping menu is one "secret" way to enable it. // We can't rely on /cache or /sdcard since they may not be available. int wrap_count = 0; while (chosen_item < 0 && chosen_item != GO_BACK) { struct keyStruct *key; key = ui_wait_key(); int visible = ui_text_visible(); int action; if(key->code == ABS_MT_POSITION_X) action = device_handle_mouse(key, visible); else action = device_handle_key(key->code, visible); int old_selected = selected; if (action < 0) { switch (action) { case HIGHLIGHT_UP: --selected; selected = ui_menu_select(selected); break; case HIGHLIGHT_DOWN: ++selected; selected = ui_menu_select(selected); break; case SELECT_ITEM: chosen_item = selected; if (ui_get_showing_back_button()) { if (chosen_item == item_count) { chosen_item = GO_BACK; } } break; case NO_ACTION: break; case GO_BACK: chosen_item = GO_BACK; break; } } else if (!menu_only) { chosen_item = action; } if (abs(selected - old_selected) > 1) { wrap_count++; if (wrap_count == 3) { wrap_count = 0; if (ui_get_showing_back_button()) { ui_print("Back menu button disabled.\n"); ui_set_showing_back_button(0); } else { ui_print("Back menu button enabled.\n"); ui_set_showing_back_button(1); } } } } ui_end_menu(); ui_clear_key_queue(); return chosen_item; }
void show_advanced_menu() { static char* headers[] = { "Advanced and Debugging Menu", "", NULL }; static char* list[] = { "Reboot Recovery", "Wipe Dalvik Cache", "Wipe Battery Stats", "Wipe /data/userinit script", "Report Error", "Key Test", #ifndef BOARD_HAS_SMALL_RECOVERY "Partition SD Card", "Fix Permissions", #endif "Create image for Odin", "---Flash Kernel------", "---Flash Recovery----", "Unlock Kernel 4 Flash", "Unlock Recovery 4 Flash", NULL }; for (;;) { int chosen_item = get_menu_selection(headers, list, 0); if (chosen_item == GO_BACK) break; switch (chosen_item) { case 0: __reboot(LINUX_REBOOT_MAGIC1, LINUX_REBOOT_MAGIC2, LINUX_REBOOT_CMD_RESTART2, "recovery"); break; case 1: { if (0 != ensure_root_path_mounted("DATA:")) break; ensure_root_path_mounted("SDEXT:"); ensure_root_path_mounted("CACHE:"); if (confirm_selection( "Confirm wipe?", "Yes - Wipe Dalvik Cache")) { __system("rm -r /data/dalvik-cache"); __system("rm -r /cache/dalvik-cache"); __system("rm -r /sd-ext/dalvik-cache"); } ensure_root_path_unmounted("DATA:"); ui_print("Dalvik Cache wiped.\n"); break; } case 2: { if (confirm_selection( "Confirm wipe?", "Yes - Wipe Battery Stats")) wipe_battery_stats(); break; } case 3: ui_print("Wiping /data/userinit.sh...\n"); ensure_root_path_mounted("DATA:"); remove("/data/userinit.sh"); ensure_root_path_unmounted("DATA:"); ui_print("Done.\n"); break; case 4: handle_failure(1); break; case 5: { ui_print("Outputting key codes.\n"); ui_print("Go back to end debugging.\n"); int key; int action; do { key = ui_wait_key(); action = device_handle_key(key, 1); ui_print("Key: %d\n", key); } while (action != GO_BACK); break; } case 6: { static char* ext_sizes[] = { "128M", "256M", "512M", "1024M", "2048M", "4096M", "8192M", "16384M", NULL }; static char* swap_sizes[] = { "0M", "32M", "64M", "128M", "256M", NULL }; static char* ext_headers[] = { "Ext Size", "", NULL }; static char* swap_headers[] = { "Swap Size", "", NULL }; int ext_size = get_menu_selection(ext_headers, ext_sizes, 0); if (ext_size == GO_BACK) continue; int swap_size = get_menu_selection(swap_headers, swap_sizes, 0); if (swap_size == GO_BACK) continue; char sddevice[256]; const RootInfo *ri = get_root_info_for_path("SDCARD:"); strcpy(sddevice, ri->device); // we only want the mmcblk, not the partition sddevice[strlen("/dev/block/mmcblkX")] = NULL; char cmd[PATH_MAX]; setenv("SDPATH", sddevice, 1); sprintf(cmd, "sdparted -es %s -ss %s -efs ext3 -s", ext_sizes[ext_size], swap_sizes[swap_size]); ui_print("Partitioning SD Card... please wait...\n"); if (0 == __system(cmd)) ui_print("Done!\n"); else ui_print("An error occured while partitioning your SD Card. Please see /tmp/recovery.log for more details.\n"); break; } case 7: { ensure_root_path_mounted("SYSTEM:"); ensure_root_path_mounted("DATA:"); ui_print("Fixing permissions...\n"); __system("fix_permissions"); ui_print("Done!\n"); break; } case 8: { // create image for Odin dump_odin_image(); break; } case 9: { ui_print("Flashing kernel...\n"); __system("flash_kernel"); ui_print("Done!\n"); break; } case 10: { ui_print("Flashing recovery...\n"); __system("flash_recovery"); ui_print("Done!\n"); break; } case 11: { ui_print("Unlocking Kernel...\n"); __system("unlock_kernel"); ui_print("Done!\n"); break; } case 12: { ui_print("Unlocking Recovery...\n"); __system("unlock_recovery"); ui_print("Done!\n"); break; } } } }
char ui_get_char() { char ret = NULL; int key; while (ret==NULL) { key = ui_wait_key(); switch(key) { case KEY_A: ret='a'; break; case KEY_B: ret='b'; break; case KEY_C: ret='c'; break; case KEY_D: ret='d'; break; case KEY_E: ret='e'; break; case KEY_F: ret='f'; break; case KEY_G: ret='g'; break; case KEY_H: ret='h'; break; case KEY_I: ret='i'; break; case KEY_J: ret='j'; break; case KEY_K: ret='k'; break; case KEY_L: ret='l'; break; case KEY_M: ret='m'; break; case KEY_N: ret='n'; break; case KEY_O: ret='o'; break; case KEY_P: ret='p'; break; case KEY_Q: ret='q'; break; case KEY_R: ret='r'; break; case KEY_S: ret='s'; break; case KEY_T: ret='t'; break; case KEY_U: ret='u'; break; case KEY_V: ret='v'; break; case KEY_W: ret='w'; break; case KEY_X: ret='x'; break; case KEY_Y: ret='y'; break; case KEY_Z: ret='z'; break; case KEY_COMMA: ret=','; break; case KEY_DOT: ret='.'; break; case KEY_SLASH: ret='/'; break; case KEY_QUESTION: ret='?'; break; case KEY_EMAIL: ret='@'; break; case KEY_BACKSPACE: ret='\b'; break; case KEY_ENTER: ret='\n'; break; } } ui_char_shifted(&ret); return ret; }
void show_advanced_menu() { static char* headers[] = { "Advanced Menu", "", NULL }; static char* list[] = { "reboot recovery", "wipe dalvik cache", "wipe battery stats", "report error", "key test", "show log", "fix permissions", "partition sdcard", "partition external sdcard", "partition internal sdcard", NULL }; if (!can_partition("/sdcard")) { list[7] = NULL; } if (!can_partition("/external_sd")) { list[8] = NULL; } if (!can_partition("/emmc")) { list[9] = NULL; } for (;;) { int chosen_item = get_filtered_menu_selection(headers, list, 0, 0, sizeof(list) / sizeof(char*)); if (chosen_item == GO_BACK) break; switch (chosen_item) { case 0: android_reboot(ANDROID_RB_RESTART2, 0, "recovery"); break; case 1: if (0 != ensure_path_mounted("/data")) break; ensure_path_mounted("/sd-ext"); ensure_path_mounted("/cache"); if (confirm_selection( "Confirm wipe?", "Yes - Wipe Dalvik Cache")) { __system("rm -r /data/dalvik-cache"); __system("rm -r /cache/dalvik-cache"); __system("rm -r /sd-ext/dalvik-cache"); ui_print("Dalvik Cache wiped.\n"); } ensure_path_unmounted("/data"); break; case 2: if (confirm_selection( "Confirm wipe?", "Yes - Wipe Battery Stats")) wipe_battery_stats(); break; case 3: handle_failure(1); break; case 4: { ui_print("Outputting key codes.\n"); ui_print("Go back to end debugging.\n"); int key; int action; do { key = ui_wait_key(); action = device_handle_key(key, 1); ui_print("Key: %d\n", key); } while (action != GO_BACK); break; } case 5: ui_printlogtail(12); break; case 6: ensure_path_mounted("/system"); ensure_path_mounted("/data"); ui_print("Fixing permissions...\n"); __system("fix_permissions"); ui_print("Done!\n"); break; case 7: partition_sdcard("/sdcard"); break; case 8: partition_sdcard("/external_sd"); break; case 9: partition_sdcard("/emmc"); break; } } }
int atouch_wait_ex(ATEV *atev, byte calibratingtouch){ atev->x = -1; atev->y = -1; // if (prev_was_key) ui_clear_key_queue(); while (1){ int key = ui_wait_key(); //-- Custom Message if (key==atouch_message_code){ atev->msg = atouch_message_value; atev->d = 0; atev->x = 0; atev->y = 0; atev->k = 0; ui_clear_key_queue(); atouch_message_value = 0; return ATEV_MESSAGE; } atev->d = ui_key_pressed(key); atev->k = key; if (key==evtouch_code){ if ((evtouch_x>0)&&(evtouch_y>0)){ //-- GENERIC TOUCH SCREEN INPUT EVENT if (((evtouch_x<=agw())&&(evtouch_y<=agh()))||(calibratingtouch)){ atev->x = evtouch_x; atev->y = evtouch_y; evtouch_locked=0; switch(evtouch_state){ case 1: return ATEV_MOUSEDN; break; case 2: return ATEV_MOUSEMV; break; default: return ATEV_MOUSEUP; break; } } //-- CAPIATIVE KEY INPUT EVENT else if(evtouch_y>(agh()+(agdp()*10))){ int capiative_btnsz = agw()/4; if (evtouch_state==0){ atev->d = 0; if (evtouch_x<capiative_btnsz){ vibrate(30); atev->k = KEY_HOME; evtouch_locked=0; return ATEV_SELECT; } else if (evtouch_x<(capiative_btnsz*2)){ vibrate(30); atev->k = KEY_MENU; evtouch_locked=0; return ATEV_MENU; } else if (evtouch_x<(capiative_btnsz*3)){ vibrate(30); atev->k = KEY_BACK; evtouch_locked=0; return ATEV_BACK; } else if (evtouch_x<(capiative_btnsz*4)){ vibrate(30); atev->k = KEY_SEARCH; evtouch_locked=0; return ATEV_MENU; } } // home,menu,back,search } } evtouch_locked=0; } else if ((key!=0)&&(key==acfg()->ckey_up)) return ATEV_UP; else if ((key!=0)&&(key==acfg()->ckey_down)) return ATEV_DOWN; else if ((key!=0)&&(key==acfg()->ckey_select)) return ATEV_SELECT; else if ((key!=0)&&(key==acfg()->ckey_back)) return ATEV_BACK; else if ((key!=0)&&(key==acfg()->ckey_menu)) return ATEV_MENU; else{ /* DEFINED KEYS */ switch (key){ /* RIGHT */ case KEY_RIGHT: return ATEV_RIGHT; break; /* LEFT */ case KEY_LEFT: return ATEV_LEFT; break; /* DOWN */ case KEY_DOWN: case KEY_CAPSLOCK: case KEY_VOLUMEDOWN: return ATEV_DOWN; break; /* UP */ case KEY_UP: case KEY_LEFTSHIFT: case KEY_VOLUMEUP: return ATEV_UP; break; /* SELECT */ case KEY_LEFTBRACE: case KEY_POWER: case KEY_HOME: case BTN_MOUSE: case KEY_ENTER: case KEY_CENTER: case KEY_CAMERA: case KEY_F21: case KEY_SEND: return ATEV_SELECT; break; /* SHOW MENU */ case KEY_SEARCH: case 229: case KEY_MENU: return ATEV_MENU; break; /* BACK */ case KEY_END: case KEY_BACKSPACE: case KEY_BACK: return ATEV_BACK; break; } } } return 0; }
int test_key_start(void) { int ret; struct timespec ntime; ntime.tv_sec= time(NULL)+KEY_TIMEOUT; ntime.tv_nsec=0; int menu_count=0; int key = -1; int test_cnt = sizeof(test_key_info) / sizeof(struct test_key); int i = 0; int cur_row = 2; int count = 0; LOGD("mmitest start"); ui_fill_locked(); ui_show_title(MENU_TEST_KEY); ui_set_color(CL_GREEN); cur_row=ui_show_text(cur_row, 0, TEXT_KEY_ILLUSTRATE); for(i = 0; i < test_cnt; i++) { test_key_info[i].done = 0; } for(;;) { cur_row = 4; for(i = 0; i < test_cnt; i++) { if(test_key_info[i].done) { ui_set_color(CL_GREEN); } else { ui_set_color(CL_RED); } cur_row = ui_show_text(cur_row, 0, test_key_info[i].name); } gr_flip(); if((count >= test_cnt)) break; if(key==ETIMEDOUT) break; key = ui_wait_key(&ntime); LOGD("mmitest key = %d",key); for(i = 0; i < test_cnt; i++) { if((test_key_info[i].key == key) &&(test_key_info[i].done == 0)) { test_key_info[i].done = 1; count++; } } LOGD("mmitest count=%d",count); } LOGD("mmitest key over"); if(key==ETIMEDOUT){ ui_set_color(CL_RED); ui_show_text(cur_row+2, 0, TEXT_TEST_FAIL); gr_flip(); sleep(1); ret=RL_FAIL; }else{ ui_set_color(CL_GREEN); ui_show_text(cur_row+2, 0, TEXT_TEST_PASS); gr_flip(); sleep(1); ret=RL_PASS; } save_result(CASE_TEST_KEY,ret); return ret; }
void show_advanced_menu() { static char* headers[] = { "Advanced and Debugging Menu", "", NULL }; static char* list[] = { "~~~> Go Back <~~~", "Report Error", "Key Test", #ifndef BOARD_HAS_SMALL_RECOVERY "Partition SD Card", "Fix Permissions", #ifdef BOARD_HAS_SDCARD_INTERNAL "Partition Internal SD Card", #endif #endif NULL }; for (;;) { int chosen_item = get_menu_selection(headers, list, 0); if (chosen_item == GO_BACK) break; switch (chosen_item) { case 0: { return; break; } case 1: handle_failure(1); break; case 2: { ui_print("Outputting key codes.\n"); ui_print("Go back to end debugging.\n"); int key; int action; do { key = ui_wait_key(); action = device_handle_key(key, 1); ui_print("Key: %d\n", key); } while (action != GO_BACK); break; } case 3: { static char* ext_sizes[] = { "128M", "256M", "512M", "1024M", "2048M", "4096M", NULL }; static char* swap_sizes[] = { "0M", "32M", "64M", "128M", "256M", NULL }; static char* ext_headers[] = { "Ext Size", "", NULL }; static char* swap_headers[] = { "Swap Size", "", NULL }; int ext_size = get_menu_selection(ext_headers, ext_sizes, 0); if (ext_size == GO_BACK) continue; int swap_size = get_menu_selection(swap_headers, swap_sizes, 0); if (swap_size == GO_BACK) continue; char sddevice[256]; const RootInfo *ri = get_root_info_for_path("SDCARD:"); strcpy(sddevice, ri->device); // we only want the mmcblk, not the partition sddevice[strlen("/dev/block/mmcblkX")] = NULL; char cmd[PATH_MAX]; setenv("SDPATH", sddevice, 1); sprintf(cmd, "sdparted -es %s -ss %s -efs ext3 -s", ext_sizes[ext_size], swap_sizes[swap_size]); ui_print("Partitioning SD Card... please wait...\n"); if (0 == __system(cmd)) ui_print("Done!\n"); else ui_print("An error occured while partitioning your SD Card. Please see /tmp/recovery.log for more details.\n"); break; } case 4: { ensure_root_path_mounted("SYSTEM:"); ensure_root_path_mounted("DATA:"); ui_print("Fixing permissions...\n"); __system("fix_permissions"); ui_print("Done!\n"); break; } case 5: { static char* ext_sizes[] = { "128M", "256M", "512M", "1024M", "2048M", "4096M", NULL }; static char* swap_sizes[] = { "0M", "32M", "64M", "128M", "256M", NULL }; static char* ext_headers[] = { "Data Size", "", NULL }; static char* swap_headers[] = { "Swap Size", "", NULL }; int ext_size = get_menu_selection(ext_headers, ext_sizes, 0); if (ext_size == GO_BACK) continue; int swap_size = 0; if (swap_size == GO_BACK) continue; char sddevice[256]; const RootInfo *ri = get_root_info_for_path("SDINTERNAL:"); strcpy(sddevice, ri->device); // we only want the mmcblk, not the partition sddevice[strlen("/dev/block/mmcblkX")] = NULL; char cmd[PATH_MAX]; setenv("SDPATH", sddevice, 1); sprintf(cmd, "sdparted -es %s -ss %s -efs ext3 -s", ext_sizes[ext_size], swap_sizes[swap_size]); ui_print("Partitioning Internal SD Card... please wait...\n"); if (0 == __system(cmd)) ui_print("Done!\n"); else ui_print("An error occured while partitioning your Internal SD Card. Please see /tmp/recovery.log for more details.\n"); break; } } } }
int get_menu_selection(const char** headers, char** items, int menu_only, int initial_selection) { // throw away keys pressed previously, so user doesn't // accidentally trigger menu items. ui_clear_key_queue(); int item_count = ui_start_menu(headers, items, initial_selection); int selected = initial_selection; int chosen_item = -1; // NO_ACTION #ifdef NOT_ENOUGH_RAINBOWS int wrap_count = 0; #endif while (chosen_item < 0 && chosen_item != GO_BACK) { int key = ui_wait_key(); int visible = ui_IsTextVisible(); if (key == -1) { // ui_wait_key() timed out, always reboot to main system LOGI("timed out waiting for key input; rebooting.\n"); ui_end_menu(); reboot_main_system(ANDROID_RB_RESTART, 0, 0); sleep(5); LOGE("Failed to reboot system on timed out key input!!\n"); return GO_BACK; } else if (key == -2) { // we are returning from ui_cancel_wait_key(): trigger a GO_BACK return GO_BACK; } else if (key == -3) { // an USB device was plugged in (returning from ui_wait_key()) return REFRESH; } int action = ui_handle_key(key, visible); int old_selected = selected; selected = ui_get_selected_item(); if (action < 0) { switch (action) { case HIGHLIGHT_UP: --selected; selected = ui_menu_select(selected); break; case HIGHLIGHT_DOWN: ++selected; selected = ui_menu_select(selected); break; #ifdef PHILZ_TOUCH_RECOVERY case HIGHLIGHT_ON_TOUCH: selected = ui_menu_touch_select(); break; #endif case SELECT_ITEM: chosen_item = selected; if (ui_is_showing_back_button()) { if (chosen_item == item_count) { chosen_item = GO_BACK; } } break; case NO_ACTION: break; case GO_BACK: chosen_item = GO_BACK; break; #ifdef PHILZ_TOUCH_RECOVERY case GESTURE_ACTIONS: handle_gesture_actions(headers, items, initial_selection); break; #endif } } else if (!menu_only) { chosen_item = action; } #ifdef NOT_ENOUGH_RAINBOWS if (abs(selected - old_selected) > 1) { wrap_count++; if (wrap_count == 5) { wrap_count = 0; if (ui_get_rainbow_mode()) { ui_set_rainbow_mode(0); ui_print("Rainbow mode disabled\n"); } else { ui_set_rainbow_mode(1); ui_print("Rainbow mode enabled!\n"); } } } #endif } ui_end_menu(); ui_clear_key_queue(); return chosen_item; }
int get_menu_selection(const char** headers, char** items, int menu_only, int initial_selection) { // throw away keys pressed previously, so user doesn't // accidentally trigger menu items. ui_clear_key_queue(); int item_count = ui_start_menu(headers, items, initial_selection); int selected = initial_selection; int chosen_item = -1; // NO_ACTION int wrap_count = 0; while (chosen_item < 0 && chosen_item != GO_BACK) { int key = ui_wait_key(); int visible = ui_text_visible(); if (key == -1) { // ui_wait_key() timed out if (ui_text_ever_visible()) { continue; } else { LOGI("timed out waiting for key input; rebooting.\n"); ui_end_menu(); return ITEM_REBOOT; } } else if (key == -2) { // we are returning from ui_cancel_wait_key(): trigger a GO_BACK return GO_BACK; } else if (key == -3) { // an USB device was plugged in (returning from ui_wait_key()) return REFRESH; } int action = ui_handle_key(key, visible); int old_selected = selected; selected = ui_get_selected_item(); if (action < 0) { switch (action) { case HIGHLIGHT_UP: --selected; selected = ui_menu_select(selected); break; case HIGHLIGHT_DOWN: ++selected; selected = ui_menu_select(selected); break; case SELECT_ITEM: chosen_item = selected; if (ui_is_showing_back_button()) { if (chosen_item == item_count) { chosen_item = GO_BACK; } } break; case NO_ACTION: break; case GO_BACK: chosen_item = GO_BACK; break; } } else if (!menu_only) { chosen_item = action; } if (abs(selected - old_selected) > 1) { wrap_count++; if (wrap_count == 5) { wrap_count = 0; if (ui_get_rainbow_mode()) { ui_set_rainbow_mode(0); ui_print("Rainbow mode disabled\n"); } else { ui_set_rainbow_mode(1); ui_print("Rainbow mode enabled!\n"); } } } } ui_end_menu(); ui_clear_key_queue(); return chosen_item; }
static int get_menu_selection(char** headers, char** items, unsigned char* selectability, int title_length, int start_sel, int menu_only) { // throw away keys pressed previously, so user doesn't // accidentally trigger menu items. ui_clear_key_queue(); //get no items int num_items = 0; while (items[num_items] != NULL) num_items++; if (start_sel >= num_items) start_sel = num_items - 1; if (start_sel < 0) start_sel = 0; ui_start_menu(headers, items, title_length, start_sel); int selected = start_sel; int chosen_item = -1; while (chosen_item < 0) { int key = ui_wait_key(); int visible = ui_text_visible(); int action = device_handle_key(key, visible); if (action < 0) { switch (action) { case HIGHLIGHT_UP: while(1) { --selected; //wrap if (selected < 0) selected = num_items - 1; if (selectability[selected]) break; } selected = ui_menu_select(selected); break; case HIGHLIGHT_DOWN: while(1) { ++selected; //wrap if (selected >= num_items) selected = 0; if (selectability[selected]) break; } selected = ui_menu_select(selected); break; case SELECT_ITEM: chosen_item = selected; break; case NO_ACTION: break; } } else if (!menu_only) chosen_item = action; } //check first if to hide menu (don't do on menu changes or tags), //because the flicker is annoying //that is implemented elsewhere //ui_end_menu(); return chosen_item; }
int get_menu_selection(char** headers, char** items, int menu_only, int initial_selection) { // throw away keys pressed previously, so user doesn't // accidentally trigger menu items. ui_clear_key_queue(); int item_count = ui_start_menu(headers, items, initial_selection); int selected = initial_selection; int chosen_item = -1; // Some users with dead enter keys need a way to turn on power to select. // Jiggering across the wrapping menu is one "secret" way to enable it. // We can't rely on /cache or /sdcard since they may not be available. int wrap_count = 0; while (chosen_item < 0 && chosen_item != GO_BACK) { int key = ui_wait_key(); int visible = ui_text_visible(); if (key == -1) { // ui_wait_key() timed out if (ui_text_ever_visible()) { continue; } else { LOGI("timed out waiting for key input; rebooting.\n"); ui_end_menu(); return ITEM_REBOOT; } } int action = ui_handle_key(key, visible); int old_selected = selected; selected = ui_get_selected_item(); if (action < 0) { switch (action) { case HIGHLIGHT_UP: --selected; selected = ui_menu_select(selected); break; case HIGHLIGHT_DOWN: ++selected; selected = ui_menu_select(selected); break; case SELECT_ITEM: chosen_item = selected; if (ui_is_showing_back_button()) { if (chosen_item == item_count) { chosen_item = GO_BACK; } } break; case NO_ACTION: break; case GO_BACK: chosen_item = GO_BACK; break; } } else if (!menu_only) { chosen_item = action; } } ui_end_menu(); ui_clear_key_queue(); return chosen_item; }
void ts_calibrate() { ui_set_background(BACKGROUND_ICON_TSCAL); ui_print("Beginning touchscreen calibration.\n"); ui_print("Tap the red dot. 3 taps remaining.\n"); struct keyStruct{ int code; int x; int y; }*key; int step = 1; int prev_touch_y, prev_max_x, prev_max_y; int sum_x, sum_y; int final_x, final_y; int ts_x_1, ts_x_2, ts_x_3; int ts_y_1, ts_y_2, ts_y_3; prev_touch_y = touchY; prev_max_x = maxX; prev_max_y = maxY; maxX = 0; maxY = 0; touchY = 0; do { key = ui_wait_key(); switch(step) { case 1: { if(key->code == ABS_MT_POSITION_X) { ts_x_1 = key->x; ts_y_1 = key->y; step = 2; ui_print("Tap the red dot. 2 taps remaining.\n"); break; } } case 2: { if(key->code == ABS_MT_POSITION_X) { ts_x_2 = key->x; ts_y_2 = key->y; step = 3; ui_print("Tap the red dot. 1 tap remaining.\n"); break; } } case 3: { if(key->code == ABS_MT_POSITION_X) { ts_x_3 = key->x; ts_y_3 = key->y; step = 4; ui_print("Now calculating calibration data...\n"); break; } } default: { break; } } } while (step != 4); sum_x = ts_x_1+ts_x_2+ts_x_3; sum_y = ts_y_1+ts_y_2+ts_y_3; final_x = sum_x/3; final_y = sum_y/3; final_x = final_x*2; final_y = final_y*2; maxX = final_x; maxY = final_y; #ifndef BOARD_TS_NO_BOUNDARY int y_calc; int fb_height; int fb_limit; fb_height = gr_fb_height(); y_calc = fb_height/6; fb_limit = fb_height-y_calc; touchY = fb_limit; #else touchY = 0; #endif ui_print("Calibration complete!\n"); ui_set_background(BACKGROUND_ICON_CLOCKWORK); return; }
void show_advanced_menu() { static char* headers[] = { "Advanced Menu", "", NULL }; static char* list[] = { "reboot recovery", "reboot to bootloader", "power off", "wipe dalvik cache", "report error", "key test", "show log", "partition sdcard", "partition external sdcard", "partition internal sdcard", NULL }; char bootloader_mode[PROPERTY_VALUE_MAX]; property_get("ro.bootloader.mode", bootloader_mode, ""); if (!strcmp(bootloader_mode, "download")) { list[1] = "reboot to download mode"; } if (!can_partition("/sdcard")) { list[7] = NULL; } if (!can_partition("/external_sd")) { list[8] = NULL; } if (!can_partition("/emmc")) { list[9] = NULL; } for (;;) { int chosen_item = get_filtered_menu_selection(headers, list, 0, 0, sizeof(list) / sizeof(char*)); if (chosen_item == GO_BACK) break; switch (chosen_item) { case 0: { ui_print("Rebooting recovery...\n"); reboot_main_system(ANDROID_RB_RESTART2, 0, "recovery"); break; } case 1: { if (!strcmp(bootloader_mode, "download")) { ui_print("Rebooting to download mode...\n"); reboot_main_system(ANDROID_RB_RESTART2, 0, "download"); } else { ui_print("Rebooting to bootloader...\n"); reboot_main_system(ANDROID_RB_RESTART2, 0, "bootloader"); } break; } case 2: { ui_print("Shutting down...\n"); reboot_main_system(ANDROID_RB_POWEROFF, 0, 0); break; } case 3: if (0 != ensure_path_mounted("/data")) break; ensure_path_mounted("/sd-ext"); ensure_path_mounted("/cache"); if (confirm_selection( "Confirm wipe?", "Yes - Wipe Dalvik Cache")) { __system("rm -r /data/dalvik-cache"); __system("rm -r /cache/dalvik-cache"); __system("rm -r /sd-ext/dalvik-cache"); ui_print("Dalvik Cache wiped.\n"); } ensure_path_unmounted("/data"); break; case 4: handle_failure(1); break; case 5: { ui_print("Outputting key codes.\n"); ui_print("Go back to end debugging.\n"); int key; int action; do { key = ui_wait_key(); action = device_handle_key(key, 1); ui_print("Key: %d\n", key); } while (action != GO_BACK); break; } case 6: ui_printlogtail(12); break; case 7: partition_sdcard("/sdcard"); break; case 8: partition_sdcard("/external_sd"); break; case 9: partition_sdcard("/emmc"); break; } } }
void show_advanced_menu() { static char* headers[] = { "高级设置", "", NULL }; static char* list[] = { "清空Dalvik Cache", "发送错误报告", "按键测试", "显示日志", "对SD卡进行分区", "对外置SD卡进行分区", "对内置SD卡进行分区", NULL }; if (!can_partition("/sdcard")) { list[4] = NULL; } if (!can_partition("/external_sd")) { list[5] = NULL; } if (!can_partition("/emmc")) { list[6] = NULL; } for (;;) { int chosen_item = get_filtered_menu_selection(headers, list, 0, 0, sizeof(list) / sizeof(char*)); if (chosen_item == GO_BACK) break; switch (chosen_item) { case 0: if (0 != ensure_path_mounted("/data")) break; ensure_path_mounted("/sd-ext"); ensure_path_mounted("/cache"); if (confirm_selection( "确定清空?", "是 - 清空Dalvik Cache")) { __system("rm -r /data/dalvik-cache"); __system("rm -r /cache/dalvik-cache"); __system("rm -r /sd-ext/dalvik-cache"); ui_print("Dalvik Cache 已经清空!\n"); } ensure_path_unmounted("/data"); break; case 1: handle_failure(1); break; case 2: { ui_print("正在进行键位测试\n"); ui_print("按返回结束测试.\n"); int key; int action; do { key = ui_wait_key(); action = device_handle_key(key, 1); ui_print("键值: %d\n", key); } while (action != GO_BACK); break; } case 3: ui_printlogtail(12); break; case 4: partition_sdcard("/sdcard"); break; case 5: partition_sdcard("/external_sd"); break; case 6: partition_sdcard("/emmc"); break; } } }