diff options
author | Prashant Malani <pmalani@google.com> | 2016-02-29 23:56:30 +0100 |
---|---|---|
committer | Android (Google) Code Review <android-gerrit@google.com> | 2016-02-29 23:56:30 +0100 |
commit | 9db7964834694e10ce0945e17ac7fefc066d8deb (patch) | |
tree | 9c6abab38389c7c536cf8beea4e695726e1a15da /wear_ui.cpp | |
parent | Merge "uncrypt: Retire pre-recovery service." into nyc-dev (diff) | |
parent | Fixes to wear recovery for N (diff) | |
download | android_bootable_recovery-9db7964834694e10ce0945e17ac7fefc066d8deb.tar android_bootable_recovery-9db7964834694e10ce0945e17ac7fefc066d8deb.tar.gz android_bootable_recovery-9db7964834694e10ce0945e17ac7fefc066d8deb.tar.bz2 android_bootable_recovery-9db7964834694e10ce0945e17ac7fefc066d8deb.tar.lz android_bootable_recovery-9db7964834694e10ce0945e17ac7fefc066d8deb.tar.xz android_bootable_recovery-9db7964834694e10ce0945e17ac7fefc066d8deb.tar.zst android_bootable_recovery-9db7964834694e10ce0945e17ac7fefc066d8deb.zip |
Diffstat (limited to 'wear_ui.cpp')
-rw-r--r-- | wear_ui.cpp | 33 |
1 files changed, 33 insertions, 0 deletions
diff --git a/wear_ui.cpp b/wear_ui.cpp index 50aeb3849..8a57cfffa 100644 --- a/wear_ui.cpp +++ b/wear_ui.cpp @@ -36,6 +36,7 @@ #include "ui.h" #include "cutils/properties.h" #include "android-base/strings.h" +#include "android-base/stringprintf.h" static int char_width; static int char_height; @@ -653,3 +654,35 @@ void WearRecoveryUI::ClearText() { } pthread_mutex_unlock(&updateMutex); } + +void WearRecoveryUI::PrintOnScreenOnly(const char *fmt, ...) { + va_list ap; + va_start(ap, fmt); + PrintV(fmt, false, ap); + va_end(ap); +} + +void WearRecoveryUI::PrintV(const char* fmt, bool copy_to_stdout, va_list ap) { + std::string str; + android::base::StringAppendV(&str, fmt, ap); + + if (copy_to_stdout) { + fputs(str.c_str(), stdout); + } + + pthread_mutex_lock(&updateMutex); + if (text_rows > 0 && text_cols > 0) { + for (const char* ptr = str.c_str(); *ptr != '\0'; ++ptr) { + if (*ptr == '\n' || text_col >= text_cols) { + text[text_row][text_col] = '\0'; + text_col = 0; + text_row = (text_row + 1) % text_rows; + if (text_row == text_top) text_top = (text_top + 1) % text_rows; + } + if (*ptr != '\n') text[text_row][text_col++] = *ptr; + } + text[text_row][text_col] = '\0'; + update_screen_locked(); + } + pthread_mutex_unlock(&updateMutex); +} |