The Android Open Source Project | c24a8e6 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 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 | |
| 22 | // Initialize the graphics system. |
| 23 | void ui_init(); |
| 24 | |
| 25 | // Use KEY_* codes from <linux/input.h> or KEY_DREAM_* from "minui/minui.h". |
| 26 | int ui_wait_key(); // waits for a key/button press, returns the code |
| 27 | int ui_key_pressed(int key); // returns >0 if the code is currently pressed |
| 28 | int ui_text_visible(); // returns >0 if text log is currently visible |
Doug Zongker | 5cae445 | 2011-01-25 13:15:30 -0800 | [diff] [blame] | 29 | int ui_text_ever_visible(); // returns >0 if text log was ever visible |
Doug Zongker | 4bc9806 | 2010-09-03 11:00:13 -0700 | [diff] [blame] | 30 | void ui_show_text(int visible); |
The Android Open Source Project | c24a8e6 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 31 | void ui_clear_key_queue(); |
| 32 | |
| 33 | // Write a message to the on-screen log shown with Alt-L (also to stderr). |
| 34 | // The screen is small, and users may need to report these messages to support, |
| 35 | // so keep the output short and not too cryptic. |
Nick Kralevich | 21b97ed | 2010-06-24 16:11:17 -0700 | [diff] [blame] | 36 | void ui_print(const char *fmt, ...) __attribute__((format(printf, 1, 2))); |
The Android Open Source Project | c24a8e6 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 37 | |
| 38 | // Display some header text followed by a menu of items, which appears |
| 39 | // at the top of the screen (in place of any scrolling ui_print() |
| 40 | // output, if necessary). |
Doug Zongker | be59888 | 2010-04-08 14:36:55 -0700 | [diff] [blame] | 41 | void ui_start_menu(char** headers, char** items, int initial_selection); |
The Android Open Source Project | c24a8e6 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 42 | // Set the menu highlight to the given index, and return it (capped to |
| 43 | // the range [0..numitems). |
| 44 | int ui_menu_select(int sel); |
| 45 | // End menu mode, resetting the text overlay so that ui_print() |
| 46 | // statements will be displayed. |
| 47 | void ui_end_menu(); |
| 48 | |
| 49 | // Set the icon (normally the only thing visible besides the progress bar). |
| 50 | enum { |
| 51 | BACKGROUND_ICON_NONE, |
The Android Open Source Project | c24a8e6 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 52 | BACKGROUND_ICON_INSTALLING, |
| 53 | BACKGROUND_ICON_ERROR, |
The Android Open Source Project | c24a8e6 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 54 | NUM_BACKGROUND_ICONS |
| 55 | }; |
| 56 | void ui_set_background(int icon); |
| 57 | |
The Android Open Source Project | c24a8e6 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 58 | // Show a progress bar and define the scope of the next operation: |
| 59 | // portion - fraction of the progress bar the next operation will use |
| 60 | // seconds - expected time interval (progress bar moves at this minimum rate) |
| 61 | void ui_show_progress(float portion, int seconds); |
| 62 | void ui_set_progress(float fraction); // 0.0 - 1.0 within the defined scope |
| 63 | |
| 64 | // Default allocation of progress bar segments to operations |
| 65 | static const int VERIFICATION_PROGRESS_TIME = 60; |
Doug Zongker | fd8fb0c | 2009-09-20 14:10:27 -0700 | [diff] [blame] | 66 | static const float VERIFICATION_PROGRESS_FRACTION = 0.25; |
The Android Open Source Project | c24a8e6 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 67 | static const float DEFAULT_FILES_PROGRESS_FRACTION = 0.4; |
| 68 | static const float DEFAULT_IMAGE_PROGRESS_FRACTION = 0.1; |
| 69 | |
| 70 | // Show a rotating "barberpole" for ongoing operations. Updates automatically. |
| 71 | void ui_show_indeterminate_progress(); |
| 72 | |
| 73 | // Hide and reset the progress bar. |
| 74 | void ui_reset_progress(); |
| 75 | |
| 76 | #define LOGE(...) ui_print("E:" __VA_ARGS__) |
Doug Zongker | 3d177d0 | 2010-07-01 09:18:44 -0700 | [diff] [blame] | 77 | #define LOGW(...) fprintf(stdout, "W:" __VA_ARGS__) |
| 78 | #define LOGI(...) fprintf(stdout, "I:" __VA_ARGS__) |
The Android Open Source Project | c24a8e6 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 79 | |
| 80 | #if 0 |
Doug Zongker | 3d177d0 | 2010-07-01 09:18:44 -0700 | [diff] [blame] | 81 | #define LOGV(...) fprintf(stdout, "V:" __VA_ARGS__) |
| 82 | #define LOGD(...) fprintf(stdout, "D:" __VA_ARGS__) |
The Android Open Source Project | c24a8e6 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 83 | #else |
| 84 | #define LOGV(...) do {} while (0) |
| 85 | #define LOGD(...) do {} while (0) |
| 86 | #endif |
| 87 | |
Doug Zongker | fb2e3af | 2009-06-17 17:29:40 -0700 | [diff] [blame] | 88 | #define STRINGIFY(x) #x |
| 89 | #define EXPAND(x) STRINGIFY(x) |
| 90 | |
Doug Zongker | cc8cd3f | 2010-09-20 12:16:13 -0700 | [diff] [blame] | 91 | typedef struct { |
| 92 | const char* mount_point; // eg. "/cache". must live in the root directory. |
| 93 | |
| 94 | const char* fs_type; // "yaffs2" or "ext4" or "vfat" |
| 95 | |
| 96 | const char* device; // MTD partition name if fs_type == "yaffs" |
| 97 | // block device if fs_type == "ext4" or "vfat" |
| 98 | |
| 99 | const char* device2; // alternative device to try if fs_type |
| 100 | // == "ext4" or "vfat" and mounting |
| 101 | // 'device' fails |
Doug Zongker | 2810ced | 2011-02-17 15:55:21 -0800 | [diff] [blame] | 102 | |
| 103 | long long length; // (ext4 partition only) when |
| 104 | // formatting, size to use for the |
| 105 | // partition. 0 or negative number |
| 106 | // means to format all but the last |
| 107 | // (that much). |
Doug Zongker | cc8cd3f | 2010-09-20 12:16:13 -0700 | [diff] [blame] | 108 | } Volume; |
| 109 | |
Doug Zongker | 6809c51 | 2011-03-01 14:04:34 -0800 | [diff] [blame] | 110 | typedef struct { |
| 111 | // number of frames in indeterminate progress bar animation |
| 112 | int indeterminate_frames; |
| 113 | |
| 114 | // number of frames per second to try to maintain when animating |
| 115 | int update_fps; |
| 116 | |
| 117 | // number of frames in installing animation. may be zero for a |
| 118 | // static installation icon. |
| 119 | int installing_frames; |
| 120 | |
| 121 | // the install icon is animated by drawing images containing the |
| 122 | // changing part over the base icon. These specify the |
| 123 | // coordinates of the upper-left corner. |
| 124 | int install_overlay_offset_x; |
| 125 | int install_overlay_offset_y; |
| 126 | |
| 127 | } UIParameters; |
| 128 | |
The Android Open Source Project | c24a8e6 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 129 | #endif // RECOVERY_COMMON_H |