1*4882a593Smuzhiyun /* 2*4882a593Smuzhiyun * Copyright (C) 2007 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_COMMON_H 18*4882a593Smuzhiyun #define RECOVERY_COMMON_H 19*4882a593Smuzhiyun 20*4882a593Smuzhiyun #include <stdio.h> 21*4882a593Smuzhiyun 22*4882a593Smuzhiyun // Initialize the graphics system. 23*4882a593Smuzhiyun void ui_init(); 24*4882a593Smuzhiyun 25*4882a593Smuzhiyun // Use KEY_* codes from <linux/input.h> or KEY_DREAM_* from "minui/minui.h". 26*4882a593Smuzhiyun int ui_wait_key(); // waits for a key/button press, returns the code 27*4882a593Smuzhiyun int ui_key_pressed(int key); // returns >0 if the code is currently pressed 28*4882a593Smuzhiyun int ui_text_visible(); // returns >0 if text log is currently visible 29*4882a593Smuzhiyun void ui_show_text(int visible); 30*4882a593Smuzhiyun void ui_clear_key_queue(); 31*4882a593Smuzhiyun 32*4882a593Smuzhiyun // Write a message to the on-screen log shown with Alt-L (also to stderr). 33*4882a593Smuzhiyun // The screen is small, and users may need to report these messages to support, 34*4882a593Smuzhiyun // so keep the output short and not too cryptic. 35*4882a593Smuzhiyun void ui_print(const char *fmt, ...) __attribute__((format(printf, 1, 2))); 36*4882a593Smuzhiyun 37*4882a593Smuzhiyun // Display some header text followed by a menu of items, which appears 38*4882a593Smuzhiyun // at the top of the screen (in place of any scrolling ui_print() 39*4882a593Smuzhiyun // output, if necessary). 40*4882a593Smuzhiyun void ui_start_menu(char** headers, char** items, int initial_selection); 41*4882a593Smuzhiyun // Set the menu highlight to the given index, and return it (capped to 42*4882a593Smuzhiyun // the range [0..numitems). 43*4882a593Smuzhiyun int ui_menu_select(int sel); 44*4882a593Smuzhiyun // End menu mode, resetting the text overlay so that ui_print() 45*4882a593Smuzhiyun // statements will be displayed. 46*4882a593Smuzhiyun void ui_end_menu(); 47*4882a593Smuzhiyun 48*4882a593Smuzhiyun // Set the icon (normally the only thing visible besides the progress bar). 49*4882a593Smuzhiyun enum { 50*4882a593Smuzhiyun BACKGROUND_ICON_NONE, 51*4882a593Smuzhiyun BACKGROUND_ICON_INSTALLING, 52*4882a593Smuzhiyun BACKGROUND_ICON_ERROR, 53*4882a593Smuzhiyun NUM_BACKGROUND_ICONS 54*4882a593Smuzhiyun }; 55*4882a593Smuzhiyun void ui_set_background(int icon); 56*4882a593Smuzhiyun 57*4882a593Smuzhiyun // Show a progress bar and define the scope of the next operation: 58*4882a593Smuzhiyun // portion - fraction of the progress bar the next operation will use 59*4882a593Smuzhiyun // seconds - expected time interval (progress bar moves at this minimum rate) 60*4882a593Smuzhiyun void ui_show_progress(float portion, int seconds); 61*4882a593Smuzhiyun void ui_set_progress(float fraction); // 0.0 - 1.0 within the defined scope 62*4882a593Smuzhiyun 63*4882a593Smuzhiyun // Default allocation of progress bar segments to operations 64*4882a593Smuzhiyun static const int VERIFICATION_PROGRESS_TIME = 60; 65*4882a593Smuzhiyun static const float VERIFICATION_PROGRESS_FRACTION = 0.25; 66*4882a593Smuzhiyun static const float DEFAULT_FILES_PROGRESS_FRACTION = 0.4; 67*4882a593Smuzhiyun static const float DEFAULT_IMAGE_PROGRESS_FRACTION = 0.1; 68*4882a593Smuzhiyun 69*4882a593Smuzhiyun // Show a rotating "barberpole" for ongoing operations. Updates automatically. 70*4882a593Smuzhiyun void ui_show_indeterminate_progress(); 71*4882a593Smuzhiyun 72*4882a593Smuzhiyun // Hide and reset the progress bar. 73*4882a593Smuzhiyun void ui_reset_progress(); 74*4882a593Smuzhiyun 75*4882a593Smuzhiyun #define LOGE(...) fprintf(stdout, "E:" __VA_ARGS__) 76*4882a593Smuzhiyun #define LOGW(...) fprintf(stdout, "W:" __VA_ARGS__) 77*4882a593Smuzhiyun #define LOGI(...) fprintf(stdout, "I:" __VA_ARGS__) 78*4882a593Smuzhiyun 79*4882a593Smuzhiyun #if 0 80*4882a593Smuzhiyun #define LOGV(...) fprintf(stdout, "V:" __VA_ARGS__) 81*4882a593Smuzhiyun #define LOGD(...) fprintf(stdout, "D:" __VA_ARGS__) 82*4882a593Smuzhiyun #else 83*4882a593Smuzhiyun #define LOGV(...) do {} while (0) 84*4882a593Smuzhiyun #define LOGD(...) do {} while (0) 85*4882a593Smuzhiyun #endif 86*4882a593Smuzhiyun 87*4882a593Smuzhiyun #define STRINGIFY(x) #x 88*4882a593Smuzhiyun #define EXPAND(x) STRINGIFY(x) 89*4882a593Smuzhiyun 90*4882a593Smuzhiyun typedef struct { 91*4882a593Smuzhiyun const char* mount_point; // eg. "/cache". must live in the root directory. 92*4882a593Smuzhiyun 93*4882a593Smuzhiyun const char* fs_type; // "yaffs2" or "ext4" or "vfat" 94*4882a593Smuzhiyun 95*4882a593Smuzhiyun const char* device; // MTD partition name if fs_type == "yaffs" 96*4882a593Smuzhiyun // block device if fs_type == "ext4" or "vfat" 97*4882a593Smuzhiyun 98*4882a593Smuzhiyun const char* device2; // alternative device to try if fs_type 99*4882a593Smuzhiyun // == "ext4" or "vfat" and mounting 100*4882a593Smuzhiyun // 'device' fails 101*4882a593Smuzhiyun 102*4882a593Smuzhiyun const char* option; // mount parameter 103*4882a593Smuzhiyun 104*4882a593Smuzhiyun const char* dump; // 105*4882a593Smuzhiyun 106*4882a593Smuzhiyun const char* pass; // 107*4882a593Smuzhiyun } Volume; 108*4882a593Smuzhiyun 109*4882a593Smuzhiyun #define MAX_COLS 96 110*4882a593Smuzhiyun #define MAX_ROWS 32 111*4882a593Smuzhiyun #define CHAR_WIDTH 10 112*4882a593Smuzhiyun #define CHAR_HEIGHT 18 113*4882a593Smuzhiyun 114*4882a593Smuzhiyun #define kMaxTiles 50 115*4882a593Smuzhiyun 116*4882a593Smuzhiyun struct display_info { 117*4882a593Smuzhiyun int col; 118*4882a593Smuzhiyun int row; 119*4882a593Smuzhiyun int r; 120*4882a593Smuzhiyun int g; 121*4882a593Smuzhiyun int b; 122*4882a593Smuzhiyun int a; 123*4882a593Smuzhiyun char string[128]; 124*4882a593Smuzhiyun }; 125*4882a593Smuzhiyun 126*4882a593Smuzhiyun void ui_print_init(void); 127*4882a593Smuzhiyun void ui_print_xy_rgba(int t_col,int t_row,int r,int g,int b,int a,const char* fmt, ...); 128*4882a593Smuzhiyun void drawline(int r,int g,int b,int a,int x0,int y0,int x1,int y1,int linewidth); 129*4882a593Smuzhiyun void drawline_4(int r,int g,int b,int a,int left,int top,int width,int height,int linewidth); 130*4882a593Smuzhiyun void ui_print_xy_rgba_multi(struct display_info *info, int count); 131*4882a593Smuzhiyun void ui_display_sync(int t_col,int t_row,int r,int g,int b,int a,const char* fmt, ...); 132*4882a593Smuzhiyun void FillColor(int r,int g,int b,int a,int left,int top,int width,int height); 133*4882a593Smuzhiyun 134*4882a593Smuzhiyun void start_input_thread(void); 135*4882a593Smuzhiyun 136*4882a593Smuzhiyun int get_cur_print_y(void); 137*4882a593Smuzhiyun 138*4882a593Smuzhiyun int run_test_item_cmd(char* item_bin); 139*4882a593Smuzhiyun int parse_test_result(char* rst_filename, char* test_item, char* para0); 140*4882a593Smuzhiyun 141*4882a593Smuzhiyun 142*4882a593Smuzhiyun 143*4882a593Smuzhiyun #endif // RECOVERY_COMMON_H 144