Skip to content

Commit

Permalink
fix for STS testPocCVE_2021_0318
Browse files Browse the repository at this point in the history
when there is no actual sensors hardware available, Sensors services
was crashing because of improper TAG reference in SensorEvent. As a
result, unacceptable default values is received in senssors framework
layer.

proper TAG values is now updated in Sensors AIDL HAL layer according
to its types - vec3,vec4,uncal,data and scalar to handle all 9 types
of sensors.

Tracked-On: OAM-114640
Signed-off-by: Ranjan, Rajani <rajani.ranjan@intel.com>
  • Loading branch information
RajaniRanjan committed Jan 29, 2024
1 parent eddd832 commit d708e22
Showing 1 changed file with 55 additions and 12 deletions.
67 changes: 55 additions & 12 deletions sensors/aidl/Sensor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -148,33 +148,76 @@ std::vector<Event> Sensor::readEvents() {
event.sensorType = mSensorInfo.type;
event.timestamp = ::android::elapsedRealtimeNano();
memset(&event.payload, 0, sizeof(event.payload));
EventPayload::Vec3 vec3 ;
EventPayload::Vec3 vec3;
EventPayload::Vec4 vec4;
EventPayload::Uncal uncal;
EventPayload::Data data;

if (iioc && iioc->is_iioc_initialized) {
vec3 = {
.x = iioc->devlist[mSensorInfo.sensorHandle].data[0],
.y = iioc->devlist[mSensorInfo.sensorHandle].data[1],
.z = iioc->devlist[mSensorInfo.sensorHandle].data[2],
.status = SensorStatus::ACCURACY_HIGH,
};
event.payload.set<EventPayload::Tag::vec3>(vec3);
} else {
if (event.sensorHandle == 1) {
vec3 = {
.x = 0,
.y = 0,
.z = -9.8,
.status = SensorStatus::ACCURACY_HIGH,
};
switch (event.sensorType) {
case SensorType::ACCELEROMETER:
case SensorType::MAGNETIC_FIELD:
case SensorType::ORIENTATION:
case SensorType::GYROSCOPE:
case SensorType::GRAVITY:
case SensorType::LINEAR_ACCELERATION: {
event.payload.set<EventPayload::Tag::vec3>(vec3);
break;
}
case SensorType::GAME_ROTATION_VECTOR: {
event.payload.set<EventPayload::Tag::vec4>(vec4);
break;
}
else {
case SensorType::ROTATION_VECTOR:
case SensorType::GEOMAGNETIC_ROTATION_VECTOR: {
event.payload.set<EventPayload::Tag::data>(data);
break;
}
case SensorType::MAGNETIC_FIELD_UNCALIBRATED:
case SensorType::GYROSCOPE_UNCALIBRATED:
case SensorType::ACCELEROMETER_UNCALIBRATED: {
event.payload.set<EventPayload::Tag::uncal>(uncal);
break;
}
case SensorType::DEVICE_ORIENTATION:
case SensorType::LIGHT:
case SensorType::PRESSURE:
case SensorType::PROXIMITY:
case SensorType::RELATIVE_HUMIDITY:
case SensorType::AMBIENT_TEMPERATURE:
case SensorType::SIGNIFICANT_MOTION:
case SensorType::STEP_DETECTOR:
case SensorType::TILT_DETECTOR:
case SensorType::WAKE_GESTURE:
case SensorType::GLANCE_GESTURE:
case SensorType::PICK_UP_GESTURE:
case SensorType::WRIST_TILT_GESTURE:
case SensorType::STATIONARY_DETECT:
case SensorType::MOTION_DETECT:
case SensorType::HEART_BEAT:
case SensorType::LOW_LATENCY_OFFBODY_DETECT:
case SensorType::HINGE_ANGLE: {
event.payload.set<EventPayload::Tag::scalar>(00.0f);
break;
}
default :{
vec3 = {
.x = 0,
.y = 0,
.z = 0,
.status = SensorStatus::ACCURACY_HIGH,
};
.status = SensorStatus::ACCURACY_HIGH,};
event.payload.set<EventPayload::Tag::vec3>(vec3);
}
}
}
event.payload.set<EventPayload::Tag::vec3>(vec3);
events.push_back(event);
#ifdef DEBUG // Probing data to debug
ALOGD("readEvents: handle(%d) name -> %s data[%f, %f, %f]",
Expand Down

0 comments on commit d708e22

Please sign in to comment.