mirror of
https://github.com/Quill-OS/quill.git
synced 2024-12-29 00:57:22 -08:00
Improved OTA handling
We almost have (let's hope!) a working prototype...
This commit is contained in:
parent
1ba81f6e89
commit
0cbf1a59e6
6 changed files with 78 additions and 22 deletions
15
functions.h
15
functions.h
|
@ -78,6 +78,13 @@ namespace global {
|
||||||
namespace device {
|
namespace device {
|
||||||
inline bool isWifiAble;
|
inline bool isWifiAble;
|
||||||
}
|
}
|
||||||
|
namespace network {
|
||||||
|
inline bool isConnected;
|
||||||
|
}
|
||||||
|
namespace otaUpdate {
|
||||||
|
inline bool isUpdateOta;
|
||||||
|
inline bool downloadOta;
|
||||||
|
}
|
||||||
inline QString systemInfoText;
|
inline QString systemInfoText;
|
||||||
inline bool forbidOpenSearchDialog;
|
inline bool forbidOpenSearchDialog;
|
||||||
inline bool isN705;
|
inline bool isN705;
|
||||||
|
@ -492,11 +499,13 @@ namespace {
|
||||||
if(checkconfig("/run/wifi_connected_successfully") == true) {
|
if(checkconfig("/run/wifi_connected_successfully") == true) {
|
||||||
QFile::remove("/run/wifi_connected_successfully");
|
QFile::remove("/run/wifi_connected_successfully");
|
||||||
connectionSuccessful = 1;
|
connectionSuccessful = 1;
|
||||||
|
global::network::isConnected = true;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
QFile::remove("/run/wifi_connected_successfully");
|
QFile::remove("/run/wifi_connected_successfully");
|
||||||
connectionSuccessful = 0;
|
connectionSuccessful = 0;
|
||||||
|
global::network::isConnected = false;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -527,6 +536,12 @@ namespace {
|
||||||
}
|
}
|
||||||
string_writeconfig(sysfsWarmthPath, warmthValueStr);
|
string_writeconfig(sysfsWarmthPath, warmthValueStr);
|
||||||
}
|
}
|
||||||
|
void installUpdate() {
|
||||||
|
string_writeconfig("/mnt/onboard/onboard/.inkbox/can_really_update", "true");
|
||||||
|
string_writeconfig("/external_root/opt/update/will_update", "true");
|
||||||
|
string_writeconfig("/external_root/boot/flags/WILL_UPDATE", "true");
|
||||||
|
reboot(true);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif // FUNCTIONS_H
|
#endif // FUNCTIONS_H
|
||||||
|
|
|
@ -196,10 +196,15 @@ void generalDialog::on_okBtn_clicked()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if(updateDialog == true) {
|
if(updateDialog == true) {
|
||||||
string_writeconfig("/mnt/onboard/onboard/.inkbox/can_really_update", "true");
|
if(global::otaUpdate::isUpdateOta == true) {
|
||||||
string_writeconfig("/external_root/opt/update/will_update", "true");
|
global::otaUpdate::downloadOta = true;
|
||||||
string_writeconfig("/external_root/boot/flags/WILL_UPDATE", "true");
|
otaManagerWindow = new otaManager(this);
|
||||||
reboot(true);
|
connect(otaManagerWindow, SIGNAL(downloadedOtaUpdate(bool)), SLOT(startOtaUpdate(bool)));
|
||||||
|
otaManagerWindow->setAttribute(Qt::WA_DeleteOnClose);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
installUpdate();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if(usbmsDialog == true) {
|
if(usbmsDialog == true) {
|
||||||
global::usbms::usbmsDialog = false;
|
global::usbms::usbmsDialog = false;
|
||||||
|
@ -390,3 +395,14 @@ void generalDialog::connectToNetworkSlot() {
|
||||||
}
|
}
|
||||||
generalDialog::close();
|
generalDialog::close();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void generalDialog::startOtaUpdate(bool wasDownloadSuccessful) {
|
||||||
|
if(wasDownloadSuccessful == true) {
|
||||||
|
global::otaUpdate::isUpdateOta = false;
|
||||||
|
installUpdate();
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
showToast("Download failed");
|
||||||
|
global::otaUpdate::isUpdateOta = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
@ -8,6 +8,7 @@
|
||||||
#include "virtualkeyboard.h"
|
#include "virtualkeyboard.h"
|
||||||
#include "virtualkeypad.h"
|
#include "virtualkeypad.h"
|
||||||
#include "dictionarywidget.h"
|
#include "dictionarywidget.h"
|
||||||
|
#include "otamanager.h"
|
||||||
|
|
||||||
using namespace std;
|
using namespace std;
|
||||||
|
|
||||||
|
@ -51,6 +52,7 @@ private slots:
|
||||||
void restartSearchDialog();
|
void restartSearchDialog();
|
||||||
void refreshScreenNative();
|
void refreshScreenNative();
|
||||||
void connectToNetworkSlot();
|
void connectToNetworkSlot();
|
||||||
|
void startOtaUpdate(bool wasDownloadSuccessful);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Ui::generalDialog *ui;
|
Ui::generalDialog *ui;
|
||||||
|
@ -59,6 +61,7 @@ private:
|
||||||
virtualkeyboard *keyboardWidget;
|
virtualkeyboard *keyboardWidget;
|
||||||
virtualkeypad *keypadWidget;
|
virtualkeypad *keypadWidget;
|
||||||
dictionaryWidget *dictionaryWidgetWindow;
|
dictionaryWidget *dictionaryWidgetWindow;
|
||||||
|
otaManager *otaManagerWindow;
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
void gotoPageSelected(int value);
|
void gotoPageSelected(int value);
|
||||||
|
|
|
@ -953,12 +953,11 @@ void MainWindow::showToast(QString messageToDisplay) {
|
||||||
connect(toastWindow, SIGNAL(closeIndefiniteToast()), SLOT(closeIndefiniteToast()));
|
connect(toastWindow, SIGNAL(closeIndefiniteToast()), SLOT(closeIndefiniteToast()));
|
||||||
toastWindow->show();
|
toastWindow->show();
|
||||||
|
|
||||||
// Testing
|
if(messageToDisplay == "Connection successful") {
|
||||||
/* if(messageToDisplay == "Connection successful") {
|
|
||||||
otaManagerWindow = new otaManager(this);
|
otaManagerWindow = new otaManager(this);
|
||||||
connect(otaManagerWindow, SIGNAL(canInstallOtaUpdate(bool)), SLOT(openUpdateDialogOTA(bool)));
|
connect(otaManagerWindow, SIGNAL(canOtaUpdate(bool)), SLOT(openUpdateDialogOTA(bool)));
|
||||||
otaManagerWindow->setAttribute(Qt::WA_DeleteOnClose);
|
otaManagerWindow->setAttribute(Qt::WA_DeleteOnClose);
|
||||||
} */
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainWindow::hello(int testNumber) {
|
void MainWindow::hello(int testNumber) {
|
||||||
|
@ -972,6 +971,7 @@ void MainWindow::closeIndefiniteToast() {
|
||||||
|
|
||||||
void MainWindow::openUpdateDialogOTA(bool open) {
|
void MainWindow::openUpdateDialogOTA(bool open) {
|
||||||
if(open == true) {
|
if(open == true) {
|
||||||
|
global::otaUpdate::isUpdateOta = true;
|
||||||
openUpdateDialog();
|
openUpdateDialog();
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
|
|
@ -9,21 +9,42 @@ otaManager::otaManager(QWidget *parent) :
|
||||||
ui(new Ui::otaManager)
|
ui(new Ui::otaManager)
|
||||||
{
|
{
|
||||||
ui->setupUi(this);
|
ui->setupUi(this);
|
||||||
|
if(global::otaUpdate::downloadOta != true) {
|
||||||
string_writeconfig("/opt/ibxd", "ota_update_check\n");
|
string_writeconfig("/opt/ibxd", "ota_update_check\n");
|
||||||
QTimer *otaCheckTimer = new QTimer();
|
QTimer *otaCheckTimer = new QTimer();
|
||||||
otaCheckTimer->setInterval(100);
|
otaCheckTimer->setInterval(100);
|
||||||
connect(otaCheckTimer, &QTimer::timeout, [&]() {
|
connect(otaCheckTimer, &QTimer::timeout, [&]() {
|
||||||
if(QFile::exists("/run/can_install_ota_update") == true) {
|
if(QFile::exists("/run/can_ota_update") == true) {
|
||||||
if(checkconfig("/run/can_install_ota_update") == true) {
|
if(checkconfig("/run/can_ota_update") == true) {
|
||||||
emit canInstallOtaUpdate(true);
|
emit canOtaUpdate(true);
|
||||||
otaManager::close();
|
otaManager::close();
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
emit canInstallOtaUpdate(false);
|
emit canOtaUpdate(false);
|
||||||
otaManager::close();
|
otaManager::close();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} );
|
} );
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
string_writeconfig("/opt/ibxd", "ota_update_download\n");
|
||||||
|
QTimer *otaDownloadTimer = new QTimer();
|
||||||
|
otaDownloadTimer->setInterval(500);
|
||||||
|
connect(otaDownloadTimer, &QTimer::timeout, [&]() {
|
||||||
|
if(QFile::exists("/run/can_install_ota_update") == true) {
|
||||||
|
if(checkconfig("/run/can_install_ota_update") == true) {
|
||||||
|
emit downloadedOta(true);
|
||||||
|
global::otaUpdate::downloadOta = false;
|
||||||
|
otaManager::close();
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
emit downloadedOta(false);
|
||||||
|
global::otaUpdate::downloadOta = false;
|
||||||
|
otaManager::close();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} );
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
otaManager::~otaManager()
|
otaManager::~otaManager()
|
||||||
|
|
|
@ -19,7 +19,8 @@ private:
|
||||||
Ui::otaManager *ui;
|
Ui::otaManager *ui;
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
void canInstallOtaUpdate(bool yesno);
|
void canOtaUpdate(bool yesno);
|
||||||
|
void downloadedOta(bool wasDownloadSuccessful);
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue