Commit 07e0cb08 authored by Marius Gripsgard's avatar Marius Gripsgard

Add patched needed for lomiri

NOTE: None of these patches break any abi or api, they only add qml functions nor does these patches change the code, only adds code.
parent b674ccad
Pipeline #837 failed with stage
From 8b00dd89cb0be7319acc21a69cf477fbbad992d3 Mon Sep 17 00:00:00 2001
From: Marius Gripsgard <marius@ubports.com>
Date: Sat, 12 Sep 2020 20:03:14 +0200
Subject: [PATCH] [connman] Add support for reset contexts dbus call
This adds support for reset contexts dbus call
See upstream ofono commit:
https://git.kernel.org/pub/scm/network/ofono/ofono.git/commit/src/gprs.c?id=444611c086d3c333546e2645feba96020a4c030e
---
src/dbus/ofono_connection_manager.xml | 1 +
src/qofonoconnectionmanager.cpp | 15 +++++++++++
src/qofonoconnectionmanager.h | 1 +
test/auto/tests/tst_qofonoconnman.cpp | 37 +++++++++++++++++++++++++++
4 files changed, 54 insertions(+)
diff --git a/src/dbus/ofono_connection_manager.xml b/src/dbus/ofono_connection_manager.xml
index 6ac0965..e5156cf 100644
--- a/src/dbus/ofono_connection_manager.xml
+++ b/src/dbus/ofono_connection_manager.xml
@@ -18,6 +18,7 @@
<arg type="o" direction="in"/>
</method>
<method name="DeactivateAll"/>
+ <method name="ResetContexts"/>
<method name="GetContexts">
<arg type="a(oa{sv})" direction="out"/>
<annotation name="org.qtproject.QtDBus.QtTypeName.Out0" value="ObjectPathPropertiesList"/>
diff --git a/src/qofonoconnectionmanager.cpp b/src/qofonoconnectionmanager.cpp
index aac507c..c8fafaa 100644
--- a/src/qofonoconnectionmanager.cpp
+++ b/src/qofonoconnectionmanager.cpp
@@ -143,6 +143,21 @@ void QOfonoConnectionManager::removeContext(const QString &path)
}
}
+void QOfonoConnectionManager::resetContexts()
+{
+ OfonoConnectionManager *iface = (OfonoConnectionManager*)dbusInterface();
+ if (iface) {
+ QDBusPendingReply<> deactivate = iface->DeactivateAll();
+ deactivate.waitForFinished();
+ QDBusPendingReply<> reset = iface->ResetContexts();
+ reset.waitForFinished();
+ if (reset.isError()) {
+ qDebug() << reset.error();
+ Q_EMIT reportError(reset.error().message());
+ }
+ }
+}
+
bool QOfonoConnectionManager::attached() const
{
return getBool("Attached");
diff --git a/src/qofonoconnectionmanager.h b/src/qofonoconnectionmanager.h
index c937f91..9d66bcf 100644
--- a/src/qofonoconnectionmanager.h
+++ b/src/qofonoconnectionmanager.h
@@ -79,6 +79,7 @@ public slots:
void deactivateAll();
void addContext(const QString &type);
void removeContext(const QString &path);
+ void resetContexts();
private slots:
void onAddContextFinished(QDBusPendingCallWatcher *watch);
diff --git a/test/auto/tests/tst_qofonoconnman.cpp b/test/auto/tests/tst_qofonoconnman.cpp
index 2e06120..ada1d60 100644
--- a/test/auto/tests/tst_qofonoconnman.cpp
+++ b/test/auto/tests/tst_qofonoconnman.cpp
@@ -107,8 +107,45 @@ private slots:
QCOMPARE(rem.count(), 0);
}
+ void testResetContexts()
+ {
+ Q_FOREACH (QString context, m->contexts()) {
+ m->removeContext(context);
+ }
+ QTRY_VERIFY(m->contexts().isEmpty());
+
+ QSignalSpy pow(m, SIGNAL(poweredChanged(bool)));
+ QSignalSpy add(m, SIGNAL(contextAdded(QString)));
+ QSignalSpy rem(m, SIGNAL(contextRemoved(QString)));
+
+ // Add new context.
+ m->addContext(QString("internet"));
+ QTRY_COMPARE(add.count(), 1);
+ QString path = add.takeFirst().at(0).toString();
+ QOfonoConnectionContext* contextInternet = new QOfonoConnectionContext(this);
+ contextInternet->setContextPath(path);
+
+ // We activate context to make sure connman is deactivating on reset.
+ contextInternet->setActive(true);
+ QTRY_VERIFY(contextInternet->active());
+
+ // Connman needs to be powered down before calling reset.
+ m->setPowered(false);
+ QTRY_COMPARE(pow.count(), 1);
+ QCOMPARE(pow.takeFirst().at(0).toBool(), false);
+ QCOMPARE(m->powered(), false);
+
+ m->resetContexts();
+ QTRY_COMPARE(rem.count(), 1);
+ }
+
void cleanupTestCase()
{
+ QSignalSpy pow(m, SIGNAL(poweredChanged(bool)));
+ m->setPowered(true);
+ QTRY_COMPARE(pow.count(), 1);
+ QCOMPARE(pow.takeFirst().at(0).toBool(), true);
+ QCOMPARE(m->powered(), true);
}
private:
--
2.23.0
......@@ -9,12 +9,28 @@ url="https://git.merproject.org/mer-core/libqofono"
license=('LGPL')
depends=('qt5-declarative' 'qt5-xmlpatterns')
provides=("libqofono-qt5")
source=("https://git.merproject.org/mer-core/libqofono/-/archive/${pkgver}/libqofono-${pkgver}.tar.gz")
md5sums=('1175c0e5f396a8f605092eb98ffb1dd8')
source=("https://git.merproject.org/mer-core/libqofono/-/archive/${pkgver}/libqofono-${pkgver}.tar.gz"
"0001-add-support-for-reset-contexts.patch"
"context-preferred.patch"
"mtk_settings_binding.patch")
md5sums=('1175c0e5f396a8f605092eb98ffb1dd8'
'18cd69a363041b4b3e72a565ab68b69b'
'17444b274709abf45a7e871c9f8b6407'
'19aac206aab5c3e4f115f7e7ba55e541')
prepare() {
cd libqofono-$pkgver
mkdir -p build
# None of these patches break any abi or api, they only add qml functions
# nor does these patches change the code, only adds code
# upstreamed patch, adds support for upstream ofono dbus call
patch -Np1 -i "${srcdir}/0001-add-support-for-reset-contexts.patch"
# Not upstreamed patches
patch -Np1 -i "${srcdir}/context-preferred.patch"
patch -Np1 -i "${srcdir}/mtk_settings_binding.patch"
}
build() {
......
Index: libqofono-ubuntu/src/qofonoconnectioncontext.cpp
===================================================================
--- libqofono-ubuntu.orig/src/qofonoconnectioncontext.cpp
+++ libqofono-ubuntu/src/qofonoconnectioncontext.cpp
@@ -117,6 +117,8 @@ void QOfonoConnectionContext::propertyCh
SUPER::propertyChanged(property, value);
if (property == QLatin1String("Active")) {
Q_EMIT activeChanged(value.value<bool>());
+ } else if (property == QLatin1String("Preferred")) {
+ Q_EMIT preferredChanged(value.value<bool>());
} else if (property == QLatin1String("Name")) {
Q_EMIT nameChanged(value.value<QString>());
} else if (property == QLatin1String("AccessPointName")) {
@@ -147,6 +149,11 @@ bool QOfonoConnectionContext::active() c
return getBool("Active");
}
+bool QOfonoConnectionContext::preferred() const
+{
+ return getBool("Preferred");
+}
+
QString QOfonoConnectionContext::accessPointName() const
{
return getString("AccessPointName");
@@ -211,6 +218,11 @@ void QOfonoConnectionContext::setActive(
setProperty("Active", value);
}
+void QOfonoConnectionContext::setPreferred(const bool value)
+{
+ setProperty("Preferred", value);
+}
+
void QOfonoConnectionContext::setAccessPointName(const QString &value)
{
setProperty("AccessPointName", value);
Index: libqofono-ubuntu/src/qofonoconnectioncontext.h
===================================================================
--- libqofono-ubuntu.orig/src/qofonoconnectioncontext.h
+++ libqofono-ubuntu/src/qofonoconnectioncontext.h
@@ -28,6 +28,7 @@ class QOFONOSHARED_EXPORT QOfonoConnecti
{
Q_OBJECT
Q_PROPERTY(bool active READ active WRITE setActive NOTIFY activeChanged)
+ Q_PROPERTY(bool preferred READ preferred WRITE setPreferred NOTIFY preferredChanged)
Q_PROPERTY(bool provisioning READ provisioning NOTIFY provisioningChanged)
Q_PROPERTY(QString accessPointName READ accessPointName WRITE setAccessPointName NOTIFY accessPointNameChanged)
Q_PROPERTY(QString type READ type WRITE setType NOTIFY typeChanged)
@@ -56,6 +57,9 @@ public:
bool provisioning() const;
+ bool preferred() const;
+ void setPreferred(bool);
+
QString accessPointName() const;
void setAccessPointName(const QString &);
@@ -104,6 +108,7 @@ public:
Q_SIGNALS:
void disconnectRequested();
void activeChanged(bool active);
+ void preferredChanged(bool preferred);
void provisioningChanged(bool provisioning);
void accessPointNameChanged(const QString &apn);
void nameChanged(const QString &name);
Index: libqofono-ubuntu/test/auto/tests/tst_qofonoconnmancontext.cpp
===================================================================
--- libqofono-ubuntu.orig/test/auto/tests/tst_qofonoconnmancontext.cpp
+++ libqofono-ubuntu/test/auto/tests/tst_qofonoconnmancontext.cpp
@@ -61,6 +61,7 @@ private slots:
QTRY_COMPARE(context->isValid(), true);
QSignalSpy active(context, SIGNAL(activeChanged(bool)));
+ QSignalSpy preferred(context, SIGNAL(preferredChanged(bool)));
QSignalSpy apn(context,SIGNAL(accessPointNameChanged(QString)));
QSignalSpy name(context, SIGNAL(nameChanged(QString)));
QSignalSpy type (context, SIGNAL(typeChanged(QString)));
@@ -93,6 +94,10 @@ private slots:
QTRY_COMPARE(active.count(), 1);
QCOMPARE(active.takeFirst().at(0).toBool(), true);
+ context->setPreferred(true);
+ QTRY_COMPARE(preferred.count(), 1);
+ QCOMPARE(preferred.takeFirst().at(0).toBool(), true);
+
QTRY_COMPARE(sett6.count(), 1);
QCOMPARE(sett6.takeFirst().at(0).toMap()["Interface"].value<QString>().left(5),
QString("dummy")); // "dummy" plus number
@@ -109,11 +114,16 @@ private slots:
QCOMPARE(sett.count(), 0);
QCOMPARE(proto.count(), 0);
QCOMPARE(active.count(), 0);
+ QCOMPARE(preferred.count(), 0);
context->setActive(false);
QTRY_COMPARE(active.count(), 1);
QCOMPARE(active.takeFirst().at(0).toBool(), false);
+ context->setPreferred(false);
+ QTRY_COMPARE(preferred.count(), 1);
+ QCOMPARE(preferred.takeFirst().at(0).toBool(), false);
+
delete context;
m->removeContext(contextid);
This diff is collapsed.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment