summaryrefslogtreecommitdiffstats
path: root/screen_ui.cpp
diff options
context:
space:
mode:
authorTao Bao <tbao@google.com>2015-06-03 20:36:16 +0200
committerAndroid Git Automerger <android-git-automerger@android.com>2015-06-03 20:36:16 +0200
commit5393149d53785cc8a690b93ca4f0db490d216937 (patch)
tree453a397c8efa9f42307fd4fd5f681466d7fc20ed /screen_ui.cpp
parentam 02b64725: Merge "uncrypt: Write status when it reboots to factory reset" into mnc-dev (diff)
parentam a69e608a: Merge "Log update outputs in order" (diff)
downloadandroid_bootable_recovery-5393149d53785cc8a690b93ca4f0db490d216937.tar
android_bootable_recovery-5393149d53785cc8a690b93ca4f0db490d216937.tar.gz
android_bootable_recovery-5393149d53785cc8a690b93ca4f0db490d216937.tar.bz2
android_bootable_recovery-5393149d53785cc8a690b93ca4f0db490d216937.tar.lz
android_bootable_recovery-5393149d53785cc8a690b93ca4f0db490d216937.tar.xz
android_bootable_recovery-5393149d53785cc8a690b93ca4f0db490d216937.tar.zst
android_bootable_recovery-5393149d53785cc8a690b93ca4f0db490d216937.zip
Diffstat (limited to '')
-rw-r--r--screen_ui.cpp35
1 files changed, 25 insertions, 10 deletions
diff --git a/screen_ui.cpp b/screen_ui.cpp
index ff9591514..ddf85c19e 100644
--- a/screen_ui.cpp
+++ b/screen_ui.cpp
@@ -30,8 +30,10 @@
#include <vector>
-#include "base/strings.h"
-#include "cutils/properties.h"
+#include <base/strings.h>
+#include <base/stringprintf.h>
+#include <cutils/properties.h>
+
#include "common.h"
#include "device.h"
#include "minui/minui.h"
@@ -506,18 +508,17 @@ void ScreenRecoveryUI::SetStage(int current, int max) {
pthread_mutex_unlock(&updateMutex);
}
-void ScreenRecoveryUI::Print(const char *fmt, ...) {
- char buf[256];
- va_list ap;
- va_start(ap, fmt);
- vsnprintf(buf, 256, fmt, ap);
- va_end(ap);
+void ScreenRecoveryUI::PrintV(const char* fmt, bool copy_to_stdout, va_list ap) {
+ std::string str;
+ android::base::StringAppendV(&str, fmt, ap);
- fputs(buf, stdout);
+ if (copy_to_stdout) {
+ fputs(str.c_str(), stdout);
+ }
pthread_mutex_lock(&updateMutex);
if (text_rows_ > 0 && text_cols_ > 0) {
- for (const char* ptr = buf; *ptr != '\0'; ++ptr) {
+ 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;
@@ -532,6 +533,20 @@ void ScreenRecoveryUI::Print(const char *fmt, ...) {
pthread_mutex_unlock(&updateMutex);
}
+void ScreenRecoveryUI::Print(const char* fmt, ...) {
+ va_list ap;
+ va_start(ap, fmt);
+ PrintV(fmt, true, ap);
+ va_end(ap);
+}
+
+void ScreenRecoveryUI::PrintOnScreenOnly(const char *fmt, ...) {
+ va_list ap;
+ va_start(ap, fmt);
+ PrintV(fmt, false, ap);
+ va_end(ap);
+}
+
void ScreenRecoveryUI::PutChar(char ch) {
pthread_mutex_lock(&updateMutex);
if (ch != '\n') text_[text_row_][text_col_++] = ch;