Doug Zongker | ddd6a28 | 2009-06-09 12:22:33 -0700 | [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 | |
Doug Zongker | 6809c51 | 2011-03-01 14:04:34 -0800 | [diff] [blame] | 20 | #include "common.h" |
| 21 | |
Doug Zongker | 10e418d | 2011-10-28 10:33:05 -0700 | [diff] [blame^] | 22 | #ifdef __cplusplus |
| 23 | extern "C" { |
| 24 | #endif |
| 25 | |
Doug Zongker | 6809c51 | 2011-03-01 14:04:34 -0800 | [diff] [blame] | 26 | // Called before UI library is initialized. Can change things like |
| 27 | // how many frames are included in various animations, etc. |
| 28 | extern void device_ui_init(UIParameters* ui_parameters); |
| 29 | |
Doug Zongker | efa1bab | 2010-02-01 15:59:12 -0800 | [diff] [blame] | 30 | // Called when recovery starts up. Returns 0. |
| 31 | extern int device_recovery_start(); |
| 32 | |
Doug Zongker | ddd6a28 | 2009-06-09 12:22:33 -0700 | [diff] [blame] | 33 | // Called in the input thread when a new key (key_code) is pressed. |
| 34 | // *key_pressed is an array of KEY_MAX+1 bytes indicating which other |
| 35 | // keys are already pressed. Return true if the text display should |
| 36 | // be toggled. |
Doug Zongker | 23412e6 | 2009-07-23 10:16:07 -0700 | [diff] [blame] | 37 | extern int device_toggle_display(volatile char* key_pressed, int key_code); |
Doug Zongker | ddd6a28 | 2009-06-09 12:22:33 -0700 | [diff] [blame] | 38 | |
| 39 | // Called in the input thread when a new key (key_code) is pressed. |
| 40 | // *key_pressed is an array of KEY_MAX+1 bytes indicating which other |
| 41 | // keys are already pressed. Return true if the device should reboot |
| 42 | // immediately. |
Doug Zongker | 23412e6 | 2009-07-23 10:16:07 -0700 | [diff] [blame] | 43 | extern int device_reboot_now(volatile char* key_pressed, int key_code); |
Doug Zongker | ddd6a28 | 2009-06-09 12:22:33 -0700 | [diff] [blame] | 44 | |
| 45 | // Called from the main thread when recovery is waiting for input and |
| 46 | // a key is pressed. key is the code of the key pressed; visible is |
| 47 | // true if the recovery menu is being shown. Implementations can call |
| 48 | // ui_key_pressed() to discover if other keys are being held down. |
| 49 | // Return one of the defined constants below in order to: |
| 50 | // |
| 51 | // - move the menu highlight (HIGHLIGHT_*) |
| 52 | // - invoke the highlighted item (SELECT_ITEM) |
| 53 | // - do nothing (NO_ACTION) |
| 54 | // - invoke a specific action (a menu position: any non-negative number) |
| 55 | extern int device_handle_key(int key, int visible); |
| 56 | |
| 57 | // Perform a recovery action selected from the menu. 'which' will be |
| 58 | // the item number of the selected menu item, or a non-negative number |
| 59 | // returned from device_handle_key(). The menu will be hidden when |
| 60 | // this is called; implementations can call ui_print() to print |
| 61 | // information to the screen. |
| 62 | extern int device_perform_action(int which); |
| 63 | |
Doug Zongker | b128f54 | 2009-06-18 15:07:14 -0700 | [diff] [blame] | 64 | // Called when we do a wipe data/factory reset operation (either via a |
| 65 | // reboot from the main system with the --wipe_data flag, or when the |
| 66 | // user boots into recovery manually and selects the option from the |
| 67 | // menu.) Can perform whatever device-specific wiping actions are |
| 68 | // needed. Return 0 on success. The userdata and cache partitions |
| 69 | // are erased after this returns (whether it returns success or not). |
| 70 | int device_wipe_data(); |
| 71 | |
Doug Zongker | ddd6a28 | 2009-06-09 12:22:33 -0700 | [diff] [blame] | 72 | #define NO_ACTION -1 |
| 73 | |
| 74 | #define HIGHLIGHT_UP -2 |
| 75 | #define HIGHLIGHT_DOWN -3 |
| 76 | #define SELECT_ITEM -4 |
| 77 | |
| 78 | #define ITEM_REBOOT 0 |
Doug Zongker | dc9e87c | 2010-07-29 17:08:50 -0700 | [diff] [blame] | 79 | #define ITEM_APPLY_EXT 1 |
| 80 | #define ITEM_APPLY_SDCARD 1 // historical synonym for ITEM_APPLY_EXT |
Doug Zongker | ddd6a28 | 2009-06-09 12:22:33 -0700 | [diff] [blame] | 81 | #define ITEM_WIPE_DATA 2 |
| 82 | #define ITEM_WIPE_CACHE 3 |
Michael Ward | 9d2629c | 2011-06-23 22:14:24 -0700 | [diff] [blame] | 83 | #define ITEM_APPLY_CACHE 4 |
Doug Zongker | ddd6a28 | 2009-06-09 12:22:33 -0700 | [diff] [blame] | 84 | |
| 85 | // Header text to display above the main menu. |
| 86 | extern char* MENU_HEADERS[]; |
| 87 | |
| 88 | // Text of menu items. |
| 89 | extern char* MENU_ITEMS[]; |
| 90 | |
Doug Zongker | 10e418d | 2011-10-28 10:33:05 -0700 | [diff] [blame^] | 91 | #ifdef __cplusplus |
| 92 | } |
| 93 | #endif |
| 94 | |
Doug Zongker | ddd6a28 | 2009-06-09 12:22:33 -0700 | [diff] [blame] | 95 | #endif |