diff options
author | Tianjie Xu <xunchang@google.com> | 2019-08-16 03:05:25 +0200 |
---|---|---|
committer | android-build-merger <android-build-merger@google.com> | 2019-08-16 03:05:25 +0200 |
commit | 03fd851f611a2ad624a09e6e089dc5e8c029c62c (patch) | |
tree | b8c1549829d01b50e461befdb06655046dcd6136 /recovery_ui | |
parent | Merge "minui: Support input device hotplug in recovery mode." (diff) | |
parent | Merge "Remove common.h" (diff) | |
download | android_bootable_recovery-03fd851f611a2ad624a09e6e089dc5e8c029c62c.tar android_bootable_recovery-03fd851f611a2ad624a09e6e089dc5e8c029c62c.tar.gz android_bootable_recovery-03fd851f611a2ad624a09e6e089dc5e8c029c62c.tar.bz2 android_bootable_recovery-03fd851f611a2ad624a09e6e089dc5e8c029c62c.tar.lz android_bootable_recovery-03fd851f611a2ad624a09e6e089dc5e8c029c62c.tar.xz android_bootable_recovery-03fd851f611a2ad624a09e6e089dc5e8c029c62c.tar.zst android_bootable_recovery-03fd851f611a2ad624a09e6e089dc5e8c029c62c.zip |
Diffstat (limited to 'recovery_ui')
-rw-r--r-- | recovery_ui/device.cpp | 13 | ||||
-rw-r--r-- | recovery_ui/include/recovery_ui/device.h | 10 |
2 files changed, 23 insertions, 0 deletions
diff --git a/recovery_ui/device.cpp b/recovery_ui/device.cpp index e7ae1a3e1..d46df92d3 100644 --- a/recovery_ui/device.cpp +++ b/recovery_ui/device.cpp @@ -23,6 +23,7 @@ #include <android-base/logging.h> +#include "otautil/boot_state.h" #include "recovery_ui/ui.h" static std::vector<std::pair<std::string, Device::BuiltinAction>> g_menu_actions{ @@ -95,3 +96,15 @@ int Device::HandleMenuKey(int key, bool visible) { return ui_->HasThreeButtons() ? kNoAction : kHighlightDown; } } + +void Device::SetBootState(const BootState* state) { + boot_state_ = state; +} + +std::optional<std::string> Device::GetReason() const { + return boot_state_ ? std::make_optional(boot_state_->reason()) : std::nullopt; +} + +std::optional<std::string> Device::GetStage() const { + return boot_state_ ? std::make_optional(boot_state_->stage()) : std::nullopt; +} diff --git a/recovery_ui/include/recovery_ui/device.h b/recovery_ui/include/recovery_ui/device.h index 9a4edf261..f4f993638 100644 --- a/recovery_ui/include/recovery_ui/device.h +++ b/recovery_ui/include/recovery_ui/device.h @@ -20,12 +20,15 @@ #include <stddef.h> #include <memory> +#include <optional> #include <string> #include <vector> // Forward declaration to avoid including "ui.h". class RecoveryUI; +class BootState; + class Device { public: static constexpr const int kNoAction = -1; @@ -126,9 +129,16 @@ class Device { return true; } + void SetBootState(const BootState* state); + // The getters for reason and stage may return std::nullopt until StartRecovery() is called. It's + // the caller's responsibility to perform the check and handle the exception. + std::optional<std::string> GetReason() const; + std::optional<std::string> GetStage() const; + private: // The RecoveryUI object that should be used to display the user interface for this device. std::unique_ptr<RecoveryUI> ui_; + const BootState* boot_state_{ nullptr }; }; // Disable name mangling, as this function will be loaded via dlsym(3). |