Added failed software update splash

This commit is contained in:
Nicolas Mailloux 2021-04-02 13:42:00 -04:00
parent dd65339e6c
commit 8e9cdaac5a
3 changed files with 178 additions and 96 deletions

View file

@ -28,6 +28,13 @@ alert::alert(QWidget *parent) :
this->setStyleSheet(stylesheetFile.readAll());
stylesheetFile.close();
// Checking if the update signature was bad
if(checkconfig("/external_root/boot/flags/ALERT_SIGN") == true) {
ui->securityLabel->setText("Failed to install update.");
ui->messageLabel->setText("The update's digital signature is untrusted. For security reasons, it is not possible to install it.");
ui->stackedWidget->setCurrentIndex(1);
}
ui->warningLabel->setStyleSheet("QLabel { background-color : black; color : white; font-size: 16pt}");
ui->messageLabel->setStyleSheet("QLabel { background-color : black; color : white; font-size: 9pt}");
ui->securityLabel->setStyleSheet("QLabel { background-color : black; color : white; font-size: 11pt}");
@ -35,6 +42,8 @@ alert::alert(QWidget *parent) :
ui->resetBtn->setProperty("type", "borderless");
ui->continueBtn->setStyleSheet("padding: 20px");
ui->resetBtn->setStyleSheet("padding: 20px");
ui->continue2Btn->setProperty("type", "borderless");
ui->continue2Btn->setStyleSheet("padding: 20px");
}
alert::~alert()
@ -46,6 +55,7 @@ void alert::on_continueBtn_clicked()
{
// We continue anyway and re-set the ALERT flag
string_writeconfig("/external_root/boot/flags/ALERT", "false");
string_writeconfig("/external_root/boot/flags/ALERT_SIGN", "false");
QProcess process;
process.startDetached("inkbox", QStringList());
qApp->quit();
@ -63,3 +73,13 @@ void alert::on_resetBtn_clicked()
reboot_proc->start(reboot_prog, reboot_args);
reboot_proc->waitForFinished();
}
void alert::on_continue2Btn_clicked()
{
// We continue anyway and re-set the ALERT flag
string_writeconfig("/external_root/boot/flags/ALERT", "false");
string_writeconfig("/external_root/boot/flags/ALERT_SIGN", "false");
QProcess process;
process.startDetached("inkbox", QStringList());
qApp->quit();
}

18
alert.h
View file

@ -4,6 +4,8 @@
#include <QWidget>
#include <iostream>
#include <fstream>
#include <QFile>
#include <QTextStream>
namespace Ui {
class alert;
@ -24,12 +26,28 @@ public:
fhandler << config_option;
fhandler.close();
}
bool checkconfig(QString file) {
QFile config(file);
config.open(QIODevice::ReadOnly);
QTextStream in (&config);
const QString content = in.readAll();
string contentstr = content.toStdString();
if(contentstr.find("true") != std::string::npos) {
return true;
}
else {
return false;
}
config.close();
};
private slots:
void on_continueBtn_clicked();
void on_resetBtn_clicked();
void on_continue2Btn_clicked();
private:
Ui::alert *ui;
};

236
alert.ui
View file

