Merge "screen_ui: Drop the dependency on common.h." am: 738a4258d8
am: 30f2775b37
Change-Id: Id553c1f1de86fa292c0327f6fcc00fb8cd17bec3
This commit is contained in:
+1
-1
@@ -820,7 +820,7 @@ static void choose_recovery_file(Device* device) {
|
|||||||
std::bind(&Device::HandleMenuKey, device, std::placeholders::_1, std::placeholders::_2));
|
std::bind(&Device::HandleMenuKey, device, std::placeholders::_1, std::placeholders::_2));
|
||||||
if (entries[chosen_item] == "Back") break;
|
if (entries[chosen_item] == "Back") break;
|
||||||
|
|
||||||
ui->ShowFile(entries[chosen_item].c_str());
|
ui->ShowFile(entries[chosen_item]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+5
-7
@@ -42,7 +42,6 @@
|
|||||||
#include <android-base/strings.h>
|
#include <android-base/strings.h>
|
||||||
#include <minui/minui.h>
|
#include <minui/minui.h>
|
||||||
|
|
||||||
#include "common.h"
|
|
||||||
#include "device.h"
|
#include "device.h"
|
||||||
#include "ui.h"
|
#include "ui.h"
|
||||||
|
|
||||||
@@ -951,10 +950,10 @@ void ScreenRecoveryUI::ShowFile(FILE* fp) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void ScreenRecoveryUI::ShowFile(const char* filename) {
|
void ScreenRecoveryUI::ShowFile(const std::string& filename) {
|
||||||
FILE* fp = fopen_path(filename, "re");
|
std::unique_ptr<FILE, decltype(&fclose)> fp(fopen(filename.c_str(), "re"), fclose);
|
||||||
if (fp == nullptr) {
|
if (!fp) {
|
||||||
Print(" Unable to open %s: %s\n", filename, strerror(errno));
|
Print(" Unable to open %s: %s\n", filename.c_str(), strerror(errno));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -966,8 +965,7 @@ void ScreenRecoveryUI::ShowFile(const char* filename) {
|
|||||||
text_ = file_viewer_text_;
|
text_ = file_viewer_text_;
|
||||||
ClearText();
|
ClearText();
|
||||||
|
|
||||||
ShowFile(fp);
|
ShowFile(fp.get());
|
||||||
fclose(fp);
|
|
||||||
|
|
||||||
text_ = old_text;
|
text_ = old_text;
|
||||||
text_col_ = old_text_col;
|
text_col_ = old_text_col;
|
||||||
|
|||||||
+1
-1
@@ -133,7 +133,7 @@ class ScreenRecoveryUI : public RecoveryUI {
|
|||||||
// printing messages
|
// printing messages
|
||||||
void Print(const char* fmt, ...) override __printflike(2, 3);
|
void Print(const char* fmt, ...) override __printflike(2, 3);
|
||||||
void PrintOnScreenOnly(const char* fmt, ...) override __printflike(2, 3);
|
void PrintOnScreenOnly(const char* fmt, ...) override __printflike(2, 3);
|
||||||
void ShowFile(const char* filename) override;
|
void ShowFile(const std::string& filename) override;
|
||||||
|
|
||||||
// menu display
|
// menu display
|
||||||
int ShowMenu(const char* const* headers, const char* const* items, int initial_selection,
|
int ShowMenu(const char* const* headers, const char* const* items, int initial_selection,
|
||||||
|
|||||||
@@ -17,6 +17,9 @@
|
|||||||
#ifndef RECOVERY_STUB_UI_H
|
#ifndef RECOVERY_STUB_UI_H
|
||||||
#define RECOVERY_STUB_UI_H
|
#define RECOVERY_STUB_UI_H
|
||||||
|
|
||||||
|
#include <functional>
|
||||||
|
#include <string>
|
||||||
|
|
||||||
#include "ui.h"
|
#include "ui.h"
|
||||||
|
|
||||||
// Stub implementation of RecoveryUI for devices without screen.
|
// Stub implementation of RecoveryUI for devices without screen.
|
||||||
@@ -51,7 +54,7 @@ class StubRecoveryUI : public RecoveryUI {
|
|||||||
va_end(ap);
|
va_end(ap);
|
||||||
}
|
}
|
||||||
void PrintOnScreenOnly(const char* /* fmt */, ...) override {}
|
void PrintOnScreenOnly(const char* /* fmt */, ...) override {}
|
||||||
void ShowFile(const char* /* filename */) override {}
|
void ShowFile(const std::string& /* filename */) override {}
|
||||||
|
|
||||||
// menu display
|
// menu display
|
||||||
int ShowMenu(const char* const* /* headers */, const char* const* /* items */,
|
int ShowMenu(const char* const* /* headers */, const char* const* /* items */,
|
||||||
|
|||||||
@@ -88,7 +88,9 @@ class RecoveryUI {
|
|||||||
virtual void Print(const char* fmt, ...) __printflike(2, 3) = 0;
|
virtual void Print(const char* fmt, ...) __printflike(2, 3) = 0;
|
||||||
virtual void PrintOnScreenOnly(const char* fmt, ...) __printflike(2, 3) = 0;
|
virtual void PrintOnScreenOnly(const char* fmt, ...) __printflike(2, 3) = 0;
|
||||||
|
|
||||||
virtual void ShowFile(const char* filename) = 0;
|
// Shows the contents of the given file. Caller ensures the patition that contains the file has
|
||||||
|
// been mounted.
|
||||||
|
virtual void ShowFile(const std::string& filename) = 0;
|
||||||
|
|
||||||
// --- key handling ---
|
// --- key handling ---
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user