mirror of
https://github.com/Quill-OS/quill.git
synced 2024-12-26 23:57:22 -08:00
fix for wifi not working + cpu usage
This commit is contained in:
parent
6a4f8835d4
commit
af75ba1969
3 changed files with 18 additions and 30 deletions
|
@ -1,4 +1,4 @@
|
||||||
QT += core gui network
|
QT += core gui network
|
||||||
|
|
||||||
greaterThan(QT_MAJOR_VERSION, 4): QT += widgets
|
greaterThan(QT_MAJOR_VERSION, 4): QT += widgets
|
||||||
|
|
||||||
|
|
|
@ -185,7 +185,7 @@ bool userapps::manageRequiredFeatures()
|
||||||
if(featureId == 0) {
|
if(featureId == 0) {
|
||||||
// Double 'if' conditions to avoid launching unnecesery testPing() in emu
|
// Double 'if' conditions to avoid launching unnecesery testPing() in emu
|
||||||
if(global::deviceID != "emu\n") {
|
if(global::deviceID != "emu\n") {
|
||||||
if(testPing() != 0) {
|
if(checkWifiState() != global::wifi::wifiState::configured) {
|
||||||
global::userApps::appCompatibilityText = "<font face='u001'>This app needs a Wi-Fi connection, continue anyway</font><font face='Inter'>?</font>";
|
global::userApps::appCompatibilityText = "<font face='u001'>This app needs a Wi-Fi connection, continue anyway</font><font face='Inter'>?</font>";
|
||||||
launchDialog = true;
|
launchDialog = true;
|
||||||
}
|
}
|
||||||
|
|
|
@ -20,6 +20,7 @@
|
||||||
#include <QJsonValue>
|
#include <QJsonValue>
|
||||||
#include <QJsonArray>
|
#include <QJsonArray>
|
||||||
#include <QCryptographicHash>
|
#include <QCryptographicHash>
|
||||||
|
#include <QNetworkInterface>
|
||||||
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <fcntl.h>
|
#include <fcntl.h>
|
||||||
|
@ -1101,35 +1102,22 @@ namespace {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
global::wifi::wifiState checkWifiState() {
|
global::wifi::wifiState checkWifiState() {
|
||||||
QProcess *wifiStateProcess = new QProcess();
|
foreach(QNetworkInterface interface, QNetworkInterface::allInterfaces()) {
|
||||||
QString path = "/external_root/usr/local/bin/wifi/wifi_status.sh";
|
// If something is wrong, debug with this:
|
||||||
QStringList args;
|
// qDebug() << interface;
|
||||||
wifiStateProcess->start(path, args);
|
if(interface.flags().testFlag(QNetworkInterface::IsLoopBack) == false) {
|
||||||
wifiStateProcess->waitForFinished();
|
if(interface.flags().testFlag(QNetworkInterface::IsUp) == true) {
|
||||||
wifiStateProcess->deleteLater();
|
if(interface.flags().testFlag(QNetworkInterface::IsRunning) == true) {
|
||||||
|
global::wifi::isConnected = true;
|
||||||
QString currentWifiState;
|
return global::wifi::wifiState::configured;
|
||||||
if(QFile("/run/wifi_status").exists() == true) {
|
}
|
||||||
currentWifiState = readFile("/run/wifi_status");
|
global::wifi::isConnected = false;
|
||||||
} else {
|
return global::wifi::wifiState::enabled;
|
||||||
log("/run/wifi_status doesn't exist", "functions");
|
}
|
||||||
}
|
}
|
||||||
if (currentWifiState.contains("configured") == true) {
|
|
||||||
global::wifi::isConnected = true;
|
|
||||||
return global::wifi::wifiState::configured;
|
|
||||||
}
|
|
||||||
else if (currentWifiState.contains("enabled") == true) {
|
|
||||||
global::wifi::isConnected = false;
|
|
||||||
return global::wifi::wifiState::enabled;
|
|
||||||
}
|
|
||||||
else if (currentWifiState.contains("disabled") == true) {
|
|
||||||
global::wifi::isConnected = false;
|
|
||||||
return global::wifi::wifiState::disabled;
|
|
||||||
} else {
|
|
||||||
global::wifi::isConnected = false;
|
|
||||||
QString function = __func__; log(function + ": Critical error", "functions");
|
|
||||||
return global::wifi::wifiState::unknown;
|
|
||||||
}
|
}
|
||||||
|
global::wifi::isConnected = false;
|
||||||
|
return global::wifi::wifiState::disabled;
|
||||||
}
|
}
|
||||||
int testPing() {
|
int testPing() {
|
||||||
// For some reason, implementing a non-blocking version of this functions triggers a "terminate called without an active exception" error with a platform plugin compiled with a newer GCC 11 toolchain. The problem has been solved by transplanting this function into the related area which uses it.
|
// For some reason, implementing a non-blocking version of this functions triggers a "terminate called without an active exception" error with a platform plugin compiled with a newer GCC 11 toolchain. The problem has been solved by transplanting this function into the related area which uses it.
|
||||||
|
|
Loading…
Reference in a new issue