diff options
author | The Android Open Source Project | 2008-10-21 09:00:00 -0500 |
---|---|---|
committer | The Android Open Source Project | 2008-10-21 09:00:00 -0500 |
commit | 23580ca27a0a8109312fdd36cc363ad1f4719889 (patch) | |
tree | 0bb90eaa72f8df110162499f756b5cbfb7d49235 /common.h | |
download | platform-bootable-recovery-23580ca27a0a8109312fdd36cc363ad1f4719889.tar.gz platform-bootable-recovery-23580ca27a0a8109312fdd36cc363ad1f4719889.tar.xz platform-bootable-recovery-23580ca27a0a8109312fdd36cc363ad1f4719889.zip |
Initial Contribution
Diffstat (limited to 'common.h')
-rw-r--r-- | common.h | 82 |
1 files changed, 82 insertions, 0 deletions
diff --git a/common.h b/common.h new file mode 100644 index 00000000..76d5747b --- /dev/null +++ b/common.h | |||
@@ -0,0 +1,82 @@ | |||
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 | ||
29 | |||
30 | // Write a message to the on-screen log shown with Alt-L (also to stderr). | ||
31 | // The screen is small, and users may need to report these messages to support, | ||
32 | // so keep the output short and not too cryptic. | ||
33 | void ui_print(const char *fmt, ...); | ||
34 | |||
35 | // Set the icon (normally the only thing visible besides the progress bar). | ||
36 | enum { | ||
37 | BACKGROUND_ICON_NONE, | ||
38 | BACKGROUND_ICON_UNPACKING, | ||
39 | BACKGROUND_ICON_INSTALLING, | ||
40 | BACKGROUND_ICON_ERROR, | ||
41 | BACKGROUND_ICON_FIRMWARE_INSTALLING, | ||
42 | BACKGROUND_ICON_FIRMWARE_ERROR, | ||
43 | NUM_BACKGROUND_ICONS | ||
44 | }; | ||
45 | void ui_set_background(int icon); | ||
46 | |||
47 | // Get a malloc'd copy of the screen image showing (only) the specified icon. | ||
48 | // Also returns the width, height, and bits per pixel of the returned image. | ||
49 | // TODO: Use some sort of "struct Bitmap" here instead of all these variables? | ||
50 | char *ui_copy_image(int icon, int *width, int *height, int *bpp); | ||
51 | |||
52 | // Show a progress bar and define the scope of the next operation: | ||
53 | // portion - fraction of the progress bar the next operation will use | ||
54 | // seconds - expected time interval (progress bar moves at this minimum rate) | ||
55 | void ui_show_progress(float portion, int seconds); | ||
56 | void ui_set_progress(float fraction); // 0.0 - 1.0 within the defined scope | ||
57 | |||
58 | // Default allocation of progress bar segments to operations | ||
59 | static const int VERIFICATION_PROGRESS_TIME = 60; | ||
60 | static const float VERIFICATION_PROGRESS_FRACTION = 0.5; | ||
61 | static const float DEFAULT_FILES_PROGRESS_FRACTION = 0.4; | ||
62 | static const float DEFAULT_IMAGE_PROGRESS_FRACTION = 0.1; | ||
63 | |||
64 | // Show a rotating "barberpole" for ongoing operations. Updates automatically. | ||
65 | void ui_show_indeterminate_progress(); | ||
66 | |||
67 | // Hide and reset the progress bar. | ||
68 | void ui_reset_progress(); | ||
69 | |||
70 | #define LOGE(...) ui_print("E:" __VA_ARGS__) | ||
71 | #define LOGW(...) fprintf(stderr, "W:" __VA_ARGS__) | ||
72 | #define LOGI(...) fprintf(stderr, "I:" __VA_ARGS__) | ||
73 | |||
74 | #if 0 | ||
75 | #define LOGV(...) fprintf(stderr, "V:" __VA_ARGS__) | ||
76 | #define LOGD(...) fprintf(stderr, "D:" __VA_ARGS__) | ||
77 | #else | ||
78 | #define LOGV(...) do {} while (0) | ||
79 | #define LOGD(...) do {} while (0) | ||
80 | #endif | ||
81 | |||
82 | #endif // RECOVERY_COMMON_H | ||