Skip to content

Commit

Permalink
Workspace and hardware Info in diagnostic log file (#3419)
Browse files Browse the repository at this point in the history
Fix #2983 and Fix #2978

* workspace info in log header
* hardware info into header file
  • Loading branch information
VitorVieiraZ authored May 14, 2024
1 parent 7a5b72b commit 0196b23
Show file tree
Hide file tree
Showing 9 changed files with 97 additions and 2 deletions.
8 changes: 8 additions & 0 deletions app/android/src/uk/co/lutraconsulting/InputActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,14 @@ public String getSafeArea() {
}
}

public String getManufacturer() {
return android.os.Build.MANUFACTURER.toUpperCase();
}

public String getDeviceModel() {
return android.os.Build.MODEL.toUpperCase();
}

public void hideSplashScreen()
{
keepSplashScreenVisible = false;
Expand Down
20 changes: 20 additions & 0 deletions app/androidutils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,26 @@ void AndroidUtils::quitApp()
#endif
}

QString AndroidUtils::getManufacturer()
{
QString manufacturer = "";
#ifdef ANDROID
QJniObject activity = QJniObject( QNativeInterface::QAndroidApplication::context() );
manufacturer = activity.callObjectMethod( "getManufacturer", "()Ljava/lang/String;" ).toString().toUpper();
#endif
return manufacturer;
}

QString AndroidUtils::getDeviceModel()
{
QString deviceModel = "";
#ifdef ANDROID
QJniObject activity = QJniObject( QNativeInterface::QAndroidApplication::context() );
deviceModel = activity.callObjectMethod( "getDeviceModel", "()Ljava/lang/String;" ).toString();
#endif
return deviceModel;
}

