From 8b4b3e22e7f35de880dbba9253e7b23136b9a4bd Mon Sep 17 00:00:00 2001 From: Florian RICHER Date: Sat, 12 Jul 2025 14:54:24 +0200 Subject: [PATCH] Hide Google services if is not Gapps System Type installed --- .../waydroidstate.cpp | 38 +++++++++++++++++++ .../waydroidintegrationplugin/waydroidstate.h | 8 +++- .../ui/WaydroidConfigurationForm.qml | 1 + 3 files changed, 46 insertions(+), 1 deletion(-) diff --git a/components/waydroidintegrationplugin/waydroidstate.cpp b/components/waydroidintegrationplugin/waydroidstate.cpp index 95fcb984..7fcd9416 100644 --- a/components/waydroidintegrationplugin/waydroidstate.cpp +++ b/components/waydroidintegrationplugin/waydroidstate.cpp @@ -9,6 +9,7 @@ #include #include +#include #include #include #include @@ -28,12 +29,14 @@ using namespace Qt::StringLiterals; static const QRegularExpression sessionRegExp(u"Session:\\s*(\\w+)"_s); static const QRegularExpression ipAdressRegExp(u"IP address:\\s*(\\d+\\.\\d+\\.\\d+\\.\\d+)"_s); +static const QRegularExpression systemOtaRegExp(u"system_ota\\s*=\\s*(\\S+)"_s); WaydroidState::WaydroidState(QObject *parent) : QObject{parent} { // Connect it-self to auto-refresh when required status has changed connect(this, &WaydroidState::statusChanged, this, &WaydroidState::refreshSessionInfo); + connect(this, &WaydroidState::statusChanged, this, &WaydroidState::refreshInstallationInfo); connect(this, &WaydroidState::sessionStatusChanged, this, &WaydroidState::refreshPropsInfo); refreshSupportsInfo(); @@ -63,6 +66,33 @@ void WaydroidState::refreshSupportsInfo() Q_EMIT statusChanged(); } +void WaydroidState::refreshInstallationInfo() +{ + if (m_status != Initialized) { + return; + } + + QFile file("/var/lib/waydroid/waydroid.cfg"); + if (!file.open(QIODevice::ReadOnly | QIODevice::Text)) { + return; + } + + QTextStream in(&file); + const QString fileContent = in.readAll(); + + const QString systemMatch = extractRegExp(fileContent, systemOtaRegExp); + if (systemMatch.contains("vanilla", Qt::CaseInsensitive)) { + m_systemType = Vanilla; + } else if (systemMatch.contains("gapps", Qt::CaseInsensitive)) { + m_systemType = Gapps; + } else if (systemMatch.contains("foss", Qt::CaseInsensitive)) { + m_systemType = Foss; + } else { + m_systemType = UnknownSystemType; + } + Q_EMIT systemTypeChanged(); +} + void WaydroidState::refreshSessionInfo() { if (m_status != Initialized) { @@ -164,6 +194,9 @@ void WaydroidState::initialize(const SystemType systemType, const RomType romTyp case SystemType::Gapps: systemTypeArg = "GAPPS"; break; + default: + systemTypeArg = "VANILLA"; + break; } QString romTypeArg; @@ -277,6 +310,11 @@ WaydroidState::SessionStatus WaydroidState::sessionStatus() const return m_sessionStatus; } +WaydroidState::SystemType WaydroidState::systemType() const +{ + return m_systemType; +} + QString WaydroidState::ipAddress() const { return m_ipAddress; diff --git a/components/waydroidintegrationplugin/waydroidstate.h b/components/waydroidintegrationplugin/waydroidstate.h index 4f82bca5..98d6a8d1 100644 --- a/components/waydroidintegrationplugin/waydroidstate.h +++ b/components/waydroidintegrationplugin/waydroidstate.h @@ -25,6 +25,7 @@ class WaydroidState : public QObject Q_PROPERTY(Status status READ status NOTIFY statusChanged) Q_PROPERTY(SessionStatus sessionStatus READ sessionStatus NOTIFY sessionStatusChanged) + Q_PROPERTY(SystemType systemType READ systemType NOTIFY systemTypeChanged) Q_PROPERTY(QString ipAddress READ ipAddress NOTIFY ipAddressChanged) Q_PROPERTY(QString androidId READ androidId NOTIFY androidIdChanged) Q_PROPERTY(QString errorTitle READ errorTitle NOTIFY errorTitleChanged) @@ -66,7 +67,8 @@ public: enum SystemType { Vanilla = 0, ///< Vanilla Android system. Foss, ///< Free and Open Source Software variant. - Gapps ///< Variant with Google Apps included. + Gapps, ///< Variant with Google Apps included. + UnknownSystemType }; Q_ENUM(SystemType) @@ -83,6 +85,7 @@ public: Q_ENUM(RomType) Q_INVOKABLE void refreshSupportsInfo(); + Q_INVOKABLE void refreshInstallationInfo(); Q_INVOKABLE void refreshSessionInfo(); Q_INVOKABLE void refreshAndroidId(); Q_INVOKABLE void refreshPropsInfo(); @@ -94,6 +97,7 @@ public: Status status() const; SessionStatus sessionStatus() const; + SystemType systemType() const; QString ipAddress() const; QString androidId() const; QString errorTitle() const; @@ -108,6 +112,7 @@ public: Q_SIGNALS: void statusChanged(); void sessionStatusChanged(); + void systemTypeChanged(); void ipAddressChanged(); void multiWindowsChanged(); void suspendChanged(); @@ -119,6 +124,7 @@ Q_SIGNALS: private: Status m_status{NotInitialized}; SessionStatus m_sessionStatus{SessionStopped}; + SystemType m_systemType{SystemType::UnknownSystemType}; QString m_ipAddress{""}; QString m_errorTitle{""}; QString m_errorMessage{""}; diff --git a/kcms/waydroidintegration/ui/WaydroidConfigurationForm.qml b/kcms/waydroidintegration/ui/WaydroidConfigurationForm.qml index 47180f1a..2e2f1ba8 100644 --- a/kcms/waydroidintegration/ui/WaydroidConfigurationForm.qml +++ b/kcms/waydroidintegration/ui/WaydroidConfigurationForm.qml @@ -43,6 +43,7 @@ ColumnLayout { FormCard.FormButtonDelegate { id: quickSettingsButton + visible: AIP.WaydroidState.systemType === AIP.WaydroidState.Gapps text: i18n("Certify my device for Google Play Protect") onClicked: kcm.push("WaydroidGooglePlayProtectConfigurationPage.qml") }