@ -16,19 +16,6 @@
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<layout class="QGridLayout" name="gridLayout">
<item row="2" column="0">
<spacer name="verticalSpacer">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>40</height>
</size>
</property>
</spacer>
</item>
<item row="1" column="0">
<widget class="QLabel" name="warningLabel">
<property name="font">
@ -45,32 +32,6 @@
</property>
</widget>
</item>
<item row="4" column="0">
<spacer name="verticalSpacer_2">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>40</height>
</size>
</property>
</spacer>
</item>
<item row="9" column="0">
<spacer name="verticalSpacer_5">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>40</height>
</size>
</property>
</spacer>
</item>
<item row="3" column="0">
<widget class="QLabel" name="alertIconLabel">
<property name="text">
@ -81,52 +42,6 @@
</property>
</widget>
</item>
<item row="8" column="0">
<layout class="QGridLayout" name="gridLayout_2">
<property name="bottomMargin">
<number>0</number>
</property>
<item row="0" column="1">
<widget class="QPushButton" name="resetBtn">
<property name="font">
<font>
<weight>75</weight>
<bold>true</bold>
</font>
</property>
<property name="text">
<string>Reset</string>
</property>
</widget>
</item>
<item row="0" column="0">
<widget class="QPushButton" name="continueBtn">
<property name="font">
<font>
<weight>75</weight>
<bold>true</bold>
</font>
</property>
<property name="text">
<string>Continue anyway</string>
</property>
</widget>
</item>
</layout>
</item>
<item row="7" column="0">
<spacer name="verticalSpacer_4">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>40</height>
</size>
</property>
</spacer>
</item>
<item row="0" column="0">
<spacer name="verticalSpacer_3">
<property name="orientation">
@ -140,20 +55,44 @@
</property>
</spacer>
</item>
<item row="6" column="0">
<widget class="QLabel" name="messageLabel">
<property name="text">
<string>This could mean that someone is trying to steal your data or gain root access to the device.
A factory reset is recommended.</string>
<item row="2" column="0">
<spacer name="verticalSpacer">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="alignment">
<set>Qt::AlignCenter</set>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>40</height>
</size>
</property>
<property name="wordWrap">
<bool>true</bool>
</spacer>
</item>
<item row="7" column="0">
<spacer name="verticalSpacer_4">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
</widget>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>40</height>
</size>
</property>
</spacer>
</item>
<item row="4" column="0">
<spacer name="verticalSpacer_2">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>40</height>
</size>
</property>
</spacer>
</item>
<item row="5" column="0">
<widget class="QLabel" name="securityLabel">
@ -171,6 +110,111 @@ A factory reset is recommended.</string>
</property>
</widget>
</item>
<item row="8" column="0">
<widget class="QStackedWidget" name="stackedWidget">
<property name="currentIndex">
<number>0</number>
</property>
<widget class="QWidget" name="page">
<layout class="QVBoxLayout" name="verticalLayout_2">
<property name="leftMargin">
<number>0</number>
</property>
<property name="topMargin">
<number>0</number>
</property>
<property name="rightMargin">
<number>0</number>
</property>
<property name="bottomMargin">
<number>0</number>
</property>
<item>
<layout class="QGridLayout" name="gridLayout_2">
<property name="bottomMargin">
<number>0</number>
</property>
<item row="0" column="1">
<widget class="QPushButton" name="resetBtn">
<property name="font">
<font>
<weight>75</weight>
<bold>true</bold>
</font>
</property>
<property name="text">
<string>Reset</string>
</property>
</widget>
</item>
<item row="0" column="0">
<widget class="QPushButton" name="continueBtn">
<property name="font">
<font>
<weight>75</weight>
<bold>true</bold>
</font>
</property>
<property name="text">
<string>Continue anyway</string>
</property>
</widget>
</item>
</layout>
</item>
</layout>
</widget>
<widget class="QWidget" name="page_2">
<layout class="QVBoxLayout" name="verticalLayout_3">
<item>
<layout class="QGridLayout" name="gridLayout_3">
<item row="0" column="0">
<widget class="QPushButton" name="continue2Btn">
<property name="font">
<font>
<weight>75</weight>
<bold>true</bold>
</font>
</property>
<property name="text">
<string>Continue</string>
</property>
</widget>
</item>
</layout>
</item>
</layout>
</widget>
</widget>
</item>
<item row="6" column="0">
<widget class="QLabel" name="messageLabel">
<property name="text">
<string>This could mean that someone is trying to steal your data or gain root access to the device.
A factory reset is recommended.</string>
</property>
<property name="alignment">
<set>Qt::AlignCenter</set>
</property>
<property name="wordWrap">
<bool>true</bool>
</property>
</widget>
</item>
<item row="9" column="0">
<spacer name="verticalSpacer_5">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>40</height>
</size>
</property>
</spacer>
</item>
</layout>
</item>
</layout>