quill/otamanager.cpp

63 lines
1.9 KiB
C++
Raw Normal View History

#include "otamanager.h"
#include "ui_otamanager.h"
#include "functions.h"
#include <QTimer>
2021-08-20 14:12:51 -07:00
#include <QDebug>
otaManager::otaManager(QWidget *parent) :
QWidget(parent),
ui(new Ui::otaManager)
{
ui->setupUi(this);
2021-08-20 14:12:51 -07:00
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;
}
}
2021-08-20 14:12:51 -07:00
}
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;
}
}
}
2021-08-20 14:12:51 -07:00
QThread::msleep(500);
otaManager::close();
}
}
else {
2021-08-20 14:12:51 -07:00
qDebug() << "Skip OTA update check!";
}
}
otaManager::~otaManager()
{
delete ui;
}