boot/gui: Use HAL configs for reboot options
This way we can clean up the recovery menu from useless options.
Furthermore, if a device in the future gives us more option, we can
implement them.
@@ -7,6 +7,23 @@ def run(*cmd)
system(*cmd) unless LVGL::Introspection.simulator?
end
+module RebootModes
+ Android = {
+ "recovery" => ["Reboot to recovery", ->() { run("reboot recovery") }],
+ "bootloader" => ["Reboot to bootloader", ->() { run("reboot bootloader") }],
+ }
+
+ def self.options()
+ [
+ ["Reboot to system", ->() { run("reboot") }],
+ ] +
+ Configuration["HAL"]["boot"]["rebootModes"].map do |identifier|
+ const, key = identifier.split(".", 2)
+ const_get(const)[key]
+ end
+ end
+end
+
module BootGUI
class MainWindow < LVGUI::BaseWindow
include LVGUI::ButtonPalette
@@ -50,9 +67,7 @@ module BootGUI
# Our buttons palette!
add_buttons([
["Generations #{LVGL::Symbols::RIGHT}", ->() { GenerationsWindow.instance.present }],
- ["Reboot to bootloader", ->() { run("reboot bootloader") }],
- ["Reboot to recovery", ->() { run("reboot recovery") }],
- ["Reboot to system", ->() { run("reboot") }],
+ *(RebootModes.options),
["Power off", ->() { run("poweroff") }],
])
end
