[-]
[+]
|
Changed |
_service:tar_git:sensorfw.changes
|
|
[-]
[+]
|
Changed |
_service:tar_git:sensorfw-qt5-hybris.spec
^
|
|
[-]
[+]
|
Changed |
_service:tar_git:hybris-libsensorfw-qt5-0.10.8.tar.bz2/adaptors/accelerometeradaptor/accelerometeradaptor.cpp
^
|
@@ -44,8 +44,8 @@
accelerometerBuffer_ = new DeviceAdaptorRingBuffer<OrientationData>(1);
setAdaptedSensor("accelerometer", "Internal accelerometer coordinates", accelerometerBuffer_);
setDescription("Input device accelerometer adaptor");
- powerStatePath_ = Config::configuration()->value("accelerometer/powerstate_path").toByteArray();
- accelMultiplier = Config::configuration()->value("accelerometer/multiplier", QVariant(1)).toReal();
+ powerStatePath_ = SensorFrameworkConfig::configuration()->value("accelerometer/powerstate_path").toByteArray();
+ accelMultiplier = SensorFrameworkConfig::configuration()->value("accelerometer/multiplier", QVariant(1)).toReal();
}
AccelerometerAdaptor::~AccelerometerAdaptor()
|
[-]
[+]
|
Changed |
_service:tar_git:hybris-libsensorfw-qt5-0.10.8.tar.bz2/adaptors/alsadaptor-ascii/alsadaptor-ascii.cpp
^
|
@@ -52,7 +52,7 @@
setDescription("Ambient light");
// Get range from a file, if the path is found in configuration
- QString rangeFilePath_ = Config::configuration()->value("als/range_file_path",QVariant("")).toString();
+ QString rangeFilePath_ = SensorFrameworkConfig::configuration()->value("als/range_file_path",QVariant("")).toString();
if (rangeFilePath_ != "") {
QFile sysFile(rangeFilePath_);
@@ -66,8 +66,8 @@
sensordLogT() << "Ambient light range: " << range;
}
}
- powerStatePath = Config::configuration()->value("als/powerstate_path").toByteArray();
- powerMode = Config::configuration()->value("als/mode").toByteArray();
+ powerStatePath = SensorFrameworkConfig::configuration()->value("als/powerstate_path").toByteArray();
+ powerMode = SensorFrameworkConfig::configuration()->value("als/mode").toByteArray();
}
ALSAdaptorAscii::~ALSAdaptorAscii()
|
[-]
[+]
|
Changed |
_service:tar_git:hybris-libsensorfw-qt5-0.10.8.tar.bz2/adaptors/alsadaptor-evdev/alsevdevadaptor.cpp
^
|
@@ -43,7 +43,7 @@
alsBuffer_ = new DeviceAdaptorRingBuffer<TimedUnsigned>(1);
setAdaptedSensor("als", "Internal ambient light sensor lux values", alsBuffer_);
setDescription("Input device als adaptor");
- powerStatePath_ = Config::configuration()->value("als/powerstate_path").toByteArray();
+ powerStatePath_ = SensorFrameworkConfig::configuration()->value("als/powerstate_path").toByteArray();
introduceAvailableDataRange(DataRange(0, 4095, 1));
setDefaultInterval(10);
}
|
[-]
[+]
|
Changed |
_service:tar_git:hybris-libsensorfw-qt5-0.10.8.tar.bz2/adaptors/alsadaptor/alsadaptor.cpp
^
|
@@ -62,8 +62,8 @@
alsBuffer_ = new DeviceAdaptorRingBuffer<TimedUnsigned>(1);
setAdaptedSensor("als", "Internal ambient light sensor lux values", alsBuffer_);
setDescription("Ambient light");
- deviceType_ = (DeviceType)Config::configuration()->value<int>("als/driver_type", DeviceUnknown);
- powerStatePath_ = Config::configuration()->value("als/powerstate_path").toByteArray();
+ deviceType_ = (DeviceType)SensorFrameworkConfig::configuration()->value<int>("als/driver_type", DeviceUnknown);
+ powerStatePath_ = SensorFrameworkConfig::configuration()->value("als/powerstate_path").toByteArray();
#ifdef SENSORFW_MCE_WATCHER
dbusIfc = new QDBusInterface(MCE_SERVICE, MCE_REQUEST_PATH, MCE_REQUEST_IF,
|
[-]
[+]
|
Changed |
_service:tar_git:hybris-libsensorfw-qt5-0.10.8.tar.bz2/adaptors/gyroscopeadaptor-evdev/gyroevdevadaptor.cpp
^
|
@@ -43,7 +43,7 @@
gyroscopeBuffer_ = new DeviceAdaptorRingBuffer<TimedXyzData>(1);
setAdaptedSensor("gyroscope", "Internal gyroscope values", gyroscopeBuffer_);
setDescription("Input device gyroscope adaptor");
- powerStatePath_ = Config::configuration()->value("gyroscope/powerstate_path").toByteArray();
+ powerStatePath_ = SensorFrameworkConfig::configuration()->value("gyroscope/powerstate_path").toByteArray();
// introduceAvailableDataRange(DataRange(0, 4095, 1));
setDefaultInterval(10);
}
|
[-]
[+]
|
Changed |
_service:tar_git:hybris-libsensorfw-qt5-0.10.8.tar.bz2/adaptors/gyroscopeadaptor/gyroscopeadaptor.cpp
^
|
@@ -41,7 +41,7 @@
gyroscopeBuffer_ = new DeviceAdaptorRingBuffer<TimedXyzData>(1);
setAdaptedSensor("gyroscope", "l3g4200dh", gyroscopeBuffer_);
setDescription("Sysfs Gyroscope adaptor (l3g4200dh)");
- dataRatePath_ = Config::configuration()->value("gyroscope/path_datarate").toByteArray();
+ dataRatePath_ = SensorFrameworkConfig::configuration()->value("gyroscope/path_datarate").toByteArray();
}
GyroscopeAdaptor::~GyroscopeAdaptor()
|
[-]
[+]
|
Changed |
_service:tar_git:hybris-libsensorfw-qt5-0.10.8.tar.bz2/adaptors/humidityadaptor/humidityadaptor.cpp
^
|
@@ -40,7 +40,7 @@
humidityBuffer_ = new DeviceAdaptorRingBuffer<TimedUnsigned>(1);
setAdaptedSensor("humidity", "Relative Humidity values", humidityBuffer_);
setDescription("Input device humidity adaptor");
- powerStatePath_ = Config::configuration()->value("humidity/powerstate_path").toByteArray();
+ powerStatePath_ = SensorFrameworkConfig::configuration()->value("humidity/powerstate_path").toByteArray();
introduceAvailableDataRange(DataRange(0, 4095, 1));
setDefaultInterval(10);
}
|
[-]
[+]
|
Changed |
_service:tar_git:hybris-libsensorfw-qt5-0.10.8.tar.bz2/adaptors/hybrisaccelerometer/hybrisaccelerometeradaptor.cpp
^
|
@@ -33,7 +33,7 @@
setAdaptedSensor("accelerometer", "Internal accelerometer coordinates", buffer);
setDescription("Hybris accelerometer");
- powerStatePath = Config::configuration()->value("accelerometer/powerstate_path").toByteArray();
+ powerStatePath = SensorFrameworkConfig::configuration()->value("accelerometer/powerstate_path").toByteArray();
// setDefaultInterval(50);
}
@@ -44,20 +44,19 @@
bool HybrisAccelerometerAdaptor::startSensor()
{
- if(!powerStatePath.isEmpty())
- writeToFile(powerStatePath, "1");
if (!(HybrisAdaptor::startSensor()))
return false;
-
+ if (isRunning() && !powerStatePath.isEmpty())
+ writeToFile(powerStatePath, "1");
sensordLogD() << "Hybris AccelAdaptor start\n";
return true;
}
void HybrisAccelerometerAdaptor::stopSensor()
{
- if(!powerStatePath.isEmpty())
- writeToFile(powerStatePath, "0");
HybrisAdaptor::stopSensor();
+ if (!isRunning() && !powerStatePath.isEmpty())
+ writeToFile(powerStatePath, "0");
sensordLogD() << "Hybris AccelAdaptor stop\n";
}
|
[-]
[+]
|
Changed |
_service:tar_git:hybris-libsensorfw-qt5-0.10.8.tar.bz2/adaptors/hybrisalsadaptor/hybrisalsadaptor.cpp
^
|
@@ -37,7 +37,7 @@
buffer = new DeviceAdaptorRingBuffer<TimedUnsigned>(1);
setAdaptedSensor("als", "Internal ambient light sensor lux values", buffer);
setDescription("Hybris als");
- powerStatePath = Config::configuration()->value("als/powerstate_path").toByteArray();
+ powerStatePath = SensorFrameworkConfig::configuration()->value("als/powerstate_path").toByteArray();
if (!powerStatePath.isEmpty() && !QFile::exists(powerStatePath))
{
sensordLogW() << "Path does not exists: " << powerStatePath;
@@ -52,11 +52,10 @@
bool HybrisAlsAdaptor::startSensor()
{
- if(!powerStatePath.isEmpty())
- writeToFile(powerStatePath, "1");
if (!(HybrisAdaptor::startSensor()))
return false;
-
+ if (isRunning() && !powerStatePath.isEmpty())
+ writeToFile(powerStatePath, "1");
sensordLogD() << "Hybris HybrisAlsAdaptor start\n";
return true;
}
@@ -120,9 +119,9 @@
void HybrisAlsAdaptor::stopSensor()
{
- if(!powerStatePath.isEmpty())
- writeToFile(powerStatePath, "0");
HybrisAdaptor::stopSensor();
+ if (!isRunning() && !powerStatePath.isEmpty())
+ writeToFile(powerStatePath, "0");
sensordLogD() << "Hybris HybrisAlsAdaptor stop\n";
}
|
[-]
[+]
|
Changed |
_service:tar_git:hybris-libsensorfw-qt5-0.10.8.tar.bz2/adaptors/hybrisgyroscopeadaptor/hybrisgyroscopeadaptor.cpp
^
|
@@ -35,7 +35,7 @@
setAdaptedSensor("gyroscopeadaptor", "Internal gyroscope coordinates", buffer);
setDescription("Hybris gyroscope");
- powerStatePath = Config::configuration()->value("gyroscope/powerstate_path").toByteArray();
+ powerStatePath = SensorFrameworkConfig::configuration()->value("gyroscope/powerstate_path").toByteArray();
if (!powerStatePath.isEmpty() && !QFile::exists(powerStatePath))
{
sensordLogW() << "Path does not exists: " << powerStatePath;
@@ -51,20 +51,19 @@
bool HybrisGyroscopeAdaptor::startSensor()
{
- if(!powerStatePath.isEmpty())
- writeToFile(powerStatePath, "1");
if (!(HybrisAdaptor::startSensor()))
return false;
-
+ if (isRunning() && !powerStatePath.isEmpty())
+ writeToFile(powerStatePath, "1");
sensordLogD() << "HybrisGyroscopeAdaptor start\n";
return true;
}
void HybrisGyroscopeAdaptor::stopSensor()
{
- if(!powerStatePath.isEmpty())
- writeToFile(powerStatePath, "0");
HybrisAdaptor::stopSensor();
+ if (!isRunning() &&!powerStatePath.isEmpty())
+ writeToFile(powerStatePath, "0");
sensordLogD() << "HybrisGyroscopeAdaptor stop\n";
}
|
[-]
[+]
|
Changed |
_service:tar_git:hybris-libsensorfw-qt5-0.10.8.tar.bz2/adaptors/hybrismagnetometeradaptor/hybrismagnetometeradaptor.cpp
^
|
@@ -31,7 +31,7 @@
setAdaptedSensor("magnetometer", "Internal magnetometer coordinates", buffer);
setDescription("Hybris magnetometer");
- powerStatePath = Config::configuration()->value("magnetometer/powerstate_path").toByteArray();
+ powerStatePath = SensorFrameworkConfig::configuration()->value("magnetometer/powerstate_path").toByteArray();
if (!powerStatePath.isEmpty() && !QFile::exists(powerStatePath))
{
sensordLogW() << "Path does not exists: " << powerStatePath;
@@ -48,20 +48,19 @@
bool HybrisMagnetometerAdaptor::startSensor()
{
- if(!powerStatePath.isEmpty())
- writeToFile(powerStatePath, "1");
if (!(HybrisAdaptor::startSensor()))
return false;
-
+ if (isRunning() &&!powerStatePath.isEmpty())
+ writeToFile(powerStatePath, "1");
sensordLogD() << "HybrisMagnetometerAdaptor start\n";
return true;
}
void HybrisMagnetometerAdaptor::stopSensor()
{
- if(!powerStatePath.isEmpty())
- writeToFile(powerStatePath, "0");
HybrisAdaptor::stopSensor();
+ if (!isRunning() && !powerStatePath.isEmpty())
+ writeToFile(powerStatePath, "0");
sensordLogD() << "HybrisMagnetometerAdaptor stop\n";
}
|
[-]
[+]
|
Changed |
_service:tar_git:hybris-libsensorfw-qt5-0.10.8.tar.bz2/adaptors/hybrisorientationadaptor/hybrisorientationadaptor.cpp
^
|
@@ -48,7 +48,7 @@
setAdaptedSensor("hybrisorientation", "Internal orientation coordinates", buffer);
setDescription("Hybris orientation");
- powerStatePath = Config::configuration()->value("orientation/powerstate_path").toByteArray();
+ powerStatePath = SensorFrameworkConfig::configuration()->value("orientation/powerstate_path").toByteArray();
if (!powerStatePath.isEmpty() && !QFile::exists(powerStatePath))
{
sensordLogW() << "Path does not exists: " << powerStatePath;
@@ -64,20 +64,19 @@
bool HybrisOrientationAdaptor::startSensor()
{
- if(!powerStatePath.isEmpty())
- writeToFile(powerStatePath, "1");
if (!(HybrisAdaptor::startSensor()))
return false;
-
+ if (isRunning() && !powerStatePath.isEmpty())
+ writeToFile(powerStatePath, "1");
sensordLogD() << "Hybris OrientationAdaptor start\n";
return true;
}
void HybrisOrientationAdaptor::stopSensor()
{
- if(!powerStatePath.isEmpty())
- writeToFile(powerStatePath, "0");
HybrisAdaptor::stopSensor();
+ if (!isRunning() && !powerStatePath.isEmpty())
+ writeToFile(powerStatePath, "0");
sensordLogD() << "Hybris OrientationAdaptor stop\n";
}
|
[-]
[+]
|
Changed |
_service:tar_git:hybris-libsensorfw-qt5-0.10.8.tar.bz2/adaptors/hybrispressureadaptor/hybrispressureadaptor.cpp
^
|
@@ -35,7 +35,7 @@
buffer = new DeviceAdaptorRingBuffer<TimedUnsigned>(1);
setAdaptedSensor("pressure", "Internal ambient pressure sensor values", buffer);
setDescription("Hybris pressure");
- powerStatePath = Config::configuration()->value("pressure/powerstate_path").toByteArray();
+ powerStatePath = SensorFrameworkConfig::configuration()->value("pressure/powerstate_path").toByteArray();
if (!powerStatePath.isEmpty() && !QFile::exists(powerStatePath))
{
sensordLogW() << "Path does not exists: " << powerStatePath;
@@ -50,20 +50,19 @@
bool HybrisPressureAdaptor::startSensor()
{
- if(!powerStatePath.isEmpty())
- writeToFile(powerStatePath, "1");
if (!(HybrisAdaptor::startSensor()))
return false;
-
+ if (isRunning() && !powerStatePath.isEmpty())
+ writeToFile(powerStatePath, "1");
sensordLogD() << "Hybris HybrisPressureAdaptor start\n";
return true;
}
void HybrisPressureAdaptor::stopSensor()
{
- if(!powerStatePath.isEmpty())
- writeToFile(powerStatePath, "0");
HybrisAdaptor::stopSensor();
+ if (!isRunning() && !powerStatePath.isEmpty())
+ writeToFile(powerStatePath, "0");
sensordLogD() << "Hybris HybrisPressureAdaptor stop\n";
}
|
[-]
[+]
|
Changed |
_service:tar_git:hybris-libsensorfw-qt5-0.10.8.tar.bz2/adaptors/hybrisproximityadaptor/hybrisproximityadaptor.cpp
^
|
@@ -39,7 +39,7 @@
setAdaptedSensor("proximity", "Internal proximity coordinates", buffer);
setDescription("Hybris proximity");
- powerStatePath = Config::configuration()->value("proximity/powerstate_path").toByteArray();
+ powerStatePath = SensorFrameworkConfig::configuration()->value("proximity/powerstate_path").toByteArray();
if (!powerStatePath.isEmpty() && !QFile::exists(powerStatePath))
{
sensordLogW() << "Path does not exists: " << powerStatePath;
@@ -57,10 +57,10 @@
bool HybrisProximityAdaptor::startSensor()
{
- if(!powerStatePath.isEmpty())
- writeToFile(powerStatePath, "1");
if (!(HybrisAdaptor::startSensor()))
return false;
+ if (isRunning() && !powerStatePath.isEmpty())
+ writeToFile(powerStatePath, "1");
sensordLogD() << "HybrisProximityAdaptor start\n";
return true;
}
@@ -127,9 +127,9 @@
void HybrisProximityAdaptor::stopSensor()
{
- if(!powerStatePath.isEmpty())
- writeToFile(powerStatePath, "0");
HybrisAdaptor::stopSensor();
+ if (!isRunning() && !powerStatePath.isEmpty())
+ writeToFile(powerStatePath, "0");
sensordLogD() << "HybrisProximityAdaptor stop\n";
}
@@ -138,7 +138,7 @@
ProximityData *d = buffer->nextSlot();
d->timestamp_ = quint64(data.timestamp * .001);
bool near = false;
- if (data.distance < maxRange) {
+ if (data.distance < maxRange()) {
near = true;
}
d->withinProximity_ = near;
|
[-]
[+]
|
Changed |
_service:tar_git:hybris-libsensorfw-qt5-0.10.8.tar.bz2/adaptors/hybrisstepcounteradaptor/hybrisstepcounteradaptor.cpp
^
|
@@ -41,7 +41,7 @@
buffer = new DeviceAdaptorRingBuffer<TimedUnsigned>(1);
setAdaptedSensor("stepcounter", "Internal step counter steps since reboot", buffer);
setDescription("Hybris step counter");
- powerStatePath = Config::configuration()->value("stepcounter/powerstate_path").toByteArray();
+ powerStatePath = SensorFrameworkConfig::configuration()->value("stepcounter/powerstate_path").toByteArray();
if (!powerStatePath.isEmpty() && !QFile::exists(powerStatePath))
{
sensordLogW() << "Path does not exists: " << powerStatePath;
@@ -56,11 +56,10 @@
bool HybrisStepCounterAdaptor::startSensor()
{
- if(!powerStatePath.isEmpty())
- writeToFile(powerStatePath, "1");
if (!(HybrisAdaptor::startSensor()))
return false;
-
+ if (isRunning() && !powerStatePath.isEmpty())
+ writeToFile(powerStatePath, "1");
sensordLogD() << "Hybris HybrisStepCounterAdaptor start\n";
return true;
}
@@ -72,9 +71,9 @@
void HybrisStepCounterAdaptor::stopSensor()
{
- if(!powerStatePath.isEmpty())
- writeToFile(powerStatePath, "0");
HybrisAdaptor::stopSensor();
+ if (!isRunning() && !powerStatePath.isEmpty())
+ writeToFile(powerStatePath, "0");
sensordLogD() << "Hybris HybrisStepCounterAdaptor stop\n";
}
|
[-]
[+]
|
Changed |
_service:tar_git:hybris-libsensorfw-qt5-0.10.8.tar.bz2/adaptors/iioadaptor/iioadaptor.cpp
^
|
@@ -81,7 +81,7 @@
if (deviceId.startsWith("accel")) {
const QString name = "accelerometer";
- const QString inputMatch = Config::configuration()->value<QString>(name + "/input_match");
+ const QString inputMatch = SensorFrameworkConfig::configuration()->value<QString>(name + "/input_match");
qDebug() << "input_match" << inputMatch;
devNodeNumber = findSensor(inputMatch);
@@ -96,7 +96,7 @@
}
else if (deviceId.startsWith("gyro")) {
const QString name = "gyroscope";
- const QString inputMatch = Config::configuration()->value<QString>(name + "/input_match");
+ const QString inputMatch = SensorFrameworkConfig::configuration()->value<QString>(name + "/input_match");
qDebug() << "input_match" << inputMatch;
devNodeNumber = findSensor(inputMatch);
@@ -110,7 +110,7 @@
}
else if (deviceId.startsWith("mag")) {
const QString name = "magnetometer";
- const QString inputMatch = Config::configuration()->value<QString>(name + "/input_match");
+ const QString inputMatch = SensorFrameworkConfig::configuration()->value<QString>(name + "/input_match");
qDebug() << "input_match" << inputMatch;
devNodeNumber = findSensor(inputMatch);
@@ -125,7 +125,7 @@
}
else if (deviceId.startsWith("als")) {
const QString name = "als";
- const QString inputMatch = Config::configuration()->value<QString>(name + "/input_match");
+ const QString inputMatch = SensorFrameworkConfig::configuration()->value<QString>(name + "/input_match");
devNodeNumber = findSensor(inputMatch);
if (devNodeNumber!= -1) {
|
[-]
[+]
|
Changed |
_service:tar_git:hybris-libsensorfw-qt5-0.10.8.tar.bz2/adaptors/lidsensoradaptor-evdev/lidsensoradaptor-evdev.cpp
^
|
@@ -47,7 +47,7 @@
{
lidBuffer_ = new DeviceAdaptorRingBuffer<LidData>(1);
setAdaptedSensor("lidsensor", "Lid state", lidBuffer_);
- powerStatePath_ = Config::configuration()->value("lidsensor/powerstate_path").toByteArray();
+ powerStatePath_ = SensorFrameworkConfig::configuration()->value("lidsensor/powerstate_path").toByteArray();
}
@@ -76,7 +76,7 @@
void LidSensorAdaptorEvdev::init()
{
qDebug() << Q_FUNC_INFO << name();
- QStringList strList = Config::configuration()->value<QStringList>(name() + "/input_match");
+ QStringList strList = SensorFrameworkConfig::configuration()->value<QStringList>(name() + "/input_match");
qDebug() << strList;
foreach (const QString str, strList) {
if (!getInputDevices(str)) {
|
[-]
[+]
|
Changed |
_service:tar_git:hybris-libsensorfw-qt5-0.10.8.tar.bz2/adaptors/magnetometeradaptor-evdev/magnetometerevdevadaptor.cpp
^
|
@@ -42,7 +42,7 @@
magnetometerBuffer_ = new DeviceAdaptorRingBuffer<CalibratedMagneticFieldData>(1);
setAdaptedSensor("magnetometer", "Internal magnetometer coordinates", magnetometerBuffer_);
setDescription("Input device magnetometer adaptor");
- powerStatePath_ = Config::configuration()->value("magnetometer/powerstate_path").toByteArray();
+ powerStatePath_ = SensorFrameworkConfig::configuration()->value("magnetometer/powerstate_path").toByteArray();
// introduceAvailableDataRange(DataRange(0, 4095, 1));
setDefaultInterval(10);
}
|
[-]
[+]
|
Changed |
_service:tar_git:hybris-libsensorfw-qt5-0.10.8.tar.bz2/adaptors/magnetometeradaptor-ncdk/magnetometeradaptor-ncdk.cpp
^
|
@@ -34,9 +34,9 @@
SysfsAdaptor(id, SysfsAdaptor::IntervalMode),
powerState_(false)
{
- intervalCompensation_ = Config::configuration()->value<int>("magnetometer/interval_compensation", 0);
- powerStateFilePath_ = Config::configuration()->value<QByteArray>("magnetometer/path_power_state", "");
- sensAdjFilePath_ = Config::configuration()->value<QByteArray>("magnetometer/path_sens_adjust", "");
+ intervalCompensation_ = SensorFrameworkConfig::configuration()->value<int>("magnetometer/interval_compensation", 0);
+ powerStateFilePath_ = SensorFrameworkConfig::configuration()->value<QByteArray>("magnetometer/path_power_state", "");
+ sensAdjFilePath_ = SensorFrameworkConfig::configuration()->value<QByteArray>("magnetometer/path_sens_adjust", "");
magnetometerBuffer_ = new DeviceAdaptorRingBuffer<CalibratedMagneticFieldData>(128);
setAdaptedSensor("magnetometer", "Internal magnetometer coordinates", magnetometerBuffer_);
setDescription("Magnetometer adaptor (ak8975) for NCDK");
@@ -44,7 +44,7 @@
//get sensitivity adjustment
getSensitivityAdjustment(x_adj, y_adj, z_adj);
- overflowLimit_ = Config::configuration()->value<int>("magnetometer/overflow_limit", 8000);
+ overflowLimit_ = SensorFrameworkConfig::configuration()->value<int>("magnetometer/overflow_limit", 8000);
}
MagnetometerAdaptorNCDK::~MagnetometerAdaptorNCDK()
|
[-]
[+]
|
Changed |
_service:tar_git:hybris-libsensorfw-qt5-0.10.8.tar.bz2/adaptors/magnetometeradaptor/magnetometeradaptor.cpp
^
|
@@ -46,10 +46,10 @@
MagnetometerAdaptor::MagnetometerAdaptor(const QString& id) :
SysfsAdaptor(id, SysfsAdaptor::IntervalMode, false)
{
- intervalCompensation_ = Config::configuration()->value<int>("magnetometer/interval_compensation", 0);
+ intervalCompensation_ = SensorFrameworkConfig::configuration()->value<int>("magnetometer/interval_compensation", 0);
magnetometerBuffer_ = new DeviceAdaptorRingBuffer<CalibratedMagneticFieldData>(1);
setAdaptedSensor("magnetometer", "Internal magnetometer coordinates", magnetometerBuffer_);
- overflowLimit_ = Config::configuration()->value<int>("magnetometer/overflow_limit", 8000);
+ overflowLimit_ = SensorFrameworkConfig::configuration()->value<int>("magnetometer/overflow_limit", 8000);
setDescription("Input device Magnetometer adaptor (ak897x)");
}
|
[-]
[+]
|
Changed |
_service:tar_git:hybris-libsensorfw-qt5-0.10.8.tar.bz2/adaptors/mpu6050accelerometer/mpu6050accelerometeradaptor.cpp
^
|
@@ -40,21 +40,21 @@
{
struct stat st;
- QString xAxisPath = Config::configuration()->value("accelerometer/x_axis_path").toString ();
+ QString xAxisPath = SensorFrameworkConfig::configuration()->value("accelerometer/x_axis_path").toString ();
if ( lstat (xAxisPath.toLatin1().constData(), &st) < 0 ) {
sensordLogW () << "x_axis_path: " << xAxisPath << " not found";
return;
}
addPath(xAxisPath, X_AXIS);
- QString yAxisPath = Config::configuration()->value("accelerometer/y_axis_path").toString ();
+ QString yAxisPath = SensorFrameworkConfig::configuration()->value("accelerometer/y_axis_path").toString ();
if ( lstat (yAxisPath.toLatin1().constData(), &st) < 0 ) {
sensordLogW () << "y_axis_path: " << yAxisPath << " not found";
return;
}
addPath(yAxisPath, Y_AXIS);
- QString zAxisPath = Config::configuration()->value("accelerometer/z_axis_path").toString ();
+ QString zAxisPath = SensorFrameworkConfig::configuration()->value("accelerometer/z_axis_path").toString ();
if ( lstat (zAxisPath.toLatin1().constData(), &st) < 0 ) {
sensordLogW () << "z_axis_path: " << zAxisPath << " not found";
return;
|
[-]
[+]
|
Changed |
_service:tar_git:hybris-libsensorfw-qt5-0.10.8.tar.bz2/adaptors/oaktrailaccelerometer/oaktrailaccelerometeradaptor.cpp
^
|
@@ -13,7 +13,7 @@
{
struct stat st;
- devPath = Config::configuration ()->value ("oaktrail_acc_sys_path").toString ();
+ devPath = SensorFrameworkConfig::configuration ()->value ("oaktrail_acc_sys_path").toString ();
if ( lstat (devPath.toLatin1().constData(), &st) < 0 ) {
sensordLogW () << devPath << "no found";
return;
|
[-]
[+]
|
Changed |
_service:tar_git:hybris-libsensorfw-qt5-0.10.8.tar.bz2/adaptors/oemtabletaccelerometer/oemtabletaccelerometeradaptor.cpp
^
|
@@ -13,7 +13,7 @@
{
struct stat st;
- devPath = Config::configuration ()->value ("oem_tablet_acc_sys_path").toString ();
+ devPath = SensorFrameworkConfig::configuration ()->value ("oem_tablet_acc_sys_path").toString ();
if ( lstat (devPath.toLatin1().constData(), &st) < 0 ) {
sensordLogW () << devPath << "no found";
return;
|
[-]
[+]
|
Changed |
_service:tar_git:hybris-libsensorfw-qt5-0.10.8.tar.bz2/adaptors/oemtabletalsadaptor-ascii/oemtabletalsadaptor-ascii.cpp
^
|
@@ -16,7 +16,7 @@
const unsigned int DEFAULT_RANGE = 65535;
int range = DEFAULT_RANGE;
- QFile sysFile(Config::configuration()->value("als-ascii_range_sysfs_path").toString());
+ QFile sysFile(SensorFrameworkConfig::configuration()->value("als-ascii_range_sysfs_path").toString());
if (!(sysFile.open(QIODevice::ReadOnly))) {
sensordLogW() << "Unable to config ALS range from sysfs, using default value: " << DEFAULT_RANGE;
@@ -28,7 +28,7 @@
sensordLogT() << "Ambient light range: " << range;
// Locate the actual handle
- QString devPath = Config::configuration()->value("als-ascii_sysfs_path").toString();
+ QString devPath = SensorFrameworkConfig::configuration()->value("als-ascii_sysfs_path").toString();
if (devPath.isEmpty())
{
|
[-]
[+]
|
Changed |
_service:tar_git:hybris-libsensorfw-qt5-0.10.8.tar.bz2/adaptors/pressureadaptor/pressureadaptor.cpp
^
|
@@ -40,7 +40,7 @@
pressureBuffer_ = new DeviceAdaptorRingBuffer<TimedUnsigned>(1);
setAdaptedSensor("pressure", "Pressure values", pressureBuffer_);
setDescription("Input device pressure adaptor");
- powerStatePath_ = Config::configuration()->value("pressure/powerstate_path").toByteArray();
+ powerStatePath_ = SensorFrameworkConfig::configuration()->value("pressure/powerstate_path").toByteArray();
introduceAvailableDataRange(DataRange(0, 4095, 1));
setDefaultInterval(10);
}
|
[-]
[+]
|
Changed |
_service:tar_git:hybris-libsensorfw-qt5-0.10.8.tar.bz2/adaptors/proximityadaptor-evdev/proximityadaptor-evdev.cpp
^
|
@@ -46,7 +46,7 @@
{
proximityBuffer_ = new DeviceAdaptorRingBuffer<ProximityData>(1);
setAdaptedSensor("proximity", "Proximity state", proximityBuffer_);
- powerStatePath_ = Config::configuration()->value("proximity/powerstate_path").toByteArray();
+ powerStatePath_ = SensorFrameworkConfig::configuration()->value("proximity/powerstate_path").toByteArray();
}
ProximityAdaptorEvdev::~ProximityAdaptorEvdev()
|
[-]
[+]
|
Changed |
_service:tar_git:hybris-libsensorfw-qt5-0.10.8.tar.bz2/adaptors/proximityadaptor/proximityadaptor.cpp
^
|
@@ -53,9 +53,9 @@
ProximityAdaptor::ProximityAdaptor(const QString& id) :
SysfsAdaptor(id, SysfsAdaptor::SelectMode, false)
{
- deviceType_ = (DeviceType)Config::configuration()->value<int>("proximity/driver_type", 0);
- threshold_ = Config::configuration()->value<int>("proximity/threshold", 35);
- powerStatePath_ = Config::configuration()->value("proximity/powerstate_path").toByteArray();
+ deviceType_ = (DeviceType)SensorFrameworkConfig::configuration()->value<int>("proximity/driver_type", 0);
+ threshold_ = SensorFrameworkConfig::configuration()->value<int>("proximity/threshold", 35);
+ powerStatePath_ = SensorFrameworkConfig::configuration()->value("proximity/powerstate_path").toByteArray();
proximityBuffer_ = new DeviceAdaptorRingBuffer<ProximityData>(1);
setAdaptedSensor("proximity", "Proximity state", proximityBuffer_);
setDescription("Proximity sensor readings (Dipro sensor)");
|
[-]
[+]
|
Changed |
_service:tar_git:hybris-libsensorfw-qt5-0.10.8.tar.bz2/adaptors/steaccelerometeradaptor/steaccelerometeradaptor.cpp
^
|
@@ -26,8 +26,8 @@
1: +/- 4g (2 mg/LSB)
2: +/- 8g (4 mg/LSB)
*/
- QByteArray rangePath = Config::configuration()->value("accelerometer/range_path").toByteArray();
- range = Config::configuration()->value("accelerometer/range_mode").toByteArray();
+ QByteArray rangePath = SensorFrameworkConfig::configuration()->value("accelerometer/range_path").toByteArray();
+ range = SensorFrameworkConfig::configuration()->value("accelerometer/range_mode").toByteArray();
if(!rangePath.isEmpty()) {
writeToFile(rangePath, range);
}
@@ -44,8 +44,8 @@
7: 400 Hz
*/
- powerStatePath = Config::configuration()->value("accelerometer/mode_path").toByteArray();
- frequency = Config::configuration()->value("accelerometer/frequency_mode").toInt();
+ powerStatePath = SensorFrameworkConfig::configuration()->value("accelerometer/mode_path").toByteArray();
+ frequency = SensorFrameworkConfig::configuration()->value("accelerometer/frequency_mode").toInt();
setDescription("ste accelerometer");
}
|
[-]
[+]
|
Changed |
_service:tar_git:hybris-libsensorfw-qt5-0.10.8.tar.bz2/adaptors/temperatureadaptor/temperatureadaptor.cpp
^
|
@@ -40,7 +40,7 @@
temperatureBuffer_ = new DeviceAdaptorRingBuffer<TimedUnsigned>(1);
setAdaptedSensor("temperature", "Temperature values", temperatureBuffer_);
setDescription("Input device temperature adaptor");
- powerStatePath_ = Config::configuration()->value("temperature/powerstate_path").toByteArray();
+ powerStatePath_ = SensorFrameworkConfig::configuration()->value("temperature/powerstate_path").toByteArray();
introduceAvailableDataRange(DataRange(0, 4095, 1));
setDefaultInterval(10);
}
|
[-]
[+]
|
Changed |
_service:tar_git:hybris-libsensorfw-qt5-0.10.8.tar.bz2/chains/accelerometerchain/accelerometerchain.cpp
^
|
@@ -52,7 +52,7 @@
accelerometerReader_ = new BufferReader<AccelerationData>(1);
// Get the transformation matrix from config file
- QString aconvString = Config::configuration()->value<QString>("accelerometer/transformation_matrix", "");
+ QString aconvString = SensorFrameworkConfig::configuration()->value<QString>("accelerometer/transformation_matrix", "");
if (aconvString.size() > 0)
{
if (!setMatrixFromString(aconvString))
|
[-]
[+]
|
Changed |
_service:tar_git:hybris-libsensorfw-qt5-0.10.8.tar.bz2/chains/compasschain/compasschainplugin.cpp
^
|
@@ -37,7 +37,7 @@
}
QStringList CompassChainPlugin::Dependencies() {
- QByteArray orientationConfiguration = Config::configuration()->value("plugins/orientationadaptor").toByteArray();
+ QByteArray orientationConfiguration = SensorFrameworkConfig::configuration()->value("plugins/orientationadaptor").toByteArray();
if (orientationConfiguration.isEmpty()) {
return QString("accelerometerchain:magcalibrationchain:declinationfilter:downsamplefilter:avgaccfilter").split(":", QString::SkipEmptyParts);
} else {
|
[-]
[+]
|
Changed |
_service:tar_git:hybris-libsensorfw-qt5-0.10.8.tar.bz2/chains/magcalibrationchain/calibrationfilter.cpp
^
|
@@ -47,7 +47,7 @@
minMaxList.insert(1,qMakePair(0,0));
minMaxList.insert(2,qMakePair(0,0));
- manualCalibration = Config::configuration()->value<bool>("magnetometer/needs_calibration", false);
+ manualCalibration = SensorFrameworkConfig::configuration()->value<bool>("magnetometer/needs_calibration", false);
qDebug() << Q_FUNC_INFO << manualCalibration;
#ifdef CALIBRATE_DATA
|
[-]
[+]
|
Changed |
_service:tar_git:hybris-libsensorfw-qt5-0.10.8.tar.bz2/chains/magcalibrationchain/magcalibrationchain.cpp
^
|
@@ -54,16 +54,16 @@
if (magAdaptor)
setValid(magAdaptor->isValid());
-// Config::configuration()->value<int>("magnetometer/interval_compensation", 16);
+// SensorFrameworkConfig::configuration()->value<int>("magnetometer/interval_compensation", 16);
// Get the transformation matrix from config file
- QString aconvString = Config::configuration()->value<QString>("magnetometer/transformation_matrix", "");
+ QString aconvString = SensorFrameworkConfig::configuration()->value<QString>("magnetometer/transformation_matrix", "");
if (aconvString.size() > 0) {
if (!setMatrixFromString(aconvString)) {
sensordLogW() << "Failed to parse 'transformation_matrix' configuration key. Coordinate alignment may be invalid";
}
}
- needsCalibration = Config::configuration()->value<bool>("magnetometer/needs_calibration", true);
+ needsCalibration = SensorFrameworkConfig::configuration()->value<bool>("magnetometer/needs_calibration", true);
calibratedMagnetometerData = new RingBuffer<CalibratedMagneticFieldData>(1);
nameOutputBuffer("calibratedmagnetometerdata", calibratedMagnetometerData);
|
[-]
[+]
|
Changed |
_service:tar_git:hybris-libsensorfw-qt5-0.10.8.tar.bz2/core/config.cpp
^
|
@@ -33,23 +33,23 @@
#include <QDir>
#include <QList>
-static Config *static_configuration = 0;
+static SensorFrameworkConfig *static_configuration = 0;
-Config::Config() {
+SensorFrameworkConfig::SensorFrameworkConfig() {
}
-Config::~Config() {
+SensorFrameworkConfig::~SensorFrameworkConfig() {
}
-void Config::clearConfig() {
+void SensorFrameworkConfig::clearConfig() {
m_settings.clear();
}
-bool Config::loadConfig(const QString &defConfigPath, const QString &configDPath) {
+bool SensorFrameworkConfig::loadConfig(const QString &defConfigPath, const QString &configDPath) {
/* Not having config files is ok, failing to load one that exists is not */
bool ret = true;
if (!static_configuration) {
- static_configuration = new Config();
+ static_configuration = new SensorFrameworkConfig();
}
/* Process config.d dir in alnum order */
if (!configDPath.isEmpty()) {
@@ -68,7 +68,7 @@
return ret;
}
-bool Config::loadConfigFile(const QString &configFileName) {
+bool SensorFrameworkConfig::loadConfigFile(const QString &configFileName) {
/* Success means the file was loaded and processed without hiccups */
bool loaded = false;
if (!QFile::exists(configFileName)) {
@@ -90,7 +90,7 @@
return loaded;
}
-QVariant Config::value(const QString &key) const {
+QVariant SensorFrameworkConfig::value(const QString &key) const {
QVariant var = m_settings.value(key, QVariant());
if(var.isValid()) {
sensordLogT() << "Value for key" << key << ":" << var.toString();
@@ -98,25 +98,25 @@
return var;
}
-QStringList Config::groups() const
+QStringList SensorFrameworkConfig::groups() const
{
QStringList groups = m_settings.childGroups();
return groups;
}
-Config *Config::configuration() {
+SensorFrameworkConfig *SensorFrameworkConfig::configuration() {
if (!static_configuration) {
sensordLogW() << "Configuration has not been loaded";
}
return static_configuration;
}
-void Config::close() {
+void SensorFrameworkConfig::close() {
delete static_configuration;
static_configuration = 0;
}
-bool Config::exists(const QString &key) const
+bool SensorFrameworkConfig::exists(const QString &key) const
{
return value(key).isValid();
}
|
[-]
[+]
|
Changed |
_service:tar_git:hybris-libsensorfw-qt5-0.10.8.tar.bz2/core/config.h
^
|
@@ -35,16 +35,16 @@
/**
* Sensord configuration parser. Configuration is read and parsed with
- * the QSettings class. Config is a singleton instance to which configuration
+ * the QSettings class. SensorFrameworkConfig is a singleton instance to which configuration
* is loaded once during startup.
*/
-class Config
+class SensorFrameworkConfig
{
public:
/**
* Destructor.
*/
- ~Config();
+ ~SensorFrameworkConfig();
/**
* Find value for given key. Default QVariant is returned if key does
@@ -86,7 +86,7 @@
*
* @return configuration instance.
*/
- static Config *configuration();
+ static SensorFrameworkConfig *configuration();
/**
* Load configuration from given paths and append them to singleton
@@ -106,14 +106,14 @@
/**
* Constructor.
*/
- Config();
+ SensorFrameworkConfig();
/**
* Copy constructor.
*
* @param c source object.
*/
- Config(const Config &c);
+ SensorFrameworkConfig(const SensorFrameworkConfig &c);
/**
* Assignment operator.
@@ -121,7 +121,7 @@
* @param c source object.
* @return current object.
*/
- Config& operator=(const Config &c);
+ SensorFrameworkConfig& operator=(const SensorFrameworkConfig &c);
/**
* Load configuration file from given path.
@@ -140,7 +140,7 @@
};
template<typename T>
-T Config::value(const QString &key, const T &def) const
+T SensorFrameworkConfig::value(const QString &key, const T &def) const
{
QVariant val(value(key));
if(!val.isValid())
|
[-]
[+]
|
Changed |
_service:tar_git:hybris-libsensorfw-qt5-0.10.8.tar.bz2/core/hybrisadaptor.cpp
^
|
@@ -34,221 +34,430 @@
#include <time.h>
#include <signal.h>
+/* Older devices probably have old android hal and thus do
+ * not define sensor all sensor types that have been added
+ * later on -> In order to both use symbolic names and
+ * compile for all devices we need to fill in holes that
+ * android hal for some particular device might have.
+ */
+#ifndef SENSOR_TYPE_META_DATA
+#define SENSOR_TYPE_META_DATA (0)
+#endif
#ifndef SENSOR_TYPE_ACCELEROMETER
-#define SENSOR_TYPE_ACCELEROMETER (1)
+#define SENSOR_TYPE_ACCELEROMETER (1)
+#endif
+#ifndef SENSOR_TYPE_GEOMAGNETIC_FIELD
+#define SENSOR_TYPE_GEOMAGNETIC_FIELD (2) // alias for SENSOR_TYPE_MAGNETIC_FIELD
#endif
#ifndef SENSOR_TYPE_MAGNETIC_FIELD
-#define SENSOR_TYPE_MAGNETIC_FIELD (2)
+#define SENSOR_TYPE_MAGNETIC_FIELD (2) // alias for SENSOR_TYPE_GEOMAGNETIC_FIELD
#endif
#ifndef SENSOR_TYPE_ORIENTATION
-#define SENSOR_TYPE_ORIENTATION (3)
+#define SENSOR_TYPE_ORIENTATION (3)
#endif
#ifndef SENSOR_TYPE_GYROSCOPE
-#define SENSOR_TYPE_GYROSCOPE (4)
+#define SENSOR_TYPE_GYROSCOPE (4)
#endif
#ifndef SENSOR_TYPE_LIGHT
-#define SENSOR_TYPE_LIGHT (5)
+#define SENSOR_TYPE_LIGHT (5)
#endif
#ifndef SENSOR_TYPE_PRESSURE
-#define SENSOR_TYPE_PRESSURE (6)
+#define SENSOR_TYPE_PRESSURE (6)
#endif
#ifndef SENSOR_TYPE_TEMPERATURE
-#define SENSOR_TYPE_TEMPERATURE (7)
+#define SENSOR_TYPE_TEMPERATURE (7)
#endif
#ifndef SENSOR_TYPE_PROXIMITY
-#define SENSOR_TYPE_PROXIMITY (8)
+#define SENSOR_TYPE_PROXIMITY (8)
#endif
#ifndef SENSOR_TYPE_GRAVITY
-#define SENSOR_TYPE_GRAVITY (9)
+#define SENSOR_TYPE_GRAVITY (9)
#endif
#ifndef SENSOR_TYPE_LINEAR_ACCELERATION
-#define SENSOR_TYPE_LINEAR_ACCELERATION (10)
+#define SENSOR_TYPE_LINEAR_ACCELERATION (10)
#endif
#ifndef SENSOR_TYPE_ROTATION_VECTOR
-#define SENSOR_TYPE_ROTATION_VECTOR (11)
+#define SENSOR_TYPE_ROTATION_VECTOR (11)
#endif
#ifndef SENSOR_TYPE_RELATIVE_HUMIDITY
-#define SENSOR_TYPE_RELATIVE_HUMIDITY (12)
+#define SENSOR_TYPE_RELATIVE_HUMIDITY (12)
#endif
#ifndef SENSOR_TYPE_AMBIENT_TEMPERATURE
-#define SENSOR_TYPE_AMBIENT_TEMPERATURE (13)
+#define SENSOR_TYPE_AMBIENT_TEMPERATURE (13)
+#endif
+#ifndef SENSOR_TYPE_MAGNETIC_FIELD_UNCALIBRATED
+#define SENSOR_TYPE_MAGNETIC_FIELD_UNCALIBRATED (14)
+#endif
+#ifndef SENSOR_TYPE_GAME_ROTATION_VECTOR
+#define SENSOR_TYPE_GAME_ROTATION_VECTOR (15)
+#endif
+#ifndef SENSOR_TYPE_GYROSCOPE_UNCALIBRATED
+#define SENSOR_TYPE_GYROSCOPE_UNCALIBRATED (16)
+#endif
+#ifndef SENSOR_TYPE_SIGNIFICANT_MOTION
+#define SENSOR_TYPE_SIGNIFICANT_MOTION (17)
+#endif
+#ifndef SENSOR_TYPE_STEP_DETECTOR
+#define SENSOR_TYPE_STEP_DETECTOR (18)
#endif
-//#define SENSOR_TYPE_MAGNETIC_FIELD_UNCALIBRATED (14)
-//#define SENSOR_TYPE_GAME_ROTATION_VECTOR (15)
-//#define SENSOR_TYPE_GYROSCOPE_UNCALIBRATED (16)
-//#define SENSOR_TYPE_SIGNIFICANT_MOTION (17)
-//#define SENSOR_TYPE_STEP_DETECTOR (18)
#ifndef SENSOR_TYPE_STEP_COUNTER
-#define SENSOR_TYPE_STEP_COUNTER (19)
+#define SENSOR_TYPE_STEP_COUNTER (19)
#endif
-//#define SENSOR_TYPE_GEOMAGNETIC_ROTATION_VECTOR (20)
-
-Q_GLOBAL_STATIC(HybrisManager, hybrisManager)
-
-HybrisManager::HybrisManager(QObject *parent)
- : QObject(parent)
- , device(NULL)
- , sensorList(NULL)
- , module(NULL)
- , sensorsCount(0)
- , sensorMap()
- , registeredAdaptors()
- , adaptorReaderTid(0)
-{
- init();
+#ifndef SENSOR_TYPE_GEOMAGNETIC_ROTATION_VECTOR
+#define SENSOR_TYPE_GEOMAGNETIC_ROTATION_VECTOR (20)
+#endif
+#ifndef SENSOR_TYPE_HEART_RATE
+#define SENSOR_TYPE_HEART_RATE (21)
+#endif
+#ifndef SENSOR_TYPE_TILT_DETECTOR
+#define SENSOR_TYPE_TILT_DETECTOR (22)
+#endif
+#ifndef SENSOR_TYPE_WAKE_GESTURE
+#define SENSOR_TYPE_WAKE_GESTURE (23)
+#endif
+#ifndef SENSOR_TYPE_GLANCE_GESTURE
+#define SENSOR_TYPE_GLANCE_GESTURE (24)
+#endif
+#ifndef SENSOR_TYPE_PICK_UP_GESTURE
+#define SENSOR_TYPE_PICK_UP_GESTURE (25)
+#endif
+#ifndef SENSOR_TYPE_WRIST_TILT_GESTURE
+#define SENSOR_TYPE_WRIST_TILT_GESTURE (26)
+#endif
+
+/* ========================================================================= *
+ * UTILITIES
+ * ========================================================================= */
+
+static char const *
+sensorTypeName(int type)
+{
+ switch (type) {
+ case SENSOR_TYPE_META_DATA: return "META_DATA";
+ case SENSOR_TYPE_ACCELEROMETER: return "ACCELEROMETER";
+ case SENSOR_TYPE_GEOMAGNETIC_FIELD: return "GEOMAGNETIC_FIELD";
+ case SENSOR_TYPE_ORIENTATION: return "ORIENTATION";
+ case SENSOR_TYPE_GYROSCOPE: return "GYROSCOPE";
+ case SENSOR_TYPE_LIGHT: return "LIGHT";
+ case SENSOR_TYPE_PRESSURE: return "PRESSURE";
+ case SENSOR_TYPE_TEMPERATURE: return "TEMPERATURE";
+ case SENSOR_TYPE_PROXIMITY: return "PROXIMITY";
+ case SENSOR_TYPE_GRAVITY: return "GRAVITY";
+ case SENSOR_TYPE_LINEAR_ACCELERATION: return "LINEAR_ACCELERATION";
+ case SENSOR_TYPE_ROTATION_VECTOR: return "ROTATION_VECTOR";
+ case SENSOR_TYPE_RELATIVE_HUMIDITY: return "RELATIVE_HUMIDITY";
+ case SENSOR_TYPE_AMBIENT_TEMPERATURE: return "AMBIENT_TEMPERATURE";
+ case SENSOR_TYPE_MAGNETIC_FIELD_UNCALIBRATED: return "MAGNETIC_FIELD_UNCALIBRATED";
+ case SENSOR_TYPE_GAME_ROTATION_VECTOR: return "GAME_ROTATION_VECTOR";
+ case SENSOR_TYPE_GYROSCOPE_UNCALIBRATED: return "GYROSCOPE_UNCALIBRATED";
+ case SENSOR_TYPE_SIGNIFICANT_MOTION: return "SIGNIFICANT_MOTION";
+ case SENSOR_TYPE_STEP_DETECTOR: return "STEP_DETECTOR";
+ case SENSOR_TYPE_STEP_COUNTER: return "STEP_COUNTER";
+ case SENSOR_TYPE_GEOMAGNETIC_ROTATION_VECTOR: return "GEOMAGNETIC_ROTATION_VECTOR";
+ case SENSOR_TYPE_HEART_RATE: return "HEART_RATE";
+ case SENSOR_TYPE_TILT_DETECTOR: return "TILT_DETECTOR";
+ case SENSOR_TYPE_WAKE_GESTURE: return "WAKE_GESTURE";
+ case SENSOR_TYPE_GLANCE_GESTURE: return "GLANCE_GESTURE";
+ case SENSOR_TYPE_PICK_UP_GESTURE: return "PICK_UP_GESTURE";
+ case SENSOR_TYPE_WRIST_TILT_GESTURE: return "WRIST_TILT_GESTURE";
+ }
+
+ static char buf[32];
+ snprintf(buf, sizeof buf, "type%d", type);
+ return buf;
}
-HybrisManager::~HybrisManager()
+static void ObtainTemporaryWakeLock()
{
- closeAllSensors();
- if (adaptorReaderTid) {
- sensordLogD() << "Canceling hal reader thread";
- int err = pthread_cancel(adaptorReaderTid);
- if( err ) {
- sensordLogC() << "Failed to cancel hal reader thread";
- }
- else {
- sensordLogD() << "Waiting for hal reader thread to exit";
- void *ret = 0;
- struct timespec tmo = { 0, 0};
- clock_gettime(CLOCK_REALTIME, &tmo);
- tmo.tv_sec += 3;
- err = pthread_timedjoin_np(adaptorReaderTid, &ret, &tmo);
- if( err ) {
- sensordLogC() << "Hal reader thread did not exit";
- } else {
- sensordLogD() << "Hal reader thread terminated";
- adaptorReaderTid = 0;
- }
+ static bool triedToOpen = false;
+ static int wakeLockFd = -1;
+
+ if (!triedToOpen) {
+ triedToOpen = true;
+ wakeLockFd = ::open("/sys/power/wake_lock", O_RDWR);
+ if (wakeLockFd == -1) {
+ sensordLogW() << "wake locks not available:" << ::strerror(errno);
}
- if (adaptorReaderTid) {
- /* The reader thread is stuck at android hal blob.
- * Continuing would be likely to release resourse
- * still in active use and lead to segfaulting.
- * Resort to doing a quick and dirty exit. */
- _exit(EXIT_FAILURE);
+ }
+
+ if (wakeLockFd != -1) {
+ sensordLogD() << "wake lock to guard sensor data io";
+ static const char m[] = "sensorfwd_pass_data 1000000000\n";
+ if (::write(wakeLockFd, m, sizeof m - 1) == -1) {
+ sensordLogW() << "wake locking failed:" << ::strerror(errno);
+ ::close(wakeLockFd), wakeLockFd = -1;
}
}
}
-HybrisManager *HybrisManager::instance()
+/* ========================================================================= *
+ * HybrisSensorState
+ * ========================================================================= */
+
+HybrisSensorState::HybrisSensorState()
+ : m_minDelay(0)
+ , m_maxDelay(0)
+ , m_delay(-1)
+ , m_active(-1)
{
- HybrisManager *priv = hybrisManager();
- return priv;
+ memset(&m_fallbackEvent, 0, sizeof m_fallbackEvent);
}
-void HybrisManager::init()
+HybrisSensorState::~HybrisSensorState()
{
- int errorCode = hw_get_module(SENSORS_HARDWARE_MODULE_ID, (hw_module_t const**)&module);
- if (errorCode != 0) {
- qDebug() << "hw_get_module() failed" << strerror(-errorCode);
+}
+
+/* ========================================================================= *
+ * HybrisManager
+ * ========================================================================= */
+
+Q_GLOBAL_STATIC(HybrisManager, hybrisManager)
+
+HybrisManager::HybrisManager(QObject *parent)
+ : QObject(parent)
+ , m_initialized(false)
+ , m_registeredAdaptors()
+ , m_halModule(NULL)
+ , m_halDevice(NULL)
+ , m_halSensorCount(0)
+ , m_halSensorArray(NULL)
+ , m_halSensorState(NULL)
+ , m_halIndexOfType()
+ , m_halIndexOfHandle()
+ , m_halEventReaderTid(0)
+{
+ int err;
+
+ /* Open android sensor plugin */
+ err = hw_get_module(SENSORS_HARDWARE_MODULE_ID,
+ (hw_module_t const**)&m_halModule);
+ if (err != 0) {
+ m_halModule = 0;
+ sensordLogW() << "hw_get_module() failed" << strerror(-err);
return ;
}
- if (!openSensors()) {
- sensordLogW() << "Cannot open sensors";
+ /* Open android sensor device */
+ err = sensors_open(&m_halModule->common, &m_halDevice);
+ if (err != 0) {
+ m_halDevice = 0;
+ sensordLogW() << "sensors_open() failed:" << strerror(-err);
return;
}
- sensorsCount = module->get_sensors_list(module, &sensorList);
+ /* Get static sensor information */
+ m_halSensorCount = m_halModule->get_sensors_list(m_halModule, &m_halSensorArray);
+
+ /* Reserve space for sensor state data */
+ m_halSensorState = new HybrisSensorState[m_halSensorCount];
+
+ /* Select and initialize sensors to be used */
+ for (int i = 0 ; i < m_halSensorCount ; i++) {
+ /* Always do handle -> index mapping */
+ m_halIndexOfHandle.insert(m_halSensorArray[i].handle, i);
- for (int i = 0 ; i < sensorsCount ; i++) {
bool use = true;
// Assumption: The primary sensor variants that we want to
// use are listed before the secondary ones that we want
// to ignore -> Use the 1st entry found for each sensor type.
- if( sensorMap.contains(sensorList[i].type) ) {
+ if (m_halIndexOfType.contains(m_halSensorArray[i].type)) {
use = false;
}
// some devices have compass and compass raw,
// ignore compass raw. compass has range 360
- if (sensorList[i].type == SENSOR_TYPE_ORIENTATION &&
- sensorList[i].maxRange != 360) {
+ if (m_halSensorArray[i].type == SENSOR_TYPE_ORIENTATION &&
+ m_halSensorArray[i].maxRange != 360) {
use = false;
}
- sensordLogW() << Q_FUNC_INFO
+ sensordLogD() << Q_FUNC_INFO
<< (use ? "SELECT" : "IGNORE")
- << "type:" << sensorList[i].type
- << "name:" << (sensorList[i].name ?: "n/a");
+ << "type:" << m_halSensorArray[i].type
+ << "name:" << (m_halSensorArray[i].name ?: "n/a");
if (use) {
- sensorMap.insert(sensorList[i].type, i);
+ // min/max delay is specified in [us] -> convert to [ms]
+ int minDelay = (m_halSensorArray[i].minDelay + 999) / 1000;
+ int maxDelay = -1; // Assume: not defined by hal
+
+#ifdef SENSORS_DEVICE_API_VERSION_1_3
+ if (m_halDevice->common.version >= SENSORS_DEVICE_API_VERSION_1_3)
+ maxDelay = (m_halSensorArray[i].maxDelay + 999) / 1000;
+#endif
+ /* If HAL does not define maximum delay, we need to invent
+ * something that a) allows sensorfwd logic to see a range
+ * instead of a point, b) is unlikely to be wrong enough to
+ * cause problems...
+ *
+ * For now use: minDelay * 2, but at least 1000 ms.
+ */
+ if (maxDelay < 0 && minDelay > 0) {
+ maxDelay = (minDelay < 500) ? 1000 : (minDelay * 2);
+ sensordLogD("hal does not specify maxDelay, fallback: %d ms",
+ maxDelay);
+ }
+
+ // Positive minDelay means delay /can/ be set - but depending
+ // on sensor hal implementation it can also mean that some
+ // delay /must/ be set or the sensor does not start reporting
+ // despite being enabled -> as an protection agains clients
+ // failing to explicitly set delays / using delays that would
+ // get rejected by upper levels of sensorfwd logic -> setup
+ // 200 ms delay (capped to reported min/max range).
+ if (minDelay >= 0) {
+ if (maxDelay < minDelay)
+ maxDelay = minDelay;
+
+ int delay = minDelay ? 200 : 0;
+ if (delay < minDelay)
+ delay = minDelay;
+ else if (delay > maxDelay )
+ delay = maxDelay;
+
+ m_halSensorState[i].m_minDelay = minDelay;
+ m_halSensorState[i].m_maxDelay = maxDelay;
+
+ halSetActive(m_halSensorArray[i].handle, true);
+ halSetDelay(m_halSensorArray[i].handle, delay);
+
+ sensordLogD("delay = %d [%d, %d]",
+ m_halSensorState[i].m_delay,
+ m_halSensorState[i].m_minDelay,
+ m_halSensorState[i].m_maxDelay);
+ }
+ m_halIndexOfType.insert(m_halSensorArray[i].type, i);
+
+ /* Set sane fallback values for select sensors in case the
+ * hal does not report initial values. */
+ sensors_event_t *eve = &m_halSensorState[i].m_fallbackEvent;
+ eve->version = sizeof *eve;
+ eve->sensor = m_halSensorArray[i].handle;
+ eve->type = m_halSensorArray[i].type;
+
+ switch (m_halSensorArray[i].type) {
+ case SENSOR_TYPE_LIGHT:
+ // Roughly indoor lightning
+ eve->light = 400;
+ break;
+
+ case SENSOR_TYPE_PROXIMITY:
+ // Not-covered
+ eve->distance = m_halSensorArray[i].maxRange;
+ break;
+ default:
+ eve->sensor = 0;
+ eve->type = 0;
+ break;
+ }
}
+
+ /* Make sure all sensors are initially in stopped state */
+ halSetActive(m_halSensorArray[i].handle, false);
}
- int err = pthread_create(&adaptorReaderTid, 0, adaptorReaderThread, this);
+ /* Start android sensor event reader */
+ err = pthread_create(&m_halEventReaderTid, 0, halEventReaderThread, this);
if (err) {
- adaptorReaderTid = 0;
+ m_halEventReaderTid = 0;
sensordLogC() << "Failed to start hal reader thread";
- } else {
- sensordLogD() << "Hal reader thread started";
+ return;
}
+ sensordLogD() << "Hal reader thread started";
+
+ m_initialized = true;
}
-int HybrisManager::handleForType(int sensorType)
+HybrisManager::~HybrisManager()
{
- if (sensorMap.contains(sensorType))
- return sensorList[sensorMap[sensorType]].handle;
+ sensordLogD() << "stop all sensors";
+ foreach (HybrisAdaptor *adaptor, m_registeredAdaptors.values()) {
+ adaptor->stopSensor();
+ }
- sensordLogW() << Q_FUNC_INFO << "No sensor of type:" << sensorType;
- return -1;
+ if (m_halDevice) {
+ sensordLogD() << "close sensor device";
+ int errorCode = sensors_close(m_halDevice);
+ if (errorCode != 0) {
+ sensordLogW() << "sensors_close() failed:" << strerror(-errorCode);
+ }
+ m_halDevice = NULL;
+ }
+
+ if (m_halEventReaderTid) {
+ sensordLogD() << "Canceling hal reader thread";
+ int err = pthread_cancel(m_halEventReaderTid);
+ if (err) {
+ sensordLogC() << "Failed to cancel hal reader thread";
+ } else {
+ sensordLogD() << "Waiting for hal reader thread to exit";
+ void *ret = 0;
+ struct timespec tmo = { 0, 0};
+ clock_gettime(CLOCK_REALTIME, &tmo);
+ tmo.tv_sec += 3;
+ err = pthread_timedjoin_np(m_halEventReaderTid, &ret, &tmo);
+ if (err) {
+ sensordLogC() << "Hal reader thread did not exit";
+ } else {
+ sensordLogD() << "Hal reader thread terminated";
+ m_halEventReaderTid = 0;
+ }
+ }
+ if (m_halEventReaderTid) {
+ /* The reader thread is stuck at android hal blob.
+ * Continuing would be likely to release resourse
+ * still in active use and lead to segfaulting.
+ * Resort to doing a quick and dirty exit. */
+ _exit(EXIT_FAILURE);
+ }
+ }
+ delete[] m_halSensorState;
}
-int HybrisManager::maxRange(int sensorType)
+HybrisManager *HybrisManager::instance()
{
- if (sensorMap.contains(sensorType))
- return sensorList[sensorMap[sensorType]].maxRange;
- return 0;
+ HybrisManager *priv = hybrisManager();
+ return priv;
}
-int HybrisManager::minDelay(int sensorType)
+int HybrisManager::halHandleForType(int sensorType) const
{
- int res = 0;
- if (sensorMap.contains(sensorType)) {
- res = sensorList[sensorMap[sensorType]].minDelay;
- // us -> ms, round up
- res = (res + 999) / 1000;
- }
- return res;
+ int index = halIndexForType(sensorType);
+ return (index < 0) ? -1 : m_halSensorArray[index].handle;
}
-int HybrisManager::resolution(int sensorType)
+sensors_event_t *HybrisManager::halEventForHandle(int handle) const
{
- if (sensorMap.contains(sensorType))
- return sensorList[sensorMap[sensorType]].resolution;
- return 0;
+ sensors_event_t *event = 0;
+ int index = halIndexForHandle(handle);
+ if (index != -1) {
+ event = &m_halSensorState[index].m_fallbackEvent;
+ }
+ return event;
}
-bool HybrisManager::setDelay(int sensorHandle, int interval)
+int HybrisManager::halIndexForHandle(int handle) const
{
- bool ok = true;
- if (interval > 0) {
- int result = device->setDelay(device, sensorHandle, interval);
- if (result < 0) {
- sensordLogW() << "setDelay() failed" << strerror(-result);
- ok = false;
- }
- }
- QList <HybrisAdaptor *> list;
- list = registeredAdaptors.values();
- for (int i = 0; i < list.count(); i++) {
- if (list.at(i)->sensorHandle == sensorHandle) {
- list.at(i)->sendInitialData();
- }
- }
+ int index = m_halIndexOfHandle.value(handle, -1);
+ if (index == -1)
+ sensordLogW("HYBRIS CTL invalid sensor handle: %d", handle);
+ return index;
+}
- return ok;
+int HybrisManager::halIndexForType(int sensorType) const
+{
+ int index = m_halIndexOfType.value(sensorType, -1);
+ if (index == -1)
+ sensordLogW("HYBRIS CTL invalid sensor type: %d", sensorType);
+ return index;
}
void HybrisManager::startReader(HybrisAdaptor *adaptor)
{
- if (registeredAdaptors.values().contains(adaptor)) {
- sensordLogD() << "activating " << adaptor->name() << adaptor->sensorHandle;
- int error = device->activate(device, adaptor->sensorHandle, 1);
- if (error != 0) {
- sensordLogW() <<Q_FUNC_INFO<< "failed for"<< strerror(-error);
+ if (m_registeredAdaptors.values().contains(adaptor)) {
+ sensordLogD() << "activating " << adaptor->name() << adaptor->m_sensorHandle;
+ if (!halSetActive(adaptor->m_sensorHandle, true)) {
+ sensordLogW() <<Q_FUNC_INFO<< "failed";
adaptor->setValid(false);
}
}
@@ -256,328 +465,380 @@
void HybrisManager::stopReader(HybrisAdaptor *adaptor)
{
- QList <HybrisAdaptor *> list;
- list = registeredAdaptors.values();
- bool okToStop = true;
-
- for (int i = 0; i < list.count(); i++) {
- if (list.at(i) == adaptor && !list.at(i)->isRunning()) {
+ if (m_registeredAdaptors.values().contains(adaptor)) {
sensordLogD() << "deactivating " << adaptor->name();
- int error = device->activate(device, adaptor->sensorHandle, 0);
- if (error != 0) {
- sensordLogW() <<Q_FUNC_INFO<< "failed for"<< strerror(-error);
+ if (!halSetActive(adaptor->m_sensorHandle, false)) {
+ sensordLogW() <<Q_FUNC_INFO<< "failed";
}
- }
- if (list.at(i) != adaptor && list.at(i)->shouldBeRunning_) {
- okToStop = false;
- }
}
- qDebug() << "okToStop" << okToStop;
}
-bool HybrisManager::resumeReader(HybrisAdaptor *adaptor)
+void HybrisManager::processSample(const sensors_event_t& data)
{
- sensordLogD() << Q_FUNC_INFO << adaptor->id()
- << adaptor->deviceStandbyOverride()
- << adaptor->isRunning(); //alwaysOn
-
- if (!adaptor->isRunning()) {
- sensordLogD() << "activating for resume" << adaptor->name();
- int error = device->activate(device, adaptor->sensorHandle, 1);
- if (error != 0) {
- sensordLogW() <<Q_FUNC_INFO<< "failed for"<< strerror(-error);
+ foreach (HybrisAdaptor *adaptor, m_registeredAdaptors.values(data.type)) {
+ if (adaptor->isRunning()) {
+ adaptor->processSample(data);
}
}
- return true;
}
-void HybrisManager::standbyReader(HybrisAdaptor *adaptor)
+void HybrisManager::registerAdaptor(HybrisAdaptor *adaptor)
{
- sensordLogD() << Q_FUNC_INFO << adaptor->id()
- << adaptor->deviceStandbyOverride()
- << adaptor->isRunning(); //alwaysOn
-
- if (adaptor->isRunning() && !adaptor->deviceStandbyOverride()) {
- sensordLogD() << "deactivating for standby" << adaptor->name();
- int error = device->activate(device, adaptor->sensorHandle, 0);
- if (error != 0) {
- sensordLogW() <<Q_FUNC_INFO<< "failed for"<< strerror(-error);
- }
+ if (!m_registeredAdaptors.values().contains(adaptor) && adaptor->isValid()) {
+ m_registeredAdaptors.insertMulti(adaptor->m_sensorType, adaptor);
}
}
-bool HybrisManager::openSensors()
+float HybrisManager::halGetMaxRange(int handle) const
{
- if (!device) {
- sensordLogD() << "Calling sensors_open";
- int errorCode = sensors_open(&module->common, &device);
- if (errorCode != 0) {
- sensordLogW() << "sensors_open() failed:" << strerror(-errorCode);
- device = NULL;
- }
+ float range = 0;
+ int index = halIndexForHandle(handle);
+
+ if (index != -1) {
+ const struct sensor_t *sensor = &m_halSensorArray[index];
+
+ range = sensor->maxRange;
+ sensordLogT("HYBRIS CTL getMaxRange(%d=%s) -> %g",
+ sensor->handle, sensorTypeName(sensor->type), range);
}
- return (device != NULL);
+ return range;
}
-bool HybrisManager::closeSensors()
+float HybrisManager::halGetResolution(int handle) const
{
- if (device) {
- foreach (HybrisAdaptor *adaptor, registeredAdaptors.values()) {
- if (adaptor->isRunning()) {
- sensordLogW() << Q_FUNC_INFO << "still running:" << adaptor;
- return false;
- }
- }
+ float resolution = 0;
+ int index = halIndexForHandle(handle);
- sensordLogD() << "Calling sensors_close";
- int errorCode = sensors_close(device);
- if (errorCode != 0) {
- sensordLogW() << "sensors_close() failed:" << strerror(-errorCode);
- }
+ if (index != -1) {
+ const struct sensor_t *sensor = &m_halSensorArray[index];
+
+ resolution = sensor->resolution;
+ sensordLogT("HYBRIS CTL getResolution(%d=%s) -> %g",
+ sensor->handle, sensorTypeName(sensor->type), resolution);
}
- device = NULL;
- return true;
+ return resolution;
}
-void HybrisManager::closeAllSensors()
+int HybrisManager::halGetMinDelay(int handle) const
{
- QList <HybrisAdaptor *> list;
- list = registeredAdaptors.values();
+ int delay = 0;
+ int index = halIndexForHandle(handle);
- for (int i = 0; i < list.count(); i++) {
- if (list.at(i)->isRunning())
- list.at(i)->stopSensor();
- }
+ if (index != -1) {
+ const struct sensor_t *sensor = &m_halSensorArray[index];
+ HybrisSensorState *state = &m_halSensorState[index];
- if (!closeSensors()) {
- sensordLogW() << "Cannot close sensors";
+ delay = state->m_minDelay;
+ sensordLogT("HYBRIS CTL getMinDelay(%d=%s) -> %d",
+ sensor->handle, sensorTypeName(sensor->type), delay);
}
+
+ return delay;
}
-void HybrisManager::processSample(const sensors_event_t& data)
+int HybrisManager::halGetMaxDelay(int handle) const
{
- foreach (HybrisAdaptor *adaptor, registeredAdaptors.values(data.type)) {
- if (adaptor->isRunning()) {
- adaptor->processSample(data);
- }
+ int delay = 0;
+ int index = halIndexForHandle(handle);
+
+ if (index != -1) {
+ const struct sensor_t *sensor = &m_halSensorArray[index];
+ HybrisSensorState *state = &m_halSensorState[index];
+
+ delay = state->m_maxDelay;
+ sensordLogT("HYBRIS CTL getMaxDelay(%d=%s) -> %d",
+ sensor->handle, sensorTypeName(sensor->type), delay);
}
+
+ return delay;
}
-void HybrisManager::registerAdaptor(HybrisAdaptor *adaptor)
+int HybrisManager::halGetDelay(int handle) const
{
- if (!registeredAdaptors.values().contains(adaptor) && adaptor->isValid()) {
- registeredAdaptors.insertMulti(adaptor->sensorType, adaptor);
- }
-}
+ int delay = 0;
+ int index = halIndexForHandle(handle);
-//////////////////////////////////
-HybrisAdaptor::HybrisAdaptor(const QString& id, int type)
- : DeviceAdaptor(id),
- sensorType(type),
- cachedInterval(50),
- inStandbyMode_(false),
- running_(false)
-{
- sensorHandle = hybrisManager()->handleForType(sensorType);
- if (sensorHandle == -1) {
- qDebug() << Q_FUNC_INFO <<"no such sensor" << id;
- setValid(false);
- return;
+ if (index != -1) {
+ const struct sensor_t *sensor = &m_halSensorArray[index];
+ HybrisSensorState *state = &m_halSensorState[index];
+
+ delay = state->m_delay;
+ sensordLogT("HYBRIS CTL getDelay(%d=%s) -> %d",
+ sensor->handle, sensorTypeName(sensor->type), delay);
}
- hybrisManager()->registerAdaptor(this);
- init();
- introduceAvailableInterval(DataRange(minDelay, 1000, 0));
- introduceAvailableDataRange(DataRange(-(maxRange*.5), (maxRange*.5), 1));
+ return delay;
}
-HybrisAdaptor::~HybrisAdaptor()
+bool HybrisManager::halSetDelay(int handle, int delay_ms)
{
-}
+ bool success = false;
+ int index = halIndexForHandle(handle);
-void HybrisAdaptor::init()
-{
- maxRange = hybrisManager()->maxRange(sensorType);
- minDelay = hybrisManager()->minDelay(sensorType);
- if (minDelay > 1000)
- minDelay = 0;
- resolution = hybrisManager()->resolution(sensorType);
-}
+ if (index != -1) {
+ const struct sensor_t *sensor = &m_halSensorArray[index];
+ HybrisSensorState *state = &m_halSensorState[index];
-bool HybrisAdaptor::addSensorType(int type)
-{
- sensorIds.append(type);
- return true;
-}
+ if (state->m_delay == delay_ms) {
+ sensordLogT("HYBRIS CTL setDelay(%d=%s, %d) -> no-change",
+ sensor->handle, sensorTypeName(sensor->type), delay_ms);
+ } else {
+ int64_t delay_ns = delay_ms * 1000LL * 1000LL;
+ int error = m_halDevice->setDelay(m_halDevice, sensor->handle, delay_ns);
+ if (error) {
+ sensordLogW("HYBRIS CTL setDelay(%d=%s, %d) -> %d=%s",
+ sensor->handle, sensorTypeName(sensor->type), delay_ms,
+ error, strerror(error));
+ } else {
+ sensordLogD("HYBRIS CTL setDelay(%d=%s, %d) -> success",
+ sensor->handle, sensorTypeName(sensor->type), delay_ms);
+ state->m_delay = delay_ms;
+ success = true;
+ }
+ }
+ }
-bool HybrisAdaptor::startAdaptor()
-{
- if (!isValid())
- return false;
- return hybrisManager()->openSensors();
+ return success;
}
-bool HybrisAdaptor::isRunning() const
+bool HybrisManager::halGetActive(int handle) const
{
- return running_;
-}
+ bool active = false;
+ int index = halIndexForHandle(handle);
-void HybrisAdaptor::stopAdaptor()
-{
- if (getAdaptedSensor()->isRunning())
- stopSensor();
- hybrisManager()->closeSensors();
+ if (index != -1) {
+ const struct sensor_t *sensor = &m_halSensorArray[index];
+ HybrisSensorState *state = &m_halSensorState[index];
+
+ active = (state->m_active > 0);
+ sensordLogT("HYBRIS CTL getActive(%d=%s) -> %s",
+ sensor->handle, sensorTypeName(sensor->type),
+ active ? "true" : "false");
+ }
+ return active;
}
-bool HybrisAdaptor::startSensor()
+bool HybrisManager::halSetActive(int handle, bool active)
{
- AdaptedSensorEntry *entry = getAdaptedSensor();
- if (entry == NULL) {
- qDebug() << "Sensor not found: " << name();
- return false;
- }
+ bool success = false;
+ int index = halIndexForHandle(handle);
- // Increase listener count
- entry->addReference();
+ if (index != -1) {
+ const struct sensor_t *sensor = &m_halSensorArray[index];
+ HybrisSensorState *state = &m_halSensorState[index];
- /// Check from entry
- if (isRunning()) {
- qDebug() << Q_FUNC_INFO << "already running";
- shouldBeRunning_ = true;
- return false;
+ if (state->m_active == active) {
+ sensordLogT("HYBRIS CTL setActive%d=%s, %s) -> no-change",
+ sensor->handle, sensorTypeName(sensor->type), active ? "true" : "false");
+ success = true;
+ } else {
+ int error = m_halDevice->activate(m_halDevice, sensor->handle, active);
+ if (error) {
+ sensordLogW("HYBRIS CTL setActive%d=%s, %s) -> %d=%s",
+ sensor->handle, sensorTypeName(sensor->type), active ? "true" : "false",
+ error, strerror(error));
+ } else {
+ sensordLogD("HYBRIS CTL setActive%d=%s, %s) -> success",
+ sensor->handle, sensorTypeName(sensor->type), active ? "true" : "false");
+ state->m_active = active;
+ success = true;
+ }
+ if (state->m_active == true && state->m_delay != -1) {
+ sensordLogD("HYBRIS CTL FORCE DELAY UPDATE");
+ int delay_ms = state->m_delay;
+ state->m_delay = -1;
+ halSetDelay(handle, delay_ms);
+ }
+ }
}
+ return success;
+}
- // Do not open if in standby mode.
- if (inStandbyMode_ && !deviceStandbyOverride()) {
- qDebug() << Q_FUNC_INFO << "inStandbyMode_ true";
- return false;
- }
+void *HybrisManager::halEventReaderThread(void *aptr)
+{
+ HybrisManager *manager = static_cast<HybrisManager *>(aptr);
+ static const size_t numEvents = 16;
+ sensors_event_t buffer[numEvents];
+ /* Async cancellation, but disabled */
+ pthread_setcancelstate(PTHREAD_CANCEL_DISABLE, 0);
+ pthread_setcanceltype(PTHREAD_CANCEL_ASYNCHRONOUS, 0);
+ /* Leave INT/TERM signal processing up to the main thread */
+ sigset_t ss;
+ sigemptyset(&ss);
+ sigaddset(&ss, SIGINT);
+ sigaddset(&ss, SIGTERM);
+ pthread_sigmask(SIG_BLOCK, &ss, 0);
+ /* Loop until explicitly canceled */
+ for (;;) {
+ /* Async cancellation point at android hal poll() */
+ pthread_setcancelstate(PTHREAD_CANCEL_ENABLE, 0);
+ int numberOfEvents = manager->m_halDevice->poll(manager->m_halDevice, buffer, numEvents);
+ pthread_setcancelstate(PTHREAD_CANCEL_DISABLE, 0);
+ /* Rate limit in poll() error situations */
+ if (numberOfEvents < 0) {
+ sensordLogW() << "android device->poll() failed" << strerror(-numberOfEvents);
+ struct timespec ts = { 1, 0 }; // 1000 ms
+ do { } while (nanosleep(&ts, &ts) == -1 && errno == EINTR);
+ continue;
+ }
+ /* Process received events */
+ bool blockSuspend = false;
+ bool errorInInput = false;
+ for (int i = 0; i < numberOfEvents; i++) {
+ const sensors_event_t& data = buffer[i];
- shouldBeRunning_ = true;
- /// We are waking up from standby or starting fresh, no matter
- inStandbyMode_ = false;
-
- if (!startReaderThread()) {
- entry->removeReference();
- entry->setIsRunning(false);
- running_ = false;
- shouldBeRunning_ = false;
- return false;
- }
+ sensordLogT("HYBRIS EVE %s", sensorTypeName(data.type));
- entry->setIsRunning(true);
- running_ = true;
- shouldBeRunning_ = true;
+ /* Got data -> Clear the no longer needed fallback event */
+ sensors_event_t *fallback = manager->halEventForHandle(data.sensor);
+ if (fallback && fallback->type == data.type && fallback->sensor == data.sensor) {
+ fallback->type = fallback->sensor = 0;
+ }
- return true;
+ if (data.version != sizeof(sensors_event_t)) {
+ sensordLogW()<< QString("incorrect event version (version=%1, expected=%2").arg(data.version).arg(sizeof(sensors_event_t));
+ errorInInput = true;
+ }
+ if (data.type == SENSOR_TYPE_PROXIMITY) {
+ blockSuspend = true;
+ }
+ // FIXME: is this thread safe?
+ manager->processSample(data);
+ }
+ /* Suspend proof sensor reporting that could occur in display off */
+ if (blockSuspend) {
+ ObtainTemporaryWakeLock();
+ }
+ /* Rate limit after receiving erraneous events */
+ if (errorInInput) {
+ struct timespec ts = { 0, 50 * 1000 * 1000 }; // 50 ms
+ do { } while (nanosleep(&ts, &ts) == -1 && errno == EINTR);
+ }
+ }
+ return 0;
}
-void HybrisAdaptor::stopSensor()
-{
- AdaptedSensorEntry *entry = getAdaptedSensor();
+/* ========================================================================= *
+ * HybrisAdaptor
+ * ========================================================================= */
- if (entry == NULL) {
- sensordLogW() << "Sensor not found " << name();
+HybrisAdaptor::HybrisAdaptor(const QString& id, int type)
+ : DeviceAdaptor(id)
+ , m_inStandbyMode(false)
+ , m_isRunning(false)
+ , m_shouldBeRunning(false)
+ , m_sensorHandle(-1)
+ , m_sensorType(type)
+{
+ m_sensorHandle = hybrisManager()->halHandleForType(m_sensorType);
+ if (m_sensorHandle == -1) {
+ sensordLogW() << Q_FUNC_INFO <<"no such sensor" << id;
+ setValid(false);
return;
}
- qDebug() << "shouldBeRunning_" << shouldBeRunning_
- << "inStandbyMode_" << inStandbyMode_
- << "reference count" << entry->referenceCount();
- if (!shouldBeRunning_) {
- return;
- }
+ hybrisManager()->registerAdaptor(this);
+}
- entry->removeReference();
- if (entry->referenceCount() <= 0) {
- entry->setIsRunning(false);
- running_ = false;
- shouldBeRunning_ = false;
- inStandbyMode_ = false;
- if (!inStandbyMode_) {
- stopReaderThread();
- }
- }
+HybrisAdaptor::~HybrisAdaptor()
+{
}
-bool HybrisAdaptor::standby()
+void HybrisAdaptor::init()
{
- sensordLogD() << "Adaptor '" << id() << "' requested to go to standby" << "deviceStandbyOverride" << deviceStandbyOverride();
- if (inStandbyMode_ && deviceStandbyOverride()) {
- sensordLogD() << "Adaptor '" << id() << "' not going to standby: already in standby";
+ introduceAvailableDataRange(DataRange(minRange(), maxRange(), resolution()));
+ introduceAvailableInterval(DataRange(minInterval(), maxInterval(), 0));
+}
+
+void HybrisAdaptor::sendInitialData()
+{
+ // virtual dummy
+ // used for ps/als initial value hacks
+}
+
+bool HybrisAdaptor::writeToFile(const QByteArray& path, const QByteArray& content)
+{
+ sensordLogT() << "Writing to '" << path << ": " << content;
+ QFile file(path);
+ if (!file.open(QIODevice::WriteOnly))
+ {
+ sensordLogW() << "Failed to open '" << path << "': " << file.errorString();
return false;
}
-
- if (!isRunning()) {
- sensordLogD() << "Adaptor '" << id() << "' not going to standby: not running";
+ if (file.write(content.constData(), content.size()) == -1)
+ {
+ sensordLogW() << "Failed to write to '" << path << "': " << file.errorString();
+ file.close();
return false;
}
- inStandbyMode_ = true;
- hybrisManager()->standbyReader(this);
- running_ = deviceStandbyOverride();
-
+ file.close();
return true;
}
-bool HybrisAdaptor::resume()
+/* ------------------------------------------------------------------------- *
+ * range
+ * ------------------------------------------------------------------------- */
+
+qreal HybrisAdaptor::minRange() const
{
- sensordLogD() << "Adaptor '" << id() << "' requested to resume from standby";
- sensordLogD() << "deviceStandbyOverride" << deviceStandbyOverride();
+ return 0;
+}
- // Don't resume if not in standby
- if (!inStandbyMode_ && !deviceStandbyOverride()) {
- sensordLogD() << "Adaptor '" << id() << "' not resuming: not in standby";
- return false;
- }
+qreal HybrisAdaptor::maxRange() const
+{
+ return hybrisManager()->halGetMaxRange(m_sensorHandle);
+}
- if (!shouldBeRunning_) {
- sensordLogD() << "Adaptor '" << id() << "' not resuming from standby: not running";
- return false;
- }
+qreal HybrisAdaptor::resolution() const
+{
+ return hybrisManager()->halGetResolution(m_sensorHandle);
+}
- sensordLogD() << "Adaptor '" << id() << "' resuming from standby";
- inStandbyMode_ = false;
+/* ------------------------------------------------------------------------- *
+ * interval
+ * ------------------------------------------------------------------------- */
- if (!hybrisManager()->resumeReader(this)) {
- sensordLogW() << "Adaptor '" << id() << "' failed to resume from standby!";
- return false;
- }
- running_ = true;
+unsigned int HybrisAdaptor::minInterval() const
+{
+ return hybrisManager()->halGetMinDelay(m_sensorHandle);
+}
- return true;
+unsigned int HybrisAdaptor::maxInterval() const
+{
+ return hybrisManager()->halGetMaxDelay(m_sensorHandle);
}
unsigned int HybrisAdaptor::interval() const
{
- return cachedInterval;
+ return hybrisManager()->halGetDelay(m_sensorHandle);
}
-bool HybrisAdaptor::setInterval(const unsigned int value, const int /*sessionId*/)
-{ // 1000000
- cachedInterval = value;
- bool ok;
- qreal ns = value * 1000000; // ms to ns
- ok = hybrisManager()->setDelay(sensorHandle, ns);
+bool HybrisAdaptor::setInterval(const unsigned int value, const int sessionId)
+{
+ Q_UNUSED(sessionId);
+
+ bool ok = hybrisManager()->halSetDelay(m_sensorHandle, value);
+
if (!ok) {
- qDebug() << Q_FUNC_INFO << "setInterval not ok";
- }
- return ok;
-}
+ sensordLogW() << Q_FUNC_INFO << "setInterval not ok";
+ } else {
+ /* If we have not yet received sensor data, apply fallback value */
+ sensors_event_t *fallback = hybrisManager()->halEventForHandle(m_sensorHandle);
+ if (fallback && fallback->sensor == m_sensorHandle && fallback->type == m_sensorType) {
+ sensordLogT("HYBRIS FALLBACK type:%s sensor:%d",
+ sensorTypeName(fallback->type),
+ fallback->sensor);
+ processSample(*fallback);
+ fallback->sensor = fallback->type = 0;
+ }
-void HybrisAdaptor::stopReaderThread()
-{
- hybrisManager()->stopReader(this);
- running_ = false;
-}
+ sendInitialData();
+ }
-bool HybrisAdaptor::startReaderThread()
-{
- running_ = true;
- hybrisManager()->startReader(this);
- return true;
+ return ok;
}
unsigned int HybrisAdaptor::evaluateIntervalRequests(int& sessionId) const
@@ -605,100 +866,109 @@
return highestValue > 0 ? highestValue : defaultInterval();
}
-bool HybrisAdaptor::writeToFile(const QByteArray& path, const QByteArray& content)
+/* ------------------------------------------------------------------------- *
+ * start/stop adaptor
+ * ------------------------------------------------------------------------- */
+
+bool HybrisAdaptor::startAdaptor()
{
- sensordLogT() << "Writing to '" << path << ": " << content;
- QFile file(path);
- if (!file.open(QIODevice::WriteOnly))
- {
- sensordLogW() << "Failed to open '" << path << "': " << file.errorString();
- return false;
+ return isValid();
+}
+
+void HybrisAdaptor::stopAdaptor()
+{
+ if (getAdaptedSensor()->isRunning())
+ stopSensor();
+}
+
+/* ------------------------------------------------------------------------- *
+ * start/stop sensor
+ * ------------------------------------------------------------------------- */
+
+bool HybrisAdaptor::isRunning() const
+{
+ return m_isRunning;
+}
+
+void HybrisAdaptor::evaluateSensor()
+{
+ // Get listener object
+ AdaptedSensorEntry *entry = getAdaptedSensor();
+ if (entry == NULL) {
+ sensordLogW() << Q_FUNC_INFO << "Sensor not found: " << name();
+ return;
}
- if (file.write(content.constData(), content.size()) == -1)
- {
- sensordLogW() << "Failed to write to '" << path << "': " << file.errorString();
- file.close();
- return false;
+
+ // Check policy
+ bool runningAllowed = (deviceStandbyOverride() || !m_inStandbyMode);
+
+ // Target state
+ bool startRunning = m_shouldBeRunning && runningAllowed;
+
+ if (m_isRunning != startRunning) {
+ if ((m_isRunning = startRunning)) {
+ hybrisManager()->startReader(this);
+ if (entry->addReference() == 1) {
+ entry->setIsRunning(true);
+ }
+
+ /* If we have not yet received sensor data, apply fallback value */
+ sensors_event_t *fallback = hybrisManager()->halEventForHandle(m_sensorHandle);
+ if (fallback && fallback->sensor == m_sensorHandle && fallback->type == m_sensorType) {
+ sensordLogT("HYBRIS FALLBACK type:%s sensor:%d",
+ sensorTypeName(fallback->type),
+ fallback->sensor);
+ processSample(*fallback);
+ fallback->sensor = fallback->type = 0;
+ }
+ } else {
+ if (entry->removeReference() == 0) {
+ entry->setIsRunning(false);
+ }
+ hybrisManager()->stopReader(this);
+ }
+ sensordLogT() << Q_FUNC_INFO << "entry" << entry->name()
+ << "refs:" << entry->referenceCount() << "running:" << entry->isRunning();
}
+}
- file.close();
+bool HybrisAdaptor::startSensor()
+{
+ // Note: This is overloaded and called by each HybrisXxxAdaptor::startSensor()
+ if (!m_shouldBeRunning) {
+ m_shouldBeRunning = true;
+ sensordLogT("%s m_shouldBeRunning = %d", sensorTypeName(m_sensorType), m_shouldBeRunning);
+ evaluateSensor();
+ }
return true;
}
-static void ObtainTemporaryWakeLock()
+void HybrisAdaptor::stopSensor()
{
- static bool triedToOpen = false;
- static int wakeLockFd = -1;
-
- if (!triedToOpen) {
- triedToOpen = true;
- wakeLockFd = ::open("/sys/power/wake_lock", O_RDWR);
- if (wakeLockFd == -1) {
- sensordLogW() << "wake locks not available:" << ::strerror(errno);
- }
+ // Note: This is overloaded and called by each HybrisXxxAdaptor::stopSensor()
+ if (m_shouldBeRunning) {
+ m_shouldBeRunning = false;
+ sensordLogT("%s m_shouldBeRunning = %d", sensorTypeName(m_sensorType), m_shouldBeRunning);
+ evaluateSensor();
}
+}
- if (wakeLockFd != -1) {
- sensordLogD() << "wake lock to guard sensor data io";
- static const char m[] = "sensorfwd_pass_data 1000000000\n";
- if( ::write(wakeLockFd, m, sizeof m - 1) == -1 ) {
- sensordLogW() << "wake locking failed:" << ::strerror(errno);
- ::close(wakeLockFd), wakeLockFd = -1;
- }
+bool HybrisAdaptor::standby()
+{
+ if (!m_inStandbyMode) {
+ m_inStandbyMode = true;
+ sensordLogT("%s m_inStandbyMode = %d", sensorTypeName(m_sensorType), m_inStandbyMode);
+ evaluateSensor();
}
+ return true;
}
-void *HybrisManager::adaptorReaderThread(void *aptr)
+bool HybrisAdaptor::resume()
{
- HybrisManager *manager = static_cast<HybrisManager *>(aptr);
- static const size_t numEvents = 16;
- sensors_event_t buffer[numEvents];
- /* Async cancellation, but disabled */
- pthread_setcancelstate(PTHREAD_CANCEL_DISABLE, 0);
- pthread_setcanceltype(PTHREAD_CANCEL_ASYNCHRONOUS, 0);
- /* Leave INT/TERM signal processing up to the main thread */
- sigset_t ss;
- sigemptyset(&ss);
- sigaddset(&ss, SIGINT);
- sigaddset(&ss, SIGTERM);
- pthread_sigmask(SIG_BLOCK, &ss, 0);
- /* Loop until explicitly canceled */
- for( ;; ) {
- /* Async cancellation point at android hal poll() */
- pthread_setcancelstate(PTHREAD_CANCEL_ENABLE, 0);
- int numberOfEvents = manager->device->poll(manager->device, buffer, numEvents);
- pthread_setcancelstate(PTHREAD_CANCEL_DISABLE, 0);
- /* Rate limit in poll() error situations */
- if (numberOfEvents < 0) {
- sensordLogW() << "android device->poll() failed" << strerror(-numberOfEvents);
- struct timespec ts = { 1, 0 }; // 1000 ms
- do { } while( nanosleep(&ts, &ts) == -1 && errno == EINTR );
- continue;
- }
- /* Process received events */
- bool blockSuspend = false;
- bool errorInInput = false;
- for (int i = 0; i < numberOfEvents; i++) {
- const sensors_event_t& data = buffer[i];
- if (data.version != sizeof(sensors_event_t)) {
- sensordLogW()<< QString("incorrect event version (version=%1, expected=%2").arg(data.version).arg(sizeof(sensors_event_t));
- errorInInput = true;
- }
- if (data.type == SENSOR_TYPE_PROXIMITY) {
- blockSuspend = true;
- }
- // FIXME: is this thread safe?
- manager->processSample(data);
- }
- /* Suspend proof sensor reporting that could occur in display off */
- if (blockSuspend) {
- ObtainTemporaryWakeLock();
- }
- /* Rate limit after receiving erraneous events */
- if (errorInInput) {
- struct timespec ts = { 0, 50 * 1000 * 1000 }; // 50 ms
- do { } while( nanosleep(&ts, &ts) == -1 && errno == EINTR );
- }
+ if (m_inStandbyMode) {
+ m_inStandbyMode = false;
+ sensordLogT("%s m_inStandbyMode = %d", sensorTypeName(m_sensorType), m_inStandbyMode);
+ evaluateSensor();
}
- return 0;
+ return true;
}
|
[-]
[+]
|
Changed |
_service:tar_git:hybris-libsensorfw-qt5-0.10.8.tar.bz2/core/hybrisadaptor.h
^
|
@@ -34,50 +34,70 @@
class HybrisAdaptor;
+struct HybrisSensorState
+{
+ HybrisSensorState();
+ ~HybrisSensorState();
+
+ int m_minDelay;
+ int m_maxDelay;
+ int m_delay;
+ int m_active;
+ sensors_event_t m_fallbackEvent;
+};
+
class HybrisManager : public QObject
{
Q_OBJECT
public:
- explicit HybrisManager(QObject *parent = 0);
static HybrisManager *instance();
- virtual ~HybrisManager();
-
- int handleForType(int sensorType);
- int maxRange(int sensorType);
- int minDelay(int sensorType);
- int resolution(int sensorType);
-
- bool setDelay(int handle, int interval);
- void startReader(HybrisAdaptor *adaptor);
- void stopReader(HybrisAdaptor *adaptor);
-
- bool resumeReader(HybrisAdaptor *adaptor);
- void standbyReader(HybrisAdaptor *adaptor);
-
- bool openSensors();
- bool closeSensors();
-
- void registerAdaptor(HybrisAdaptor * adaptor);
- void processSample(const sensors_event_t& data);
+ explicit HybrisManager(QObject *parent = 0);
+ virtual ~HybrisManager();
-protected:
- // methods
- void init();
- void closeAllSensors();
+ /* - - - - - - - - - - - - - - - - - - - *
+ * android sensor hal functions
+ * - - - - - - - - - - - - - - - - - - - */
+
+ sensors_event_t *halEventForHandle(int handle) const;
+ int halIndexForHandle(int handle) const;
+ int halIndexForType (int sensorType) const;
+ int halHandleForType (int sensorType) const;
+ float halGetMaxRange (int handle) const;
+ float halGetResolution (int handle) const;
+ int halGetMinDelay (int handle) const;
+ int halGetMaxDelay (int handle) const;
+ int halGetDelay (int handle) const;
+ bool halSetDelay (int handle, int delay_ms);
+ bool halGetActive (int handle) const;
+ bool halSetActive (int handle, bool active);
+
+ /* - - - - - - - - - - - - - - - - - - - *
+ * HybrisManager <--> sensorfwd
+ * - - - - - - - - - - - - - - - - - - - */
+
+ void startReader (HybrisAdaptor *adaptor);
+ void stopReader (HybrisAdaptor *adaptor);
+ void registerAdaptor (HybrisAdaptor * adaptor);
+ void processSample (const sensors_event_t& data);
+private:
// fields
- struct sensors_poll_device_t* device;
- struct sensor_t const* sensorList;
- struct sensors_module_t* module;
- int sensorsCount;
- QMap <int, int> sensorMap; //type, index
- QMap <int, HybrisAdaptor *> registeredAdaptors; //type, obj
- pthread_t adaptorReaderTid;
+ bool m_initialized;
+ QMap <int, HybrisAdaptor *> m_registeredAdaptors; // type -> obj
+ struct sensors_module_t *m_halModule;
+ struct sensors_poll_device_t *m_halDevice;
+ int m_halSensorCount;
+ const struct sensor_t *m_halSensorArray; // [m_halSensorCount]
+ HybrisSensorState *m_halSensorState; // [m_halSensorCount]
+ QMap <int, int> m_halIndexOfType; // type -> index
+ QMap <int, int> m_halIndexOfHandle; // handle -> index
+ pthread_t m_halEventReaderTid;
+
friend class HybrisAdaptorReader;
private:
- static void *adaptorReaderThread(void *aptr);
+ static void *halEventReaderThread(void *aptr);
};
class HybrisAdaptor : public DeviceAdaptor
@@ -87,47 +107,44 @@
virtual ~HybrisAdaptor();
virtual void init();
- bool addSensorType(int type);
+
virtual bool startAdaptor();
- bool isRunning() const;
+ bool isRunning() const;
virtual void stopAdaptor();
+ void evaluateSensor();
virtual bool startSensor();
virtual void stopSensor();
virtual bool standby();
-
virtual bool resume();
- qreal maxRange;
- qint32 minDelay;
- qreal resolution;
+ virtual void sendInitialData();
friend class HybrisManager;
- int sensorHandle;
- int sensorType;
- int cachedInterval;
-
- virtual void sendInitialData() {}
protected:
virtual void processSample(const sensors_event_t& data) = 0;
+ qreal minRange() const;
+ qreal maxRange() const;
+ qreal resolution() const;
+
+ unsigned int minInterval() const;
+ unsigned int maxInterval() const;
+
virtual unsigned int interval() const;
virtual bool setInterval(const unsigned int value, const int sessionId);
virtual unsigned int evaluateIntervalRequests(int& sessionId) const;
static bool writeToFile(const QByteArray& path, const QByteArray& content);
private:
- void stopReaderThread();
- bool startReaderThread();
-
- QList<int> sensorIds;
- unsigned int interval_;
- bool inStandbyMode_;
- volatile bool running_;
- bool shouldBeRunning_;
+ bool m_inStandbyMode;
+ volatile bool m_isRunning;
+ bool m_shouldBeRunning;
+ int m_sensorHandle;
+ int m_sensorType;
};
#endif // HybrisAdaptor_H
|
[-]
[+]
|
Changed |
_service:tar_git:hybris-libsensorfw-qt5-0.10.8.tar.bz2/core/inputdevadaptor.cpp
^
|
@@ -59,14 +59,14 @@
int InputDevAdaptor::getInputDevices(const QString& typeName)
{
qDebug() << Q_FUNC_INFO << typeName;
- QString deviceSysPathString = Config::configuration()->value("global/device_sys_path").toString();
- QString devicePollFilePath = Config::configuration()->value("global/device_poll_file_path").toString();
+ QString deviceSysPathString = SensorFrameworkConfig::configuration()->value("global/device_sys_path").toString();
+ QString devicePollFilePath = SensorFrameworkConfig::configuration()->value("global/device_poll_file_path").toString();
int deviceNumber = 0;
deviceString_ = typeName;
// Check if this device name is defined in configuration
- QString deviceName = Config::configuration()->value<QString>(typeName + "/device", "");
+ QString deviceName = SensorFrameworkConfig::configuration()->value<QString>(typeName + "/device", "");
// Do not perform strict checks for the input device
if (deviceName.size() && checkInputDevice(deviceName, typeName, false)) {
@@ -90,8 +90,8 @@
}
QString pollConfigKey = QString(typeName + "/poll_file");
- if (Config::configuration()->exists(pollConfigKey)) {
- usedDevicePollFilePath_ = Config::configuration()->value<QString>(pollConfigKey, "");
+ if (SensorFrameworkConfig::configuration()->exists(pollConfigKey)) {
+ usedDevicePollFilePath_ = SensorFrameworkConfig::configuration()->value<QString>(pollConfigKey, "");
} else {
usedDevicePollFilePath_ = devicePollFilePath.arg(deviceNumber);
}
@@ -191,7 +191,7 @@
void InputDevAdaptor::init()
{
qDebug() << Q_FUNC_INFO << name();
- if (!getInputDevices(Config::configuration()->value<QString>(name() + "/input_match", name()))) {
+ if (!getInputDevices(SensorFrameworkConfig::configuration()->value<QString>(name() + "/input_match", name()))) {
sensordLogW() << "Input device not found.";
SysfsAdaptor::init();
}
|
[-]
[+]
|
Changed |
_service:tar_git:hybris-libsensorfw-qt5-0.10.8.tar.bz2/core/loader.cpp
^
|
@@ -192,7 +192,7 @@
int end = file.size() - suffix.size();
const QString name(file.mid(beg, end-beg));
QString key = QString("available/%1").arg(name);
- QString val = Config::configuration()->value(key).toString();
+ QString val = SensorFrameworkConfig::configuration()->value(key).toString();
if( evaluateAvailabilityValue(name, val) ) {
res.append(name);
}
@@ -235,7 +235,7 @@
QString Loader::resolveRealPluginName(const QString& pluginName) const
{
QString key = QString("plugins/%1").arg(pluginName);
- QString nameFromConfig = Config::configuration()->value(key).toString();
+ QString nameFromConfig = SensorFrameworkConfig::configuration()->value(key).toString();
if (nameFromConfig.isEmpty()) {
sensordLogT() << "Plugin setting for " << pluginName << " not found from configuration. Using key as value.";
return pluginName;
|
[-]
[+]
|
Changed |
_service:tar_git:hybris-libsensorfw-qt5-0.10.8.tar.bz2/core/logging.h
^
|
@@ -29,9 +29,9 @@
#include <QDebug>
-#define sensordLogT() (qDebug())
-#define sensordLogD() (qInfo())
-#define sensordLogW() (qWarning())
-#define sensordLogC() (qCritical())
+#define sensordLogT(ARGS_...) (qDebug(ARGS_))
+#define sensordLogD(ARGS_...) (qInfo(ARGS_))
+#define sensordLogW(ARGS_...) (qWarning(ARGS_))
+#define sensordLogC(ARGS_...) (qCritical(ARGS_))
#endif //LOGGING_H
|
[-]
[+]
|
Changed |
_service:tar_git:hybris-libsensorfw-qt5-0.10.8.tar.bz2/core/nodebase.cpp
^
|
@@ -87,7 +87,7 @@
void NodeBase::introduceAvailableDataRanges(const QString& typeName)
{
- QVariant ranges = Config::configuration()->value(typeName + "/dataranges");
+ QVariant ranges = SensorFrameworkConfig::configuration()->value(typeName + "/dataranges");
if(ranges.isValid())
{
DataRangeList list(parseDataRangeList(ranges.toString(), 1));
@@ -280,7 +280,7 @@
void NodeBase::introduceAvailableIntervals(const QString& typeName)
{
- QVariant ranges = Config::configuration()->value(typeName + "/intervals");
+ QVariant ranges = SensorFrameworkConfig::configuration()->value(typeName + "/intervals");
if(ranges.isValid())
{
DataRangeList list(parseDataRangeList(ranges.toString(), 0));
|
[-]
[+]
|
Changed |
_service:tar_git:hybris-libsensorfw-qt5-0.10.8.tar.bz2/core/sysfsadaptor.cpp
^
|
@@ -478,7 +478,7 @@
void SysfsAdaptor::init()
{
- QString path = Config::configuration()->value(name() + "/path").toString();
+ QString path = SensorFrameworkConfig::configuration()->value(name() + "/path").toString();
if(!path.isEmpty())
{
addPath(path);
@@ -487,10 +487,10 @@
{
sensordLogW() << "No sysfs path defined for: " << name();
}
- mode_ = (PollMode)Config::configuration()->value<int>(name() + "/mode", mode_);
- doSeek_ = Config::configuration()->value<bool>(name() + "/seek", doSeek_);
+ mode_ = (PollMode)SensorFrameworkConfig::configuration()->value<int>(name() + "/mode", mode_);
+ doSeek_ = SensorFrameworkConfig::configuration()->value<bool>(name() + "/seek", doSeek_);
introduceAvailableDataRanges(name());
introduceAvailableIntervals(name());
- setDefaultInterval(Config::configuration()->value<int>(name() + "/default_interval", 0));
+ setDefaultInterval(SensorFrameworkConfig::configuration()->value<int>(name() + "/default_interval", 0));
}
|
[-]
[+]
|
Changed |
_service:tar_git:hybris-libsensorfw-qt5-0.10.8.tar.bz2/debian/changelog
^
|
@@ -94,13 +94,13 @@
* Proximity sensor dataflow now uses datatype ProximityData.
* ProximitySensorChannelInterface provides signal and accessor for getting proximity reading with reflectance value.
* c-api removed from doxygen targets.
- * Config-class now better handles errors.
+ * SensorFrameworkConfig-class now better handles errors.
* AccelerometerAdaptor used for some reason OrientationData. Should have
been AccelerometerData. Only cosmetic change.
* Implemented new downsampling logic (Fixes: NB#234563):
- AccelerometerAdaptor, MagnetometerAdaptor and RotationSensorChannel interval rangelist has been limited to certain sizes.
- AccelerometerSensorChannel, RotationSensorChannel and MagnetometerSensorChannel downsamples data before propagating it.
- * Config-class has now more friendly API.
+ * SensorFrameworkConfig-class has now more friendly API.
* sensorfw-qt5testapp improvements.
* API documentation improvements.
* Improved dataflowtests.
@@ -431,7 +431,7 @@
- Replaced direct usage of qDebug() with logging macros.
- Improved error-handling in Loader.
- Sensorfw-Qt5Logger now correctly prints QStrings.
- - Config/Logging singletons are now unloaded before exitting from main().
+ - SensorFrameworkConfig/Logging singletons are now unloaded before exitting from main().
-- Timo Rongas <ext-timo.2.rongas@nokia.com> Tue, 21 Sep 2010 10:32:41 +0300
|
[-]
[+]
|
Changed |
_service:tar_git:hybris-libsensorfw-qt5-0.10.8.tar.bz2/filters/declinationfilter/declinationfilter.cpp
^
|
@@ -37,7 +37,7 @@
Filter<CompassData, DeclinationFilter, CompassData>(this, &DeclinationFilter::correct),
declinationCorrection_(0)
{
- updateInterval_ = Config::configuration()->value<quint64>("compass/declination_update_interval", 1000 * 60 * 60) * 1000;
+ updateInterval_ = SensorFrameworkConfig::configuration()->value<quint64>("compass/declination_update_interval", 1000 * 60 * 60) * 1000;
loadSettings();
}
|
[-]
[+]
|
Changed |
_service:tar_git:hybris-libsensorfw-qt5-0.10.8.tar.bz2/filters/orientationinterpreter/orientationinterpreter.cpp
^
|
@@ -59,13 +59,13 @@
addSource(&faceSource, "face");
addSource(&orientationSource, "orientation");
- minLimit = Config::configuration()->value("orientation/overflow_min", QVariant(OVERFLOW_MIN)).toInt();
- maxLimit = Config::configuration()->value("orientation/overflow_max", QVariant(OVERFLOW_MAX)).toInt();
+ minLimit = SensorFrameworkConfig::configuration()->value("orientation/overflow_min", QVariant(OVERFLOW_MIN)).toInt();
+ maxLimit = SensorFrameworkConfig::configuration()->value("orientation/overflow_max", QVariant(OVERFLOW_MAX)).toInt();
- angleThresholdPortrait = Config::configuration()->value("orientation/threshold_portrait",QVariant(THRESHOLD_PORTRAIT)).toInt();
- angleThresholdLandscape = Config::configuration()->value("orientation/threshold_landscape",QVariant(THRESHOLD_LANDSCAPE)).toInt();
- discardTime = Config::configuration()->value("orientation/discard_time", QVariant(DISCARD_TIME)).toUInt();
- maxBufferSize = Config::configuration()->value("orientation/buffer_size", QVariant(AVG_BUFFER_MAX_SIZE)).toInt();
+ angleThresholdPortrait = SensorFrameworkConfig::configuration()->value("orientation/threshold_portrait",QVariant(THRESHOLD_PORTRAIT)).toInt();
+ angleThresholdLandscape = SensorFrameworkConfig::configuration()->value("orientation/threshold_landscape",QVariant(THRESHOLD_LANDSCAPE)).toInt();
+ discardTime = SensorFrameworkConfig::configuration()->value("orientation/discard_time", QVariant(DISCARD_TIME)).toUInt();
+ maxBufferSize = SensorFrameworkConfig::configuration()->value("orientation/buffer_size", QVariant(AVG_BUFFER_MAX_SIZE)).toInt();
// Open the handle for boosting cpu on changes that affect orientation
if (cpuBoostFile.exists()) {
|
[-]
[+]
|
Changed |
_service:tar_git:hybris-libsensorfw-qt5-0.10.8.tar.bz2/sensord/calibrationhandler.cpp
^
|
@@ -41,8 +41,8 @@
{
m_timer.setSingleShot(true);
- m_calibRate = Config::configuration()->value<int>("magnetometer/calibration_rate", 100);
- m_calibTimeout = Config::configuration()->value<int>("magnetometer/calibration_timeout", 60000);
+ m_calibRate = SensorFrameworkConfig::configuration()->value<int>("magnetometer/calibration_rate", 100);
+ m_calibTimeout = SensorFrameworkConfig::configuration()->value<int>("magnetometer/calibration_timeout", 60000);
}
CalibrationHandler::~CalibrationHandler()
|
[-]
[+]
|
Changed |
_service:tar_git:hybris-libsensorfw-qt5-0.10.8.tar.bz2/sensord/main.cpp
^
|
@@ -227,10 +227,10 @@
defConfigDir = parser.configDirPath();
}
- if (!Config::loadConfig(defConfigFile, defConfigDir))
+ if (!SensorFrameworkConfig::loadConfig(defConfigFile, defConfigDir))
{
- sensordLogC() << "Config file error! Load using default paths.";
- if (!Config::loadConfig(CONFIG_FILE_PATH, CONFIG_DIR_PATH))
+ sensordLogC() << "SensorFrameworkConfig file error! Load using default paths.";
+ if (!SensorFrameworkConfig::loadConfig(CONFIG_FILE_PATH, CONFIG_DIR_PATH))
{
sensordLogC() << "Which also failed. Bailing out";
return 1;
@@ -287,7 +287,7 @@
delete signalNotifier; signalNotifier = 0;
sensordLogD() << "Exiting...";
- Config::close();
+ SensorFrameworkConfig::close();
return ret;
}
|
[-]
[+]
|
Changed |
_service:tar_git:hybris-libsensorfw-qt5-0.10.8.tar.bz2/sensors/contextplugin/orientationbin.cpp
^
|
@@ -101,7 +101,7 @@
start();
orientationChain->start();
- unsigned int pollInterval = Config::configuration()->value("context/orientation_poll_interval", QVariant(POLL_INTERVAL)).toUInt();
+ unsigned int pollInterval = SensorFrameworkConfig::configuration()->value("context/orientation_poll_interval", QVariant(POLL_INTERVAL)).toUInt();
orientationChain->setIntervalRequest(sessionId, pollInterval);
}
|
[-]
[+]
|
Changed |
_service:tar_git:hybris-libsensorfw-qt5-0.10.8.tar.bz2/sensors/contextplugin/screeninterpreterfilter.cpp
^
|
@@ -47,7 +47,7 @@
topEdge("top")
{
// Get offset from config
- offset = Config::configuration()->value("context/orientation_offset", QVariant(0)).toInt();
+ offset = SensorFrameworkConfig::configuration()->value("context/orientation_offset", QVariant(0)).toInt();
}
void ScreenInterpreterFilter::interpret(unsigned, const PoseData* data)
|
[-]
[+]
|
Changed |
_service:tar_git:hybris-libsensorfw-qt5-0.10.8.tar.bz2/sensors/contextplugin/stabilityfilter.cpp
^
|
@@ -38,7 +38,7 @@
unstableProperty(unstableProperty)
{
connect(&timer, SIGNAL(timeout()), this, SLOT(timeoutTriggered()));
- timeout = Config::configuration()->value("context/stability_timeout", QVariant(defaultTimeout)).toInt() * 1000;
+ timeout = SensorFrameworkConfig::configuration()->value("context/stability_timeout", QVariant(defaultTimeout)).toInt() * 1000;
}
void StabilityFilter::interpret(unsigned, const QPair<double, double>* data)
|
[-]
[+]
|
Changed |
_service:tar_git:hybris-libsensorfw-qt5-0.10.8.tar.bz2/sensors/magnetometersensor/magnetometerscalefilter.cpp
^
|
@@ -30,7 +30,7 @@
MagnetometerScaleFilter::MagnetometerScaleFilter() :
Filter<CalibratedMagneticFieldData, MagnetometerScaleFilter, CalibratedMagneticFieldData>(this, &MagnetometerScaleFilter::filter)
{
- factor = Config::configuration()->value("magnetometer/scale_coefficient", QVariant(1)).toInt();
+ factor = SensorFrameworkConfig::configuration()->value("magnetometer/scale_coefficient", QVariant(1)).toInt();
}
void MagnetometerScaleFilter::filter(unsigned, const CalibratedMagneticFieldData* data)
|
[-]
[+]
|
Changed |
_service:tar_git:hybris-libsensorfw-qt5-0.10.8.tar.bz2/sensors/magnetometersensor/magnetometersensor.cpp
^
|
@@ -49,7 +49,7 @@
magnetometerReader_ = new BufferReader<CalibratedMagneticFieldData>(1);
- scaleCoefficient_ = Config::configuration()->value("magnetometer/scale_coefficient", QVariant(300)).toInt();
+ scaleCoefficient_ = SensorFrameworkConfig::configuration()->value("magnetometer/scale_coefficient", QVariant(300)).toInt();
if (scaleCoefficient_ != 1)
{
|
[-]
[+]
|
Changed |
_service:tar_git:hybris-libsensorfw-qt5-0.10.8.tar.bz2/tests/adaptors/adaptortest.cpp
^
|
@@ -45,7 +45,7 @@
void AdaptorTest::initTestCase()
{
- Config::loadConfig("/etc/sensorfw/sensord.conf", "/etc/sensorfw/sensord.conf.d");
+ SensorFrameworkConfig::loadConfig("/etc/sensorfw/sensord.conf", "/etc/sensorfw/sensord.conf.d");
}
void AdaptorTest::init() {}
|
[-]
[+]
|
Changed |
_service:tar_git:hybris-libsensorfw-qt5-0.10.8.tar.bz2/tests/chains/chainstest.cpp
^
|
@@ -33,7 +33,7 @@
void ChainTest::initTestCase()
{
- Config::loadConfig("/etc/sensorfw/sensord.conf", "/etc/sensorfw/sensord.conf.d");
+ SensorFrameworkConfig::loadConfig("/etc/sensorfw/sensord.conf", "/etc/sensorfw/sensord.conf.d");
}
void ChainTest::init() {}
|
[-]
[+]
|
Changed |
_service:tar_git:hybris-libsensorfw-qt5-0.10.8.tar.bz2/tests/dataflow/dataflowtests.cpp
^
|
@@ -47,7 +47,7 @@
void DataFlowTest::initTestCase()
{
- Config::loadConfig("/etc/sensorfw/sensord.conf", "/etc/sensorfw/sensord.conf.d");
+ SensorFrameworkConfig::loadConfig("/etc/sensorfw/sensord.conf", "/etc/sensorfw/sensord.conf.d");
// Initialise sensormanager
SensorManager& sm = SensorManager::instance();
|
[-]
[+]
|
Changed |
_service:tar_git:hybris-libsensorfw-qt5-0.10.8.tar.bz2/tests/filters/filtertests.cpp
^
|
@@ -44,7 +44,7 @@
void FilterApiTest::initTestCase()
{
- Config::loadConfig(CONFIG_FILE_PATH, CONFIG_DIR_PATH);
+ SensorFrameworkConfig::loadConfig(CONFIG_FILE_PATH, CONFIG_DIR_PATH);
}
/**
|
[-]
[+]
|
Changed |
_service:tar_git:hybris-libsensorfw-qt5-0.10.8.tar.bz2/tests/testapp/abstractsensorhandler.cpp
^
|
@@ -38,13 +38,13 @@
frameCount_(0),
downsample_(false)
{
- if (Config::configuration() != NULL)
+ if (SensorFrameworkConfig::configuration() != NULL)
{
- interval_ = Config::configuration()->value(sensorName_ + "/interval", 100);
- bufferinterval_ = Config::configuration()->value(sensorName_ + "/bufferinterval", 0);
- standbyoverride_ = Config::configuration()->value(sensorName_ + "/standbyoverride", false);
- buffersize_ = Config::configuration()->value(sensorName_ + "/buffersize", 0);
- downsample_ = Config::configuration()->value(sensorName_ + "/downsample", false);
+ interval_ = SensorFrameworkConfig::configuration()->value(sensorName_ + "/interval", 100);
+ bufferinterval_ = SensorFrameworkConfig::configuration()->value(sensorName_ + "/bufferinterval", 0);
+ standbyoverride_ = SensorFrameworkConfig::configuration()->value(sensorName_ + "/standbyoverride", false);
+ buffersize_ = SensorFrameworkConfig::configuration()->value(sensorName_ + "/buffersize", 0);
+ downsample_ = SensorFrameworkConfig::configuration()->value(sensorName_ + "/downsample", false);
}
}
|
[-]
[+]
|
Changed |
_service:tar_git:hybris-libsensorfw-qt5-0.10.8.tar.bz2/tests/testapp/clientadmin.cpp
^
|
@@ -51,24 +51,24 @@
if (parser.configFileInput())
{
QString defConfigFile = parser.configFilePath();
- if (Config::loadConfig(defConfigFile, ""))
- sensordLogT() << "Config file is loading successfully.";
+ if (SensorFrameworkConfig::loadConfig(defConfigFile, ""))
+ sensordLogT() << "SensorFrameworkConfig file is loading successfully.";
else
{
- sensordLogW() << "Config file error! Load using default path.";
- Config::loadConfig(CONFIG_FILE_PATH, "");
+ sensordLogW() << "SensorFrameworkConfig file error! Load using default path.";
+ SensorFrameworkConfig::loadConfig(CONFIG_FILE_PATH, "");
}
} else {
- Config::loadConfig(CONFIG_FILE_PATH, "");
+ SensorFrameworkConfig::loadConfig(CONFIG_FILE_PATH, "");
}
- if (Config::configuration() == NULL)
+ if (SensorFrameworkConfig::configuration() == NULL)
{
sensordLogC() << "Failed to load configuration. Aborting.";
exit(EXIT_FAILURE);
}
- if (!SensorHandler::init(Config::configuration()->groups()))
+ if (!SensorHandler::init(SensorFrameworkConfig::configuration()->groups()))
{
sensordLogC() << "Failed to initialize SensorHandler. Aborting.";
exit(EXIT_FAILURE);
@@ -79,9 +79,9 @@
{
init();
- foreach (const QString& sensorName, Config::configuration()->groups())
+ foreach (const QString& sensorName, SensorFrameworkConfig::configuration()->groups())
{
- int count = Config::configuration()->value<int>(sensorName + "/instances", 0);
+ int count = SensorFrameworkConfig::configuration()->value<int>(sensorName + "/instances", 0);
for(int i = 0; i < count; ++i)
{
SensorHandler* handler = new SensorHandler(sensorName, this);
@@ -120,5 +120,5 @@
}
delete handler;
}
- Config::close();
+ SensorFrameworkConfig::close();
}
|