1 /* 2 * Copyright (C) 2009 The Android Open Source Project 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 17 #include <unistd.h> 18 #include <linux/input.h> 19 20 #include "recovery_ui.h" 21 #include "common.h" 22 23 char* MENU_HEADERS[] = { "Use trackball to highlight;", 24 "click to select.", 25 "", 26 NULL }; 27 28 char* MENU_ITEMS[] = { "reboot system now [Home+Back]", 29 "apply sdcard:update.zip [Alt+S]", 30 "wipe data/factory reset [Alt+W]", 31 "wipe cache partition", 32 NULL }; 33 34 void recover_firmware_update_log(); 35 36 int device_recovery_start() { 37 recover_firmware_update_log(); 38 return 0; 39 } 40 41 int device_toggle_display(volatile char* key_pressed, int key_code) { 42 // home+end, or alt+L (either alt key) 43 return (key_pressed[KEY_HOME] && key_code == KEY_END) || 44 ((key_pressed[KEY_LEFTALT] || key_pressed[KEY_RIGHTALT]) && 45 key_code == KEY_L); 46 } 47 48 int device_reboot_now(volatile char* key_pressed, int key_code) { 49 return key_pressed[KEY_MENU] && // menu 50 key_pressed[KEY_SEND] && // green 51 key_code == KEY_END; // red 52 } 53 54 int device_handle_key(int key, int visible) { 55 int alt = ui_key_pressed(KEY_LEFTALT) || ui_key_pressed(KEY_RIGHTALT); 56 57 if (key == KEY_BACK && ui_key_pressed(KEY_HOME)) { 58 // Wait for the keys to be released, to avoid triggering 59 // special boot modes (like coming back into recovery!). 60 while (ui_key_pressed(KEY_BACK) || 61 ui_key_pressed(KEY_HOME)) { 62 usleep(1000); 63 } 64 return ITEM_REBOOT; 65 } else if (alt && key == KEY_W) { 66 return ITEM_WIPE_DATA; 67 } else if (alt && key == KEY_S) { 68 return ITEM_APPLY_SDCARD; 69 } else if (visible) { 70 switch (key) { 71 case KEY_DOWN: 72 case KEY_VOLUMEDOWN: 73 return HIGHLIGHT_DOWN; 74 75 case KEY_UP: 76 case KEY_VOLUMEUP: 77 return HIGHLIGHT_UP; 78 79 case BTN_MOUSE: 80 case KEY_ENTER: 81 return SELECT_ITEM; 82 } 83 } 84 85 return NO_ACTION; 86 } 87 88 int device_perform_action(int which) { 89 return which; 90 } 91 92 int device_wipe_data() { 93 return 0; 94 } 95