2021-07-20 20:27:32 -07:00
|
|
|
#include "otamanager.h"
|
|
|
|
#include "ui_otamanager.h"
|
|
|
|
#include "functions.h"
|
|
|
|
|
|
|
|
#include <QTimer>
|
2021-08-20 14:12:51 -07:00
|
|
|
#include <QDebug>
|
2021-07-20 20:27:32 -07:00
|
|
|
|
|
|
|
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-19 05:23:18 -07:00
|
|
|
}
|
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-19 05:23:18 -07:00
|
|
|
}
|
2021-07-20 20:27:32 -07:00
|
|
|
}
|
2021-08-20 14:12:51 -07:00
|
|
|
QThread::msleep(500);
|
|
|
|
otaManager::close();
|
|
|
|
}
|
2021-08-19 05:23:18 -07:00
|
|
|
}
|
|
|
|
else {
|
2021-08-20 14:12:51 -07:00
|
|
|
qDebug() << "Skip OTA update check!";
|
2021-08-19 05:23:18 -07:00
|
|
|
}
|
2021-07-20 20:27:32 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
otaManager::~otaManager()
|
|
|
|
{
|
|
|
|
delete ui;
|
|
|
|
}
|