Merge "Add a stub recovery UI." am: 8c1584feaf am: 2f8f6ec0fc
am: ef45a88680
Change-Id: I22e054d7fa4ca9986d6b9b3e625a2cbd8449aaa1
This commit is contained in:
+5
-1
@@ -68,6 +68,7 @@
|
|||||||
#include "roots.h"
|
#include "roots.h"
|
||||||
#include "rotate_logs.h"
|
#include "rotate_logs.h"
|
||||||
#include "screen_ui.h"
|
#include "screen_ui.h"
|
||||||
|
#include "stub_ui.h"
|
||||||
#include "ui.h"
|
#include "ui.h"
|
||||||
|
|
||||||
static const struct option OPTIONS[] = {
|
static const struct option OPTIONS[] = {
|
||||||
@@ -1471,8 +1472,11 @@ int main(int argc, char **argv) {
|
|||||||
Device* device = make_device();
|
Device* device = make_device();
|
||||||
ui = device->GetUI();
|
ui = device->GetUI();
|
||||||
|
|
||||||
|
if (!ui->Init()) {
|
||||||
|
printf("Failed to initialize UI, use stub UI instead.");
|
||||||
|
ui = new StubRecoveryUI();
|
||||||
|
}
|
||||||
ui->SetLocale(locale.c_str());
|
ui->SetLocale(locale.c_str());
|
||||||
ui->Init();
|
|
||||||
// Set background string to "installing security update" for security update,
|
// Set background string to "installing security update" for security update,
|
||||||
// otherwise set it to "installing system update".
|
// otherwise set it to "installing system update".
|
||||||
ui->SetSystemUpdateText(security_update);
|
ui->SetSystemUpdateText(security_update);
|
||||||
|
|||||||
+11
-4
@@ -448,17 +448,22 @@ void ScreenRecoveryUI::SetSystemUpdateText(bool security_update) {
|
|||||||
Redraw();
|
Redraw();
|
||||||
}
|
}
|
||||||
|
|
||||||
void ScreenRecoveryUI::InitTextParams() {
|
bool ScreenRecoveryUI::InitTextParams() {
|
||||||
gr_init();
|
if (gr_init() < 0) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
gr_font_size(gr_sys_font(), &char_width_, &char_height_);
|
gr_font_size(gr_sys_font(), &char_width_, &char_height_);
|
||||||
text_rows_ = gr_fb_height() / char_height_;
|
text_rows_ = gr_fb_height() / char_height_;
|
||||||
text_cols_ = gr_fb_width() / char_width_;
|
text_cols_ = gr_fb_width() / char_width_;
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void ScreenRecoveryUI::Init() {
|
bool ScreenRecoveryUI::Init() {
|
||||||
RecoveryUI::Init();
|
RecoveryUI::Init();
|
||||||
InitTextParams();
|
if (!InitTextParams()) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
density_ = static_cast<float>(android::base::GetIntProperty("ro.sf.lcd_density", 160)) / 160.f;
|
density_ = static_cast<float>(android::base::GetIntProperty("ro.sf.lcd_density", 160)) / 160.f;
|
||||||
|
|
||||||
@@ -493,6 +498,8 @@ void ScreenRecoveryUI::Init() {
|
|||||||
LoadAnimation();
|
LoadAnimation();
|
||||||
|
|
||||||
pthread_create(&progress_thread_, nullptr, ProgressThreadStartRoutine, this);
|
pthread_create(&progress_thread_, nullptr, ProgressThreadStartRoutine, this);
|
||||||
|
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void ScreenRecoveryUI::LoadAnimation() {
|
void ScreenRecoveryUI::LoadAnimation() {
|
||||||
|
|||||||
+2
-2
@@ -29,7 +29,7 @@ class ScreenRecoveryUI : public RecoveryUI {
|
|||||||
public:
|
public:
|
||||||
ScreenRecoveryUI();
|
ScreenRecoveryUI();
|
||||||
|
|
||||||
void Init();
|
bool Init() override;
|
||||||
void SetLocale(const char* locale);
|
void SetLocale(const char* locale);
|
||||||
|
|
||||||
// overall recovery state ("background image")
|
// overall recovery state ("background image")
|
||||||
@@ -137,7 +137,7 @@ class ScreenRecoveryUI : public RecoveryUI {
|
|||||||
pthread_mutex_t updateMutex;
|
pthread_mutex_t updateMutex;
|
||||||
bool rtl_locale;
|
bool rtl_locale;
|
||||||
|
|
||||||
virtual void InitTextParams();
|
virtual bool InitTextParams();
|
||||||
|
|
||||||
virtual void draw_background_locked();
|
virtual void draw_background_locked();
|
||||||
virtual void draw_foreground_locked();
|
virtual void draw_foreground_locked();
|
||||||
|
|||||||
@@ -0,0 +1,67 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (C) 2016 The Android Open Source Project
|
||||||
|
*
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef RECOVERY_STUB_UI_H
|
||||||
|
#define RECOVERY_STUB_UI_H
|
||||||
|
|
||||||
|
#include "ui.h"
|
||||||
|
|
||||||
|
// Stub implementation of RecoveryUI for devices without screen.
|
||||||
|
class StubRecoveryUI : public RecoveryUI {
|
||||||
|
public:
|
||||||
|
StubRecoveryUI() = default;
|
||||||
|
|
||||||
|
void SetLocale(const char* locale) override {}
|
||||||
|
|
||||||
|
void SetBackground(Icon icon) override {}
|
||||||
|
void SetSystemUpdateText(bool security_update) override {}
|
||||||
|
|
||||||
|
// progress indicator
|
||||||
|
void SetProgressType(ProgressType type) override {}
|
||||||
|
void ShowProgress(float portion, float seconds) override {}
|
||||||
|
void SetProgress(float fraction) override {}
|
||||||
|
|
||||||
|
void SetStage(int current, int max) override {}
|
||||||
|
|
||||||
|
// text log
|
||||||
|
void ShowText(bool visible) override {}
|
||||||
|
bool IsTextVisible() override {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
bool WasTextEverVisible() override {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
// printing messages
|
||||||
|
void Print(const char* fmt, ...) override {
|
||||||
|
va_list ap;
|
||||||
|
va_start(ap, fmt);
|
||||||
|
vprintf(fmt, ap);
|
||||||
|
va_end(ap);
|
||||||
|
}
|
||||||
|
void PrintOnScreenOnly(const char* fmt, ...) override {}
|
||||||
|
void ShowFile(const char* filename) override {}
|
||||||
|
|
||||||
|
// menu display
|
||||||
|
void StartMenu(const char* const* headers, const char* const* items,
|
||||||
|
int initial_selection) override {}
|
||||||
|
int SelectMenu(int sel) override {
|
||||||
|
return sel;
|
||||||
|
}
|
||||||
|
void EndMenu() override {}
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // RECOVERY_STUB_UI_H
|
||||||
@@ -40,7 +40,7 @@
|
|||||||
RecoveryUI* ui = NULL;
|
RecoveryUI* ui = NULL;
|
||||||
|
|
||||||
class MockUI : public RecoveryUI {
|
class MockUI : public RecoveryUI {
|
||||||
void Init() { }
|
bool Init() { return true; }
|
||||||
void SetStage(int, int) { }
|
void SetStage(int, int) { }
|
||||||
void SetLocale(const char*) { }
|
void SetLocale(const char*) { }
|
||||||
void SetBackground(Icon /*icon*/) { }
|
void SetBackground(Icon /*icon*/) { }
|
||||||
|
|||||||
@@ -80,12 +80,13 @@ static void* InputThreadLoop(void*) {
|
|||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
void RecoveryUI::Init() {
|
bool RecoveryUI::Init() {
|
||||||
ev_init(InputCallback, this);
|
ev_init(InputCallback, this);
|
||||||
|
|
||||||
ev_iterate_available_keys(std::bind(&RecoveryUI::OnKeyDetected, this, std::placeholders::_1));
|
ev_iterate_available_keys(std::bind(&RecoveryUI::OnKeyDetected, this, std::placeholders::_1));
|
||||||
|
|
||||||
pthread_create(&input_thread_, nullptr, InputThreadLoop, nullptr);
|
pthread_create(&input_thread_, nullptr, InputThreadLoop, nullptr);
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
int RecoveryUI::OnInputEvent(int fd, uint32_t epevents) {
|
int RecoveryUI::OnInputEvent(int fd, uint32_t epevents) {
|
||||||
|
|||||||
@@ -28,8 +28,8 @@ class RecoveryUI {
|
|||||||
|
|
||||||
virtual ~RecoveryUI() { }
|
virtual ~RecoveryUI() { }
|
||||||
|
|
||||||
// Initialize the object; called before anything else.
|
// Initialize the object; called before anything else. Returns true on success.
|
||||||
virtual void Init();
|
virtual bool Init();
|
||||||
// Show a stage indicator. Call immediately after Init().
|
// Show a stage indicator. Call immediately after Init().
|
||||||
virtual void SetStage(int current, int max) = 0;
|
virtual void SetStage(int current, int max) = 0;
|
||||||
|
|
||||||
|
|||||||
+10
-4
@@ -190,8 +190,10 @@ void WearRecoveryUI::update_progress_locked() {
|
|||||||
gr_flip();
|
gr_flip();
|
||||||
}
|
}
|
||||||
|
|
||||||
void WearRecoveryUI::InitTextParams() {
|
bool WearRecoveryUI::InitTextParams() {
|
||||||
ScreenRecoveryUI::InitTextParams();
|
if (!ScreenRecoveryUI::InitTextParams()) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
text_cols_ = (gr_fb_width() - (outer_width * 2)) / char_width_;
|
text_cols_ = (gr_fb_width() - (outer_width * 2)) / char_width_;
|
||||||
|
|
||||||
@@ -199,15 +201,19 @@ void WearRecoveryUI::InitTextParams() {
|
|||||||
if (text_cols_ > kMaxCols) text_cols_ = kMaxCols;
|
if (text_cols_ > kMaxCols) text_cols_ = kMaxCols;
|
||||||
|
|
||||||
visible_text_rows = (gr_fb_height() - (outer_height * 2)) / char_height_;
|
visible_text_rows = (gr_fb_height() - (outer_height * 2)) / char_height_;
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void WearRecoveryUI::Init() {
|
bool WearRecoveryUI::Init() {
|
||||||
ScreenRecoveryUI::Init();
|
if (!ScreenRecoveryUI::Init()) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
LoadBitmap("icon_installing", &backgroundIcon[INSTALLING_UPDATE]);
|
LoadBitmap("icon_installing", &backgroundIcon[INSTALLING_UPDATE]);
|
||||||
backgroundIcon[ERASING] = backgroundIcon[INSTALLING_UPDATE];
|
backgroundIcon[ERASING] = backgroundIcon[INSTALLING_UPDATE];
|
||||||
LoadBitmap("icon_error", &backgroundIcon[ERROR]);
|
LoadBitmap("icon_error", &backgroundIcon[ERROR]);
|
||||||
backgroundIcon[NO_COMMAND] = backgroundIcon[ERROR];
|
backgroundIcon[NO_COMMAND] = backgroundIcon[ERROR];
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void WearRecoveryUI::SetStage(int current, int max)
|
void WearRecoveryUI::SetStage(int current, int max)
|
||||||
|
|||||||
@@ -23,7 +23,7 @@ class WearRecoveryUI : public ScreenRecoveryUI {
|
|||||||
public:
|
public:
|
||||||
WearRecoveryUI();
|
WearRecoveryUI();
|
||||||
|
|
||||||
void Init() override;
|
bool Init() override;
|
||||||
|
|
||||||
void SetStage(int current, int max) override;
|
void SetStage(int current, int max) override;
|
||||||
|
|
||||||
@@ -52,7 +52,7 @@ class WearRecoveryUI : public ScreenRecoveryUI {
|
|||||||
|
|
||||||
int GetProgressBaseline() override;
|
int GetProgressBaseline() override;
|
||||||
|
|
||||||
void InitTextParams() override;
|
bool InitTextParams() override;
|
||||||
|
|
||||||
void update_progress_locked() override;
|
void update_progress_locked() override;
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user