summaryrefslogtreecommitdiffstats
path: root/sensors
diff options
context:
space:
mode:
authorPeng Xu <pengxu@google.com>2017-06-19 11:43:24 -0700
committerPeng Xu <pengxu@google.com>2017-06-19 20:39:48 +0000
commit36665b1b3d99a8c3d0ee37c17a524ce3fbc1a758 (patch)
treefee2452f1ece11c162e0f28fce302bb280704cb2 /sensors
parent55f3ddf53b051a28c2773c872a398786a060dc30 (diff)
downloadplatform_hardware_interfaces-36665b1b3d99a8c3d0ee37c17a524ce3fbc1a758.tar.gz
platform_hardware_interfaces-36665b1b3d99a8c3d0ee37c17a524ce3fbc1a758.tar.bz2
platform_hardware_interfaces-36665b1b3d99a8c3d0ee37c17a524ce3fbc1a758.zip
Zero uninitialized field in conversion and fix vts bug
Zero uninitialized sensor event field to zero to avoid undefined value being passed to framework. Correct sensor report type check bug in vts. Bug: 37793558 Bug: 37710268 Test: sensor vts passes Change-Id: I5042975fea8fe28ae130367ba083a4e4f4e5657e
Diffstat (limited to 'sensors')
-rw-r--r--sensors/1.0/default/convert.cpp22
-rw-r--r--sensors/1.0/vts/functional/VtsHalSensorsV1_0TargetTest.cpp4
2 files changed, 15 insertions, 11 deletions
diff --git a/sensors/1.0/default/convert.cpp b/sensors/1.0/default/convert.cpp
index 3d859ec242..047374f9ea 100644
--- a/sensors/1.0/default/convert.cpp
+++ b/sensors/1.0/default/convert.cpp
@@ -67,9 +67,11 @@ void convertFromSensorEvent(const sensors_event_t &src, Event *dst) {
typedef ::android::hardware::sensors::V1_0::SensorType SensorType;
typedef ::android::hardware::sensors::V1_0::MetaDataEventType MetaDataEventType;
- dst->sensorHandle = src.sensor;
- dst->sensorType = (SensorType)src.type;
- dst->timestamp = src.timestamp;
+ *dst = {
+ .sensorHandle = src.sensor,
+ .sensorType = (SensorType)src.type,
+ .timestamp = src.timestamp
+ };
switch (dst->sensorType) {
case SensorType::META_DATA:
@@ -206,13 +208,13 @@ void convertFromSensorEvent(const sensors_event_t &src, Event *dst) {
}
void convertToSensorEvent(const Event &src, sensors_event_t *dst) {
- dst->version = sizeof(sensors_event_t);
- dst->sensor = src.sensorHandle;
- dst->type = (int32_t)src.sensorType;
- dst->reserved0 = 0;
- dst->timestamp = src.timestamp;
- dst->flags = 0;
- dst->reserved1[0] = dst->reserved1[1] = dst->reserved1[2] = 0;
+ *dst = {
+ .version = sizeof(sensors_event_t),
+ .sensor = src.sensorHandle,
+ .type = (int32_t)src.sensorType,
+ .reserved0 = 0,
+ .timestamp = src.timestamp
+ };
switch (src.sensorType) {
case SensorType::META_DATA:
diff --git a/sensors/1.0/vts/functional/VtsHalSensorsV1_0TargetTest.cpp b/sensors/1.0/vts/functional/VtsHalSensorsV1_0TargetTest.cpp
index 06a9d7e829..2cf4ef9cd4 100644
--- a/sensors/1.0/vts/functional/VtsHalSensorsV1_0TargetTest.cpp
+++ b/sensors/1.0/vts/functional/VtsHalSensorsV1_0TargetTest.cpp
@@ -697,6 +697,7 @@ void SensorsHidlTest::assertDelayMatchReportMode(
SensorFlagBits SensorsHidlTest::expectedReportModeForType(SensorType type) {
switch (type) {
case SensorType::ACCELEROMETER:
+ case SensorType::ACCELEROMETER_UNCALIBRATED:
case SensorType::GYROSCOPE:
case SensorType::MAGNETIC_FIELD:
case SensorType::ORIENTATION:
@@ -719,7 +720,6 @@ SensorFlagBits SensorsHidlTest::expectedReportModeForType(SensorType type) {
case SensorType::AMBIENT_TEMPERATURE:
case SensorType::HEART_RATE:
case SensorType::DEVICE_ORIENTATION:
- case SensorType::MOTION_DETECT:
case SensorType::STEP_COUNTER:
case SensorType::LOW_LATENCY_OFFBODY_DETECT:
return SensorFlagBits::ON_CHANGE_MODE;
@@ -728,6 +728,8 @@ SensorFlagBits SensorsHidlTest::expectedReportModeForType(SensorType type) {
case SensorType::WAKE_GESTURE:
case SensorType::GLANCE_GESTURE:
case SensorType::PICK_UP_GESTURE:
+ case SensorType::MOTION_DETECT:
+ case SensorType::STATIONARY_DETECT:
return SensorFlagBits::ONE_SHOT_MODE;
case SensorType::STEP_DETECTOR: