summaryrefslogtreecommitdiff
path: root/src/plugins
diff options
context:
space:
mode:
authorLiang Qi <liang.qi@qt.io>2016-11-24 19:37:02 +0100
committerLiang Qi <liang.qi@qt.io>2016-11-24 19:37:02 +0100
commit4c5873b43a2d7d80a33374d89b870a67e7900eca (patch)
treea3137ca964490094f600c2f95425790aa5791111 /src/plugins
parent674916567771907c00210074249a66ce555a059a (diff)
parent12c11ffb6eb1f68c9c83a6eee3f9d4011746b122 (diff)
downloadqtsensors-4c5873b43a2d7d80a33374d89b870a67e7900eca.tar.gz
Merge remote-tracking branch 'origin/5.6' into 5.75.7
Change-Id: I77e9c7f825716af5ab4a1c04551f89e22099696e
Diffstat (limited to 'src/plugins')
-rw-r--r--src/plugins/sensors/android/src/androidmagnetometer.cpp16
1 files changed, 15 insertions, 1 deletions
diff --git a/src/plugins/sensors/android/src/androidmagnetometer.cpp b/src/plugins/sensors/android/src/androidmagnetometer.cpp
index a729ddd..fcde4cf 100644
--- a/src/plugins/sensors/android/src/androidmagnetometer.cpp
+++ b/src/plugins/sensors/android/src/androidmagnetometer.cpp
@@ -39,13 +39,27 @@
#include "androidmagnetometer.h"
+enum AndroidSensorStatus
+{
+ SENSOR_STATUS_UNRELIABLE = 0,
+ SENSOR_STATUS_ACCURACY_LOW = 1,
+ SENSOR_STATUS_ACCURACY_MEDIUM = 2,
+ SENSOR_STATUS_ACCURACY_HIGH = 3,
+};
+
AndroidMagnetometer::AndroidMagnetometer(AndroidSensors::AndroidSensorType type, QSensor *sensor)
:AndroidCommonSensor<QMagnetometerReading>(type, sensor)
{}
void AndroidMagnetometer::onAccuracyChanged(jint accuracy)
{
- m_reader.setCalibrationLevel(accuracy);
+ // Expected range is [0, 3]
+ if (accuracy < SENSOR_STATUS_UNRELIABLE || accuracy > SENSOR_STATUS_ACCURACY_HIGH) {
+ qWarning("Unable to get sensor accuracy. Unexpected value: %d", accuracy);
+ return;
+ }
+
+ m_reader.setCalibrationLevel(accuracy / qreal(3.0));
}
void AndroidMagnetometer::onSensorChanged(jlong timestamp, const jfloat *values, uint size)