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 #ifndef _RECOVERY_UI_H 18 #define _RECOVERY_UI_H 19 20 // Called in the input thread when a new key (key_code) is pressed. 21 // *key_pressed is an array of KEY_MAX+1 bytes indicating which other 22 // keys are already pressed. Return true if the text display should 23 // be toggled. 24 extern int device_toggle_display(volatile char* key_pressed, int key_code); 25 26 // Called in the input thread when a new key (key_code) is pressed. 27 // *key_pressed is an array of KEY_MAX+1 bytes indicating which other 28 // keys are already pressed. Return true if the device should reboot 29 // immediately. 30 extern int device_reboot_now(volatile char* key_pressed, int key_code); 31 32 // Called from the main thread when recovery is waiting for input and 33 // a key is pressed. key is the code of the key pressed; visible is 34 // true if the recovery menu is being shown. Implementations can call 35 // ui_key_pressed() to discover if other keys are being held down. 36 // Return one of the defined constants below in order to: 37 // 38 // - move the menu highlight (HIGHLIGHT_*) 39 // - invoke the highlighted item (SELECT_ITEM) 40 // - do nothing (NO_ACTION) 41 // - invoke a specific action (a menu position: any non-negative number) 42 extern int device_handle_key(int key, int visible); 43 44 // Perform a recovery action selected from the menu. 'which' will be 45 // the item number of the selected menu item, or a non-negative number 46 // returned from device_handle_key(). The menu will be hidden when 47 // this is called; implementations can call ui_print() to print 48 // information to the screen. 49 extern int device_perform_action(int which); 50 51 // Called when we do a wipe data/factory reset operation (either via a 52 // reboot from the main system with the --wipe_data flag, or when the 53 // user boots into recovery manually and selects the option from the 54 // menu.) Can perform whatever device-specific wiping actions are 55 // needed. Return 0 on success. The userdata and cache partitions 56 // are erased after this returns (whether it returns success or not). 57 int device_wipe_data(); 58 59 #define NO_ACTION -1 60 61 #define HIGHLIGHT_UP -2 62 #define HIGHLIGHT_DOWN -3 63 #define SELECT_ITEM -4 64 65 #define ITEM_REBOOT 0 66 #define ITEM_APPLY_SDCARD 1 67 #define ITEM_WIPE_DATA 2 68 #define ITEM_WIPE_CACHE 3 69 70 // Header text to display above the main menu. 71 extern char* MENU_HEADERS[]; 72 73 // Text of menu items. 74 extern char* MENU_ITEMS[]; 75 76 #endif 77