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
This commit is contained in:
Mathias Agopian 2012-06-28 19:46:54 -07:00
parent bdf277355d
commit 33264868ba
2 changed files with 28 additions and 7 deletions

View File

@ -117,17 +117,16 @@ void SensorService::onFirstRef()
// these are optional // these are optional
registerVirtualSensor( new OrientationSensor() ); registerVirtualSensor( new OrientationSensor() );
registerVirtualSensor( new CorrectedGyroSensor(list, count) ); 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 // build the sensor list returned to users
mUserSensorList = mSensorList; mUserSensorList = mSensorList;
if (hasGyro) {
// virtual debugging sensors are not added to mUserSensorList
registerVirtualSensor( new GyroDriftSensor() );
}
if (hasGyro && if (hasGyro &&
(virtualSensorsNeeds & (1<<SENSOR_TYPE_ROTATION_VECTOR))) { (virtualSensorsNeeds & (1<<SENSOR_TYPE_ROTATION_VECTOR))) {
// if we have the fancy sensor fusion, and it's not provided by the // 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); run("SensorService", PRIORITY_URGENT_DISPLAY);
mInitCheck = NO_ERROR; mInitCheck = NO_ERROR;
} }
@ -358,6 +373,11 @@ String8 SensorService::getSensorName(int handle) const {
Vector<Sensor> SensorService::getSensorList() Vector<Sensor> SensorService::getSensorList()
{ {
char value[PROPERTY_VALUE_MAX];
property_get("debug.sensors", value, "0");
if (atoi(value)) {
return mUserSensorListDebug;
}
return mUserSensorList; return mUserSensorList;
} }

View File

@ -113,6 +113,7 @@ class SensorService :
// constants // constants
Vector<Sensor> mSensorList; Vector<Sensor> mSensorList;
Vector<Sensor> mUserSensorListDebug;
Vector<Sensor> mUserSensorList; Vector<Sensor> mUserSensorList;
DefaultKeyedVector<int, SensorInterface*> mSensorMap; DefaultKeyedVector<int, SensorInterface*> mSensorMap;
Vector<SensorInterface *> mVirtualSensorList; Vector<SensorInterface *> mVirtualSensorList;