Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit e357a6a9 authored by Brian Duddie's avatar Brian Duddie
Browse files

Support multiple sensors in AOSP fusion algorithms

In situations where multiple sensors of the same type are active, only
one must used for running sensor fusion algorithms otherwise they will
produce invalid output. Ensure that the first sensor of each type is
selected, and also ensure that if other sensors of the same type are
active, their sensor samples are not used in the fusion algorithms.

Fixes: 408064104
Test: manual validation
Flag: EXEMPT bugfix
Change-Id: I1497224b18a2e6cef6b4a4b863a8615504d9a356
parent efa38e3b
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -55,7 +55,7 @@ CorrectedGyroSensor::CorrectedGyroSensor(sensor_t const* list, size_t count)
bool CorrectedGyroSensor::process(sensors_event_t* outEvent,
        const sensors_event_t& event)
{
    if (event.type == SENSOR_TYPE_GYROSCOPE) {
    if (event.sensor == mGyro.getHandle()) {
        const vec3_t bias(mSensorFusion.getGyroBias());
        *outEvent = event;
        outEvent->data[0] -= bias.x;
+1 −1
Original line number Diff line number Diff line
@@ -54,7 +54,7 @@ GravitySensor::GravitySensor(sensor_t const* list, size_t count) {
bool GravitySensor::process(sensors_event_t* outEvent,
        const sensors_event_t& event)
{
    if (event.type == SENSOR_TYPE_ACCELEROMETER) {
    if (event.sensor == mAccelerometer.getHandle()) {
        vec3_t g;
        if (!mSensorFusion.hasEstimate(FUSION_NOMAG))
            return false;
+1 −0
Original line number Diff line number Diff line
@@ -39,6 +39,7 @@ public:
    virtual bool process(sensors_event_t* outEvent, const sensors_event_t& event) override;
    virtual status_t activate(void* ident, bool enabled) override;
    virtual status_t setDelay(void* ident, int handle, int64_t ns) override;
    int32_t getAccelHandle() const { return mAccelerometer.getHandle(); }
};

// ---------------------------------------------------------------------------
+1 −1
Original line number Diff line number Diff line
@@ -63,7 +63,7 @@ LimitedAxesImuSensor::LimitedAxesImuSensor(sensor_t const* list, size_t count,
}

bool LimitedAxesImuSensor::process(sensors_event_t* outEvent, const sensors_event_t& event) {
    if (event.type == mImu3dSensor.getType()) {
    if (event.sensor == mImu3dSensor.getHandle()) {
        *outEvent = event;
        size_t imu3dDataSize = SensorServiceUtil::eventSizeBySensorType(mImu3dSensor.getType());
        outEvent->data[0 + imu3dDataSize] = 1;
+1 −1
Original line number Diff line number Diff line
@@ -50,7 +50,7 @@ bool LinearAccelerationSensor::process(sensors_event_t* outEvent,
        const sensors_event_t& event)
{
    bool result = mGravitySensor.process(outEvent, event);
    if (result && event.type == SENSOR_TYPE_ACCELEROMETER) {
    if (result && event.sensor == mGravitySensor.getAccelHandle()) {
        outEvent->data[0] = event.acceleration.x - outEvent->data[0];
        outEvent->data[1] = event.acceleration.y - outEvent->data[1];
        outEvent->data[2] = event.acceleration.z - outEvent->data[2];
Loading