1*4882a593Smuzhiyun /* 2*4882a593Smuzhiyun * Copyright (C) 2009 The Android Open Source Project 3*4882a593Smuzhiyun * 4*4882a593Smuzhiyun * Licensed under the Apache License, Version 2.0 (the "License"); 5*4882a593Smuzhiyun * you may not use this file except in compliance with the License. 6*4882a593Smuzhiyun * You may obtain a copy of the License at 7*4882a593Smuzhiyun * 8*4882a593Smuzhiyun * http://www.apache.org/licenses/LICENSE-2.0 9*4882a593Smuzhiyun * 10*4882a593Smuzhiyun * Unless required by applicable law or agreed to in writing, software 11*4882a593Smuzhiyun * distributed under the License is distributed on an "AS IS" BASIS, 12*4882a593Smuzhiyun * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13*4882a593Smuzhiyun * See the License for the specific language governing permissions and 14*4882a593Smuzhiyun * limitations under the License. 15*4882a593Smuzhiyun */ 16*4882a593Smuzhiyun 17*4882a593Smuzhiyun #ifndef _RECOVERY_UI_H 18*4882a593Smuzhiyun #define _RECOVERY_UI_H 19*4882a593Smuzhiyun 20*4882a593Smuzhiyun // Called when recovery starts up. Returns 0. 21*4882a593Smuzhiyun extern int device_recovery_start(); 22*4882a593Smuzhiyun 23*4882a593Smuzhiyun // Called in the input thread when a new key (key_code) is pressed. 24*4882a593Smuzhiyun // *key_pressed is an array of KEY_MAX+1 bytes indicating which other 25*4882a593Smuzhiyun // keys are already pressed. Return true if the text display should 26*4882a593Smuzhiyun // be toggled. 27*4882a593Smuzhiyun extern int device_toggle_display(volatile char* key_pressed, int key_code); 28*4882a593Smuzhiyun 29*4882a593Smuzhiyun // Called in the input thread when a new key (key_code) is pressed. 30*4882a593Smuzhiyun // *key_pressed is an array of KEY_MAX+1 bytes indicating which other 31*4882a593Smuzhiyun // keys are already pressed. Return true if the device should reboot 32*4882a593Smuzhiyun // immediately. 33*4882a593Smuzhiyun extern int device_reboot_now(volatile char* key_pressed, int key_code); 34*4882a593Smuzhiyun 35*4882a593Smuzhiyun // Called from the main thread when recovery is waiting for input and 36*4882a593Smuzhiyun // a key is pressed. key is the code of the key pressed; visible is 37*4882a593Smuzhiyun // true if the recovery menu is being shown. Implementations can call 38*4882a593Smuzhiyun // ui_key_pressed() to discover if other keys are being held down. 39*4882a593Smuzhiyun // Return one of the defined constants below in order to: 40*4882a593Smuzhiyun // 41*4882a593Smuzhiyun // - move the menu highlight (HIGHLIGHT_*) 42*4882a593Smuzhiyun // - invoke the highlighted item (SELECT_ITEM) 43*4882a593Smuzhiyun // - do nothing (NO_ACTION) 44*4882a593Smuzhiyun // - invoke a specific action (a menu position: any non-negative number) 45*4882a593Smuzhiyun extern int device_handle_key(int key, int visible); 46*4882a593Smuzhiyun 47*4882a593Smuzhiyun // Perform a recovery action selected from the menu. 'which' will be 48*4882a593Smuzhiyun // the item number of the selected menu item, or a non-negative number 49*4882a593Smuzhiyun // returned from device_handle_key(). The menu will be hidden when 50*4882a593Smuzhiyun // this is called; implementations can call ui_print() to print 51*4882a593Smuzhiyun // information to the screen. 52*4882a593Smuzhiyun extern int device_perform_action(int which); 53*4882a593Smuzhiyun 54*4882a593Smuzhiyun // Called when we do a wipe data/factory reset operation (either via a 55*4882a593Smuzhiyun // reboot from the main system with the --wipe_data flag, or when the 56*4882a593Smuzhiyun // user boots into recovery manually and selects the option from the 57*4882a593Smuzhiyun // menu.) Can perform whatever device-specific wiping actions are 58*4882a593Smuzhiyun // needed. Return 0 on success. The userdata and cache partitions 59*4882a593Smuzhiyun // are erased after this returns (whether it returns success or not). 60*4882a593Smuzhiyun int device_wipe_data(); 61*4882a593Smuzhiyun 62*4882a593Smuzhiyun #define NO_ACTION -1 63*4882a593Smuzhiyun 64*4882a593Smuzhiyun #define HIGHLIGHT_UP -2 65*4882a593Smuzhiyun #define HIGHLIGHT_DOWN -3 66*4882a593Smuzhiyun #define SELECT_ITEM -4 67*4882a593Smuzhiyun 68*4882a593Smuzhiyun #define ITEM_REBOOT 0 69*4882a593Smuzhiyun #define ITEM_APPLY_SDCARD 1 70*4882a593Smuzhiyun #define ITEM_APPLY_USERDATA 2 71*4882a593Smuzhiyun #define ITEM_APPLY_UDISK 3 72*4882a593Smuzhiyun #define ITEM_WIPE_DATA 4 73*4882a593Smuzhiyun #define ITEM_WIPE_CACHE 3 74*4882a593Smuzhiyun 75*4882a593Smuzhiyun // Header text to display above the main menu. 76*4882a593Smuzhiyun extern char* MENU_HEADERS[]; 77*4882a593Smuzhiyun 78*4882a593Smuzhiyun // Text of menu items. 79*4882a593Smuzhiyun extern char* MENU_ITEMS[]; 80*4882a593Smuzhiyun 81*4882a593Smuzhiyun #endif 82