diff --git a/selfdrive/common/params.cc b/selfdrive/common/params.cc index c14a2288a3..17fe1a25ae 100644 --- a/selfdrive/common/params.cc +++ b/selfdrive/common/params.cc @@ -141,6 +141,7 @@ std::unordered_map keys = { {"RecordFrontLock", PERSISTENT}, // for the internal fleet {"ReleaseNotes", PERSISTENT}, {"ShouldDoUpdate", CLEAR_ON_MANAGER_START}, + {"SnoozeUpdate", CLEAR_ON_MANAGER_START | CLEAR_ON_IGNITION_OFF}, {"SshEnabled", PERSISTENT}, {"SubscriberInfo", PERSISTENT}, {"TermsVersion", PERSISTENT}, diff --git a/selfdrive/controls/lib/alerts_offroad.json b/selfdrive/controls/lib/alerts_offroad.json index b1b04db41e..9a863551a8 100644 --- a/selfdrive/controls/lib/alerts_offroad.json +++ b/selfdrive/controls/lib/alerts_offroad.json @@ -13,7 +13,7 @@ "_comment": "Append the number of days at the end of the text" }, "Offroad_ConnectivityNeeded": { - "text": "Connect to internet to check for updates. openpilot won't start until it connects to internet to check for updates.", + "text": "Connect to internet to check for updates. openpilot won't automatically start until it connects to internet to check for updates.", "severity": 1 }, "Offroad_UpdateFailed": { diff --git a/selfdrive/thermald/thermald.py b/selfdrive/thermald/thermald.py index e9e33c9da7..5e67858791 100755 --- a/selfdrive/thermald/thermald.py +++ b/selfdrive/thermald/thermald.py @@ -357,7 +357,7 @@ def thermald_thread(): set_offroad_alert_if_changed("Offroad_ConnectivityNeeded", False) set_offroad_alert_if_changed("Offroad_ConnectivityNeededPrompt", False) - startup_conditions["up_to_date"] = params.get("Offroad_ConnectivityNeeded") is None or params.get_bool("DisableUpdates") + startup_conditions["up_to_date"] = params.get("Offroad_ConnectivityNeeded") is None or params.get_bool("DisableUpdates") or params.get_bool("SnoozeUpdate") startup_conditions["not_uninstalling"] = not params.get_bool("DoUninstall") startup_conditions["accepted_terms"] = params.get("HasAcceptedTerms") == terms_version diff --git a/selfdrive/ui/qt/widgets/offroad_alerts.cc b/selfdrive/ui/qt/widgets/offroad_alerts.cc index 9dd9e139e6..2d7ae39c36 100644 --- a/selfdrive/ui/qt/widgets/offroad_alerts.cc +++ b/selfdrive/ui/qt/widgets/offroad_alerts.cc @@ -3,7 +3,6 @@ #include #include #include -#include #include "selfdrive/common/util.h" #include "selfdrive/hardware/hw.h" @@ -23,17 +22,28 @@ AbstractAlert::AbstractAlert(bool hasRebootBtn, QWidget *parent) : QFrame(parent QHBoxLayout *footer_layout = new QHBoxLayout(); main_layout->addLayout(footer_layout); - QPushButton *dismiss_btn = new QPushButton("Dismiss"); + QPushButton *dismiss_btn = new QPushButton("Close"); dismiss_btn->setFixedSize(400, 125); footer_layout->addWidget(dismiss_btn, 0, Qt::AlignBottom | Qt::AlignLeft); QObject::connect(dismiss_btn, &QPushButton::clicked, this, &AbstractAlert::dismiss); + snooze_btn = new QPushButton("Snooze Update"); + snooze_btn->setVisible(false); + snooze_btn->setFixedSize(550, 125); + footer_layout->addWidget(snooze_btn, 0, Qt::AlignBottom | Qt::AlignRight); + QObject::connect(snooze_btn, &QPushButton::clicked, [=]() { + params.putBool("SnoozeUpdate", true); + }); + QObject::connect(snooze_btn, &QPushButton::clicked, this, &AbstractAlert::dismiss); + snooze_btn->setStyleSheet(R"(color: white; background-color: #4F4F4F;)"); + if (hasRebootBtn) { QPushButton *rebootBtn = new QPushButton("Reboot and Update"); rebootBtn->setFixedSize(600, 125); footer_layout->addWidget(rebootBtn, 0, Qt::AlignBottom | Qt::AlignRight); QObject::connect(rebootBtn, &QPushButton::clicked, [=]() { Hardware::reboot(); }); } + setStyleSheet(R"( * { font-size: 48px; @@ -53,10 +63,11 @@ AbstractAlert::AbstractAlert(bool hasRebootBtn, QWidget *parent) : QFrame(parent } int OffroadAlert::refresh() { + // build widgets for each offroad alert on first refresh if (alerts.empty()) { - // setup labels for each alert QString json = util::read_file("../controls/lib/alerts_offroad.json").c_str(); QJsonObject obj = QJsonDocument::fromJson(json.toUtf8()).object(); + // descending sort labels by severity std::vector> sorted; for (auto it = obj.constBegin(); it != obj.constEnd(); ++it) { @@ -87,6 +98,7 @@ int OffroadAlert::refresh() { label->setVisible(!text.isEmpty()); alertCount += !text.isEmpty(); } + snooze_btn->setVisible(!alerts["Offroad_ConnectivityNeeded"]->text().isEmpty()); return alertCount; } diff --git a/selfdrive/ui/qt/widgets/offroad_alerts.h b/selfdrive/ui/qt/widgets/offroad_alerts.h index c285457c6f..4110bdaa4e 100644 --- a/selfdrive/ui/qt/widgets/offroad_alerts.h +++ b/selfdrive/ui/qt/widgets/offroad_alerts.h @@ -3,6 +3,7 @@ #include #include +#include #include #include "selfdrive/common/params.h" @@ -12,6 +13,8 @@ class AbstractAlert : public QFrame { protected: AbstractAlert(bool hasRebootBtn, QWidget *parent = nullptr); + + QPushButton *snooze_btn; QVBoxLayout *scrollable_layout; Params params;