diff options
author | Lorn Potter <lorn.potter@jollamobile.com> | 2014-07-08 07:43:27 +1000 |
---|---|---|
committer | Lorn Potter <lorn.potter@jollamobile.com> | 2014-07-10 21:57:10 +0200 |
commit | 044486f8b41b9ae7bdfad838be79ec5b2782fed5 (patch) | |
tree | 2cd63a30b3edf5aefa265e494a99e2181318d3af | |
parent | 3690925021c60378bb1d21e9102f7f8aa8627716 (diff) | |
download | qtsensors-044486f8b41b9ae7bdfad838be79ec5b2782fed5.tar.gz qtsensors-044486f8b41b9ae7bdfad838be79ec5b2782fed5.tar.bz2 qtsensors-044486f8b41b9ae7bdfad838be79ec5b2782fed5.zip |
[sensorfw] need to run init after sensord has been restarted
This ensures things are setup and work properly.
Change-Id: I23c8b53e760d49695c5ae207eed77a2e7d2be3a4
Reviewed-by: Alex Blasche <alexander.blasche@digia.com>
19 files changed, 63 insertions, 0 deletions
diff --git a/src/plugins/sensors/sensorfw/sensorfwaccelerometer.cpp b/src/plugins/sensors/sensorfw/sensorfwaccelerometer.cpp index d38f1a0..8efd127 100644 --- a/src/plugins/sensors/sensorfw/sensorfwaccelerometer.cpp +++ b/src/plugins/sensors/sensorfw/sensorfwaccelerometer.cpp @@ -96,3 +96,10 @@ void sensorfwaccelerometer::init() m_initDone = false; initSensor<AccelerometerSensorChannelInterface>(m_initDone); } + +void sensorfwaccelerometer::start() +{ + if (reinitIsNeeded) + init(); + SensorfwSensorBase::start(); +} diff --git a/src/plugins/sensors/sensorfw/sensorfwaccelerometer.h b/src/plugins/sensors/sensorfw/sensorfwaccelerometer.h index e0e84cc..e3ded24 100644 --- a/src/plugins/sensors/sensorfw/sensorfwaccelerometer.h +++ b/src/plugins/sensors/sensorfw/sensorfwaccelerometer.h @@ -60,6 +60,7 @@ protected: bool doConnect() Q_DECL_OVERRIDE; QString sensorName() const Q_DECL_OVERRIDE; qreal correctionFactor() const Q_DECL_OVERRIDE; + void start() Q_DECL_OVERRIDE; virtual void init(); private: diff --git a/src/plugins/sensors/sensorfw/sensorfwals.cpp b/src/plugins/sensors/sensorfw/sensorfwals.cpp index 0de7e71..e5dd051 100644 --- a/src/plugins/sensors/sensorfw/sensorfwals.cpp +++ b/src/plugins/sensors/sensorfw/sensorfwals.cpp @@ -59,6 +59,8 @@ Sensorfwals::Sensorfwals(QSensor *sensor) void Sensorfwals::start() { + if (reinitIsNeeded) + init(); if (m_sensorInterface) { Unsigned data(((ALSSensorChannelInterface*)m_sensorInterface)->lux()); m_reading.setLightLevel(getLightLevel(data.x())); diff --git a/src/plugins/sensors/sensorfw/sensorfwcompass.cpp b/src/plugins/sensors/sensorfw/sensorfwcompass.cpp index ad41cfe..e565bce 100644 --- a/src/plugins/sensors/sensorfw/sensorfwcompass.cpp +++ b/src/plugins/sensors/sensorfw/sensorfwcompass.cpp @@ -84,3 +84,10 @@ void SensorfwCompass::init() m_initDone = false; initSensor<CompassSensorChannelInterface>(m_initDone); } + +void SensorfwCompass::start() +{ + if (reinitIsNeeded) + init(); + SensorfwSensorBase::start(); +} diff --git a/src/plugins/sensors/sensorfw/sensorfwcompass.h b/src/plugins/sensors/sensorfw/sensorfwcompass.h index 951435c..aa8e3bd 100644 --- a/src/plugins/sensors/sensorfw/sensorfwcompass.h +++ b/src/plugins/sensors/sensorfw/sensorfwcompass.h @@ -59,6 +59,7 @@ public: protected: bool doConnect() Q_DECL_OVERRIDE; QString sensorName() const Q_DECL_OVERRIDE; + void start() Q_DECL_OVERRIDE; virtual void init(); private: QCompassReading m_reading; diff --git a/src/plugins/sensors/sensorfw/sensorfwgyroscope.cpp b/src/plugins/sensors/sensorfw/sensorfwgyroscope.cpp index deca190..6001d47 100644 --- a/src/plugins/sensors/sensorfw/sensorfwgyroscope.cpp +++ b/src/plugins/sensors/sensorfw/sensorfwgyroscope.cpp @@ -95,3 +95,10 @@ void SensorfwGyroscope::init() m_initDone = false; initSensor<GyroscopeSensorChannelInterface>(m_initDone); } + +void SensorfwGyroscope::start() +{ + if (reinitIsNeeded) + init(); + SensorfwSensorBase::start(); +} diff --git a/src/plugins/sensors/sensorfw/sensorfwgyroscope.h b/src/plugins/sensors/sensorfw/sensorfwgyroscope.h index f489bf6..bfbad62 100644 --- a/src/plugins/sensors/sensorfw/sensorfwgyroscope.h +++ b/src/plugins/sensors/sensorfw/sensorfwgyroscope.h @@ -62,6 +62,7 @@ protected: bool doConnect() Q_DECL_OVERRIDE; QString sensorName() const Q_DECL_OVERRIDE; qreal correctionFactor() const Q_DECL_OVERRIDE; + void start() Q_DECL_OVERRIDE; virtual void init(); private: diff --git a/src/plugins/sensors/sensorfw/sensorfwirproximitysensor.cpp b/src/plugins/sensors/sensorfw/sensorfwirproximitysensor.cpp index 4207735..6855158 100644 --- a/src/plugins/sensors/sensorfw/sensorfwirproximitysensor.cpp +++ b/src/plugins/sensors/sensorfw/sensorfwirproximitysensor.cpp @@ -83,3 +83,10 @@ void SensorfwIrProximitySensor::init() m_initDone = false; initSensor<ProximitySensorChannelInterface>(m_initDone); } + +void SensorfwIrProximitySensor::start() +{ + if (reinitIsNeeded) + init(); + SensorfwSensorBase::start(); +} diff --git a/src/plugins/sensors/sensorfw/sensorfwirproximitysensor.h b/src/plugins/sensors/sensorfw/sensorfwirproximitysensor.h index 642570d..3c176ff 100644 --- a/src/plugins/sensors/sensorfw/sensorfwirproximitysensor.h +++ b/src/plugins/sensors/sensorfw/sensorfwirproximitysensor.h @@ -58,6 +58,7 @@ public: protected: bool doConnect() Q_DECL_OVERRIDE; QString sensorName() const Q_DECL_OVERRIDE; + void start() Q_DECL_OVERRIDE; virtual void init(); private: QIRProximityReading m_reading; diff --git a/src/plugins/sensors/sensorfw/sensorfwlightsensor.cpp b/src/plugins/sensors/sensorfw/sensorfwlightsensor.cpp index 6607433..6badd7c 100644 --- a/src/plugins/sensors/sensorfw/sensorfwlightsensor.cpp +++ b/src/plugins/sensors/sensorfw/sensorfwlightsensor.cpp @@ -75,3 +75,10 @@ void SensorfwLightSensor::init() m_initDone = false; initSensor<ALSSensorChannelInterface>(m_initDone); } + +void SensorfwLightSensor::start() +{ + if (reinitIsNeeded) + init(); + SensorfwSensorBase::start(); +} diff --git a/src/plugins/sensors/sensorfw/sensorfwlightsensor.h b/src/plugins/sensors/sensorfw/sensorfwlightsensor.h index 244f795..911ec55 100644 --- a/src/plugins/sensors/sensorfw/sensorfwlightsensor.h +++ b/src/plugins/sensors/sensorfw/sensorfwlightsensor.h @@ -59,6 +59,7 @@ public: protected: bool doConnect() Q_DECL_OVERRIDE; QString sensorName() const Q_DECL_OVERRIDE; + void start() Q_DECL_OVERRIDE; virtual void init(); private: QLightReading m_reading; diff --git a/src/plugins/sensors/sensorfw/sensorfwmagnetometer.cpp b/src/plugins/sensors/sensorfw/sensorfwmagnetometer.cpp index 10b1afe..12465a3 100644 --- a/src/plugins/sensors/sensorfw/sensorfwmagnetometer.cpp +++ b/src/plugins/sensors/sensorfw/sensorfwmagnetometer.cpp @@ -59,6 +59,8 @@ SensorfwMagnetometer::SensorfwMagnetometer(QSensor *sensor) void SensorfwMagnetometer::start() { + if (reinitIsNeeded) + init(); QMagnetometer *const magnetometer = qobject_cast<QMagnetometer *>(sensor()); if (magnetometer) m_isGeoMagnetometer = magnetometer->returnGeoValues(); diff --git a/src/plugins/sensors/sensorfw/sensorfworientationsensor.cpp b/src/plugins/sensors/sensorfw/sensorfworientationsensor.cpp index b45b731..bd91ac2 100644 --- a/src/plugins/sensors/sensorfw/sensorfworientationsensor.cpp +++ b/src/plugins/sensors/sensorfw/sensorfworientationsensor.cpp @@ -57,6 +57,8 @@ SensorfwOrientationSensor::SensorfwOrientationSensor(QSensor *sensor) void SensorfwOrientationSensor::start() { + if (reinitIsNeeded) + init(); if (m_sensorInterface) { Unsigned data(((OrientationSensorChannelInterface*)m_sensorInterface)->orientation()); m_reading.setOrientation(SensorfwOrientationSensor::getOrientation(data.x())); diff --git a/src/plugins/sensors/sensorfw/sensorfwproximitysensor.cpp b/src/plugins/sensors/sensorfw/sensorfwproximitysensor.cpp index d98dfd1..4d91a02 100644 --- a/src/plugins/sensors/sensorfw/sensorfwproximitysensor.cpp +++ b/src/plugins/sensors/sensorfw/sensorfwproximitysensor.cpp @@ -57,6 +57,8 @@ SensorfwProximitySensor::SensorfwProximitySensor(QSensor *sensor) void SensorfwProximitySensor::start() { + if (reinitIsNeeded) + init(); if (m_sensorInterface) { Unsigned data(((ProximitySensorChannelInterface*)m_sensorInterface)->proximity()); m_reading.setClose(data.x()? true: false); diff --git a/src/plugins/sensors/sensorfw/sensorfwrotationsensor.cpp b/src/plugins/sensors/sensorfw/sensorfwrotationsensor.cpp index c0ba069..b63e7f6 100644 --- a/src/plugins/sensors/sensorfw/sensorfwrotationsensor.cpp +++ b/src/plugins/sensors/sensorfw/sensorfwrotationsensor.cpp @@ -86,3 +86,10 @@ void SensorfwRotationSensor::init() m_initDone = false; initSensor<RotationSensorChannelInterface>(m_initDone); } + +void SensorfwRotationSensor::start() +{ + if (reinitIsNeeded) + init(); + SensorfwSensorBase::start(); +} diff --git a/src/plugins/sensors/sensorfw/sensorfwrotationsensor.h b/src/plugins/sensors/sensorfw/sensorfwrotationsensor.h index dd41520..944d2c1 100644 --- a/src/plugins/sensors/sensorfw/sensorfwrotationsensor.h +++ b/src/plugins/sensors/sensorfw/sensorfwrotationsensor.h @@ -61,6 +61,7 @@ public: protected: bool doConnect() Q_DECL_OVERRIDE; QString sensorName() const Q_DECL_OVERRIDE; + void start() Q_DECL_OVERRIDE; virtual void init(); private: QRotationReading m_reading; diff --git a/src/plugins/sensors/sensorfw/sensorfwsensorbase.cpp b/src/plugins/sensors/sensorfw/sensorfwsensorbase.cpp index 299c20e..299a75c 100644 --- a/src/plugins/sensors/sensorfw/sensorfwsensorbase.cpp +++ b/src/plugins/sensors/sensorfw/sensorfwsensorbase.cpp @@ -56,6 +56,7 @@ SensorfwSensorBase::SensorfwSensorBase(QSensor *sensor) : QSensorBackend(sensor), m_sensorInterface(0), m_bufferSize(-1), + reinitIsNeeded(false), m_prevOutputRange(0), m_efficientBufferSize(1), m_maxBufferSize(1), @@ -216,7 +217,9 @@ void SensorfwSensorBase::connectToSensord() m_remoteSensorManager = &SensorManagerInterface::instance(); if (running) { stop(); + reinitIsNeeded = true; start(); + reinitIsNeeded = false; } } diff --git a/src/plugins/sensors/sensorfw/sensorfwsensorbase.h b/src/plugins/sensors/sensorfw/sensorfwsensorbase.h index 769a8cb..7cf5684 100644 --- a/src/plugins/sensors/sensorfw/sensorfwsensorbase.h +++ b/src/plugins/sensors/sensorfw/sensorfwsensorbase.h @@ -163,6 +163,7 @@ protected: int m_bufferSize; int bufferSize() const; virtual qreal correctionFactor() const; + bool reinitIsNeeded; private: diff --git a/src/plugins/sensors/sensorfw/sensorfwtapsensor.cpp b/src/plugins/sensors/sensorfw/sensorfwtapsensor.cpp index 1d7e950..e6f61d9 100644 --- a/src/plugins/sensors/sensorfw/sensorfwtapsensor.cpp +++ b/src/plugins/sensors/sensorfw/sensorfwtapsensor.cpp @@ -58,6 +58,9 @@ SensorfwTapSensor::SensorfwTapSensor(QSensor *sensor) void SensorfwTapSensor::start() { + if (reinitIsNeeded) + init(); + QTapSensor * const tapSensor = qobject_cast<QTapSensor *>(sensor()); bool b = tapSensor->returnDoubleTapEvents(); |