summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTao Bao <tbao@google.com>2017-09-09 00:05:10 +0200
committerandroid-build-merger <android-build-merger@google.com>2017-09-09 00:05:10 +0200
commit190d60c62661bd44f205fed107df3d0a5eab499c (patch)
tree9c0d37334ffbec42fb11df55294a7587b29b83ac
parentMerge "ui: Manage menu_ with std::vector." am: f51bb0f2d6 am: 4e3e42bed8 am: 77425c5e15 (diff)
parentMerge "wear_ui: Remove Print()/ShowFile()/PutChar()." am: fa4f014063 am: 5f5ccacef7 (diff)
downloadandroid_bootable_recovery-190d60c62661bd44f205fed107df3d0a5eab499c.tar
android_bootable_recovery-190d60c62661bd44f205fed107df3d0a5eab499c.tar.gz
android_bootable_recovery-190d60c62661bd44f205fed107df3d0a5eab499c.tar.bz2
android_bootable_recovery-190d60c62661bd44f205fed107df3d0a5eab499c.tar.lz
android_bootable_recovery-190d60c62661bd44f205fed107df3d0a5eab499c.tar.xz
android_bootable_recovery-190d60c62661bd44f205fed107df3d0a5eab499c.tar.zst
android_bootable_recovery-190d60c62661bd44f205fed107df3d0a5eab499c.zip
-rw-r--r--wear_ui.cpp114
-rw-r--r--wear_ui.h9
2 files changed, 1 insertions, 122 deletions
diff --git a/wear_ui.cpp b/wear_ui.cpp
index edc39cfb4..1859b131c 100644
--- a/wear_ui.cpp
+++ b/wear_ui.cpp
@@ -16,29 +16,16 @@
#include "wear_ui.h"
-#include <errno.h>
-#include <fcntl.h>
#include <pthread.h>
-#include <stdarg.h>
-#include <stdlib.h>
+#include <stdio.h> // TODO: Remove after killing the call to sprintf().
#include <string.h>
-#include <sys/stat.h>
-#include <sys/time.h>
-#include <sys/types.h>
-#include <time.h>
-#include <unistd.h>
#include <string>
-#include <vector>
#include <android-base/properties.h>
-#include <android-base/stringprintf.h>
#include <android-base/strings.h>
#include <minui/minui.h>
-#include "common.h"
-#include "device.h"
-
WearRecoveryUI::WearRecoveryUI()
: kProgressBarBaseline(RECOVERY_UI_PROGRESS_BAR_BASELINE),
kMenuUnusableRows(RECOVERY_UI_MENU_UNUSABLE_ROWS) {
@@ -166,34 +153,6 @@ void WearRecoveryUI::update_progress_locked() {
void WearRecoveryUI::SetStage(int current, int max) {
}
-void WearRecoveryUI::Print(const char* fmt, ...) {
- char buf[256];
- va_list ap;
- va_start(ap, fmt);
- vsnprintf(buf, 256, fmt, ap);
- va_end(ap);
-
- fputs(buf, stdout);
-
- // This can get called before ui_init(), so be careful.
- pthread_mutex_lock(&updateMutex);
- if (text_rows_ > 0 && text_cols_ > 0) {
- char* ptr;
- for (ptr = buf; *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);
-}
-
void WearRecoveryUI::StartMenu(const char* const* headers, const char* const* items,
int initial_selection) {
pthread_mutex_lock(&updateMutex);
@@ -240,74 +199,3 @@ int WearRecoveryUI::SelectMenu(int sel) {
pthread_mutex_unlock(&updateMutex);
return sel;
}
-
-void WearRecoveryUI::ShowFile(FILE* fp) {
- std::vector<off_t> offsets;
- offsets.push_back(ftello(fp));
- ClearText();
-
- struct stat sb;
- fstat(fileno(fp), &sb);
-
- bool show_prompt = false;
- while (true) {
- if (show_prompt) {
- Print("--(%d%% of %d bytes)--",
- static_cast<int>(100 * (double(ftello(fp)) / double(sb.st_size))),
- static_cast<int>(sb.st_size));
- Redraw();
- while (show_prompt) {
- show_prompt = false;
- int key = WaitKey();
- if (key == KEY_POWER || key == KEY_ENTER) {
- return;
- } else if (key == KEY_UP || key == KEY_VOLUMEUP) {
- if (offsets.size() <= 1) {
- show_prompt = true;
- } else {
- offsets.pop_back();
- fseek(fp, offsets.back(), SEEK_SET);
- }
- } else {
- if (feof(fp)) {
- return;
- }
- offsets.push_back(ftello(fp));
- }
- }
- ClearText();
- }
-
- int ch = getc(fp);
- if (ch == EOF) {
- text_row_ = text_top_ = text_rows_ - 2;
- show_prompt = true;
- } else {
- PutChar(ch);
- if (text_col_ == 0 && text_row_ >= text_rows_ - 2) {
- text_top_ = text_row_;
- show_prompt = true;
- }
- }
- }
-}
-
-void WearRecoveryUI::PutChar(char ch) {
- pthread_mutex_lock(&updateMutex);
- if (ch != '\n') text_[text_row_][text_col_++] = ch;
- if (ch == '\n' || text_col_ >= text_cols_) {
- text_col_ = 0;
- ++text_row_;
- }
- pthread_mutex_unlock(&updateMutex);
-}
-
-void WearRecoveryUI::ShowFile(const char* filename) {
- FILE* fp = fopen_path(filename, "re");
- if (fp == nullptr) {
- Print(" Unable to open %s: %s\n", filename, strerror(errno));
- return;
- }
- ShowFile(fp);
- fclose(fp);
-}
diff --git a/wear_ui.h b/wear_ui.h
index 92ef813f3..739b4cb1d 100644
--- a/wear_ui.h
+++ b/wear_ui.h
@@ -19,19 +19,12 @@
#include "screen_ui.h"
-#include <string>
-
class WearRecoveryUI : public ScreenRecoveryUI {
public:
WearRecoveryUI();
void SetStage(int current, int max) override;
- // printing messages
- void Print(const char* fmt, ...) override;
- void ShowFile(const char* filename) override;
- void ShowFile(FILE* fp) override;
-
// menu display
void StartMenu(const char* const* headers, const char* const* items,
int initial_selection) override;
@@ -53,8 +46,6 @@ class WearRecoveryUI : public ScreenRecoveryUI {
void draw_background_locked() override;
void draw_screen_locked() override;
- void PutChar(char);
-
int menu_start, menu_end;
};