diff options
author | Jari Savinainen <qt-info@nokia.com> | 2010-03-29 16:33:37 +0300 |
---|---|---|
committer | Jari Savinainen <qt-info@nokia.com> | 2010-03-31 10:19:07 +0300 |
commit | 0d617dbc5dfc289177fd9c5506b5226b02c13353 (patch) | |
tree | 1e7a34101fae3fb17e8a1eaac542e0eb8057b106 | |
parent | fcf5a72d8e8a6a5d99e2dc3a2f0a49457b87628a (diff) |
MOBILITY-702 State machine modification.
-rw-r--r-- | src/location/qgeopositioninfosource_maemo5.cpp | 192 | ||||
-rw-r--r-- | src/location/qgeopositioninfosource_maemo5_p.h | 5 | ||||
-rw-r--r-- | src/location/qgeosatelliteinfosource_maemo5.cpp | 185 | ||||
-rw-r--r-- | src/location/qgeosatelliteinfosource_maemo5_p.h | 5 |
4 files changed, 169 insertions, 218 deletions
diff --git a/src/location/qgeopositioninfosource_maemo5.cpp b/src/location/qgeopositioninfosource_maemo5.cpp index 5ad7cc4d42..001fcf59ae 100644 --- a/src/location/qgeopositioninfosource_maemo5.cpp +++ b/src/location/qgeopositioninfosource_maemo5.cpp @@ -70,7 +70,6 @@ QGeoPositionInfoSourceMaemo::QGeoPositionInfoSourceMaemo(QObject *parent) int QGeoPositionInfoSourceMaemo::init() { if (LiblocationWrapper::instance()->inited()) { - positionInfoState = QGeoPositionInfoSourceMaemo::Stopped; connect(LiblocationWrapper::instance(), SIGNAL(error()), this, SLOT(error())); return INIT_OK; } else { @@ -91,33 +90,31 @@ QGeoPositionInfoSource::PositioningMethods QGeoPositionInfoSourceMaemo::supporte void QGeoPositionInfoSourceMaemo::setUpdateInterval(int msec) { bool updateTimerInterval = false; - + if (positionInfoState & QGeoPositionInfoSourceMaemo::PowersaveActive) if (positionInfoState & QGeoPositionInfoSourceMaemo::Stopped) updateTimerInterval = true; - - positionInfoState &= ~(QGeoPositionInfoSourceMaemo::GpsOn | - QGeoPositionInfoSourceMaemo::PowersaveActive); if (!msec) { timerInterval = MINIMUM_UPDATE_INTERVAL; QGeoPositionInfoSource::setUpdateInterval(0); - } else { + } else { timerInterval = (msec < MINIMUM_UPDATE_INTERVAL) ? MINIMUM_UPDATE_INTERVAL : msec; QGeoPositionInfoSource::setUpdateInterval(timerInterval); } - if (timerInterval >= POWERSAVE_THRESHOLD) { - positionInfoState |= (QGeoPositionInfoSourceMaemo::PowersaveActive | - QGeoPositionInfoSourceMaemo::GpsOn); - } else { - positionInfoState &= ~(QGeoPositionInfoSourceMaemo::GpsOn | - QGeoPositionInfoSourceMaemo::PowersaveActive); - } - - if (updateTimerInterval || (positionInfoState & - QGeoPositionInfoSourceMaemo::Started)) - activateTimer(); + if (timerInterval >= POWERSAVE_THRESHOLD) + positionInfoState |= QGeoPositionInfoSourceMaemo::PowersaveActive; + else + positionInfoState &= ~QGeoPositionInfoSourceMaemo::PowersaveActive; + + // If powersave has been active when new update interval has been set, + // ensure that timer is started. + if(updateTimerInterval) + startLocationDaemon(); + + // Ensure that new timer interval is taken into use immediately. + activateTimer(); } void QGeoPositionInfoSourceMaemo::setPreferredPositioningMethods(PositioningMethods sources) @@ -134,40 +131,31 @@ int QGeoPositionInfoSourceMaemo::minimumUpdateInterval() const // public slots: void QGeoPositionInfoSourceMaemo::startUpdates() { - if (!(positionInfoState & QGeoPositionInfoSourceMaemo::PowersaveActive)) { - startLocationDaemon(); - positionInfoState &= ~(QGeoPositionInfoSourceMaemo::RequestSingleShot | - QGeoPositionInfoSourceMaemo::GpsOn); - } else if ((positionInfoState & QGeoPositionInfoSourceMaemo::Stopped) && - (!(positionInfoState & QGeoPositionInfoSourceMaemo::GpsOn))) { - return; - } - + startLocationDaemon(); + + // Ensure that powersave is selected, if stopUpdates() has been called, + // but selected update interval is still greater than POWERSAVE_THRESHOLD. + if (timerInterval >= POWERSAVE_THRESHOLD) + positionInfoState |= QGeoPositionInfoSourceMaemo::PowersaveActive; + activateTimer(); } void QGeoPositionInfoSourceMaemo::stopUpdates() { - if ((!(positionInfoState & QGeoPositionInfoSourceMaemo::RequestActive)) || - positionInfoState & QGeoPositionInfoSourceMaemo::RequestAndStop) { + positionInfoState &= ~QGeoPositionInfoSourceMaemo::PowersaveActive; + + if (!(positionInfoState & QGeoPositionInfoSourceMaemo::RequestActive)) { updateTimer->stop(); - requestTimer->stop(); - - positionInfoState &= ~(QGeoPositionInfoSourceMaemo::RequestActive | - QGeoPositionInfoSourceMaemo::RequestAndStop); - - if (!(positionInfoState & QGeoPositionInfoSourceMaemo::Stopped)) + if (LiblocationWrapper::instance()->isActive()) LiblocationWrapper::instance()->stop(); - - errorOccurred = false; - errorSent = false; - - positionInfoState &= ~(QGeoPositionInfoSourceMaemo::Started | - QGeoPositionInfoSourceMaemo::PowersaveActive); - positionInfoState |= QGeoPositionInfoSourceMaemo::Stopped; - } else { - positionInfoState |= QGeoPositionInfoSourceMaemo::RequestAndStop; } + + errorOccurred = false; + errorSent = false; + + positionInfoState &= ~QGeoPositionInfoSourceMaemo::Started; + positionInfoState |= QGeoPositionInfoSourceMaemo::Stopped; } void QGeoPositionInfoSourceMaemo::requestUpdate(int timeout) @@ -176,64 +164,57 @@ void QGeoPositionInfoSourceMaemo::requestUpdate(int timeout) if (!timeout) { if (LiblocationWrapper::instance()->isActive()) + // If GPS is active, assume quick fix. timeoutForRequest = DEFAULT_UPDATE_INTERVAL; else + // Otherwise reserve longer time to get a fix. timeoutForRequest = POWERSAVE_POWERON_PERIOD; } else if (timeout < MINIMUM_UPDATE_INTERVAL) { - if (positionInfoState & (QGeoPositionInfoSourceMaemo::RequestActive | - QGeoPositionInfoSourceMaemo::RequestSingleShot)) + if (positionInfoState & QGeoPositionInfoSourceMaemo::RequestActive) return; - else - positionInfoState &= ~(QGeoPositionInfoSourceMaemo::RequestActive | - QGeoPositionInfoSourceMaemo::RequestSingleShot); + emit updateTimeout(); return; } else { timeoutForRequest = timeout; } - updateTimer->stop(); - requestTimer->stop(); - positionInfoState |= QGeoPositionInfoSourceMaemo::RequestActive; - if (positionInfoState & QGeoPositionInfoSourceMaemo::Stopped) - positionInfoState |= QGeoPositionInfoSourceMaemo::RequestSingleShot; - startLocationDaemon(); - + if (!(LiblocationWrapper::instance()->isActive())) + LiblocationWrapper::instance()->start(); + activateTimer(); requestTimer->start(timeoutForRequest); } void QGeoPositionInfoSourceMaemo::newPositionUpdate() { - if (LiblocationWrapper::instance()->fixIsValid()) { + if (LiblocationWrapper::instance()->fixIsValid()) { errorOccurred = false; errorSent = false; - + if (positionInfoState & QGeoPositionInfoSourceMaemo::RequestActive) { positionInfoState &= ~QGeoPositionInfoSourceMaemo::RequestActive; requestTimer->stop(); - if (positionInfoState & QGeoPositionInfoSourceMaemo::RequestSingleShot) { - positionInfoState &= ~QGeoPositionInfoSourceMaemo::RequestSingleShot; - if (!(positionInfoState & QGeoPositionInfoSourceMaemo::PowersaveActive)) { - stopUpdates(); - emit positionUpdated(LiblocationWrapper::instance()->position()); - return; - } - } - - if (positionInfoState & QGeoPositionInfoSourceMaemo::RequestAndStop) { - stopUpdates(); + if (positionInfoState & QGeoPositionInfoSourceMaemo::Stopped) + if (LiblocationWrapper::instance()->isActive()) + LiblocationWrapper::instance()->stop(); + + // Ensure that requested position fix is emitted even though + // powersave is active and GPS would normally be off. + if ((positionInfoState & QGeoPositionInfoSourceMaemo::PowersaveActive) && + (positionInfoState & QGeoPositionInfoSourceMaemo::Stopped)) { + emit positionUpdated(LiblocationWrapper::instance()->position()); } } - - if ((positionInfoState & QGeoPositionInfoSourceMaemo::PowersaveActive) && - (!(positionInfoState & QGeoPositionInfoSourceMaemo::GpsOn))) { - return; - } - emit positionUpdated(LiblocationWrapper::instance()->position()); + + // Make sure that if update is triggered when waking up, there + // is no false position update. + if (!((positionInfoState & QGeoPositionInfoSourceMaemo::PowersaveActive) && + (positionInfoState & QGeoPositionInfoSourceMaemo::Stopped))) + emit positionUpdated(LiblocationWrapper::instance()->position()); } else { // if an error occurs when we are updating periodically and we haven't // sent an error since the last fix... @@ -254,17 +235,10 @@ void QGeoPositionInfoSourceMaemo::requestTimeoutElapsed() positionInfoState &= ~QGeoPositionInfoSourceMaemo::RequestActive; - if (positionInfoState & QGeoPositionInfoSourceMaemo::RequestSingleShot) { - positionInfoState &= ~QGeoPositionInfoSourceMaemo::RequestSingleShot; - stopUpdates(); - if (!(positionInfoState & QGeoPositionInfoSourceMaemo::PowersaveActive)) - return; - } - - // Do not trigger timer, if stop has been called after request. - if(positionInfoState & QGeoPositionInfoSourceMaemo::RequestAndStop) - stopUpdates(); - + if (positionInfoState & QGeoPositionInfoSourceMaemo::Stopped) + if (LiblocationWrapper::instance()->isActive()) + LiblocationWrapper::instance()->stop(); + activateTimer(); } @@ -273,37 +247,37 @@ void QGeoPositionInfoSourceMaemo::error() errorOccurred = true; } -void QGeoPositionInfoSourceMaemo::activateTimer() { - if ((positionInfoState & QGeoPositionInfoSourceMaemo::Stopped) && - (!(positionInfoState & QGeoPositionInfoSourceMaemo::PowersaveActive))) - return; - - // If powersave is active, ensure that correct state is restored in - // possible start->stop->start sequence. - if(timerInterval > POWERSAVE_THRESHOLD) - positionInfoState &= QGeoPositionInfoSourceMaemo::PowersaveActive; - +void QGeoPositionInfoSourceMaemo::activateTimer() { if (positionInfoState & QGeoPositionInfoSourceMaemo::RequestActive) { updateTimer->start(MINIMUM_UPDATE_INTERVAL); - } else { - if (positionInfoState & QGeoPositionInfoSourceMaemo::PowersaveActive) { - if (!(positionInfoState & QGeoPositionInfoSourceMaemo::GpsOn)) { - startLocationDaemon(); - positionInfoState |= QGeoPositionInfoSourceMaemo::GpsOn; - updateTimer->start(POWERSAVE_POWERON_PERIOD); - } else if (positionInfoState & QGeoPositionInfoSourceMaemo::GpsOn) { - stopUpdates(); - positionInfoState &= ~QGeoPositionInfoSourceMaemo::GpsOn; - updateTimer->start(timerInterval - POWERSAVE_POWERON_PERIOD); - } - } else { - updateTimer->start(timerInterval); + return; + } + + if (positionInfoState & QGeoPositionInfoSourceMaemo::PowersaveActive) { + if (positionInfoState & QGeoPositionInfoSourceMaemo::Started) { + // Cannot call stopUpdates() here since we want to keep powersave + // active. + if (LiblocationWrapper::instance()->isActive()) + LiblocationWrapper::instance()->stop(); + updateTimer->start(timerInterval - POWERSAVE_POWERON_PERIOD); + errorOccurred = false; + errorSent = false; + + positionInfoState &= ~QGeoPositionInfoSourceMaemo::Started; + positionInfoState |= QGeoPositionInfoSourceMaemo::Stopped; + } else if (positionInfoState & QGeoPositionInfoSourceMaemo::Stopped) { + startLocationDaemon(); + updateTimer->start(POWERSAVE_POWERON_PERIOD); } + return; } + + if (positionInfoState & QGeoPositionInfoSourceMaemo::Started) + updateTimer->start(timerInterval); } void QGeoPositionInfoSourceMaemo::startLocationDaemon() { - if (!(positionInfoState & QGeoPositionInfoSourceMaemo::Started)) + if (!(LiblocationWrapper::instance()->isActive())) LiblocationWrapper::instance()->start(); positionInfoState |= QGeoPositionInfoSourceMaemo::Started; positionInfoState &= ~QGeoPositionInfoSourceMaemo::Stopped; diff --git a/src/location/qgeopositioninfosource_maemo5_p.h b/src/location/qgeopositioninfosource_maemo5_p.h index 81a7478c92..6ac6584072 100644 --- a/src/location/qgeopositioninfosource_maemo5_p.h +++ b/src/location/qgeopositioninfosource_maemo5_p.h @@ -89,10 +89,7 @@ private: Started = 1, Stopped = 2, RequestActive = 4, - RequestSingleShot = 8, - PowersaveActive = 16, - GpsOn = 32, - RequestAndStop = 64 + PowersaveActive = 8 }; int positionInfoState; diff --git a/src/location/qgeosatelliteinfosource_maemo5.cpp b/src/location/qgeosatelliteinfosource_maemo5.cpp index ee2e11b383..7860e9f0b1 100644 --- a/src/location/qgeosatelliteinfosource_maemo5.cpp +++ b/src/location/qgeosatelliteinfosource_maemo5.cpp @@ -62,104 +62,87 @@ QGeoSatelliteInfoSourceMaemo::QGeoSatelliteInfoSourceMaemo(QObject *parent) int QGeoSatelliteInfoSourceMaemo::init() { - if (LiblocationWrapper::instance()->inited()) { - satelliteInfoState |= QGeoSatelliteInfoSourceMaemo::Stopped; + if (LiblocationWrapper::instance()->inited()) return INIT_OK; - } else { + else return INIT_FAILED; - } } void QGeoSatelliteInfoSourceMaemo::setUpdateInterval(int msec) { bool updateTimerInterval = false; - + if (satelliteInfoState & QGeoSatelliteInfoSourceMaemo::PowersaveActive) if (satelliteInfoState & QGeoSatelliteInfoSourceMaemo::Stopped) updateTimerInterval = true; - - satelliteInfoState &= ~(QGeoSatelliteInfoSourceMaemo::GpsOn | - QGeoSatelliteInfoSourceMaemo::PowersaveActive); - + timerInterval = (msec < MINIMUM_UPDATE_INTERVAL) ? MINIMUM_UPDATE_INTERVAL : msec; - if (timerInterval >= POWERSAVE_THRESHOLD) { - satelliteInfoState |= (QGeoSatelliteInfoSourceMaemo::PowersaveActive | - QGeoSatelliteInfoSourceMaemo::GpsOn); - } else { - satelliteInfoState &= ~(QGeoSatelliteInfoSourceMaemo::GpsOn | - QGeoSatelliteInfoSourceMaemo::PowersaveActive); - } + if (timerInterval >= POWERSAVE_THRESHOLD) + satelliteInfoState |= QGeoSatelliteInfoSourceMaemo::PowersaveActive; + else + satelliteInfoState &= ~QGeoSatelliteInfoSourceMaemo::PowersaveActive; - if (updateTimerInterval || (satelliteInfoState & - QGeoSatelliteInfoSourceMaemo::Started)) - activateTimer(); + // If powersave has been active when new update interval has been set, + // ensure that timer is started. + if(updateTimerInterval) + startLocationDaemon(); + + // Ensure that new timer interval is taken into use immediately. + activateTimer(); } void QGeoSatelliteInfoSourceMaemo::startUpdates() { - if (!(satelliteInfoState & QGeoSatelliteInfoSourceMaemo::PowersaveActive)) { - startLocationDaemon(); - satelliteInfoState &= ~(QGeoSatelliteInfoSourceMaemo::RequestSingleShot | - QGeoSatelliteInfoSourceMaemo::GpsOn); - } else if ((satelliteInfoState & QGeoSatelliteInfoSourceMaemo::Stopped) && - (!(satelliteInfoState & QGeoSatelliteInfoSourceMaemo::GpsOn))) { - // Do not restart if we are in powersave mode and GPS is off. - return; - } + startLocationDaemon(); + + // Ensure that powersave is selected, if stopUpdates() has been called, + // but selected update interval is still greater than POWERSAVE_THRESHOLD. + if (timerInterval >= POWERSAVE_THRESHOLD) + satelliteInfoState |= QGeoSatelliteInfoSourceMaemo::PowersaveActive; + activateTimer(); } void QGeoSatelliteInfoSourceMaemo::stopUpdates() { - if ((!(satelliteInfoState & QGeoSatelliteInfoSourceMaemo::RequestActive)) || - satelliteInfoState & QGeoSatelliteInfoSourceMaemo::RequestAndStop) { - updateTimer->stop(); - requestTimer->stop(); - satelliteInfoState &= ~(QGeoSatelliteInfoSourceMaemo::RequestActive | - QGeoSatelliteInfoSourceMaemo::RequestAndStop); + satelliteInfoState &= ~QGeoSatelliteInfoSourceMaemo::PowersaveActive; - if (!(satelliteInfoState & QGeoSatelliteInfoSourceMaemo::Stopped)) + if (!(satelliteInfoState & QGeoSatelliteInfoSourceMaemo::RequestActive)) { + updateTimer->stop(); + if (LiblocationWrapper::instance()->isActive()) LiblocationWrapper::instance()->stop(); - - satelliteInfoState &= ~QGeoSatelliteInfoSourceMaemo::Started; - satelliteInfoState |= QGeoSatelliteInfoSourceMaemo::Stopped; - } else { - // Stop sent while request is active. - satelliteInfoState |= QGeoSatelliteInfoSourceMaemo::RequestAndStop; } + + satelliteInfoState &= ~QGeoSatelliteInfoSourceMaemo::Started; + satelliteInfoState |= QGeoSatelliteInfoSourceMaemo::Stopped; } void QGeoSatelliteInfoSourceMaemo::requestUpdate(int timeout) { int timeoutForRequest = 0; - + if (!timeout) { if (LiblocationWrapper::instance()->isActive()) + // If GPS is active, assume quick fix. timeoutForRequest = DEFAULT_UPDATE_INTERVAL; else + // Otherwise reserve longer time to get a fix. timeoutForRequest = POWERSAVE_POWERON_PERIOD; } else if (timeout < MINIMUM_UPDATE_INTERVAL) { - if (satelliteInfoState & (QGeoSatelliteInfoSourceMaemo::RequestActive | - QGeoSatelliteInfoSourceMaemo::RequestSingleShot)) + if (satelliteInfoState & QGeoSatelliteInfoSourceMaemo::RequestActive) return; - else - satelliteInfoState &= ~(QGeoSatelliteInfoSourceMaemo::RequestActive | - QGeoSatelliteInfoSourceMaemo::RequestSingleShot); + emit requestTimeout(); return; } else { timeoutForRequest = timeout; } - updateTimer->stop(); - requestTimer->stop(); - satelliteInfoState |= QGeoSatelliteInfoSourceMaemo::RequestActive; - if (satelliteInfoState & QGeoSatelliteInfoSourceMaemo::Stopped) - satelliteInfoState |= QGeoSatelliteInfoSourceMaemo::RequestSingleShot; - startLocationDaemon(); + if (!(LiblocationWrapper::instance()->isActive())) + LiblocationWrapper::instance()->start(); activateTimer(); requestTimer->start(timeoutForRequest); @@ -174,37 +157,36 @@ void QGeoSatelliteInfoSourceMaemo::satelliteStatus() if (satelliteInfoState & QGeoSatelliteInfoSourceMaemo::RequestActive) { satelliteInfoState &= ~QGeoSatelliteInfoSourceMaemo::RequestActive; - + requestTimer->stop(); - - if (satelliteInfoState & QGeoSatelliteInfoSourceMaemo::RequestSingleShot) { - satelliteInfoState &= ~QGeoSatelliteInfoSourceMaemo::RequestSingleShot; - - if (!(satelliteInfoState & QGeoSatelliteInfoSourceMaemo::PowersaveActive)) { - stopUpdates(); - if (satellitesInView.length()) { - // If there are satellites in view, also in use can be emitted. - emit satellitesInViewUpdated(satellitesInView); - emit satellitesInUseUpdated(satellitesInUse); - } - return; + + if (satelliteInfoState & QGeoSatelliteInfoSourceMaemo::Stopped) { + if (LiblocationWrapper::instance()->isActive()) { + LiblocationWrapper::instance()->stop(); } } - if (satelliteInfoState & QGeoSatelliteInfoSourceMaemo::RequestAndStop) - stopUpdates(); + // Ensure that requested satellite info is emitted even though + // powersave is active and GPS would normally be off. + if ((satelliteInfoState & QGeoSatelliteInfoSourceMaemo::PowersaveActive) && + (satelliteInfoState & QGeoSatelliteInfoSourceMaemo::Stopped)) { + if (satellitesInView.length()) { + emit satellitesInViewUpdated(satellitesInView); + emit satellitesInUseUpdated(satellitesInUse); + } + } } - // Ensure that no fix is emitted in transition from power off to power on. - if((satelliteInfoState & QGeoSatelliteInfoSourceMaemo::PowersaveActive) && - (!(satelliteInfoState & QGeoSatelliteInfoSourceMaemo::GpsOn))) - return; - - if (satellitesInView.length()) { - emit satellitesInViewUpdated(satellitesInView); - emit satellitesInUseUpdated(satellitesInUse); + // Make sure that if update is triggered when waking up, there + // is no false position update. + if (!((satelliteInfoState & QGeoSatelliteInfoSourceMaemo::PowersaveActive) && + (satelliteInfoState & QGeoSatelliteInfoSourceMaemo::Stopped))) { + if (satellitesInView.length()) { + emit satellitesInViewUpdated(satellitesInView); + emit satellitesInUseUpdated(satellitesInUse); + } } - + activateTimer(); } @@ -215,41 +197,42 @@ void QGeoSatelliteInfoSourceMaemo::requestTimeoutElapsed() satelliteInfoState &= ~QGeoSatelliteInfoSourceMaemo::RequestActive; - if (satelliteInfoState & QGeoSatelliteInfoSourceMaemo::RequestSingleShot) { - satelliteInfoState &= ~QGeoSatelliteInfoSourceMaemo::RequestSingleShot; - stopUpdates(); - if (!(satelliteInfoState & QGeoSatelliteInfoSourceMaemo::PowersaveActive)) - return; - } + if (satelliteInfoState & QGeoSatelliteInfoSourceMaemo::Stopped) + if (LiblocationWrapper::instance()->isActive()) + LiblocationWrapper::instance()->stop(); + activateTimer(); } void QGeoSatelliteInfoSourceMaemo::activateTimer() { - if ((satelliteInfoState & QGeoSatelliteInfoSourceMaemo::Stopped) && - (!(satelliteInfoState & QGeoSatelliteInfoSourceMaemo::PowersaveActive))) - return; - if (satelliteInfoState & QGeoSatelliteInfoSourceMaemo::RequestActive) { updateTimer->start(MINIMUM_UPDATE_INTERVAL); - } else { - if (satelliteInfoState & QGeoSatelliteInfoSourceMaemo::PowersaveActive) { - if (!(satelliteInfoState & QGeoSatelliteInfoSourceMaemo::GpsOn)) { - startLocationDaemon(); - satelliteInfoState |= QGeoSatelliteInfoSourceMaemo::GpsOn; - updateTimer->start(POWERSAVE_POWERON_PERIOD); - } else if (satelliteInfoState & QGeoSatelliteInfoSourceMaemo::GpsOn) { - stopUpdates(); - satelliteInfoState &= ~QGeoSatelliteInfoSourceMaemo::GpsOn; - updateTimer->start(timerInterval - POWERSAVE_POWERON_PERIOD); - } - } else { - updateTimer->start(timerInterval); + return; + } + + if (satelliteInfoState & QGeoSatelliteInfoSourceMaemo::PowersaveActive) { + if (satelliteInfoState & QGeoSatelliteInfoSourceMaemo::Started) { + // Cannot call stopUpdates() here since we want to keep powersave + // active. + if (LiblocationWrapper::instance()->isActive()) + LiblocationWrapper::instance()->stop(); + updateTimer->start(timerInterval - POWERSAVE_POWERON_PERIOD); + + satelliteInfoState &= ~QGeoSatelliteInfoSourceMaemo::Started; + satelliteInfoState |= QGeoSatelliteInfoSourceMaemo::Stopped; + } else if (satelliteInfoState & QGeoSatelliteInfoSourceMaemo::Stopped) { + startLocationDaemon(); + updateTimer->start(POWERSAVE_POWERON_PERIOD); } + return; } + + if (satelliteInfoState & QGeoSatelliteInfoSourceMaemo::Started) + updateTimer->start(timerInterval); } void QGeoSatelliteInfoSourceMaemo::startLocationDaemon() { - if (!(satelliteInfoState & QGeoSatelliteInfoSourceMaemo::Started)) + if (!(LiblocationWrapper::instance()->isActive())) LiblocationWrapper::instance()->start(); satelliteInfoState |= QGeoSatelliteInfoSourceMaemo::Started; satelliteInfoState &= ~QGeoSatelliteInfoSourceMaemo::Stopped; diff --git a/src/location/qgeosatelliteinfosource_maemo5_p.h b/src/location/qgeosatelliteinfosource_maemo5_p.h index e3babec08a..18b2889ef0 100644 --- a/src/location/qgeosatelliteinfosource_maemo5_p.h +++ b/src/location/qgeosatelliteinfosource_maemo5_p.h @@ -80,10 +80,7 @@ private: Started = 1, Stopped = 2, RequestActive = 4, - RequestSingleShot = 8, - PowersaveActive = 16, - GpsOn = 32, - RequestAndStop = 64 + PowersaveActive = 8 }; int satelliteInfoState; |