summaryrefslogtreecommitdiffstats
path: root/screen_ui.cpp
diff options
context:
space:
mode:
authorSteve Kondik <shade@chemlab.org>2014-09-12 18:52:28 -0700
committerTom Marshall <tdm@cyngn.com>2015-11-25 15:35:22 -0800
commitf868d833885bd6118b13eae5a7347f9dd9aeda75 (patch)
tree0acd839eb7e4008ff1ad137ae610afd0fdeb85bb /screen_ui.cpp
parent8e614b89838dda1adff952c0bfbb02721bb5db2b (diff)
downloadbootable_recovery-f868d833885bd6118b13eae5a7347f9dd9aeda75.zip
bootable_recovery-f868d833885bd6118b13eae5a7347f9dd9aeda75.tar.gz
bootable_recovery-f868d833885bd6118b13eae5a7347f9dd9aeda75.tar.bz2
sr: Fix the progress bar
* The progress thread is running all the time, which causes the device to heat up while in recovery. Start this thread only when the progress mode is set to something other than EMPTY, and add a terminating condition so that it exits when finished. * Incorporate Tom's patch to keep it updated when visible, since both are needed to get working progress indications without killing batteries. * Clear buffer in draw_progress_locked() and always call this in update_progress_locked(). This is necessary to ensure that all backing frames in the graphics implementation get updated because we aren't guaranteed to have any particular number of backing frames. * Remove dialogs on wipe operations since we are using the progress animation now. * Set progress indicator after showing "Formatting" text to avoid momentary flicker. Change-Id: Ib70d2cb25f01d9920ffb698b5b5b47af827ef483
Diffstat (limited to 'screen_ui.cpp')
-rw-r--r--screen_ui.cpp22
1 files changed, 13 insertions, 9 deletions
diff --git a/screen_ui.cpp b/screen_ui.cpp
index 464e77d..2bb7112 100644
--- a/screen_ui.cpp
+++ b/screen_ui.cpp
@@ -139,6 +139,9 @@ void ScreenRecoveryUI::draw_background_locked(Icon icon) {
void ScreenRecoveryUI::draw_progress_locked() {
if (currentIcon == D_ERROR) return;
+ gr_color(0, 0, 0, 255);
+ gr_clear();
+
if (currentIcon == INSTALLING_UPDATE || currentIcon == ERASING) {
GRSurface* icon = installation[installingFrame];
gr_blit(icon, 0, 0, gr_get_width(icon), gr_get_height(icon), iconX, iconY);
@@ -394,12 +397,7 @@ void ScreenRecoveryUI::update_screen_locked() {
// Updates only the progress bar, if possible, otherwise redraws the screen.
// Should only be called with updateMutex locked.
void ScreenRecoveryUI::update_progress_locked() {
- if (show_text || !pagesIdentical) {
- draw_screen_locked(); // Must redraw the whole screen
- pagesIdentical = true;
- } else {
- draw_progress_locked(); // Draw only the progress bar and overlays
- }
+ draw_progress_locked();
gr_flip();
}
@@ -426,7 +424,7 @@ void ScreenRecoveryUI::ProgressThreadLoop() {
// update the installation animation, if active
// skip this if we have a text overlay (too expensive to update)
if ((currentIcon == INSTALLING_UPDATE || currentIcon == ERASING) &&
- installing_frames > 0 && !show_text) {
+ installing_frames > 0) {
installingFrame = (installingFrame + 1) % installing_frames;
redraw = 1;
}
@@ -446,11 +444,16 @@ void ScreenRecoveryUI::ProgressThreadLoop() {
if (redraw) update_progress_locked();
pthread_mutex_unlock(&updateMutex);
+
+ if (progressBarType == EMPTY)
+ break;
+
double end = now();
// minimum of 20ms delay between frames
double delay = interval - (end-start);
if (delay < 0.02) delay = 0.02;
usleep((long)(delay * 1000000));
+
}
}
@@ -530,8 +533,6 @@ void ScreenRecoveryUI::Init() {
LoadLocalizedBitmap("no_command_text", &backgroundText[NO_COMMAND]);
LoadLocalizedBitmap("error_text", &backgroundText[D_ERROR]);
- pthread_create(&progress_thread_, nullptr, ProgressThreadStartRoutine, this);
-
RecoveryUI::Init();
}
@@ -574,6 +575,9 @@ void ScreenRecoveryUI::SetProgressType(ProgressType type) {
pthread_mutex_lock(&updateMutex);
if (progressBarType != type) {
progressBarType = type;
+ if (progressBarType != EMPTY) {
+ pthread_create(&progress_thread_, nullptr, ProgressThreadStartRoutine, this);
+ }
}
progressScopeStart = 0;
progressScopeSize = 0;