diff options
-rw-r--r-- | bootloader_message/include/bootloader_message/bootloader_message.h | 5 | ||||
-rw-r--r-- | install.cpp | 9 | ||||
-rw-r--r-- | recovery.cpp | 22 | ||||
-rw-r--r-- | screen_ui.cpp | 15 | ||||
-rw-r--r-- | screen_ui.h | 4 | ||||
-rw-r--r-- | stub_ui.h | 67 | ||||
-rw-r--r-- | tests/component/verifier_test.cpp | 2 | ||||
-rw-r--r-- | ui.cpp | 3 | ||||
-rw-r--r-- | ui.h | 4 | ||||
-rw-r--r-- | updater/blockimg.cpp | 2 | ||||
-rw-r--r-- | wear_ui.cpp | 14 | ||||
-rw-r--r-- | wear_ui.h | 4 |
12 files changed, 107 insertions, 44 deletions
diff --git a/bootloader_message/include/bootloader_message/bootloader_message.h b/bootloader_message/include/bootloader_message/bootloader_message.h index b3d2182df..ec47facf6 100644 --- a/bootloader_message/include/bootloader_message/bootloader_message.h +++ b/bootloader_message/include/bootloader_message/bootloader_message.h @@ -42,8 +42,9 @@ static const size_t WIPE_PACKAGE_OFFSET_IN_MISC = 16 * 1024; * It is also updated by the bootloader when firmware update * is complete (to boot into recovery for any final cleanup) * - * The status field is written by the bootloader after the - * completion of an "update-radio" or "update-hboot" command. + * The status field was used by the bootloader after the completion + * of an "update-radio" or "update-hboot" command, which has been + * deprecated since Froyo. * * The recovery field is only written by linux and used * for the system to send a message to recovery or the diff --git a/install.cpp b/install.cpp index f124a2688..772d81caf 100644 --- a/install.cpp +++ b/install.cpp @@ -335,15 +335,6 @@ try_update_binary(const char* path, ZipArchiveHandle zip, bool* wipe_cache, // progress bar within the segment defined by the most // recent progress command. // - // firmware <"hboot"|"radio"> <filename> - // arrange to install the contents of <filename> in the - // given partition on reboot. - // - // (API v2: <filename> may start with "PACKAGE:" to - // indicate taking a file from the OTA package.) - // - // (API v3: this command no longer exists.) - // // ui_print <string> // display <string> on the screen. // diff --git a/recovery.cpp b/recovery.cpp index 5213301c9..0fdc31cb4 100644 --- a/recovery.cpp +++ b/recovery.cpp @@ -68,6 +68,7 @@ #include "roots.h" #include "rotate_logs.h" #include "screen_ui.h" +#include "stub_ui.h" #include "ui.h" static const struct option OPTIONS[] = { @@ -169,21 +170,7 @@ struct selabel_handle* sehandle; * -- after this, rebooting will (try to) restart the main system -- * 7. ** if install failed ** * 7a. prompt_and_wait() shows an error icon and waits for the user - * 7b; the user reboots (pulling the battery, etc) into the main system - * 8. main() calls maybe_install_firmware_update() - * ** if the update contained radio/hboot firmware **: - * 8a. m_i_f_u() writes BCB with "boot-recovery" and "--wipe_cache" - * -- after this, rebooting will reformat cache & restart main system -- - * 8b. m_i_f_u() writes firmware image into raw cache partition - * 8c. m_i_f_u() writes BCB with "update-radio/hboot" and "--wipe_cache" - * -- after this, rebooting will attempt to reinstall firmware -- - * 8d. bootloader tries to flash firmware - * 8e. bootloader writes BCB with "boot-recovery" (keeping "--wipe_cache") - * -- after this, rebooting will reformat cache & restart main system -- - * 8f. erase_volume() reformats /cache - * 8g. finish_recovery() erases BCB - * -- after this, rebooting will (try to) restart the main system -- - * 9. main() calls reboot() to boot main system + * 7b. the user reboots (pulling the battery, etc) into the main system */ // open a given path, mounting partitions as necessary @@ -1485,8 +1472,11 @@ int main(int argc, char **argv) { Device* device = make_device(); ui = device->GetUI(); + if (!ui->Init()) { + printf("Failed to initialize UI, use stub UI instead."); + ui = new StubRecoveryUI(); + } ui->SetLocale(locale.c_str()); - ui->Init(); // Set background string to "installing security update" for security update, // otherwise set it to "installing system update". ui->SetSystemUpdateText(security_update); diff --git a/screen_ui.cpp b/screen_ui.cpp index a7b03c50d..5b9e5a5a9 100644 --- a/screen_ui.cpp +++ b/screen_ui.cpp @@ -448,17 +448,22 @@ void ScreenRecoveryUI::SetSystemUpdateText(bool security_update) { Redraw(); } -void ScreenRecoveryUI::InitTextParams() { - gr_init(); +bool ScreenRecoveryUI::InitTextParams() { + if (gr_init() < 0) { + return false; + } gr_font_size(gr_sys_font(), &char_width_, &char_height_); text_rows_ = gr_fb_height() / char_height_; text_cols_ = gr_fb_width() / char_width_; + return true; } -void ScreenRecoveryUI::Init() { +bool ScreenRecoveryUI::Init() { RecoveryUI::Init(); - InitTextParams(); + if (!InitTextParams()) { + return false; + } density_ = static_cast<float>(android::base::GetIntProperty("ro.sf.lcd_density", 160)) / 160.f; @@ -493,6 +498,8 @@ void ScreenRecoveryUI::Init() { LoadAnimation(); pthread_create(&progress_thread_, nullptr, ProgressThreadStartRoutine, this); + + return true; } void ScreenRecoveryUI::LoadAnimation() { diff --git a/screen_ui.h b/screen_ui.h index de7b6442e..38e2f0723 100644 --- a/screen_ui.h +++ b/screen_ui.h @@ -29,7 +29,7 @@ class ScreenRecoveryUI : public RecoveryUI { public: ScreenRecoveryUI(); - void Init(); + bool Init() override; void SetLocale(const char* locale); // overall recovery state ("background image") @@ -137,7 +137,7 @@ class ScreenRecoveryUI : public RecoveryUI { pthread_mutex_t updateMutex; bool rtl_locale; - virtual void InitTextParams(); + virtual bool InitTextParams(); virtual void draw_background_locked(); virtual void draw_foreground_locked(); diff --git a/stub_ui.h b/stub_ui.h new file mode 100644 index 000000000..1219b284c --- /dev/null +++ b/stub_ui.h @@ -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 diff --git a/tests/component/verifier_test.cpp b/tests/component/verifier_test.cpp index 60a78f5c3..33aadb3fb 100644 --- a/tests/component/verifier_test.cpp +++ b/tests/component/verifier_test.cpp @@ -40,7 +40,7 @@ RecoveryUI* ui = NULL; class MockUI : public RecoveryUI { - void Init() { } + bool Init() { return true; } void SetStage(int, int) { } void SetLocale(const char*) { } void SetBackground(Icon /*icon*/) { } @@ -80,12 +80,13 @@ static void* InputThreadLoop(void*) { return nullptr; } -void RecoveryUI::Init() { +bool RecoveryUI::Init() { ev_init(InputCallback, this); ev_iterate_available_keys(std::bind(&RecoveryUI::OnKeyDetected, this, std::placeholders::_1)); pthread_create(&input_thread_, nullptr, InputThreadLoop, nullptr); + return true; } int RecoveryUI::OnInputEvent(int fd, uint32_t epevents) { @@ -28,8 +28,8 @@ class RecoveryUI { virtual ~RecoveryUI() { } - // Initialize the object; called before anything else. - virtual void Init(); + // Initialize the object; called before anything else. Returns true on success. + virtual bool Init(); // Show a stage indicator. Call immediately after Init(). virtual void SetStage(int current, int max) = 0; diff --git a/updater/blockimg.cpp b/updater/blockimg.cpp index 7257e2399..4dadceb5e 100644 --- a/updater/blockimg.cpp +++ b/updater/blockimg.cpp @@ -1358,7 +1358,7 @@ static Value* PerformBlockImageUpdate(const char* name, State* state, int /* arg CommandParameters params = {}; params.canwrite = !dryrun; - LOG(INFO) << "performing " << dryrun ? "verification" : "update"; + LOG(INFO) << "performing " << (dryrun ? "verification" : "update"); if (state->is_retry) { is_retry = true; LOG(INFO) << "This update is a retry."; diff --git a/wear_ui.cpp b/wear_ui.cpp index 0918ac457..11e5a7168 100644 --- a/wear_ui.cpp +++ b/wear_ui.cpp @@ -190,8 +190,10 @@ void WearRecoveryUI::update_progress_locked() { gr_flip(); } -void WearRecoveryUI::InitTextParams() { - ScreenRecoveryUI::InitTextParams(); +bool WearRecoveryUI::InitTextParams() { + if (!ScreenRecoveryUI::InitTextParams()) { + return false; + } text_cols_ = (gr_fb_width() - (outer_width * 2)) / char_width_; @@ -199,15 +201,19 @@ void WearRecoveryUI::InitTextParams() { if (text_cols_ > kMaxCols) text_cols_ = kMaxCols; visible_text_rows = (gr_fb_height() - (outer_height * 2)) / char_height_; + return true; } -void WearRecoveryUI::Init() { - ScreenRecoveryUI::Init(); +bool WearRecoveryUI::Init() { + if (!ScreenRecoveryUI::Init()) { + return false; + } LoadBitmap("icon_installing", &backgroundIcon[INSTALLING_UPDATE]); backgroundIcon[ERASING] = backgroundIcon[INSTALLING_UPDATE]; LoadBitmap("icon_error", &backgroundIcon[ERROR]); backgroundIcon[NO_COMMAND] = backgroundIcon[ERROR]; + return true; } void WearRecoveryUI::SetStage(int current, int max) @@ -23,7 +23,7 @@ class WearRecoveryUI : public ScreenRecoveryUI { public: WearRecoveryUI(); - void Init() override; + bool Init() override; void SetStage(int current, int max) override; @@ -52,7 +52,7 @@ class WearRecoveryUI : public ScreenRecoveryUI { int GetProgressBaseline() override; - void InitTextParams() override; + bool InitTextParams() override; void update_progress_locked() override; |