[-]
[+]
|
Changed |
_service:tar_git:geoclue-provider-hybris.changes
|
|
[-]
[+]
|
Changed |
_service:tar_git:geoclue-providers-hybris.spec
^
|
|
[-]
[+]
|
Changed |
_service
^
|
@@ -1,10 +1,10 @@
<services>
<service name="tar_git">
- <param name="url">https://github.com/mer-hybris/geoclue-providers-hybris.git</param>
- <param name="branch">master</param>
- <param name="revision">7a0f7c93dfcc74fca5ce68f0b260e3e7c41d6f4b</param>
- <param name="token"/>
- <param name="debian">N</param>
- <param name="dumb">N</param>
+ <param name="url">https://github.com/mer-hybris/geoclue-providers-hybris.git</param>
+ <param name="branch">master</param>
+ <param name="revision">29ec9933d09beefcc7ef24b83ef046f0150ec31e</param>
+ <param name="token"/>
+ <param name="debian">N</param>
+ <param name="dumb">N</param>
</service>
</services>
\ No newline at end of file
|
[-]
[+]
|
Added |
_service:tar_git:geoclue-provider-hybris-0.2.11.tar.gz/com.jollamobile.gps.Device.xml
^
|
@@ -0,0 +1,10 @@
+<!DOCTYPE node PUBLIC "-//freedesktop//DTD D-BUS Object Introspection 1.0//EN" "http://www.freedesktop.org/standards/dbus/1.0/introspect.dtd">
+<node>
+ <interface name="com.jollamobile.gps.Device">
+ <property name="Powered" type="b" access="readwrite"/>
+ <signal name="PropertyChanged">
+ <arg name="name" type="s" direction="out"/>
+ <arg name="value" type="v" direction="out"/>
+ </signal>
+ </interface>
+</node>
|
[-]
[+]
|
Added |
_service:tar_git:geoclue-provider-hybris-0.2.11.tar.gz/devicecontrol.cpp
^
|
@@ -0,0 +1,38 @@
+/*
+ Copyright (C) 2015 Jolla Ltd.
+ Contact: Aaron McCarthy <aaron.mccarthy@jollamobile.com>
+
+ This file is part of geoclue-hybris.
+
+ Geoclue-hybris is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License.
+*/
+
+#include "devicecontrol.h"
+
+#include "device_adaptor.h"
+
+#include <QtDBus/QDBusVariant>
+
+DeviceControl::DeviceControl(QObject *parent)
+: QObject(parent), m_powered(false)
+{
+ new DeviceAdaptor(this);
+}
+
+bool DeviceControl::powered() const
+{
+ return m_powered;
+}
+
+void DeviceControl::setPowered(bool powered)
+{
+ if (m_powered == powered)
+ return;
+
+ m_powered = powered;
+ emit poweredChanged();
+ emit PropertyChanged(QStringLiteral("Powered"), QDBusVariant(powered));
+}
|
[-]
[+]
|
Added |
_service:tar_git:geoclue-provider-hybris-0.2.11.tar.gz/devicecontrol.h
^
|
@@ -0,0 +1,40 @@
+/*
+ Copyright (C) 2015 Jolla Ltd.
+ Contact: Aaron McCarthy <aaron.mccarthy@jollamobile.com>
+
+ This file is part of geoclue-hybris.
+
+ Geoclue-hybris is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License.
+*/
+
+#ifndef DEVICECONTROL_H
+#define DEVICECONTROL_H
+
+#include <QtCore/QObject>
+
+QT_FORWARD_DECLARE_CLASS(QDBusVariant)
+
+class DeviceControl : public QObject
+{
+ Q_OBJECT
+
+ Q_PROPERTY(bool Powered READ powered WRITE setPowered NOTIFY poweredChanged)
+
+public:
+ explicit DeviceControl(QObject *parent = 0);
+
+ bool powered() const;
+ void setPowered(bool powered);
+
+signals:
+ void PropertyChanged(const QString &name, const QDBusVariant &value);
+ void poweredChanged();
+
+private:
+ bool m_powered;
+};
+
+#endif // DEVICECONTROL_H
|
[-]
[+]
|
Changed |
_service:tar_git:geoclue-provider-hybris-0.2.11.tar.gz/geoclue-providers-hybris.pro
^
|
@@ -8,10 +8,14 @@
QT = core dbus network
CONFIG += link_pkgconfig
-PKGCONFIG += libhardware android-headers connman-qt5 qofono-qt5 qofonoext systemsettings
+PKGCONFIG += libhardware android-headers connman-qt5 qofono-qt5 qofonoext
LIBS += -lrt
+dbus_power_control.files = com.jollamobile.gps.Device.xml
+dbus_power_control.header_flags = "-l DeviceControl -i devicecontrol.h"
+dbus_power_control.source_flags = "-l DeviceControl"
+
dbus_geoclue.files = \
org.freedesktop.Geoclue.xml \
org.freedesktop.Geoclue.Position.xml \
@@ -21,6 +25,7 @@
dbus_geoclue.source_flags = "-l HybrisProvider"
DBUS_ADAPTORS = \
+ dbus_power_control \
dbus_geoclue
DBUS_INTERFACES = \
@@ -38,11 +43,13 @@
HEADERS += \
hybrisprovider.h \
- locationtypes.h
+ locationtypes.h \
+ devicecontrol.h
SOURCES += \
main.cpp \
- hybrisprovider.cpp
+ hybrisprovider.cpp \
+ devicecontrol.cpp
OTHER_FILES = \
$${session_dbus_service.files} \
|
[-]
[+]
|
Changed |
_service:tar_git:geoclue-provider-hybris-0.2.11.tar.gz/hybrisprovider.cpp
^
|
@@ -11,6 +11,7 @@
*/
#include "hybrisprovider.h"
+#include "devicecontrol.h"
#include "geoclue_adaptor.h"
#include "position_adaptor.h"
@@ -429,7 +430,7 @@
HybrisProvider::HybrisProvider(QObject *parent)
: QObject(parent), m_gps(0), m_agps(0), m_agpsril(0), m_gpsni(0), m_xtra(0),
m_status(StatusUnavailable), m_positionInjectionConnected(false), m_xtraDownloadReply(0),
- m_requestedConnect(false), m_gpsStarted(false), m_locationSettings(0),
+ m_requestedConnect(false), m_gpsStarted(false), m_deviceControl(0),
m_networkManager(new NetworkManager(this)), m_cellularTechnology(0),
m_ofonoExtModemManager(new QOfonoExtModemManager(this)),
m_connectionManager(new QOfonoConnectionManager(this)), m_connectionContext(0), m_ntpSocket(0),
@@ -446,6 +447,14 @@
staticProvider = this;
+ m_locationSettings = new QFileSystemWatcher(this);
+ connect(m_locationSettings, SIGNAL(fileChanged(QString)),
+ this, SLOT(locationEnabledChanged()));
+ connect(m_locationSettings, SIGNAL(directoryChanged(QString)),
+ this, SLOT(locationEnabledChanged()));
+ m_locationSettings->addPath(LocationSettingsDir);
+ m_locationSettings->addPath(LocationSettingsFile);
+
new GeoclueAdaptor(this);
new PositionAdaptor(this);
new VelocityAdaptor(this);
@@ -556,23 +565,20 @@
staticProvider = 0;
}
-void HybrisProvider::setLocationSettings(LocationSettings *settings)
+void HybrisProvider::setDeviceController(DeviceControl *control)
{
- if (!m_locationSettings) {
- m_locationSettings = settings;
- connect(m_locationSettings, &LocationSettings::locationEnabledChanged,
- this, &HybrisProvider::locationEnabledChanged);
- connect(m_locationSettings, &LocationSettings::gpsEnabledChanged,
- this, &HybrisProvider::locationEnabledChanged);
- connect(m_locationSettings, &LocationSettings::gpsFlightModeChanged,
- this, &HybrisProvider::locationEnabledChanged);
- connect(m_locationSettings, &LocationSettings::hereStateChanged,
- this, &HybrisProvider::locationEnabledChanged);
- connect(m_locationSettings, &LocationSettings::mlsEnabledChanged,
- this, &HybrisProvider::locationEnabledChanged);
- connect(m_locationSettings, &LocationSettings::mlsOnlineStateChanged,
- this, &HybrisProvider::locationEnabledChanged);
+ if (m_deviceControl == control)
+ return;
+
+ if (m_deviceControl) {
+ disconnect(m_deviceControl, SIGNAL(poweredChanged()),
+ this, SLOT(locationEnabledChanged()));
}
+
+ m_deviceControl = control;
+
+ if (m_deviceControl)
+ connect(m_deviceControl, SIGNAL(poweredChanged()), this, SLOT(locationEnabledChanged()));
}
void HybrisProvider::AddReference()
@@ -1355,20 +1361,37 @@
/*
Returns true if positioning is enabled, otherwise returns false.
+
+ Currently checks the state of the Location enabled setting and flight mode.
*/
bool HybrisProvider::positioningEnabled()
{
- // update our AGPS enablement states, used for position injection and mode capability.
- m_agpsEnabled = (m_locationSettings->hereAvailable() && m_locationSettings->hereState() == LocationSettings::OnlineAGpsEnabled)
- || (m_locationSettings->mlsAvailable() && m_locationSettings->mlsEnabled());
- m_agpsOnlineEnabled = (m_locationSettings->hereAvailable() && m_locationSettings->hereState() == LocationSettings::OnlineAGpsEnabled)
- || (m_locationSettings->mlsAvailable() && m_locationSettings->mlsOnlineState() == LocationSettings::OnlineAGpsEnabled);
-
- // enable GPS positioning if location and the GPS are enabled, and the GPS is not in flight mode.
- return m_locationSettings->locationEnabled()
- && m_locationSettings->gpsAvailable()
- && m_locationSettings->gpsEnabled()
- && !m_locationSettings->gpsFlightMode();
+ QSettings settings(LocationSettingsFile, QSettings::IniFormat);
+
+ // 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 locationEnabled && gpsEnabled && powered;
}
quint32 HybrisProvider::minimumRequestedUpdateInterval() const
|
[-]
[+]
|
Changed |
_service:tar_git:geoclue-provider-hybris-0.2.11.tar.gz/hybrisprovider.h
^
|
@@ -23,8 +23,6 @@
#include <android-version.h>
#include <hardware/gps.h>
-#include <locationsettings.h>
-
#include "locationtypes.h"
// Define versions of the Android GPS interface supported.
@@ -61,7 +59,7 @@
explicit HybrisProvider(QObject *parent = 0);
~HybrisProvider();
- void setLocationSettings(LocationSettings *settings);
+ void setDeviceController(DeviceControl *control);
// org.freedesktop.Geoclue
void AddReference();
@@ -213,6 +211,8 @@
Status m_status;
+ QFileSystemWatcher *m_locationSettings;
+
bool m_positionInjectionConnected;
QNetworkAccessManager *m_manager;
@@ -229,7 +229,7 @@
bool m_gpsStarted;
- LocationSettings *m_locationSettings;
+ DeviceControl *m_deviceControl;
NetworkManager *m_networkManager;
NetworkTechnology *m_cellularTechnology;
|
[-]
[+]
|
Changed |
_service:tar_git:geoclue-provider-hybris-0.2.11.tar.gz/main.cpp
^
|
@@ -15,8 +15,7 @@
#include <QtDBus/QDBusConnection>
#include "hybrisprovider.h"
-
-#include <locationsettings.h>
+#include "devicecontrol.h"
#include <unistd.h>
#include <sys/types.h>
@@ -69,6 +68,14 @@
if (numberGroups == -1)
qFatal("Failed to set supplementary groups, %s", strerror(errno));
+ // Register service on DBus system bus prior to dropping privileges.
+ QDBusConnection system = QDBusConnection::systemBus();
+ DeviceControl control;
+ if (!system.registerObject(QStringLiteral("/com/jollamobile/gps/Device"), &control))
+ qFatal("Failed to register object /com/jollamobile/gps/Device");
+ if (!system.registerService(QStringLiteral("com.jollamobile.gps")))
+ qFatal("Failed to register service com.jollamobile.gps");
+
#if GEOCLUE_ANDROID_GPS_INTERFACE != 2
// Drop privileges.
result = setuid(realUid);
@@ -77,13 +84,12 @@
#endif
QDBusConnection session = QDBusConnection::sessionBus();
- LocationSettings settings;
HybrisProvider provider;
- provider.setLocationSettings(&settings);
if (!session.registerObject(QStringLiteral("/org/freedesktop/Geoclue/Providers/Hybris"), &provider))
qFatal("Failed to register object /org/freedesktop/Geoclue/Providers/Hybris");
if (!session.registerService(QStringLiteral("org.freedesktop.Geoclue.Providers.Hybris")))
qFatal("Failed to register service org.freedesktop.Geoclue.Providers.Hybris");
+ provider.setDeviceController(&control);
return a.exec();
}
|