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
This commit is contained in:
parent
55f3ddf53b
commit
36665b1b3d
2 changed files with 15 additions and 11 deletions
|
@ -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:
|
||||
|
|
|
@ -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:
|
||||
|
|
Loading…
Reference in a new issue