From f028ccd3443a4526c245c8c664b37588be301eb2 Mon Sep 17 00:00:00 2001 From: Tom Marshall Date: Tue, 3 Feb 2015 09:56:57 -0800 Subject: recovery: Headless mode Change-Id: I6b54bde65264aee99cb51a19436e82054b31fe74 --- recovery.cpp | 13 ++++++++++++- res-hdpi/images/icon_headless.png | Bin 0 -> 1155 bytes res-mdpi/images/icon_headless.png | Bin 0 -> 734 bytes res-xhdpi/images/icon_headless.png | Bin 0 -> 1536 bytes res-xxhdpi/images/icon_headless.png | Bin 0 -> 2395 bytes res-xxxhdpi/images/icon_headless.png | Bin 0 -> 3300 bytes screen_ui.cpp | 15 +++++++++++++++ screen_ui.h | 1 + ui.h | 3 ++- verifier_test.cpp | 1 + 10 files changed, 31 insertions(+), 2 deletions(-) create mode 100644 res-hdpi/images/icon_headless.png create mode 100644 res-mdpi/images/icon_headless.png create mode 100644 res-xhdpi/images/icon_headless.png create mode 100644 res-xxhdpi/images/icon_headless.png create mode 100644 res-xxxhdpi/images/icon_headless.png diff --git a/recovery.cpp b/recovery.cpp index f1c65ce..a4a4a64 100644 --- a/recovery.cpp +++ b/recovery.cpp @@ -97,6 +97,7 @@ static OemLockOp oem_lock = OEM_LOCK_NONE; static const struct option OPTIONS[] = { { "send_intent", required_argument, NULL, 'i' }, { "update_package", required_argument, NULL, 'u' }, + { "headless", no_argument, NULL, 'h' }, { "wipe_data", no_argument, NULL, 'w' }, { "wipe_cache", no_argument, NULL, 'c' }, { "wipe_media", no_argument, NULL, 'm' }, @@ -1304,6 +1305,7 @@ main(int argc, char **argv) { bool show_text = false; bool sideload = false; bool sideload_auto_reboot = false; + bool headless = false; bool just_exit = false; bool shutdown_after = false; @@ -1312,6 +1314,7 @@ main(int argc, char **argv) { switch (arg) { case 'i': send_intent = optarg; break; case 'u': update_package = optarg; break; + case 'h': headless = true; break; case 'w': should_wipe_data = true; break; case 'c': should_wipe_cache = true; break; case 't': show_text = true; break; @@ -1485,7 +1488,15 @@ main(int argc, char **argv) { } Device::BuiltinAction after = shutdown_after ? Device::SHUTDOWN : Device::REBOOT; - if ((status != INSTALL_SUCCESS && !sideload_auto_reboot) || ui->IsTextVisible()) { + if (headless) { + ui->ShowText(true); + ui->SetHeadlessMode(); + finish_recovery(NULL); + for (;;) { + pause(); + } + } + else if ((status != INSTALL_SUCCESS && !sideload_auto_reboot) || ui->IsTextVisible()) { Device::BuiltinAction temp = prompt_and_wait(device, status); if (temp != Device::NO_ACTION) { after = temp; diff --git a/res-hdpi/images/icon_headless.png b/res-hdpi/images/icon_headless.png new file mode 100644 index 0000000..780836f Binary files /dev/null and b/res-hdpi/images/icon_headless.png differ diff --git a/res-mdpi/images/icon_headless.png b/res-mdpi/images/icon_headless.png new file mode 100644 index 0000000..5d134cd Binary files /dev/null and b/res-mdpi/images/icon_headless.png differ diff --git a/res-xhdpi/images/icon_headless.png b/res-xhdpi/images/icon_headless.png new file mode 100644 index 0000000..af283e2 Binary files /dev/null and b/res-xhdpi/images/icon_headless.png differ diff --git a/res-xxhdpi/images/icon_headless.png b/res-xxhdpi/images/icon_headless.png new file mode 100644 index 0000000..09a8234 Binary files /dev/null and b/res-xxhdpi/images/icon_headless.png differ diff --git a/res-xxxhdpi/images/icon_headless.png b/res-xxxhdpi/images/icon_headless.png new file mode 100644 index 0000000..a715e3f Binary files /dev/null and b/res-xxxhdpi/images/icon_headless.png differ diff --git a/screen_ui.cpp b/screen_ui.cpp index aef714b..992210b 100644 --- a/screen_ui.cpp +++ b/screen_ui.cpp @@ -282,6 +282,9 @@ void ScreenRecoveryUI::draw_dialog() } else { draw_background_locked(dialog_icon); + if (dialog_icon == HEADLESS) { + return; + } } draw_header_icon(); @@ -522,6 +525,7 @@ void ScreenRecoveryUI::Init() { LoadBitmap("icon_info", &backgroundIcon[D_INFO]); LoadBitmap("icon_error", &backgroundIcon[D_ERROR]); backgroundIcon[NO_COMMAND] = backgroundIcon[D_ERROR]; + LoadBitmap("icon_headless", &backgroundIcon[HEADLESS]); LoadBitmap("progress_empty", &progressBarEmpty); LoadBitmap("progress_fill", &progressBarFill); @@ -802,6 +806,17 @@ void ScreenRecoveryUI::DialogDismiss() pthread_mutex_unlock(&updateMutex); } +void ScreenRecoveryUI::SetHeadlessMode() +{ + pthread_mutex_lock(&updateMutex); + free(dialog_text); + dialog_text = strdup(""); + dialog_show_log = false; + dialog_icon = HEADLESS; + update_screen_locked(); + pthread_mutex_unlock(&updateMutex); +} + void ScreenRecoveryUI::StartMenu(const char* const * headers, const char* const * items, int initial_selection) { pthread_mutex_lock(&updateMutex); diff --git a/screen_ui.h b/screen_ui.h index fff0f0e..b03b6ef 100644 --- a/screen_ui.h +++ b/screen_ui.h @@ -58,6 +58,7 @@ class ScreenRecoveryUI : public RecoveryUI { int DialogShowing() const { return (dialog_text != NULL); } bool DialogDismissable() const { return (dialog_icon == D_ERROR); } void DialogDismiss(); + void SetHeadlessMode(); // menu display virtual int MenuItemStart() const { return menu_item_start_; } diff --git a/ui.h b/ui.h index df7fbde..abe4bca 100644 --- a/ui.h +++ b/ui.h @@ -106,7 +106,7 @@ class RecoveryUI { virtual void SetLocale(const char* locale) = 0; // Set the overall recovery state ("background image"). - enum Icon { NONE, INSTALLING_UPDATE, VIEWING_LOG, ERASING, NO_COMMAND, D_INFO, D_ERROR, NR_ICONS }; + enum Icon { NONE, INSTALLING_UPDATE, VIEWING_LOG, ERASING, NO_COMMAND, D_INFO, D_ERROR, HEADLESS, NR_ICONS }; virtual void SetBackground(Icon icon) = 0; // --- progress indicator --- @@ -145,6 +145,7 @@ class RecoveryUI { virtual int DialogShowing() const = 0; virtual bool DialogDismissable() const = 0; virtual void DialogDismiss() = 0; + virtual void SetHeadlessMode() = 0; // --- key handling --- diff --git a/verifier_test.cpp b/verifier_test.cpp index d97e115..623ae64 100644 --- a/verifier_test.cpp +++ b/verifier_test.cpp @@ -156,6 +156,7 @@ class FakeUI : public RecoveryUI { virtual int DialogShowing() const { return 0; } bool DialogDismissable() const { return false; } virtual void DialogDismiss() {} + virtual void SetHeadlessMode() {} void StartMenu(const char* const * headers, const char* const * items, int initial_selection) { } -- cgit v1.1