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

Commit 7b2b32f2 authored by Mathias Agopian's avatar Mathias Agopian
Browse files

sensorservice: be more robust when there are no sensor h/w

Bug: 5030108
Change-Id: I45b85b3c492b9268cb0ae44d2e5fc8c708b6e66e
parent 0be7a262
Loading
Loading
Loading
Loading
+17 −15
Original line number Diff line number Diff line
@@ -28,8 +28,9 @@ SensorFusion::SensorFusion()
      mEnabled(false), mGyroTime(0)
{
    sensor_t const* list;
    size_t count = mSensorDevice.getSensorList(&list);
    for (size_t i=0 ; i<count ; i++) {
    ssize_t count = mSensorDevice.getSensorList(&list);
    if (count > 0) {
        for (size_t i=0 ; i<size_t(count) ; i++) {
            if (list[i].type == SENSOR_TYPE_ACCELEROMETER) {
                mAcc = Sensor(list + i);
            }
@@ -46,6 +47,7 @@ SensorFusion::SensorFusion()
        }
        mFusion.init();
    }
}

void SensorFusion::process(const sensors_event_t& event) {
    if (event.type == SENSOR_TYPE_GYROSCOPE) {
+63 −60
Original line number Diff line number Diff line
@@ -70,16 +70,18 @@ void SensorService::onFirstRef()
    SensorDevice& dev(SensorDevice::getInstance());

    if (dev.initCheck() == NO_ERROR) {
        sensor_t const* list;
        ssize_t count = dev.getSensorList(&list);
        if (count > 0) {
            ssize_t orientationIndex = -1;
            bool hasGyro = false;
            uint32_t virtualSensorsNeeds =
                    (1<<SENSOR_TYPE_GRAVITY) |
                    (1<<SENSOR_TYPE_LINEAR_ACCELERATION) |
                    (1<<SENSOR_TYPE_ROTATION_VECTOR);
        sensor_t const* list;
        int count = dev.getSensorList(&list);

            mLastEventSeen.setCapacity(count);
        for (int i=0 ; i<count ; i++) {
            for (ssize_t i=0 ; i<count ; i++) {
                registerSensor( new HardwareSensor(list[i]) );
                switch (list[i].type) {
                    case SENSOR_TYPE_ORIENTATION:
@@ -139,6 +141,7 @@ void SensorService::onFirstRef()
            mInitCheck = NO_ERROR;
        }
    }
}

void SensorService::registerSensor(SensorInterface* s)
{