@@ -61,6 +61,15 @@
const double KnotsToMps = 0.514444;
const QString LocationSettingsFile = QStringLiteral("/etc/location/location.conf");
+const QString LocationSettingsEnabledKey = QStringLiteral("location/enabled");
+const QString LocationSettingsGpsEnabledKey = QStringLiteral("location/gps/enabled");
+const QString LocationSettingsAgpsEnabledKey = QStringLiteral("location/%1/enabled");
+const QString LocationSettingsAgpsOnlineEnabledKey = QStringLiteral("location/%1/online_enabled");
+const QString LocationSettingsAgpsAgreementAcceptedKey = QStringLiteral("location/%1/agreement_accepted");
+const QString LocationSettingsAgpsProvidersKey = QStringLiteral("location/agps_providers");
+// deprecated keys
+const QString LocationSettingsOldAgpsEnabledKey = QStringLiteral("location/agreement_accepted");
+const QString LocationSettingsOldAgpsAgreementAcceptedKey = QStringLiteral("location/here_agreement_accepted");
void locationCallback(GpsLocation *location)
{
@@ -424,7 +433,7 @@
m_networkManager(new NetworkManager(this)), m_cellularTechnology(0),
m_ofonoExtModemManager(new QOfonoExtModemManager(this)),
m_connectionManager(new QOfonoConnectionManager(this)), m_connectionContext(0), m_ntpSocket(0),
- m_agpsEnabled(false)
+ m_agpsEnabled(false), m_agpsOnlineEnabled(false)
{
if (staticProvider)
qFatal("Only a single instance of HybrisProvider is supported.");
@@ -475,7 +484,9 @@
m_connectionSelector = new ComJollaLipstickConnectionSelectorIfInterface(
QStringLiteral("com.jolla.lipstick.ConnectionSelector"), QStringLiteral("/"), connection);
- m_idleTimer.start(QuitIdleTime, this);
+ if (m_watchedServices.isEmpty()) {
+ m_idleTimer.start(QuitIdleTime, this);
+ }
const hw_module_t *hwModule;
@@ -571,9 +582,14 @@
if (!calledFromDBus())
qFatal("AddReference must only be called from DBus");
+ bool wasInactive = m_watchedServices.isEmpty();
const QString service = message().service();
m_watcher->addWatchedService(service);
m_watchedServices[service].referenceCount += 1;
+ if (wasInactive) {
+ qCDebug(lcGeoclueHybris) << "new watched service, stopping idle timer.";
+ m_idleTimer.stop();
+ }
startPositioningIfNeeded();
}
@@ -593,8 +609,10 @@
m_watchedServices.remove(service);
}
- if (m_watchedServices.isEmpty())
+ if (m_watchedServices.isEmpty()) {
+ qCDebug(lcGeoclueHybris) << "no watched services, starting idle timer.";
m_idleTimer.start(QuitIdleTime, this);
+ }
stopPositioningIfNeeded();
}
@@ -701,6 +719,7 @@
{
if (event->timerId() == m_idleTimer.timerId()) {
m_idleTimer.stop();
+ qCDebug(lcGeoclueHybris) << "have been idle for too long, quitting";
qApp->quit();
} else if (event->timerId() == m_fixLostTimer.timerId()) {
m_fixLostTimer.stop();
@@ -753,8 +772,10 @@
m_watchedServices.remove(service);
m_watcher->removeWatchedService(service);
- if (m_watchedServices.isEmpty())
+ if (m_watchedServices.isEmpty()) {
+ qCDebug(lcGeoclueHybris) << "no watched services, starting idle timer.";
m_idleTimer.start(QuitIdleTime, this);
+ }
stopPositioningIfNeeded();
}
@@ -922,6 +943,9 @@
void HybrisProvider::xtraDownloadRequest()
{
+ if (!m_agpsOnlineEnabled)
+ return;
+
if (m_xtraDownloadReply)
return;
@@ -1040,6 +1064,10 @@
void HybrisProvider::dataServiceConnected()
{
qCDebug(lcGeoclueHybris);
+
+ if (!m_agpsOnlineEnabled)
+ return;
+
foreach (NetworkService *service, m_networkManager->getServices(QStringLiteral("cellular"))) {
if (!service->connected())
continue;
@@ -1154,7 +1182,7 @@
{
qCDebug(lcGeoclueHybris);
- if (!m_agpsInterface.isEmpty())
+ if (m_agpsOnlineEnabled && !m_agpsInterface.isEmpty())
processConnectionContexts();
}
@@ -1162,6 +1190,9 @@
{
qCDebug(lcGeoclueHybris);
+ if (!m_agpsOnlineEnabled)
+ return;
+
if (m_connectionContext->isValid() &&
m_connectionContext->settings().value(QStringLiteral("Interface")) == m_agpsInterface) {
const QByteArray apn = m_connectionContext->accessPointName().toLocal8Bit();
@@ -1331,23 +1362,31 @@
bool HybrisProvider::positioningEnabled()
{
QSettings settings(LocationSettingsFile, QSettings::IniFormat);
- settings.beginGroup(QStringLiteral("location"));
-
- bool enabled = settings.value(QStringLiteral("enabled"), false).toBool();
-
- // Setting names are a bit confusing, agreement_accepted is what the WLAN/CellId positioning
- // daemons check and is used to toggle use of those services. here_agreement_accepted is the
- // actual acceptance state of the agreement from the user's perspective. Both need to be true
- // for AGPS (SUPL assistance) to be used.
- bool agpsEnabled = settings.value(QStringLiteral("agreement_accepted"), false).toBool();
- bool agpsAgreementAccepted = agpsEnabled;
- if (settings.contains(QStringLiteral("here_agreement_accepted")))
- agpsAgreementAccepted = settings.value(QStringLiteral("here_agreement_accepted"), false).toBool();
- m_agpsEnabled = agpsAgreementAccepted && agpsEnabled;
+ // check the keys related to agps enablement. We can have multiple agps providers.
+ bool agpsAgreementAccepted = false;
+ bool agpsEnabled = false;
+ bool agpsOnlineEnabled = false;
+ QString agpsProviders = settings.value(LocationSettingsAgpsProvidersKey, QStringLiteral("here")).toString();
+ Q_FOREACH (const QString &agpsProvider, agpsProviders.split(',', QString::SkipEmptyParts)) {
+ agpsAgreementAccepted = settings.value(LocationSettingsAgpsAgreementAcceptedKey.arg(agpsProvider), false).toBool();
+ agpsEnabled = settings.value(LocationSettingsAgpsEnabledKey.arg(agpsProvider), false).toBool();
+ agpsOnlineEnabled = settings.value(LocationSettingsAgpsOnlineEnabledKey.arg(agpsProvider), false).toBool();
+ if (agpsAgreementAccepted && agpsEnabled && agpsOnlineEnabled) {
+ break;
+ }
+ }
+ // check the deprecated keys, also:
+ bool oldAgpsAgreementAccepted = settings.value(LocationSettingsOldAgpsAgreementAcceptedKey, false).toBool();
+ bool oldAgpsEnabled = settings.value(LocationSettingsOldAgpsEnabledKey, false).toBool();
+ m_agpsEnabled = (agpsAgreementAccepted || oldAgpsAgreementAccepted) && (agpsEnabled || oldAgpsEnabled);
+ m_agpsOnlineEnabled = agpsOnlineEnabled || (oldAgpsAgreementAccepted && oldAgpsEnabled);
+
+ // check the keys related to the location and gps enablement, plus gps power state
+ bool locationEnabled = settings.value(LocationSettingsEnabledKey, false).toBool();
+ bool gpsEnabled = settings.value(LocationSettingsGpsEnabledKey, true).toBool(); // defaults to true if no key exists but location is enabled.
bool powered = m_deviceControl->powered();
-
- return enabled && powered;
+ return locationEnabled && gpsEnabled && powered;
}
quint32 HybrisProvider::minimumRequestedUpdateInterval() const
@@ -1378,6 +1417,16 @@
{
qCDebug(lcGeoclueHybris);
+ if (!m_agpsOnlineEnabled) {
+ qCDebug(lcGeoclueHybris) << "Online aGPS not enabled, not starting data connection.";
+#if GEOCLUE_ANDROID_GPS_INTERFACE == 2 || GEOCLUE_ANDROID_GPS_INTERFACE == 1
+ m_agps->data_conn_failed();
+#else
+ m_agps->data_conn_failed(AGPS_TYPE_SUPL);
+#endif
+ return;
+ }
+
// Check if existing cellular network service is connected
NetworkTechnology *technology = m_networkManager->getTechnology(QStringLiteral("cellular"));
if (technology && technology->connected()) {
@@ -1423,8 +1472,15 @@
{
qCDebug(lcGeoclueHybris) << m_ntpServers;
- if (m_ntpServers.isEmpty())
+ if (!m_agpsOnlineEnabled) {
+ qCDebug(lcGeoclueHybris) << "Online aGPS not enabled, not sending NTP request.";
+ return;
+ }
+
+ if (m_ntpServers.isEmpty()) {
+ qCDebug(lcGeoclueHybris) << "No NTP servers known, not sending NTP request.";
return;
|