summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorIvan Solovev <ivan.solovev@qt.io>2022-12-08 17:44:51 +0100
committerQt Cherry-pick Bot <cherrypick_bot@qt-project.org>2023-01-09 20:25:38 +0000
commit564be6021544e8fcbf7909d3a74655872e47e6f7 (patch)
treed506bd244c65874189e9b2d3d1f487a2175e75d2
parent29b5588be61ac990372d7310b7fd6e35e2dccccd (diff)
Android: improve position source single update logic
When requesting a single update using the Android plugin, it tries to request a signle update for all desired positioning methods, waits for the results until the specified timeout expires, and then provides the best of the available results. This does not look like a good solution, because we will get maximum one update from each specified positioning method. Considering that the default single update interval is 2 minutes, this results in needlessly long delay before getting the position update. This patch calculates the expected maximum amount of incoming position updates, and stops the timer as soon as this amount of updates is received. In practice that does not help in all cases, because the Satellite update might not be received within the specified interval if the satellite fix was not received. In such cases the result will still be reported after the timeout expires. A possible improvement would be to wait for the first update (Network or Satellite), and just use it. That's what all other backends do as well. Task-number: QTBUG-109303 Change-Id: I65142f90de28a35209a1cef0317aefd10fae859e Reviewed-by: Juha Vuolle <juha.vuolle@qt.io> (cherry picked from commit 8f665182d1daf995ef2ea3d9b3a3aa1051ba0fb8) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
-rw-r--r--src/plugins/position/android/src/qgeopositioninfosource_android.cpp11
1 files changed, 11 insertions, 0 deletions
diff --git a/src/plugins/position/android/src/qgeopositioninfosource_android.cpp b/src/plugins/position/android/src/qgeopositioninfosource_android.cpp
index 895f12e3..25492d26 100644
--- a/src/plugins/position/android/src/qgeopositioninfosource_android.cpp
+++ b/src/plugins/position/android/src/qgeopositioninfosource_android.cpp
@@ -176,6 +176,17 @@ void QGeoPositionInfoSourceAndroid::processSinglePositionUpdate(const QGeoPositi
return;
queuedSingleUpdates.append(pInfo);
+ // Calculate the maximum amount of possibly received updates. It depends on
+ // preferred positioning methods. Two updates if we have both Satellite and
+ // Network, and only one otherwise.
+ const qsizetype maxPossibleUpdates =
+ (preferredPositioningMethods() == QGeoPositionInfoSource::AllPositioningMethods)
+ ? 2 : 1;
+ // If we get the maximum number of updates, we do not need to wait for more
+ if (queuedSingleUpdates.size() == maxPossibleUpdates) {
+ m_requestTimer.stop();
+ requestTimeout();
+ }
}
void QGeoPositionInfoSourceAndroid::locationProviderDisabled()