mirror of
https://github.com/Quill-OS/quill.git
synced 2024-10-31 21:33:22 -07: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 {
|
||||
inline bool isWifiAble;
|
||||
}
|
||||
namespace network {
|
||||
inline bool isConnected;
|
||||
}
|
||||
namespace otaUpdate {
|
||||
inline bool isUpdateOta;
|
||||
inline bool downloadOta;
|
||||
}
|
||||
inline QString systemInfoText;
|
||||
inline bool forbidOpenSearchDialog;
|
||||
inline bool isN705;
|
||||
|
@ -492,11 +499,13 @@ namespace {
|
|||
if(checkconfig("/run/wifi_connected_successfully") == true) {
|
||||
QFile::remove("/run/wifi_connected_successfully");
|
||||
connectionSuccessful = 1;
|
||||
global::network::isConnected = true;
|
||||
return true;
|
||||
}
|
||||
else {
|
||||
QFile::remove("/run/wifi_connected_successfully");
|
||||
connectionSuccessful = 0;
|
||||
global::network::isConnected = false;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
@ -527,6 +536,12 @@ namespace {
|
|||
}
|
||||
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
|
||||
|
|
|
@ -196,10 +196,15 @@ void generalDialog::on_okBtn_clicked()
|
|||
}
|
||||
}
|
||||
if(updateDialog == true) {
|
||||
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);
|
||||
if(global::otaUpdate::isUpdateOta == true) {
|
||||
global::otaUpdate::downloadOta = true;
|
||||
otaManagerWindow = new otaManager(this);
|
||||
connect(otaManagerWindow, SIGNAL(downloadedOtaUpdate(bool)), SLOT(startOtaUpdate(bool)));
|
||||
otaManagerWindow->setAttribute(Qt::WA_DeleteOnClose);
|
||||
}
|
||||
else {
|
||||
installUpdate();
|
||||
}
|
||||
}
|
||||
if(usbmsDialog == true) {
|
||||
global::usbms::usbmsDialog = false;
|
||||
|
@ -390,3 +395,14 @@ void generalDialog::connectToNetworkSlot() {
|
|||
}
|
||||
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 "virtualkeypad.h"
|
||||
#include "dictionarywidget.h"
|
||||
#include "otamanager.h"
|
||||
|
||||
using namespace std;
|
||||
|
||||
|
@ -51,6 +52,7 @@ private slots:
|
|||
void restartSearchDialog();
|
||||
void refreshScreenNative();
|
||||
void connectToNetworkSlot();
|
||||
void startOtaUpdate(bool wasDownloadSuccessful);
|
||||
|
||||
private:
|
||||
Ui::generalDialog *ui;
|
||||
|
@ -59,6 +61,7 @@ private:
|
|||
virtualkeyboard *keyboardWidget;
|
||||
virtualkeypad *keypadWidget;
|
||||
dictionaryWidget *dictionaryWidgetWindow;
|
||||
otaManager *otaManagerWindow;
|
||||
|
||||
signals:
|
||||
void gotoPageSelected(int value);
|
||||
|
|
|
@ -953,12 +953,11 @@ void MainWindow::showToast(QString messageToDisplay) {
|
|||
connect(toastWindow, SIGNAL(closeIndefiniteToast()), SLOT(closeIndefiniteToast()));
|
||||
toastWindow->show();
|
||||
|
||||
// Testing
|
||||
/* if(messageToDisplay == "Connection successful") {
|
||||
if(messageToDisplay == "Connection successful") {
|
||||
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);
|
||||
} */
|
||||
}
|
||||
}
|
||||
|
||||
void MainWindow::hello(int testNumber) {
|
||||
|
@ -972,6 +971,7 @@ void MainWindow::closeIndefiniteToast() {
|
|||
|
||||
void MainWindow::openUpdateDialogOTA(bool open) {
|
||||
if(open == true) {
|
||||
global::otaUpdate::isUpdateOta = true;
|
||||
openUpdateDialog();
|
||||
}
|
||||
else {
|
||||
|
|
|
@ -9,22 +9,43 @@ otaManager::otaManager(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_install_ota_update") == true) {
|
||||
if(checkconfig("/run/can_install_ota_update") == true) {
|
||||
emit canInstallOtaUpdate(true);
|
||||
if(QFile::exists("/run/can_ota_update") == true) {
|
||||
if(checkconfig("/run/can_ota_update") == true) {
|
||||
emit canOtaUpdate(true);
|
||||
otaManager::close();
|
||||
}
|
||||
else {
|
||||
emit canInstallOtaUpdate(false);
|
||||
emit canOtaUpdate(false);
|
||||
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()
|
||||
{
|
||||
|
|
|
@ -19,7 +19,8 @@ private:
|
|||
Ui::otaManager *ui;
|
||||
|
||||
signals:
|
||||
void canInstallOtaUpdate(bool yesno);
|
||||
void canOtaUpdate(bool yesno);
|
||||
void downloadedOta(bool wasDownloadSuccessful);
|
||||
|
||||
};
|
||||
|
||||
|
|
Loading…
Reference in a new issue