aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to 'wear_ui.cpp')
-rw-r--r--wear_ui.cpp33
1 files changed, 33 insertions, 0 deletions
diff --git a/wear_ui.cpp b/wear_ui.cpp
index 50aeb384..8a57cfff 100644
--- a/wear_ui.cpp
+++ b/wear_ui.cpp
@@ -36,6 +36,7 @@
36#include "ui.h" 36#include "ui.h"
37#include "cutils/properties.h" 37#include "cutils/properties.h"
38#include "android-base/strings.h" 38#include "android-base/strings.h"
39#include "android-base/stringprintf.h"
39 40
40static int char_width; 41static int char_width;
41static int char_height; 42static int char_height;
@@ -653,3 +654,35 @@ void WearRecoveryUI::ClearText() {
653 } 654 }
654 pthread_mutex_unlock(&updateMutex); 655 pthread_mutex_unlock(&updateMutex);
655} 656}
657
658void WearRecoveryUI::PrintOnScreenOnly(const char *fmt, ...) {
659 va_list ap;
660 va_start(ap, fmt);
661 PrintV(fmt, false, ap);
662 va_end(ap);
663}
664
665void WearRecoveryUI::PrintV(const char* fmt, bool copy_to_stdout, va_list ap) {
666 std::string str;
667 android::base::StringAppendV(&str, fmt, ap);
668
669 if (copy_to_stdout) {
670 fputs(str.c_str(), stdout);
671 }
672
673 pthread_mutex_lock(&updateMutex);
674 if (text_rows > 0 && text_cols > 0) {
675 for (const char* ptr = str.c_str(); *ptr != '\0'; ++ptr) {
676 if (*ptr == '\n' || text_col >= text_cols) {
677 text[text_row][text_col] = '\0';
678 text_col = 0;
679 text_row = (text_row + 1) % text_rows;
680 if (text_row == text_top) text_top = (text_top + 1) % text_rows;
681 }
682 if (*ptr != '\n') text[text_row][text_col++] = *ptr;
683 }
684 text[text_row][text_col] = '\0';
685 update_screen_locked();
686 }
687 pthread_mutex_unlock(&updateMutex);
688}