2021-07-20 20:27:32 -07:00
|
|
|
#include "otamanager.h"
|
|
|
|
#include "ui_otamanager.h"
|
|
|
|
#include "functions.h"
|
|
|
|
|
|
|
|
#include <QTimer>
|
|
|
|
|
|
|
|
otaManager::otaManager(QWidget *parent) :
|
|
|
|
QWidget(parent),
|
|
|
|
ui(new Ui::otaManager)
|
|
|
|
{
|
|
|
|
ui->setupUi(this);
|
2021-08-19 05:23:18 -07:00
|
|
|
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();
|
|
|
|
}
|
2021-07-20 20:27:32 -07:00
|
|
|
}
|
2021-08-19 05:23:18 -07:00
|
|
|
} );
|
|
|
|
}
|
|
|
|
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();
|
|
|
|
}
|
2021-07-20 20:27:32 -07:00
|
|
|
}
|
2021-08-19 05:23:18 -07:00
|
|
|
} );
|
|
|
|
}
|
2021-07-20 20:27:32 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
otaManager::~otaManager()
|
|
|
|
{
|
|
|
|
delete ui;
|
|
|
|
}
|