Merge "Fixes to wear recovery for N" into nyc-dev

This commit is contained in:
Prashant Malani 2016-02-29 22:56:30 +00:00 committed by Android (Google) Code Review
commit 9db7964834
2 changed files with 35 additions and 0 deletions

View file

@ -36,6 +36,7 @@
#include "ui.h" #include "ui.h"
#include "cutils/properties.h" #include "cutils/properties.h"
#include "android-base/strings.h" #include "android-base/strings.h"
#include "android-base/stringprintf.h"
static int char_width; static int char_width;
static int char_height; static int char_height;
@ -653,3 +654,35 @@ void WearRecoveryUI::ClearText() {
} }
pthread_mutex_unlock(&updateMutex); 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);
}

View file

@ -47,6 +47,7 @@ class WearRecoveryUI : public RecoveryUI {
// printing messages // printing messages
void Print(const char* fmt, ...); void Print(const char* fmt, ...);
void PrintOnScreenOnly(const char* fmt, ...) __printflike(2, 3);
void ShowFile(const char* filename); void ShowFile(const char* filename);
void ShowFile(FILE* fp); void ShowFile(FILE* fp);
@ -133,6 +134,7 @@ class WearRecoveryUI : public RecoveryUI {
void ClearText(); void ClearText();
void DrawTextLine(int x, int* y, const char* line, bool bold); void DrawTextLine(int x, int* y, const char* line, bool bold);
void DrawTextLines(int x, int* y, const char* const* lines); void DrawTextLines(int x, int* y, const char* const* lines);
void PrintV(const char*, bool, va_list);
}; };
#endif // RECOVERY_WEAR_UI_H #endif // RECOVERY_WEAR_UI_H