allow update snoozing (#22876)

* allow update snoozing

* not immediately visible

* dismiss and close

* grey button
old-commit-hash: e528e2e3e2
commatwo_master
Adeeb Shihadeh 4 years ago committed by GitHub
parent 731d85c522
commit 29f6b5cb98
  1. 1
      selfdrive/common/params.cc
  2. 2
      selfdrive/controls/lib/alerts_offroad.json
  3. 2
      selfdrive/thermald/thermald.py
  4. 18
      selfdrive/ui/qt/widgets/offroad_alerts.cc
  5. 3
      selfdrive/ui/qt/widgets/offroad_alerts.h

@ -141,6 +141,7 @@ std::unordered_map<std::string, uint32_t> keys = {
{"RecordFrontLock", PERSISTENT}, // for the internal fleet {"RecordFrontLock", PERSISTENT}, // for the internal fleet
{"ReleaseNotes", PERSISTENT}, {"ReleaseNotes", PERSISTENT},
{"ShouldDoUpdate", CLEAR_ON_MANAGER_START}, {"ShouldDoUpdate", CLEAR_ON_MANAGER_START},
{"SnoozeUpdate", CLEAR_ON_MANAGER_START | CLEAR_ON_IGNITION_OFF},
{"SshEnabled", PERSISTENT}, {"SshEnabled", PERSISTENT},
{"SubscriberInfo", PERSISTENT}, {"SubscriberInfo", PERSISTENT},
{"TermsVersion", PERSISTENT}, {"TermsVersion", PERSISTENT},

@ -13,7 +13,7 @@
"_comment": "Append the number of days at the end of the text" "_comment": "Append the number of days at the end of the text"
}, },
"Offroad_ConnectivityNeeded": { "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 "severity": 1
}, },
"Offroad_UpdateFailed": { "Offroad_UpdateFailed": {

@ -357,7 +357,7 @@ def thermald_thread():
set_offroad_alert_if_changed("Offroad_ConnectivityNeeded", False) set_offroad_alert_if_changed("Offroad_ConnectivityNeeded", False)
set_offroad_alert_if_changed("Offroad_ConnectivityNeededPrompt", 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["not_uninstalling"] = not params.get_bool("DoUninstall")
startup_conditions["accepted_terms"] = params.get("HasAcceptedTerms") == terms_version startup_conditions["accepted_terms"] = params.get("HasAcceptedTerms") == terms_version

@ -3,7 +3,6 @@
#include <QHBoxLayout> #include <QHBoxLayout>
#include <QJsonDocument> #include <QJsonDocument>
#include <QJsonObject> #include <QJsonObject>
#include <QPushButton>
#include "selfdrive/common/util.h" #include "selfdrive/common/util.h"
#include "selfdrive/hardware/hw.h" #include "selfdrive/hardware/hw.h"
@ -23,17 +22,28 @@ AbstractAlert::AbstractAlert(bool hasRebootBtn, QWidget *parent) : QFrame(parent
QHBoxLayout *footer_layout = new QHBoxLayout(); QHBoxLayout *footer_layout = new QHBoxLayout();
main_layout->addLayout(footer_layout); main_layout->addLayout(footer_layout);
QPushButton *dismiss_btn = new QPushButton("Dismiss"); QPushButton *dismiss_btn = new QPushButton("Close");
dismiss_btn->setFixedSize(400, 125); dismiss_btn->setFixedSize(400, 125);
footer_layout->addWidget(dismiss_btn, 0, Qt::AlignBottom | Qt::AlignLeft); footer_layout->addWidget(dismiss_btn, 0, Qt::AlignBottom | Qt::AlignLeft);
QObject::connect(dismiss_btn, &QPushButton::clicked, this, &AbstractAlert::dismiss); 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) { if (hasRebootBtn) {
QPushButton *rebootBtn = new QPushButton("Reboot and Update"); QPushButton *rebootBtn = new QPushButton("Reboot and Update");
rebootBtn->setFixedSize(600, 125); rebootBtn->setFixedSize(600, 125);
footer_layout->addWidget(rebootBtn, 0, Qt::AlignBottom | Qt::AlignRight); footer_layout->addWidget(rebootBtn, 0, Qt::AlignBottom | Qt::AlignRight);
QObject::connect(rebootBtn, &QPushButton::clicked, [=]() { Hardware::reboot(); }); QObject::connect(rebootBtn, &QPushButton::clicked, [=]() { Hardware::reboot(); });
} }
setStyleSheet(R"( setStyleSheet(R"(
* { * {
font-size: 48px; font-size: 48px;
@ -53,10 +63,11 @@ AbstractAlert::AbstractAlert(bool hasRebootBtn, QWidget *parent) : QFrame(parent
} }
int OffroadAlert::refresh() { int OffroadAlert::refresh() {
// build widgets for each offroad alert on first refresh
if (alerts.empty()) { if (alerts.empty()) {
// setup labels for each alert
QString json = util::read_file("../controls/lib/alerts_offroad.json").c_str(); QString json = util::read_file("../controls/lib/alerts_offroad.json").c_str();
QJsonObject obj = QJsonDocument::fromJson(json.toUtf8()).object(); QJsonObject obj = QJsonDocument::fromJson(json.toUtf8()).object();
// descending sort labels by severity // descending sort labels by severity
std::vector<std::pair<std::string, int>> sorted; std::vector<std::pair<std::string, int>> sorted;
for (auto it = obj.constBegin(); it != obj.constEnd(); ++it) { for (auto it = obj.constBegin(); it != obj.constEnd(); ++it) {
@ -87,6 +98,7 @@ int OffroadAlert::refresh() {
label->setVisible(!text.isEmpty()); label->setVisible(!text.isEmpty());
alertCount += !text.isEmpty(); alertCount += !text.isEmpty();
} }
snooze_btn->setVisible(!alerts["Offroad_ConnectivityNeeded"]->text().isEmpty());
return alertCount; return alertCount;
} }

@ -3,6 +3,7 @@
#include <map> #include <map>
#include <QLabel> #include <QLabel>
#include <QPushButton>
#include <QVBoxLayout> #include <QVBoxLayout>
#include "selfdrive/common/params.h" #include "selfdrive/common/params.h"
@ -12,6 +13,8 @@ class AbstractAlert : public QFrame {
protected: protected:
AbstractAlert(bool hasRebootBtn, QWidget *parent = nullptr); AbstractAlert(bool hasRebootBtn, QWidget *parent = nullptr);
QPushButton *snooze_btn;
QVBoxLayout *scrollable_layout; QVBoxLayout *scrollable_layout;
Params params; Params params;

Loading…
Cancel
Save