blob: 97e87eec5261b0d4a3588cc245d18559bac9c9f5 [file] [log] [blame]
The Android Open Source Projectc24a8e62009-03-03 19:28:42 -08001/*
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.
23void ui_init();
24
25// Use KEY_* codes from <linux/input.h> or KEY_DREAM_* from "minui/minui.h".
26int ui_wait_key(); // waits for a key/button press, returns the code
27int ui_key_pressed(int key); // returns >0 if the code is currently pressed
28int ui_text_visible(); // returns >0 if text log is currently visible
Doug Zongker4bc98062010-09-03 11:00:13 -070029void ui_show_text(int visible);
The Android Open Source Projectc24a8e62009-03-03 19:28:42 -080030void ui_clear_key_queue();
31
32// Write a message to the on-screen log shown with Alt-L (also to stderr).
33// The screen is small, and users may need to report these messages to support,
34// so keep the output short and not too cryptic.
Nick Kralevich21b97ed2010-06-24 16:11:17 -070035void ui_print(const char *fmt, ...) __attribute__((format(printf, 1, 2)));
The Android Open Source Projectc24a8e62009-03-03 19:28:42 -080036
37// Display some header text followed by a menu of items, which appears
38// at the top of the screen (in place of any scrolling ui_print()
39// output, if necessary).
Doug Zongkerbe598882010-04-08 14:36:55 -070040void ui_start_menu(char** headers, char** items, int initial_selection);
The Android Open Source Projectc24a8e62009-03-03 19:28:42 -080041// Set the menu highlight to the given index, and return it (capped to
42// the range [0..numitems).
43int ui_menu_select(int sel);
44// End menu mode, resetting the text overlay so that ui_print()
45// statements will be displayed.
46void ui_end_menu();
47
48// Set the icon (normally the only thing visible besides the progress bar).
49enum {
50 BACKGROUND_ICON_NONE,
The Android Open Source Projectc24a8e62009-03-03 19:28:42 -080051 BACKGROUND_ICON_INSTALLING,
52 BACKGROUND_ICON_ERROR,
The Android Open Source Projectc24a8e62009-03-03 19:28:42 -080053 NUM_BACKGROUND_ICONS
54};
55void ui_set_background(int icon);
56
The Android Open Source Projectc24a8e62009-03-03 19:28:42 -080057// Show a progress bar and define the scope of the next operation:
58// portion - fraction of the progress bar the next operation will use
59// seconds - expected time interval (progress bar moves at this minimum rate)
60void ui_show_progress(float portion, int seconds);
61void ui_set_progress(float fraction); // 0.0 - 1.0 within the defined scope
62
63// Default allocation of progress bar segments to operations
64static const int VERIFICATION_PROGRESS_TIME = 60;
Doug Zongkerfd8fb0c2009-09-20 14:10:27 -070065static const float VERIFICATION_PROGRESS_FRACTION = 0.25;
The Android Open Source Projectc24a8e62009-03-03 19:28:42 -080066static const float DEFAULT_FILES_PROGRESS_FRACTION = 0.4;
67static const float DEFAULT_IMAGE_PROGRESS_FRACTION = 0.1;
68
69// Show a rotating "barberpole" for ongoing operations. Updates automatically.
70void ui_show_indeterminate_progress();
71
72// Hide and reset the progress bar.
73void ui_reset_progress();
74
75#define LOGE(...) ui_print("E:" __VA_ARGS__)
Doug Zongker3d177d02010-07-01 09:18:44 -070076#define LOGW(...) fprintf(stdout, "W:" __VA_ARGS__)
77#define LOGI(...) fprintf(stdout, "I:" __VA_ARGS__)
The Android Open Source Projectc24a8e62009-03-03 19:28:42 -080078
79#if 0
Doug Zongker3d177d02010-07-01 09:18:44 -070080#define LOGV(...) fprintf(stdout, "V:" __VA_ARGS__)
81#define LOGD(...) fprintf(stdout, "D:" __VA_ARGS__)
The Android Open Source Projectc24a8e62009-03-03 19:28:42 -080082#else
83#define LOGV(...) do {} while (0)
84#define LOGD(...) do {} while (0)
85#endif
86
Doug Zongkerfb2e3af2009-06-17 17:29:40 -070087#define STRINGIFY(x) #x
88#define EXPAND(x) STRINGIFY(x)
89
Doug Zongkercc8cd3f2010-09-20 12:16:13 -070090typedef 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} Volume;
102
The Android Open Source Projectc24a8e62009-03-03 19:28:42 -0800103#endif // RECOVERY_COMMON_H