diff options
author | Qt Forward Merge Bot <qt_forward_merge_bot@qt-project.org> | 2019-07-22 06:41:31 +0200 |
---|---|---|
committer | Qt Forward Merge Bot <qt_forward_merge_bot@qt-project.org> | 2019-07-22 06:41:37 +0200 |
commit | 4dfa95538ff15f59880c93675676ce609b365d89 (patch) | |
tree | e3b1aded9bca7fe5280da8865cddc1214303ea55 /src/plugins | |
parent | a28678b83ac3a5a7530026027e2c16a23379168a (diff) | |
parent | c20fa3ee91cdef22f270fea7159b4a8a4eab4a50 (diff) | |
download | qtsensors-4dfa95538ff15f59880c93675676ce609b365d89.tar.gz |
Merge "Merge remote-tracking branch 'origin/5.13' into dev"
Diffstat (limited to 'src/plugins')
-rw-r--r-- | src/plugins/sensors/android/androidaccelerometer.cpp | 12 | ||||
-rw-r--r-- | src/plugins/sensors/android/sensormanager.cpp | 2 | ||||
-rw-r--r-- | src/plugins/sensors/iio-sensor-proxy/main.cpp | 17 |
3 files changed, 21 insertions, 10 deletions
diff --git a/src/plugins/sensors/android/androidaccelerometer.cpp b/src/plugins/sensors/android/androidaccelerometer.cpp index c9f5141..f38e004 100644 --- a/src/plugins/sensors/android/androidaccelerometer.cpp +++ b/src/plugins/sensors/android/androidaccelerometer.cpp @@ -82,18 +82,24 @@ void AndroidAccelerometer::applyAccelerationMode(QAccelerometer::AccelerationMod { switch (accelerationMode) { case QAccelerometer::Gravity: - if (!(m_accelerationModes & Gravity)) + if (!(m_accelerationModes & Gravity)) { qWarning() << "Gravity sensor missing"; + return; + } setSensorType(ASENSOR_TYPE_GRAVITY); break; case QAccelerometer::User: - if (!(m_accelerationModes & LinearAcceleration)) + if (!(m_accelerationModes & LinearAcceleration)) { qWarning() << "Linear acceleration sensor missing"; + return; + } setSensorType(ASENSOR_TYPE_LINEAR_ACCELERATION); break; case QAccelerometer::Combined: - if (!(m_accelerationModes & Accelerometer)) + if (!(m_accelerationModes & Accelerometer)) { qWarning() << "Accelerometer sensor missing"; + return; + } setSensorType(ASENSOR_TYPE_ACCELEROMETER); break; } diff --git a/src/plugins/sensors/android/sensormanager.cpp b/src/plugins/sensors/android/sensormanager.cpp index 590f478..542e54c 100644 --- a/src/plugins/sensors/android/sensormanager.cpp +++ b/src/plugins/sensors/android/sensormanager.cpp @@ -73,7 +73,7 @@ ALooper *SensorManager::looper() const static inline ASensorManager* androidManager() { #if __ANDROID_API__ >= 26 - retrun ASensorManager_getInstanceForPackage(QJNIObjectPrivate{QtAndroidPrivate::context()} + return ASensorManager_getInstanceForPackage(QJNIObjectPrivate{QtAndroidPrivate::context()} .callObjectMethod("getPackageName", "()Ljava/lang/String;") .toString().toUtf8().constData()); #else diff --git a/src/plugins/sensors/iio-sensor-proxy/main.cpp b/src/plugins/sensors/iio-sensor-proxy/main.cpp index 136dd40..580e2c4 100644 --- a/src/plugins/sensors/iio-sensor-proxy/main.cpp +++ b/src/plugins/sensors/iio-sensor-proxy/main.cpp @@ -46,6 +46,9 @@ #include <qsensorbackend.h> #include <qsensormanager.h> +#include <QtDBus/QDBusConnection> +#include <QtDBus/QDBusConnectionInterface> + #include <QtCore/QFile> #include <QtCore/QDebug> @@ -57,12 +60,14 @@ class IIOSensorProxySensorPlugin : public QObject, public QSensorPluginInterface public: void registerSensors() override { - if (!QSensorManager::isBackendRegistered(QOrientationSensor::type, IIOSensorProxyOrientationSensor::id)) - QSensorManager::registerBackend(QOrientationSensor::type, IIOSensorProxyOrientationSensor::id, this); - if (!QSensorManager::isBackendRegistered(QLightSensor::type, IIOSensorProxyLightSensor::id)) - QSensorManager::registerBackend(QLightSensor::type, IIOSensorProxyLightSensor::id, this); - if (!QSensorManager::isBackendRegistered(QCompass::type, IIOSensorProxyCompass::id)) - QSensorManager::registerBackend(QCompass::type, IIOSensorProxyCompass::id, this); + if (QDBusConnection::systemBus().interface()->isServiceRegistered("net.hadess.SensorProxy")) { + if (!QSensorManager::isBackendRegistered(QOrientationSensor::type, IIOSensorProxyOrientationSensor::id)) + QSensorManager::registerBackend(QOrientationSensor::type, IIOSensorProxyOrientationSensor::id, this); + if (!QSensorManager::isBackendRegistered(QLightSensor::type, IIOSensorProxyLightSensor::id)) + QSensorManager::registerBackend(QLightSensor::type, IIOSensorProxyLightSensor::id, this); + if (!QSensorManager::isBackendRegistered(QCompass::type, IIOSensorProxyCompass::id)) + QSensorManager::registerBackend(QCompass::type, IIOSensorProxyCompass::id, this); + } } QSensorBackend *createBackend(QSensor *sensor) override |