mirror of
https://github.com/Quill-OS/quill.git
synced 2024-12-26 07:37:21 -08:00
Working telemetry class
This commit is contained in:
parent
8f1003f6bb
commit
7143c85201
6 changed files with 23 additions and 53 deletions
|
@ -28,6 +28,7 @@ SOURCES += \
|
|||
src/audio/audiothread.cpp \
|
||||
src/splash/alert.cpp \
|
||||
src/apps/apps.cpp \
|
||||
src/telemetry/telemetry.cpp \
|
||||
src/widgets/dialogs/audio/audiodialog.cpp \
|
||||
src/widgets/dialogs/audio/audiofile.cpp \
|
||||
src/widgets/dialogs/audio/audiofilequeue.cpp \
|
||||
|
@ -77,6 +78,7 @@ HEADERS += \
|
|||
src/apps/todo.h \
|
||||
src/splash/alert.h \
|
||||
src/apps/apps.h \
|
||||
src/telemetry/telemetry.h \
|
||||
src/widgets/dialogs/audio/audiodialog.h \
|
||||
src/widgets/dialogs/audio/audiofile.h \
|
||||
src/widgets/dialogs/audio/audiofilequeue.h \
|
||||
|
|
|
@ -233,14 +233,6 @@ namespace global {
|
|||
namespace telemetry {
|
||||
inline bool enabled = false;
|
||||
inline bool telemetryDialog = false;
|
||||
namespace collectedData {
|
||||
inline QString message;
|
||||
inline QString deviceUID;
|
||||
inline QString systemVersion;
|
||||
inline QString device;
|
||||
inline bool deviceRooted;
|
||||
inline bool developerKeyInstalled;
|
||||
}
|
||||
}
|
||||
inline QString systemInfoText;
|
||||
inline bool forbidOpenSearchDialog;
|
||||
|
@ -1179,21 +1171,26 @@ namespace {
|
|||
}
|
||||
}
|
||||
}
|
||||
int testPing() {
|
||||
int testPing(QString ipAddress = "1.1.1.1") {
|
||||
// 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.
|
||||
QString function = __func__; log(function + ": pinging IP address " + ipAddress, "functions");
|
||||
QProcess *pingProcess = new QProcess();
|
||||
QString pingProg = "ping";
|
||||
QStringList pingArgs;
|
||||
pingArgs << "-c" << "1" << "1.1.1.1";
|
||||
pingArgs << "-c" << "1" << ipAddress;
|
||||
pingProcess->start(pingProg, pingArgs);
|
||||
pingProcess->waitForFinished();
|
||||
int exitCode = pingProcess->exitCode();
|
||||
pingProcess->deleteLater();
|
||||
if(exitCode == 0) {
|
||||
log("Ping successful", "functions");
|
||||
global::wifi::isConnected = true;
|
||||
}
|
||||
else {
|
||||
global::wifi::isConnected = false;
|
||||
log("Ping unsuccessful", "functions");
|
||||
if(ipAddress == "1.1.1.1") {
|
||||
global::wifi::isConnected = false;
|
||||
}
|
||||
}
|
||||
return exitCode;
|
||||
}
|
||||
|
@ -1232,36 +1229,6 @@ namespace {
|
|||
fhandler << str.toStdString();
|
||||
fhandler.close();
|
||||
}
|
||||
QJsonObject collectDeviceInformation() {
|
||||
global::telemetry::collectedData::deviceUID = getUID();
|
||||
global::telemetry::collectedData::systemVersion = readFile("/opt/version").trimmed();
|
||||
global::telemetry::collectedData::device = global::deviceID.trimmed();
|
||||
if(checkconfig("/external_root/opt/root/rooted")) {
|
||||
global::telemetry::collectedData::deviceRooted = "true";
|
||||
}
|
||||
else {
|
||||
global::telemetry::collectedData::deviceRooted = "false";
|
||||
}
|
||||
if(checkconfig("/external_root/opt/developer/valid-key")) {
|
||||
global::telemetry::collectedData::developerKeyInstalled = "true";
|
||||
}
|
||||
else {
|
||||
global::telemetry::collectedData::developerKeyInstalled = "false";
|
||||
}
|
||||
|
||||
QJsonObject data;
|
||||
data.insert("UID", global::telemetry::collectedData::deviceUID);
|
||||
data.insert("SystemVersion", global::telemetry::collectedData::systemVersion);
|
||||
data.insert("DeviceModel", global::telemetry::collectedData::device);
|
||||
data.insert("DeviceRooted", global::telemetry::collectedData::deviceRooted);
|
||||
data.insert("DeveloperKeyInstalled", global::telemetry::collectedData::developerKeyInstalled);
|
||||
data.insert("Message", global::telemetry::collectedData::message);
|
||||
|
||||
return(data);
|
||||
}
|
||||
bool sendDeviceInformation(QJsonObject data) {
|
||||
qDebug() << data;
|
||||
}
|
||||
}
|
||||
|
||||
#endif // FUNCTIONS_H
|
||||
|
|
|
@ -436,7 +436,7 @@ MainWindow::MainWindow(QWidget *parent)
|
|||
|
||||
// Telemetry
|
||||
if(checkconfig(".config/24-telemetry/enabled") == false && checkconfig(".config/24-telemetry/asked") == false) {
|
||||
if(testPing() == 0) {
|
||||
if(testPing("23.163.0.39") == 0) {
|
||||
QTimer::singleShot(1000, this, SLOT(openTelemetryDialog()));
|
||||
}
|
||||
}
|
||||
|
@ -1110,16 +1110,14 @@ void MainWindow::openTelemetryMessageDialog() {
|
|||
global::keyboard::keyboardDialog = true;
|
||||
global::keyboard::keyboardText = "";
|
||||
generalDialogWindow = new generalDialog(this);
|
||||
QObject::connect(generalDialogWindow, &generalDialog::destroyed, this, &MainWindow::sendDeviceInformationSlot);
|
||||
QObject::connect(generalDialogWindow, &generalDialog::telemetryMessage, this, &MainWindow::sendDeviceInformationSlot);
|
||||
generalDialogWindow->setAttribute(Qt::WA_DeleteOnClose);
|
||||
QApplication::processEvents();
|
||||
}
|
||||
}
|
||||
|
||||
void MainWindow::sendDeviceInformationSlot() {
|
||||
QJsonObject data = collectDeviceInformation();
|
||||
qDebug() << data;
|
||||
sendDeviceInformation(data);
|
||||
writeFile("/mnt/onboard/.adds/inkbox/.config/24-telemetry/asked", "true");
|
||||
writeFile("/mnt/onboard/.adds/inkbox/.config/24-telemetry/enabled", "true");
|
||||
void MainWindow::sendDeviceInformationSlot(QString message) {
|
||||
telemetryInstance = new telemetry(this);
|
||||
QObject::connect(telemetryInstance, &telemetry::showToast, this, &MainWindow::showToast);
|
||||
telemetryInstance->message = message;
|
||||
}
|
||||
|
|
|
@ -20,6 +20,7 @@
|
|||
#include "librarywidget.h"
|
||||
#include "locallibrarywidget.h"
|
||||
#include "homepagewidget.h"
|
||||
#include "telemetry.h"
|
||||
|
||||
using namespace std;
|
||||
|
||||
|
@ -105,7 +106,7 @@ private slots:
|
|||
void on_audioBtn_clicked();
|
||||
void openTelemetryDialog();
|
||||
void openTelemetryMessageDialog();
|
||||
void sendDeviceInformationSlot();
|
||||
void sendDeviceInformationSlot(QString message);
|
||||
|
||||
private:
|
||||
Ui::MainWindow * ui;
|
||||
|
@ -126,6 +127,7 @@ private:
|
|||
libraryWidget * libraryWidgetWindow;
|
||||
localLibraryWidget * localLibraryWidgetWindow;
|
||||
homePageWidget * homePageWidgetWindow;
|
||||
telemetry * telemetryInstance;
|
||||
};
|
||||
|
||||
#endif // MAINWINDOW_H
|
||||
|
|
|
@ -311,8 +311,8 @@ void generalDialog::on_cancelBtn_clicked()
|
|||
}
|
||||
else if(global::keyboard::telemetryMessageDialog == true) {
|
||||
global::keyboard::telemetryMessageDialog = false;
|
||||
emit telemetryMessage(global::keyboard::keyboardText);
|
||||
global::keyboard::keyboardText = "";
|
||||
global::telemetry::collectedData::message = "";
|
||||
log("No message to be sent along with collected data", className);
|
||||
}
|
||||
generalDialog::close();
|
||||
|
@ -558,11 +558,11 @@ void generalDialog::on_okBtn_clicked()
|
|||
}
|
||||
else if(global::keyboard::telemetryMessageDialog == true) {
|
||||
if(!global::keyboard::keyboardText.isEmpty()) {
|
||||
global::telemetry::collectedData::message = global::keyboard::keyboardText;
|
||||
emit telemetryMessage(global::keyboard::keyboardText);
|
||||
log("Message to be sent along with collected data is: " + global::keyboard::keyboardText, className);
|
||||
global::keyboard::keyboardText = "";
|
||||
global::keyboard::telemetryMessageDialog = false;
|
||||
global::keyboard::keyboardDialog = false;
|
||||
log("Message to be sent along with collected data is: " + global::telemetry::collectedData::message, className);
|
||||
this->close();
|
||||
}
|
||||
else {
|
||||
|
|
|
@ -94,6 +94,7 @@ signals:
|
|||
void disableStorageEncryption();
|
||||
void syncOnlineLibrary();
|
||||
void noSyncOnlineLibrary();
|
||||
void telemetryMessage(QString message);
|
||||
};
|
||||
|
||||
#endif // GENERALDIALOG_H
|
||||
|
|
Loading…
Reference in a new issue