blob: 5d24881e3da077738c1169b75660f871dcc0d191 [file] [log] [blame]
preludedrew38058dc2011-01-29 23:30:44 -07001/*
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
29void ui_show_text(int visible);
30void 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.
35void ui_print(const char *fmt, ...) __attribute__((format(printf, 1, 2)));
36
37void ui_reset_text_col();
38void ui_set_show_text(int value);
39
40// Display some header text followed by a menu of items, which appears
41// at the top of the screen (in place of any scrolling ui_print()
42// output, if necessary).
43int ui_start_menu(char** headers, char** items, int initial_selection);
44// Set the menu highlight to the given index, and return it (capped to
45// the range [0..numitems).
46int ui_menu_select(int sel);
47// End menu mode, resetting the text overlay so that ui_print()
48// statements will be displayed.
49void ui_end_menu();
50
51int ui_get_showing_back_button();
52void ui_set_showing_back_button(int showBackButton);
53
54// Set the icon (normally the only thing visible besides the progress bar).
55enum {
56 BACKGROUND_ICON_NONE,
57 BACKGROUND_ICON_INSTALLING,
58 BACKGROUND_ICON_ERROR,
59 BACKGROUND_ICON_CLOCKWORK,
60 BACKGROUND_ICON_FIRMWARE_INSTALLING,
61 BACKGROUND_ICON_FIRMWARE_ERROR,
62 NUM_BACKGROUND_ICONS
63};
64void ui_set_background(int icon);
65
66// Get a malloc'd copy of the screen image showing (only) the specified icon.
67// Also returns the width, height, and bits per pixel of the returned image.
68// TODO: Use some sort of "struct Bitmap" here instead of all these variables?
69char *ui_copy_image(int icon, int *width, int *height, int *bpp);
70
71// Show a progress bar and define the scope of the next operation:
72// portion - fraction of the progress bar the next operation will use
73// seconds - expected time interval (progress bar moves at this minimum rate)
74void ui_show_progress(float portion, int seconds);
75void ui_set_progress(float fraction); // 0.0 - 1.0 within the defined scope
76
77// Default allocation of progress bar segments to operations
78static const int VERIFICATION_PROGRESS_TIME = 60;
79static const float VERIFICATION_PROGRESS_FRACTION = 0.25;
80static const float DEFAULT_FILES_PROGRESS_FRACTION = 0.4;
81static const float DEFAULT_IMAGE_PROGRESS_FRACTION = 0.1;
82
83// Show a rotating "barberpole" for ongoing operations. Updates automatically.
84void ui_show_indeterminate_progress();
85
86// Hide and reset the progress bar.
87void ui_reset_progress();
88
89#define LOGE(...) ui_print("E:" __VA_ARGS__)
90#define LOGW(...) fprintf(stdout, "W:" __VA_ARGS__)
91#define LOGI(...) fprintf(stdout, "I:" __VA_ARGS__)
92
93#if 0
94#define LOGV(...) fprintf(stdout, "V:" __VA_ARGS__)
95#define LOGD(...) fprintf(stdout, "D:" __VA_ARGS__)
96#else
97#define LOGV(...) do {} while (0)
98#define LOGD(...) do {} while (0)
99#endif
100
101#define STRINGIFY(x) #x
102#define EXPAND(x) STRINGIFY(x)
103
104typedef struct {
105 const char* mount_point; // eg. "/cache". must live in the root directory.
106
107 const char* fs_type; // "yaffs2" or "ext4" or "vfat"
108
109 const char* device; // MTD partition name if fs_type == "yaffs"
110 // block device if fs_type == "ext4" or "vfat"
111
112 const char* device2; // alternative device to try if fs_type
113 // == "ext4" or "vfat" and mounting
114 // 'device' fails
preludedrewf1ec34a2011-02-17 22:42:33 -0700115 const char* fs_type2;
preludedrew38058dc2011-01-29 23:30:44 -0700116} Volume;
117
118#endif // RECOVERY_COMMON_H