allow update snoozing (#22876)

* allow update snoozing

* not immediately visible

* dismiss and close

* grey button
pull/22875/head
Adeeb Shihadeh 2021-11-11 15:32:25 -08:00 committed by GitHub
parent 308219c5b1
commit e528e2e3e2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 21 additions and 5 deletions

View File

@ -141,6 +141,7 @@ std::unordered_map<std::string, uint32_t> 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},

View File

@ -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": {

View File

@ -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

View File

@ -3,7 +3,6 @@
#include <QHBoxLayout>
#include <QJsonDocument>
#include <QJsonObject>
#include <QPushButton>
#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<std::pair<std::string, int>> 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;
}

View File

@ -3,6 +3,7 @@
#include <map>
#include <QLabel>
#include <QPushButton>
#include <QVBoxLayout>
#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;