summaryrefslogtreecommitdiffstats
path: root/recovery_ui
diff options
context:
space:
mode:
Diffstat (limited to 'recovery_ui')
-rw-r--r--recovery_ui/device.cpp13
-rw-r--r--recovery_ui/include/recovery_ui/device.h10
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).