1 /* 2 * Copyright (C) 2007 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_COMMON_H 18 #define RECOVERY_COMMON_H 19 20 #include <stdio.h> 21 #include <stdbool.h> 22 #include "update_engine/log.h" 23 24 #define MISC_PARTITION_NAME_BLOCK "/dev/block/by-name/misc" 25 #define MISC_PARTITION_NAME_MTD "misc" 26 27 // Initialize the graphics system. 28 void ui_init(); 29 30 // Use KEY_* codes from <linux/input.h> or KEY_DREAM_* from "minui/minui.h". 31 int ui_wait_key(); // waits for a key/button press, returns the code 32 int ui_key_pressed(int key); // returns >0 if the code is currently pressed 33 int ui_text_visible(); // returns >0 if text log is currently visible 34 void ui_show_text(int visible); 35 void ui_clear_key_queue(); 36 37 // Write a message to the on-screen log shown with Alt-L (also to stderr). 38 // The screen is small, and users may need to report these messages to support, 39 // so keep the output short and not too cryptic. 40 void ui_print(const char *fmt, ...) __attribute__((format(printf, 1, 2))); 41 42 // Display some header text followed by a menu of items, which appears 43 // at the top of the screen (in place of any scrolling ui_print() 44 // output, if necessary). 45 void ui_start_menu(char** headers, char** items, int initial_selection); 46 // Set the menu highlight to the given index, and return it (capped to 47 // the range [0..numitems). 48 int ui_menu_select(int sel); 49 // End menu mode, resetting the text overlay so that ui_print() 50 // statements will be displayed. 51 void ui_end_menu(); 52 53 // Set the icon (normally the only thing visible besides the progress bar). 54 enum { 55 BACKGROUND_ICON_NONE, 56 BACKGROUND_ICON_INSTALLING, 57 BACKGROUND_ICON_ERROR, 58 NUM_BACKGROUND_ICONS 59 }; 60 void ui_set_background(int icon); 61 62 // Show a progress bar and define the scope of the next operation: 63 // portion - fraction of the progress bar the next operation will use 64 // seconds - expected time interval (progress bar moves at this minimum rate) 65 void ui_show_progress(float portion, int seconds); 66 void ui_set_progress(float fraction); // 0.0 - 1.0 within the defined scope 67 68 // Default allocation of progress bar segments to operations 69 static const int VERIFICATION_PROGRESS_TIME = 60; 70 static const float VERIFICATION_PROGRESS_FRACTION = 0.25; 71 static const float DEFAULT_FILES_PROGRESS_FRACTION = 0.4; 72 static const float DEFAULT_IMAGE_PROGRESS_FRACTION = 0.1; 73 74 // Show a rotating "barberpole" for ongoing operations. Updates automatically. 75 void ui_show_indeterminate_progress(); 76 77 // Hide and reset the progress bar. 78 void ui_reset_progress(); 79 80 #define MOD_TAG "RECOVERY" 81 82 83 #define FUNC_ENTER() LOGD("%s:%d : Enter >>>>\n", __func__,__LINE__) 84 #define FUNC_LEAVE() LOGD("%s:%d : Leave <<<<\n", __func__,__LINE__) 85 86 87 #define STRINGIFY(x) #x 88 #define EXPAND(x) STRINGIFY(x) 89 90 typedef struct { 91 const char* mount_point; // eg. "/cache". must live in the root directory. 92 93 const char* fs_type; // "yaffs2" or "ext4" or "vfat" 94 95 const char* device; // MTD partition name if fs_type == "yaffs" 96 // block device if fs_type == "ext4" or "vfat" 97 98 const char* device2; // alternative device to try if fs_type 99 // == "ext4" or "vfat" and mounting 100 // 'device' fails 101 102 const char* option; // mount parameter 103 104 const char* dump; // 105 106 const char* pass; // 107 } Volume; 108 109 #endif // RECOVERY_COMMON_H 110