diff options
author | Ivan Solovev <ivan.solovev@qt.io> | 2022-12-22 13:05:33 +0100 |
---|---|---|
committer | Qt Cherry-pick Bot <cherrypick_bot@qt-project.org> | 2023-01-10 11:44:35 +0000 |
commit | ed7713a2af53e22bb68c7c1712c298ebbf63a257 (patch) | |
tree | 61f7381f6a7afcbb8fe01d6d8bfc2cd096f23cf3 | |
parent | 416e516382cab778c029fcfb401c2a21f3d6bcb7 (diff) |
Android plugin: refactor satellite info source
Android implementation of QGeoSatelliteInfoSource had two slots to
process satellites in view and satellites in use independently, and
their implementation was basically copy-pasted.
However, the underlying code is usually calling both methods together,
because we always receive both satellites in view and satellites in use
from the Android backend.
This patch refactors the implementation, converting two methods into
one. This simplifies the code, and makes the follow-up improvements
easier. Arguably, this might also have some performance benefit, as we
now do one QMetaObject::invokeMethod() call instead of two.
Task-number: QTBUG-109303
Change-Id: Ib7b4d7b91608ed0fe22eef265341ad2402846ac7
Reviewed-by: Juha Vuolle <juha.vuolle@qt.io>
(cherry picked from commit dd4a8b2770ac9eddffe9f25d68bbb1dc6504130b)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
3 files changed, 13 insertions, 21 deletions
diff --git a/src/plugins/position/android/src/jnipositioning.cpp b/src/plugins/position/android/src/jnipositioning.cpp index 1fb73a05..8554523e 100644 --- a/src/plugins/position/android/src/jnipositioning.cpp +++ b/src/plugins/position/android/src/jnipositioning.cpp @@ -612,11 +612,10 @@ static void notifySatelliteInfoUpdated(const QList<QGeoSatelliteInfo> &inView, return; } - QMetaObject::invokeMethod(source, "processSatelliteUpdateInView", Qt::AutoConnection, - Q_ARG(QList<QGeoSatelliteInfo>, inView), Q_ARG(bool, isSingleUpdate)); - - QMetaObject::invokeMethod(source, "processSatelliteUpdateInUse", Qt::AutoConnection, - Q_ARG(QList<QGeoSatelliteInfo>, inUse), Q_ARG(bool, isSingleUpdate)); + QMetaObject::invokeMethod(source, "processSatelliteUpdate", Qt::AutoConnection, + Q_ARG(QList<QGeoSatelliteInfo>, inView), + Q_ARG(QList<QGeoSatelliteInfo>, inUse), + Q_ARG(bool, isSingleUpdate)); } static void satelliteGpsUpdated(JNIEnv *env, jobject thiz, jobjectArray satellites, diff --git a/src/plugins/position/android/src/qgeosatelliteinfosource_android.cpp b/src/plugins/position/android/src/qgeosatelliteinfosource_android.cpp index 1919dd3d..e7bd2d5a 100644 --- a/src/plugins/position/android/src/qgeosatelliteinfosource_android.cpp +++ b/src/plugins/position/android/src/qgeosatelliteinfosource_android.cpp @@ -118,29 +118,21 @@ void QGeoSatelliteInfoSourceAndroid::requestUpdate(int timeout) } } -void QGeoSatelliteInfoSourceAndroid::processSatelliteUpdateInView(const QList<QGeoSatelliteInfo> &satsInView, bool isSingleUpdate) +void +QGeoSatelliteInfoSourceAndroid::processSatelliteUpdate(const QList<QGeoSatelliteInfo> &satsInView, + const QList<QGeoSatelliteInfo> &satsInUse, + bool isSingleUpdate) { if (!isSingleUpdate) { - //if requested while regular updates were running + //if single update is requested while regular updates are running if (requestTimer.isActive()) requestTimer.stop(); emit QGeoSatelliteInfoSource::satellitesInViewUpdated(satsInView); - return; - } - - m_satsInView = satsInView; -} - -void QGeoSatelliteInfoSourceAndroid::processSatelliteUpdateInUse(const QList<QGeoSatelliteInfo> &satsInUse, bool isSingleUpdate) -{ - if (!isSingleUpdate) { - //if requested while regular updates were running - if (requestTimer.isActive()) - requestTimer.stop(); emit QGeoSatelliteInfoSource::satellitesInUseUpdated(satsInUse); return; } + m_satsInView = satsInView; m_satsInUse = satsInUse; if (!m_satsInView.isEmpty() || !m_satsInUse.isEmpty()) { diff --git a/src/plugins/position/android/src/qgeosatelliteinfosource_android_p.h b/src/plugins/position/android/src/qgeosatelliteinfosource_android_p.h index 404136d6..7071a67a 100644 --- a/src/plugins/position/android/src/qgeosatelliteinfosource_android_p.h +++ b/src/plugins/position/android/src/qgeosatelliteinfosource_android_p.h @@ -37,8 +37,9 @@ public Q_SLOTS: void stopUpdates() override; void requestUpdate(int timeout = 0) override; - void processSatelliteUpdateInView(const QList<QGeoSatelliteInfo> &satsInView, bool isSingleUpdate); - void processSatelliteUpdateInUse(const QList<QGeoSatelliteInfo> &satsInUse, bool isSingleUpdate); + void processSatelliteUpdate(const QList<QGeoSatelliteInfo> &satsInView, + const QList<QGeoSatelliteInfo> &satsInUse, + bool isSingleUpdate); void locationProviderDisabled(); private Q_SLOTS: |