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

Commit 33264868 authored by Mathias Agopian's avatar Mathias Agopian
Browse files

add a way to enable debugging sensors at runtime

if debug.sensors is true, extra debugging
sensors are enabled and HAL provided sensor fusion
is disabled

Change-Id: I9b093424edb8c5363d1337237cdf6abe4ab266f9
parent bdf27735
Loading
Loading
Loading
Loading
+27 −7
Original line number Diff line number Diff line
@@ -117,17 +117,16 @@ void SensorService::onFirstRef()
                // these are optional
                registerVirtualSensor( new OrientationSensor() );
                registerVirtualSensor( new CorrectedGyroSensor(list, count) );

                // virtual debugging sensors...
                char value[PROPERTY_VALUE_MAX];
                property_get("debug.sensors", value, "0");
                if (atoi(value)) {
                    registerVirtualSensor( new GyroDriftSensor() );
                }
            }

            // build the sensor list returned to users
            mUserSensorList = mSensorList;

            if (hasGyro) {
                // virtual debugging sensors are not added to mUserSensorList
                registerVirtualSensor( new GyroDriftSensor() );
            }

            if (hasGyro &&
                    (virtualSensorsNeeds & (1<<SENSOR_TYPE_ROTATION_VECTOR))) {
                // if we have the fancy sensor fusion, and it's not provided by the
@@ -138,6 +137,22 @@ void SensorService::onFirstRef()
                }
            }

            // debugging sensor list
            for (size_t i=0 ; i<mSensorList.size() ; i++) {
                switch (mSensorList[i].getType()) {
                    case SENSOR_TYPE_GRAVITY:
                    case SENSOR_TYPE_LINEAR_ACCELERATION:
                    case SENSOR_TYPE_ROTATION_VECTOR:
                        if (strstr(mSensorList[i].getVendor().string(), "Google")) {
                            mUserSensorListDebug.add(mSensorList[i]);
                        }
                        break;
                    default:
                        mUserSensorListDebug.add(mSensorList[i]);
                        break;
                }
            }

            run("SensorService", PRIORITY_URGENT_DISPLAY);
            mInitCheck = NO_ERROR;
        }
@@ -358,6 +373,11 @@ String8 SensorService::getSensorName(int handle) const {

Vector<Sensor> SensorService::getSensorList()
{
    char value[PROPERTY_VALUE_MAX];
    property_get("debug.sensors", value, "0");
    if (atoi(value)) {
        return mUserSensorListDebug;
    }
    return mUserSensorList;
}

+1 −0
Original line number Diff line number Diff line
@@ -113,6 +113,7 @@ class SensorService :

    // constants
    Vector<Sensor> mSensorList;
    Vector<Sensor> mUserSensorListDebug;
    Vector<Sensor> mUserSensorList;
    DefaultKeyedVector<int, SensorInterface*> mSensorMap;
    Vector<SensorInterface *> mVirtualSensorList;