QVector<int> AndroidUtils::getSafeArea()
{
QVector<int> ret;
Expand Down
2 changes: 2 additions & 0 deletions app/androidutils.h
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,8 @@ class AndroidUtils: public QObject

static void quitApp();

static QString getManufacturer();
static QString getDeviceModel();
Q_INVOKABLE QVector<int> getSafeArea();

void hideSplashScreen();
Expand Down
7 changes: 5 additions & 2 deletions app/inputhelp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -238,15 +238,18 @@ QVector<QString> InputHelp::logHeader( bool isHtml )
retLines.push_back( QStringLiteral( "Device UUID: %1" ).arg( CoreUtils::deviceUuid() ) );
retLines.push_back( QStringLiteral( "Data Dir: %1" ).arg( InputUtils::appDataDir() ) );
retLines.push_back( QStringLiteral( "System: %1" ).arg( QSysInfo::prettyProductName() ) );
retLines.push_back( QStringLiteral( "CPU Architecture: %1" ).arg( QSysInfo::currentCpuArchitecture() ) );
retLines.push_back( QStringLiteral( "Device Model: %1" ).arg( InputUtils::getDeviceModel() ) );
retLines.push_back( QStringLiteral( "Device Manufacturer: %1" ).arg( InputUtils::getManufacturer() ) );
retLines.push_back( QStringLiteral( "Mergin URL: %1" ).arg( mMerginApi->apiRoot() ) );
retLines.push_back( QStringLiteral( "Mergin User: %1" ).arg( mMerginApi->userAuth()->username() ) );
if ( !mMerginApi->userInfo()->email().isEmpty() )
{
retLines.push_back( QStringLiteral( "Mergin Data: %1/%2 Bytes" )
.arg( InputUtils::bytesToHumanSize( mMerginApi->workspaceInfo()->diskUsage() ) )
.arg( InputUtils::bytesToHumanSize( mMerginApi->workspaceInfo()->storageLimit() ) ) );
retLines.push_back( QStringLiteral( "Subscription plan: %1" ).arg( mMerginApi->subscriptionInfo()->planAlias() ) );
retLines.push_back( QStringLiteral( "Subscription Status: %1" ).arg( MerginSubscriptionStatus::toString( static_cast<MerginSubscriptionStatus::SubscriptionStatus>( mMerginApi->subscriptionInfo()->subscriptionStatus() ) ) ) );
retLines.push_back( QStringLiteral( "Workspace Name: %1" ).arg( mMerginApi->userInfo()->activeWorkspaceName() ) );
retLines.push_back( QStringLiteral( "Workspace ID: %1" ).arg( mMerginApi->userInfo()->activeWorkspaceId() ) );
}
else
{
Expand Down
22 changes: 22 additions & 0 deletions app/inpututils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@
#include <QCoreApplication>
#include <QPermissions>

#include "ios/iosutils.h"

#include "qgsruntimeprofiler.h"
#include "qcoreapplication.h"
#include "qgsgeometrycollection.h"
Expand Down Expand Up @@ -2153,3 +2155,23 @@ QList<QgsPoint> InputUtils::parsePositionUpdates( const QString &data )

return parsedUpdates;
}

QString InputUtils::getManufacturer()
{
#ifdef Q_OS_ANDROID
return AndroidUtils::getManufacturer();
#elif defined(Q_OS_IOS)
return IosUtils::getManufacturer();
#endif
return QStringLiteral( "N/A" );
}

QString InputUtils::getDeviceModel()
{
#ifdef Q_OS_ANDROID
return AndroidUtils::getDeviceModel();
#elif defined(Q_OS_IOS)
return IosUtils::getDeviceModel();
#endif
return QStringLiteral( "N/A" );
}
4 changes: 4 additions & 0 deletions app/inpututils.h
Original file line number Diff line number Diff line change
Expand Up @@ -182,6 +182,10 @@ class InputUtils: public QObject

Q_INVOKABLE void quitApp();

Q_INVOKABLE static QString getManufacturer();

Q_INVOKABLE static QString getDeviceModel();

/**
* Method copies all entries from given source path to destination path. If cannot copy a file for the first time,
* removes it and tries again (overwrite a file). If failes again, skips the file, sets result to false and continue.
Expand Down
16 changes: 16 additions & 0 deletions app/ios/iosutils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -66,3 +66,19 @@ QVector<int> IosUtils::getSafeArea()
#endif
return QVector<int>();
}

QString IosUtils::getManufacturer()
{
#ifdef Q_OS_IOS
return getManufacturerImpl();
#endif
return "";
}

QString IosUtils::getDeviceModel()
{
#ifdef Q_OS_IOS
return getDeviceModelImpl();
#endif
return "";
}
6 changes: 6 additions & 0 deletions app/ios/iosutils.h
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,9 @@ class IosUtils: public QObject

Q_INVOKABLE QVector<int> getSafeArea();

static Q_INVOKABLE QString getManufacturer();
static Q_INVOKABLE QString getDeviceModel();

signals:
void imageSelected( const QString &imagePath, const QString &code );
void notifyError( const QString &message );
Expand All @@ -61,6 +64,9 @@ class IosUtils: public QObject
void setIdleTimerDisabled();

QVector<int> getSafeAreaImpl();
static QString getManufacturerImpl();
static QString getDeviceModelImpl();

};

#endif // IOSUTILS_H
14 changes: 14 additions & 0 deletions app/ios/iosutils.mm
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
***************************************************************************/

#include <UIKit/UIKit.h>
#include <sys/utsname.h>
#include "iosutils.h"

void IosUtils::setIdleTimerDisabled()
Expand All @@ -40,3 +41,16 @@

return ret;
}

QString IosUtils::getManufacturerImpl()
{
return "APPLE INC.";
}

QString IosUtils::getDeviceModelImpl()
{
struct utsname systemInfo;
uname( &systemInfo );
QString deviceModel = QString::fromUtf8( systemInfo.machine );
return deviceModel.toUpper();
}

0 comments on commit 0196b23

Please sign in to comment.