summaryrefslogtreecommitdiffstats
path: root/src/plugins/sensors/android/src/main.cpp
diff options
context:
space:
mode:
authorAndrew Inwood <ainwood@blackberry.com>2014-03-13 18:58:15 -0400
committerThe Qt Project <gerrit-noreply@qt-project.org>2014-03-20 15:27:32 +0100
commit971fc95eca1d9db93aa4bdb75793dfe83e4a97db (patch)
treecb3bc54a3d1fab5c98558c5179a6f09da4db2a46 /src/plugins/sensors/android/src/main.cpp
parent14293dcb7002b185b49ec1ad802055eee63f2473 (diff)
Implement QAccelerometer accelerationModev5.3.0-beta1
The Qt API does not expose Linear Accel and Gravity as separate sensor types, they are different versions of QAccelerometer, accessed by modifying the accelerationMode property. The possible values are Combined, User, and Gravity, which correspond to Acceleration, Linear Acceleration, and Gravity respectively. When constructing the accelerometer backend, the accelerationMode must be queried. The backend must also connect to the accelerationModeChanged signal from the QAccelerometer. I think that the existing implementation of QSensors on Android assumes that there is a one-to-one correspondence between QSensors and AndroidSensorTypes. To fix this assumption, I promoted the m_type attribute of androidcommonsensor.h from private to protected so that a sensor backend can update the Android sensor being used. Task-number: QTBUG-30531 Change-Id: I842d2485109542f74731d179e2720ea55fa248cc Reviewed-by: Fabian Bumberger <fbumberger@rim.com> Reviewed-by: Lorn Potter <lorn.potter@jollamobile.com>
Diffstat (limited to 'src/plugins/sensors/android/src/main.cpp')
-rw-r--r--src/plugins/sensors/android/src/main.cpp5
1 files changed, 5 insertions, 0 deletions
diff --git a/src/plugins/sensors/android/src/main.cpp b/src/plugins/sensors/android/src/main.cpp
index 17d499ef..3326208b 100644
--- a/src/plugins/sensors/android/src/main.cpp
+++ b/src/plugins/sensors/android/src/main.cpp
@@ -43,6 +43,7 @@
#include <qsensorplugin.h>
#include <qsensorbackend.h>
#include <qsensormanager.h>
+#include <qaccelerometer.h>
#include "androidaccelerometer.h"
#include "androidgyroscope.h"
#include "androidlight.h"
@@ -112,7 +113,11 @@ public:
AndroidSensorType type = static_cast<AndroidSensorType>(sensor->identifier().toInt());
switch (type) {
case TYPE_ACCELEROMETER:
+ {
+ QAccelerometer * const accelerometer = qobject_cast<QAccelerometer *>(sensor);
+ AndroidSensors::AndroidSensorType type = AndroidAccelerometer::modeToSensor(accelerometer->accelerationMode());
return new AndroidAccelerometer(type, sensor);
+ }
case TYPE_AMBIENT_TEMPERATURE:
case TYPE_TEMPERATURE:
return new AndroidTemperature(type, sensor);