mirror of
https://github.com/firestar5683/StarPilot.git
synced 2026-07-07 22:52:06 +08:00
ui: prevent device pairing if no internet or system time is invalid (#34403)
* gate pairing device if system time is invalid * update translations * Check for internet connectivity * Update selfdrive/ui/qt/widgets/prime.cc * Update selfdrive/ui/qt/widgets/prime.cc --------- Co-authored-by: Adeeb Shihadeh <adeebshihadeh@gmail.com>
This commit is contained in:
@@ -294,4 +294,17 @@ std::string check_output(const std::string& command) {
|
||||
return result;
|
||||
}
|
||||
|
||||
bool system_time_valid() {
|
||||
// Default to August 26, 2024
|
||||
tm min_tm = {.tm_year = 2024 - 1900, .tm_mon = 7, .tm_mday = 26};
|
||||
time_t min_date = mktime(&min_tm);
|
||||
|
||||
struct stat st;
|
||||
if (stat("/lib/systemd/systemd", &st) == 0) {
|
||||
min_date = std::max(min_date, st.st_mtime + 86400); // Add 1 day (86400 seconds)
|
||||
}
|
||||
|
||||
return time(nullptr) > min_date;
|
||||
}
|
||||
|
||||
} // namespace util
|
||||
|
||||
@@ -96,6 +96,8 @@ bool create_directories(const std::string &dir, mode_t mode);
|
||||
|
||||
std::string check_output(const std::string& command);
|
||||
|
||||
bool system_time_valid();
|
||||
|
||||
inline void sleep_for(const int milliseconds) {
|
||||
if (milliseconds > 0) {
|
||||
std::this_thread::sleep_for(std::chrono::milliseconds(milliseconds));
|
||||
|
||||
@@ -116,6 +116,14 @@ PairingPopup::PairingPopup(QWidget *parent) : DialogBase(parent) {
|
||||
hlayout->addWidget(qr, 1);
|
||||
}
|
||||
|
||||
int PairingPopup::exec() {
|
||||
if (!util::system_time_valid()) {
|
||||
ConfirmationDialog::alert(tr("Please connect to Wi-Fi to complete initial pairing"), parentWidget());
|
||||
return QDialog::Rejected;
|
||||
}
|
||||
return DialogBase::exec();
|
||||
}
|
||||
|
||||
|
||||
PrimeUserWidget::PrimeUserWidget(QWidget *parent) : QFrame(parent) {
|
||||
setObjectName("primeWidget");
|
||||
|
||||
@@ -33,6 +33,7 @@ class PairingPopup : public DialogBase {
|
||||
|
||||
public:
|
||||
explicit PairingPopup(QWidget* parent);
|
||||
int exec() override;
|
||||
};
|
||||
|
||||
|
||||
|
||||
@@ -460,6 +460,10 @@
|
||||
<source>Bookmark connect.comma.ai to your home screen to use it like an app</source>
|
||||
<translation>اجعل لـconnect.comma.ai إشارة مرجعية على شاشتك الرئيسية من أجل استخدامه مثل أي تطبيق</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Please connect to Wi-Fi to complete initial pairing</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
</context>
|
||||
<context>
|
||||
<name>ParamControl</name>
|
||||
|
||||
@@ -455,6 +455,10 @@
|
||||
<source>Bookmark connect.comma.ai to your home screen to use it like an app</source>
|
||||
<translation>Füge connect.comma.ai als Lesezeichen auf deinem Homescreen hinzu um es wie eine App zu verwenden</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Please connect to Wi-Fi to complete initial pairing</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
</context>
|
||||
<context>
|
||||
<name>ParamControl</name>
|
||||
|
||||
@@ -456,6 +456,10 @@
|
||||
<source>Bookmark connect.comma.ai to your home screen to use it like an app</source>
|
||||
<translation>Añada connect.comma.ai a su pantalla de inicio para usarlo como una aplicación</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Please connect to Wi-Fi to complete initial pairing</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
</context>
|
||||
<context>
|
||||
<name>ParamControl</name>
|
||||
|
||||
@@ -456,6 +456,10 @@
|
||||
<source>Bookmark connect.comma.ai to your home screen to use it like an app</source>
|
||||
<translation>Ajoutez connect.comma.ai à votre écran d'accueil pour l'utiliser comme une application</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Please connect to Wi-Fi to complete initial pairing</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
</context>
|
||||
<context>
|
||||
<name>ParamControl</name>
|
||||
|
||||
@@ -454,6 +454,10 @@
|
||||
<source>Bookmark connect.comma.ai to your home screen to use it like an app</source>
|
||||
<translation>「connect.comma.ai」をホーム画面に追加して、アプリのように使うことができます。</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Please connect to Wi-Fi to complete initial pairing</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
</context>
|
||||
<context>
|
||||
<name>ParamControl</name>
|
||||
|
||||
@@ -455,6 +455,10 @@
|
||||
<source>Bookmark connect.comma.ai to your home screen to use it like an app</source>
|
||||
<translation>connect.comma.ai를 앱처럼 사용하려면 홈 화면에 바로가기를 만드세요</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Please connect to Wi-Fi to complete initial pairing</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
</context>
|
||||
<context>
|
||||
<name>ParamControl</name>
|
||||
|
||||
@@ -456,6 +456,10 @@
|
||||
<source>Bookmark connect.comma.ai to your home screen to use it like an app</source>
|
||||
<translation>Salve connect.comma.ai como sua página inicial para utilizar como um app</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Please connect to Wi-Fi to complete initial pairing</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
</context>
|
||||
<context>
|
||||
<name>ParamControl</name>
|
||||
|
||||
@@ -455,6 +455,10 @@
|
||||
<source>Bookmark connect.comma.ai to your home screen to use it like an app</source>
|
||||
<translation>จดจำ connect.comma.ai โดยการเพิ่มไปยังหน้าจอโฮม เพื่อใช้งานเหมือนเป็นแอปพลิเคชัน</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Please connect to Wi-Fi to complete initial pairing</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
</context>
|
||||
<context>
|
||||
<name>ParamControl</name>
|
||||
|
||||
@@ -454,6 +454,10 @@
|
||||
<source>Bookmark connect.comma.ai to your home screen to use it like an app</source>
|
||||
<translation>Uygulama gibi kullanmak için connect.comma.ai sitesini yer işaretlerine ekleyin.</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Please connect to Wi-Fi to complete initial pairing</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
</context>
|
||||
<context>
|
||||
<name>ParamControl</name>
|
||||
|
||||
@@ -455,6 +455,10 @@
|
||||
<source>Bookmark connect.comma.ai to your home screen to use it like an app</source>
|
||||
<translation>将 connect.comma.ai 收藏到您的主屏幕,以便像应用程序一样使用它</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Please connect to Wi-Fi to complete initial pairing</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
</context>
|
||||
<context>
|
||||
<name>ParamControl</name>
|
||||
|
||||
@@ -455,6 +455,10 @@
|
||||
<source>Bookmark connect.comma.ai to your home screen to use it like an app</source>
|
||||
<translation>將 connect.comma.ai 加入您的主螢幕,以便像手機 App 一樣使用它</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Please connect to Wi-Fi to complete initial pairing</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
</context>
|
||||
<context>
|
||||
<name>ParamControl</name>
|
||||
|
||||
Reference in New Issue
Block a user