diff options
author | Peng Xu <pengxu@google.com> | 2017-06-20 00:09:11 +0000 |
---|---|---|
committer | android-build-merger <android-build-merger@google.com> | 2017-06-20 00:09:11 +0000 |
commit | 4be0fc16c85b9f86c30b8ed48fbac73fc80c4582 (patch) | |
tree | 42e9e96d681c523c3710b2a7924a31b362f5de90 /sensors | |
parent | d56f85aded230850dd4b582dce7a5b64683ec0f2 (diff) | |
parent | 36665b1b3d99a8c3d0ee37c17a524ce3fbc1a758 (diff) | |
download | platform_hardware_interfaces-4be0fc16c85b9f86c30b8ed48fbac73fc80c4582.tar.gz platform_hardware_interfaces-4be0fc16c85b9f86c30b8ed48fbac73fc80c4582.tar.bz2 platform_hardware_interfaces-4be0fc16c85b9f86c30b8ed48fbac73fc80c4582.zip |
Zero uninitialized field in conversion and fix vts bug
am: 36665b1b3d
Change-Id: Ib9c7e171da1b1acae16cb550dc1ed7d1cc635c77
Diffstat (limited to 'sensors')
-rw-r--r-- | sensors/1.0/default/convert.cpp | 22 | ||||
-rw-r--r-- | sensors/1.0/vts/functional/VtsHalSensorsV1_0TargetTest.cpp | 4 |
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 c92603b6af..48429466e7 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: |