summaryrefslogtreecommitdiffstats
path: root/screen_ui.cpp
diff options
context:
space:
mode:
authorTao Bao <tbao@google.com>2018-05-10 01:32:02 +0200
committerJerry Zhang <zhangjerry@google.com>2018-05-22 01:37:07 +0200
commit26ea9591bcb90c5ac201fce7ce2f0e1e092c703e (patch)
tree81c9c2816f8023a2477a07266a5b075afaa0033f /screen_ui.cpp
parentrecovery: Add ability to set title lines (diff)
downloadandroid_bootable_recovery-26ea9591bcb90c5ac201fce7ce2f0e1e092c703e.tar
android_bootable_recovery-26ea9591bcb90c5ac201fce7ce2f0e1e092c703e.tar.gz
android_bootable_recovery-26ea9591bcb90c5ac201fce7ce2f0e1e092c703e.tar.bz2
android_bootable_recovery-26ea9591bcb90c5ac201fce7ce2f0e1e092c703e.tar.lz
android_bootable_recovery-26ea9591bcb90c5ac201fce7ce2f0e1e092c703e.tar.xz
android_bootable_recovery-26ea9591bcb90c5ac201fce7ce2f0e1e092c703e.tar.zst
android_bootable_recovery-26ea9591bcb90c5ac201fce7ce2f0e1e092c703e.zip
Diffstat (limited to 'screen_ui.cpp')
-rw-r--r--screen_ui.cpp18
1 files changed, 10 insertions, 8 deletions
diff --git a/screen_ui.cpp b/screen_ui.cpp
index f1b38781a..0ee0ddcec 100644
--- a/screen_ui.cpp
+++ b/screen_ui.cpp
@@ -32,8 +32,10 @@
#include <unistd.h>
#include <algorithm>
+#include <chrono>
#include <memory>
#include <string>
+#include <thread>
#include <unordered_map>
#include <vector>
@@ -172,6 +174,11 @@ ScreenRecoveryUI::ScreenRecoveryUI(bool scrollable_menu)
rtl_locale_(false),
updateMutex(PTHREAD_MUTEX_INITIALIZER) {}
+ScreenRecoveryUI::~ScreenRecoveryUI() {
+ progress_thread_stopped_ = true;
+ progress_thread_.join();
+}
+
GRSurface* ScreenRecoveryUI::GetCurrentFrame() const {
if (currentIcon == INSTALLING_UPDATE || currentIcon == ERASING) {
return intro_done ? loopFrames[current_frame] : introFrames[current_frame];
@@ -613,15 +620,9 @@ void ScreenRecoveryUI::update_progress_locked() {
gr_flip();
}
-// Keeps the progress bar updated, even when the process is otherwise busy.
-void* ScreenRecoveryUI::ProgressThreadStartRoutine(void* data) {
- reinterpret_cast<ScreenRecoveryUI*>(data)->ProgressThreadLoop();
- return nullptr;
-}
-
void ScreenRecoveryUI::ProgressThreadLoop() {
double interval = 1.0 / kAnimationFps;
- while (true) {
+ while (!progress_thread_stopped_) {
double start = now();
pthread_mutex_lock(&updateMutex);
@@ -749,7 +750,8 @@ bool ScreenRecoveryUI::Init(const std::string& locale) {
LoadAnimation();
- pthread_create(&progress_thread_, nullptr, ProgressThreadStartRoutine, this);
+ // Keep the progress bar updated, even when the process is otherwise busy.
+ progress_thread_ = std::thread(&ScreenRecoveryUI::ProgressThreadLoop, this);
return true;
}