Zero uninitialized field in conversion and fix vts bug

am: 36665b1b3d

Change-Id: I9c3aa0350b90f52abb12b4c88f10ab43e82ab65b
This commit is contained in:
Peng Xu 2017-06-20 00:08:44 +00:00 committed by android-build-merger
commit 967de22a44
2 changed files with 15 additions and 11 deletions

View file

@ -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:

View file

@ -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: