Move shutdown/reboot handling to manager (#22882)
* Move shutdown/reboot handling to manager * more logging * check enagaged * Apply suggestions from code review Co-authored-by: Adeeb Shihadeh <adeebshihadeh@gmail.com>pull/22893/head
parent
4462d4c31f
commit
07ff724726
|
@ -100,6 +100,8 @@ std::unordered_map<std::string, uint32_t> keys = {
|
|||
{"DisableRadar", PERSISTENT}, // WARNING: THIS DISABLES AEB
|
||||
{"DisableUpdates", PERSISTENT},
|
||||
{"DongleId", PERSISTENT},
|
||||
{"DoReboot", CLEAR_ON_MANAGER_START},
|
||||
{"DoShutdown", CLEAR_ON_MANAGER_START},
|
||||
{"DoUninstall", CLEAR_ON_MANAGER_START},
|
||||
{"EnableWideCamera", CLEAR_ON_MANAGER_START},
|
||||
{"EndToEndToggle", PERSISTENT},
|
||||
|
|
|
@ -158,9 +158,14 @@ def manager_thread():
|
|||
msg.managerState.processes = [p.get_process_state_msg() for p in managed_processes.values()]
|
||||
pm.send('managerState', msg)
|
||||
|
||||
# TODO: let UI handle this
|
||||
# Exit main loop when uninstall is needed
|
||||
if params.get_bool("DoUninstall"):
|
||||
# Exit main loop when uninstall/shutdown/reboot is needed
|
||||
shutdown = False
|
||||
for param in ("DoUninstall", "DoShutdown", "DoReboot"):
|
||||
if params.get_bool(param):
|
||||
cloudlog.warning(f"Shutting down manager - {param} set")
|
||||
shutdown = True
|
||||
|
||||
if shutdown:
|
||||
break
|
||||
|
||||
|
||||
|
@ -189,9 +194,16 @@ def main():
|
|||
finally:
|
||||
manager_cleanup()
|
||||
|
||||
if Params().get_bool("DoUninstall"):
|
||||
params = Params()
|
||||
if params.get_bool("DoUninstall"):
|
||||
cloudlog.warning("uninstalling")
|
||||
HARDWARE.uninstall()
|
||||
elif params.get_bool("DoReboot"):
|
||||
cloudlog.warning("reboot")
|
||||
HARDWARE.reboot()
|
||||
elif params.get_bool("DoShutdown"):
|
||||
cloudlog.warning("shutdown")
|
||||
HARDWARE.shutdown()
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
|
|
|
@ -167,8 +167,15 @@ DevicePanel::DevicePanel(QWidget* parent) : ListWidget(parent) {
|
|||
reboot_btn->setObjectName("reboot_btn");
|
||||
power_layout->addWidget(reboot_btn);
|
||||
QObject::connect(reboot_btn, &QPushButton::clicked, [=]() {
|
||||
if (ConfirmationDialog::confirm("Are you sure you want to reboot?", this)) {
|
||||
Hardware::reboot();
|
||||
if (QUIState::ui_state.status == UIStatus::STATUS_DISENGAGED) {
|
||||
if (ConfirmationDialog::confirm("Are you sure you want to reboot?", this)) {
|
||||
// Check engaged again in case it changed while the dialog was open
|
||||
if (QUIState::ui_state.status == UIStatus::STATUS_DISENGAGED) {
|
||||
Params().putBool("DoReboot", true);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
ConfirmationDialog::alert("Disengage to Reboot", this);
|
||||
}
|
||||
});
|
||||
|
||||
|
@ -176,8 +183,15 @@ DevicePanel::DevicePanel(QWidget* parent) : ListWidget(parent) {
|
|||
poweroff_btn->setObjectName("poweroff_btn");
|
||||
power_layout->addWidget(poweroff_btn);
|
||||
QObject::connect(poweroff_btn, &QPushButton::clicked, [=]() {
|
||||
if (ConfirmationDialog::confirm("Are you sure you want to power off?", this)) {
|
||||
Hardware::poweroff();
|
||||
if (QUIState::ui_state.status == UIStatus::STATUS_DISENGAGED) {
|
||||
if (ConfirmationDialog::confirm("Are you sure you want to power off?", this)) {
|
||||
// Check engaged again in case it changed while the dialog was open
|
||||
if (QUIState::ui_state.status == UIStatus::STATUS_DISENGAGED) {
|
||||
Params().putBool("DoShutdown", true);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
ConfirmationDialog::alert("Disengage to Power Off", this);
|
||||
}
|
||||
});
|
||||
|
||||
|
|
Loading…
Reference in New Issue