summaryrefslogtreecommitdiffstats
path: root/screen_ui.cpp
diff options
context:
space:
mode:
authorDoug Zongker <dougz@google.com>2013-11-25 13:53:25 -0800
committerDoug Zongker <dougz@google.com>2013-11-26 15:46:57 -0800
commitc87bab101893e8322b49d7c8600e3367b20ab50a (patch)
tree7fb05cb6389b181776b4ae818e2c0883dd1a9a79 /screen_ui.cpp
parentc64e76c75088b951f61a7f7bacf8af6eccd2ccfa (diff)
downloadbootable_recovery-c87bab101893e8322b49d7c8600e3367b20ab50a.zip
bootable_recovery-c87bab101893e8322b49d7c8600e3367b20ab50a.tar.gz
bootable_recovery-c87bab101893e8322b49d7c8600e3367b20ab50a.tar.bz2
add the functions for multi-stage packages to updater
In order to support multi-stage recovery packages, we add the set_stage() and get_stage() functions, which store a short string somewhere it can be accessed across invocations of recovery. We also add reboot_now() which updater can invoke to immediately reboot the device, without doing normal recovery cleanup. (It can also choose whether to boot off the boot or recovery partition.) If the stage string is of the form "#/#", recovery's UI will be augmented with a simple indicator of what stage you're in, so it doesn't look like a reboot loop. Change-Id: I62f7ff0bc802b549c9bcf3cc154a6bad99f94603
Diffstat (limited to 'screen_ui.cpp')
-rw-r--r--screen_ui.cpp36
1 files changed, 32 insertions, 4 deletions
diff --git a/screen_ui.cpp b/screen_ui.cpp
index 8376341..27d0a24 100644
--- a/screen_ui.cpp
+++ b/screen_ui.cpp
@@ -81,7 +81,9 @@ ScreenRecoveryUI::ScreenRecoveryUI() :
install_overlay_offset_x(13),
install_overlay_offset_y(190),
overlay_offset_x(-1),
- overlay_offset_y(-1) {
+ overlay_offset_y(-1),
+ stage(-1),
+ max_stage(-1) {
for (int i = 0; i < 5; i++)
backgroundIcon[i] = NULL;
@@ -120,14 +122,28 @@ void ScreenRecoveryUI::draw_background_locked(Icon icon)
int iconHeight = gr_get_height(surface);
int textWidth = gr_get_width(text_surface);
int textHeight = gr_get_height(text_surface);
+ int stageHeight = gr_get_height(stageMarkerEmpty);
+
+ int sh = (max_stage >= 0) ? stageHeight : 0;
int iconX = (gr_fb_width() - iconWidth) / 2;
- int iconY = (gr_fb_height() - (iconHeight+textHeight+40)) / 2;
+ int iconY = (gr_fb_height() - (iconHeight+textHeight+40+sh)) / 2;
int textX = (gr_fb_width() - textWidth) / 2;
- int textY = ((gr_fb_height() - (iconHeight+textHeight+40)) / 2) + iconHeight + 40;
+ int textY = ((gr_fb_height() - (iconHeight+textHeight+40+sh)) / 2) + iconHeight + 40;
gr_blit(surface, 0, 0, iconWidth, iconHeight, iconX, iconY);
+ if (stageHeight > 0) {
+ int sw = gr_get_width(stageMarkerEmpty);
+ int x = (gr_fb_width() - max_stage * gr_get_width(stageMarkerEmpty)) / 2;
+ int y = iconY + iconHeight + 20;
+ for (int i = 0; i < max_stage; ++i) {
+ gr_blit((i < stage) ? stageMarkerFill : stageMarkerEmpty,
+ 0, 0, sw, stageHeight, x, y);
+ x += sw;
+ }
+ }
+
if (icon == INSTALLING_UPDATE || icon == ERASING) {
draw_install_overlay_locked(installingFrame);
}
@@ -383,6 +399,8 @@ void ScreenRecoveryUI::Init()
LoadBitmap("progress_empty", &progressBarEmpty);
LoadBitmap("progress_fill", &progressBarFill);
+ LoadBitmap("stage_empty", &stageMarkerEmpty);
+ LoadBitmap("stage_fill", &stageMarkerFill);
LoadLocalizedBitmap("installing_text", &backgroundText[INSTALLING_UPDATE]);
LoadLocalizedBitmap("erasing_text", &backgroundText[ERASING]);
@@ -453,7 +471,10 @@ void ScreenRecoveryUI::SetBackground(Icon icon)
gr_surface text = backgroundText[icon];
overlay_offset_x = install_overlay_offset_x + (gr_fb_width() - gr_get_width(bg)) / 2;
overlay_offset_y = install_overlay_offset_y +
- (gr_fb_height() - (gr_get_height(bg) + gr_get_height(text) + 40)) / 2;
+ (gr_fb_height() - (gr_get_height(bg) +
+ gr_get_height(text) +
+ 40 +
+ ((max_stage >= 0) ? gr_get_height(stageMarkerEmpty) : 0))) / 2;
}
currentIcon = icon;
@@ -505,6 +526,13 @@ void ScreenRecoveryUI::SetProgress(float fraction)
pthread_mutex_unlock(&updateMutex);
}
+void ScreenRecoveryUI::SetStage(int current, int max) {
+ pthread_mutex_lock(&updateMutex);
+ stage = current;
+ max_stage = max;
+ pthread_mutex_unlock(&updateMutex);
+}
+
void ScreenRecoveryUI::Print(const char *fmt, ...)
{
char buf[256];