Dees_Troy | 51a0e82 | 2012-09-05 15:24:24 -0400 | [diff] [blame] | 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 when recovery starts up. Returns 0. |
| 21 | extern int device_recovery_start(); |
| 22 | |
| 23 | // Called in the input thread when a new key (key_code) is pressed. |
| 24 | // *key_pressed is an array of KEY_MAX+1 bytes indicating which other |
| 25 | // keys are already pressed. Return true if the text display should |
| 26 | // be toggled. |
| 27 | extern int device_toggle_display(volatile char* key_pressed, int key_code); |
| 28 | |
| 29 | // Called in the input thread when a new key (key_code) is pressed. |
| 30 | // *key_pressed is an array of KEY_MAX+1 bytes indicating which other |
| 31 | // keys are already pressed. Return true if the device should reboot |
| 32 | // immediately. |
| 33 | extern int device_reboot_now(volatile char* key_pressed, int key_code); |
| 34 | |
| 35 | // Called from the main thread when recovery is waiting for input and |
| 36 | // a key is pressed. key is the code of the key pressed; visible is |
| 37 | // true if the recovery menu is being shown. Implementations can call |
| 38 | // ui_key_pressed() to discover if other keys are being held down. |
| 39 | // Return one of the defined constants below in order to: |
| 40 | // |
| 41 | // - move the menu highlight (HIGHLIGHT_*) |
| 42 | // - invoke the highlighted item (SELECT_ITEM) |
| 43 | // - do nothing (NO_ACTION) |
| 44 | // - invoke a specific action (a menu position: any non-negative number) |
| 45 | extern int device_handle_key(int key, int visible); |
| 46 | |
| 47 | // Perform a recovery action selected from the menu. 'which' will be |
| 48 | // the item number of the selected menu item, or a non-negative number |
| 49 | // returned from device_handle_key(). The menu will be hidden when |
| 50 | // this is called; implementations can call ui_print() to print |
| 51 | // information to the screen. |
| 52 | extern int device_perform_action(int which); |
| 53 | |
| 54 | // Called when we do a wipe data/factory reset operation (either via a |
| 55 | // reboot from the main system with the --wipe_data flag, or when the |
| 56 | // user boots into recovery manually and selects the option from the |
| 57 | // menu.) Can perform whatever device-specific wiping actions are |
| 58 | // needed. Return 0 on success. The userdata and cache partitions |
| 59 | // are erased after this returns (whether it returns success or not). |
| 60 | int device_wipe_data(); |
| 61 | |
| 62 | #define NO_ACTION -1 |
| 63 | |
| 64 | #define HIGHLIGHT_UP -2 |
| 65 | #define HIGHLIGHT_DOWN -3 |
| 66 | #define SELECT_ITEM -4 |
| 67 | #define UP_A_LEVEL -5 |
| 68 | #define HOME_MENU -6 |
| 69 | #define MENU_MENU -7 |
| 70 | |
| 71 | // Again, just to keep custom recovery builds happy |
| 72 | #define ITEM_APPLY_CACHE 4 |
| 73 | |
| 74 | // Header text to display above the main menu. |
| 75 | extern char* MENU_HEADERS[]; |
| 76 | |
| 77 | // Text of menu items. |
| 78 | extern char* MENU_ITEMS[]; |
| 79 | |
| 80 | // NOTE: Main Menu index definitions moved to recovery.c |
| 81 | |
| 82 | int sdcard_directory(const char* path); |
| 83 | int get_menu_selection(char** headers, char** items, int menu_only, int initial_selection); |
| 84 | void prompt_and_wait(); |
| 85 | void finish_recovery(const char *send_intent); |
| 86 | #endif |