mirror of
https://github.com/Quill-OS/quill.git
synced 2024-12-26 23:57:22 -08:00
OTA improvements
This commit is contained in:
parent
5dcc72f8b1
commit
c791da9fbf
1 changed files with 40 additions and 31 deletions
|
@ -3,47 +3,56 @@
|
|||
#include "functions.h"
|
||||
|
||||
#include <QTimer>
|
||||
#include <QDebug>
|
||||
|
||||
otaManager::otaManager(QWidget *parent) :
|
||||
QWidget(parent),
|
||||
ui(new Ui::otaManager)
|
||||
{
|
||||
ui->setupUi(this);
|
||||
if(global::otaUpdate::downloadOta != true) {
|
||||
string_writeconfig("/opt/ibxd", "ota_update_check\n");
|
||||
QTimer *otaCheckTimer = new QTimer();
|
||||
otaCheckTimer->setInterval(100);
|
||||
connect(otaCheckTimer, &QTimer::timeout, [&]() {
|
||||
if(QFile::exists("/run/can_ota_update") == true) {
|
||||
if(checkconfig("/run/can_ota_update") == true) {
|
||||
emit canOtaUpdate(true);
|
||||
otaManager::close();
|
||||
}
|
||||
else {
|
||||
emit canOtaUpdate(false);
|
||||
otaManager::close();
|
||||
if(QFile::exists("/mnt/onboard/onboard/.inkbox/SKIP_OTACHECK") == false) {
|
||||
qDebug() << "Checking for available OTA update ...";
|
||||
if(global::otaUpdate::downloadOta != true) {
|
||||
string_writeconfig("/opt/ibxd", "ota_update_check\n");
|
||||
while(true) {
|
||||
if(QFile::exists("/run/can_ota_update") == true) {
|
||||
if(checkconfig("/run/can_ota_update") == true) {
|
||||
emit canOtaUpdate(true);
|
||||
qDebug() << "OTA update is available!";
|
||||
break;
|
||||
}
|
||||
else {
|
||||
emit canOtaUpdate(false);
|
||||
qDebug() << "No OTA update available.";
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
} );
|
||||
QThread::msleep(500);
|
||||
otaManager::close();
|
||||
}
|
||||
else {
|
||||
string_writeconfig("/opt/ibxd", "ota_update_download\n");
|
||||
while(true) {
|
||||
if(QFile::exists("/run/can_install_ota_update") == true) {
|
||||
if(checkconfig("/run/can_install_ota_update") == true) {
|
||||
emit downloadedOta(true);
|
||||
global::otaUpdate::downloadOta = false;
|
||||
break;
|
||||
}
|
||||
else {
|
||||
emit downloadedOta(false);
|
||||
global::otaUpdate::downloadOta = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
QThread::msleep(500);
|
||||
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();
|
||||
}
|
||||
}
|
||||
} );
|
||||
qDebug() << "Skip OTA update check!";
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue