[-]
[+]
|
Changed |
_service:tar_git:sensorfw.changes
|
|
[-]
[+]
|
Changed |
_service:tar_git:sensorfw-qt5-hybris.spec
^
|
|
[-]
[+]
|
Changed |
_service
^
|
@@ -6,7 +6,7 @@
<service name="tar_git">
<param name="url">https://git.merproject.org/mer-core/sensorfw.git</param>
<param name="branch">master</param>
- <param name="revision">a6c46640b19245ea7e4352227f8866f89c919cd6</param>
+ <param name="revision">bd1f16eacc351afc057c621e7b4b56c17915f78f</param>
<param name="token"/>
<param name="debian">N</param>
<param name="dumb">N</param>
|
[-]
[+]
|
Changed |
_service:tar_git:hybris-libsensorfw-qt5-0.10.0.tar.bz2/config/10-sensord-default.conf
^
|
(renamed from config/90-sensord-default.conf)
|
[-]
[+]
|
Added |
_service:tar_git:hybris-libsensorfw-qt5-0.10.0.tar.bz2/config/20-sensors-default.conf
^
|
@@ -0,0 +1,36 @@
+[available]
+; Availability of some sensors can be defined in hw-settings configuration
+; files. By enabling ssu-sysinfo usage, sensorfwd configuration can be
+; written so that it just refers to hw-settings config. If ssu-sysinfo
+; is not used, these will default to "True".
+;
+; In case of virtual sensors can be implemented on top of multiple real
+; sensors, multiple '|' separated features can be given and the sensor
+; is enabled if at least one of those is set in hw-settings.
+
+accelerometersensor=Feature_AccelerationSensor
+alssensor=Feature_LightSensor
+compasssensor=Feature_CompassSensor
+gyroscopesensor=Feature_GyroSensor
+orientationsensor=Feature_GyroSensor|Feature_AccelerationSensor
+proximitysensor=Feature_ProximitySensor
+
+; In theory having Feature_CoverSensor == have lidsensor. However
+; in practice only mce is expected to track lidsensor and atm it
+; does it via suspend proofed evdev inputs rather than sensorfwd.
+; So, even if the lidsensor adaptors provided by sensorfwd would
+; work, they might interfere with the only user of the sensor.
+; lidsensor=Feature_CoverSensor
+lidsensor=False
+
+; To avoid revisiting config files for all old ports, the defaults
+; added sensors should be set "False" by default here, and to "True"
+; in device specific override config as appropriate.
+
+humiditysensor=False
+magnetometersensor=False
+pressuresensor=False
+rotationsensor=False
+stepcountersensor=False
+tapsensor=False
+temperaturesensor=False
|
[-]
[+]
|
Added |
_service:tar_git:hybris-libsensorfw-qt5-0.10.0.tar.bz2/config/60-sensor-selection-oeverrides.conf
^
|
@@ -0,0 +1,25 @@
+[available]
+
+; Sensors that are disabled by default.
+; -> Enable as appropriate
+
+;humiditysensor=True
+;magnetometersensor=True
+;pressuresensor=True
+;rotationsensor=True
+;stepcountersensor=True
+;tapsensor=True
+;temperaturesensor=True
+
+; Sensors that should/can be enabled/disabled based on
+; hw settings config - or are enabled if sensorfwd is
+; built without ssu-sysinfo support.
+; -> Override as appropriate.
+
+;accelerometersensor=False
+;alssensor=False
+;compasssensor=False
+;gyroscopesensor=False
+;lidsensor=False
+;orientationsensor=False
+;proximitysensor=False
|
[-]
[+]
|
Changed |
_service:tar_git:hybris-libsensorfw-qt5-0.10.0.tar.bz2/core/config.cpp
^
|
@@ -39,94 +39,68 @@
}
Config::~Config() {
- clearConfig();
}
void Config::clearConfig() {
- foreach(QSettings* setting, settings)
- delete setting;
- settings.clear();
+ m_settings.clear();
}
bool Config::loadConfig(const QString &defConfigPath, const QString &configDPath) {
- Config *config = NULL;
+ /* Not having config files is ok, failing to load one that exists is not */
bool ret = true;
-
- /* Check/create new static config */
- if (static_configuration) {
- config = static_configuration;
- } else {
- config = new Config();
+ if (!static_configuration) {
+ static_configuration = new Config();
}
-
- if (!config->loadConfigFile(defConfigPath))
- ret = false;
-
- /* Scan config.d dir */
- QStringList fileList;
- if(!configDPath.isEmpty())
- {
+ /* Process config.d dir in alnum order */
+ if (!configDPath.isEmpty()) {
QDir dir(configDPath, "*.conf", QDir::Name, QDir::Files);
- fileList = dir.entryList();
- foreach(const QString& file, fileList)
- {
- if (!config->loadConfigFile(dir.absoluteFilePath(file)))
+ foreach(const QString &file, dir.entryList()) {
+ if (!static_configuration->loadConfigFile(dir.absoluteFilePath(file))) {
ret = false;
+ }
}
}
-
- static_configuration = config;
-
+ /* Primary config file overrides config.d */
+ if (!defConfigPath.isEmpty() && QFile::exists(defConfigPath) ) {
+ if (!static_configuration->loadConfigFile(defConfigPath))
+ ret = false;
+ }
return ret;
}
bool Config::loadConfigFile(const QString &configFileName) {
- if(!QFile::exists(configFileName))
- {
+ /* Success means the file was loaded and processed without hiccups */
+ bool loaded = false;
+ if (!QFile::exists(configFileName)) {
sensordLogW() << "File does not exists \"" << configFileName << "\"";
- return false;
- }
- QSettings* setting = new QSettings(configFileName, QSettings::IniFormat);
- if(setting->status() == QSettings::NoError) {
- settings.append(setting);
- sensordLogD() << "Config file \"" << configFileName << "\" successfully loaded";
- return true;
+ } else {
+ QSettings merge(configFileName, QSettings::IniFormat);
+ QSettings::Status status(merge.status());
+ if (status == QSettings::FormatError ) {
+ sensordLogW() << "Configuration file \"" << configFileName << "\" is in wrong format";
+ } else if (status != QSettings::NoError) {
+ sensordLogW() << "Unable to open \"" << configFileName << "\" configuration file";
+ } else {
+ foreach (const QString &key, merge.allKeys()) {
+ m_settings.setValue(key, merge.value(key));
+ }
+ loaded = true;
+ }
}
- else if(setting->status() == QSettings::AccessError)
- sensordLogW() << "Unable to open \"" << configFileName << "\" configuration file";
- else if(setting->status() == QSettings::FormatError)
- sensordLogW() << "Configuration file \"" << configFileName << "\" is in wrong format";
- else
- sensordLogW() << "Configuration file \"" << configFileName << "\" parsing failed to unknown error: " << setting->status();
- delete setting;
- return false;
+ return loaded;
}
QVariant Config::value(const QString &key) const {
- /* Iterate through configs so that keys in the first files
- * have preference over the last.
- */
- foreach(QSettings* setting, settings) {
- if(setting->contains(key))
- {
- QVariant var = setting->value(key, QVariant());
- if(var.isValid())
- sensordLogD() << "Value for key '" << key << "': " << var.toString();
- return var;
- }
+ QVariant var = m_settings.value(key, QVariant());
+ if(var.isValid()) {
+ sensordLogT() << "Value for key" << key << ":" << var.toString();
}
- return QVariant();
+ return var;
}
QStringList Config::groups() const
{
- QStringList groups;
- foreach(QSettings* setting, settings) {
- foreach(const QString& group, setting->childGroups()) {
- if(!groups.contains(group))
- groups << group;
- }
- }
+ QStringList groups = m_settings.childGroups();
return groups;
}
|
[-]
[+]
|
Changed |
_service:tar_git:hybris-libsensorfw-qt5-0.10.0.tar.bz2/core/config.h
^
|
@@ -136,7 +136,7 @@
*/
void clearConfig();
- QList<QSettings*> settings; /**< parsed QSettings */
+ QSettings m_settings; /**< parsed QSettings */
};
template<typename T>
|
[-]
[+]
|
Changed |
_service:tar_git:hybris-libsensorfw-qt5-0.10.0.tar.bz2/core/core.pro
^
|
@@ -80,6 +80,11 @@
DEFINES += SENSORFW_MCE_WATCHER
}
+contains(CONFIG,ssusysinfo) {
+ PKGCONFIG += ssu-sysinfo
+ QMAKE_CXXFLAGS += -DUSE_SSUSYSINFO
+}
+
lunaservice {
SOURCES += lsclient.cpp
HEADERS += lsclient.h
|
[-]
[+]
|
Changed |
_service:tar_git:hybris-libsensorfw-qt5-0.10.0.tar.bz2/core/hybrisadaptor.cpp
^
|
@@ -31,6 +31,8 @@
#include <unistd.h>
#include <fcntl.h>
#include <errno.h>
+#include <time.h>
+#include <signal.h>
#ifndef SENSOR_TYPE_ACCELEROMETER
#define SENSOR_TYPE_ACCELEROMETER (1)
@@ -91,7 +93,7 @@
, sensorsCount(0)
, sensorMap()
, registeredAdaptors()
- , adaptorReader(parent)
+ , adaptorReaderTid(0)
{
init();
}
@@ -99,6 +101,34 @@
HybrisManager::~HybrisManager()
{
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;
+ }
+ }
+ 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);
+ }
+ }
}
HybrisManager *HybrisManager::instance()
@@ -147,6 +177,14 @@
sensorMap.insert(sensorList[i].type, i);
}
}
+
+ int err = pthread_create(&adaptorReaderTid, 0, adaptorReaderThread, this);
+ if (err) {
+ adaptorReaderTid = 0;
+ sensordLogC() << "Failed to start hal reader thread";
+ } else {
+ sensordLogD() << "Hal reader thread started";
+ }
}
int HybrisManager::handleForType(int sensorType)
@@ -209,8 +247,6 @@
sensordLogW() <<Q_FUNC_INFO<< "failed for"<< strerror(-error);
adaptor->setValid(false);
}
- if (!adaptorReader.isRunning())
- adaptorReader.startReader();
}
}
@@ -233,10 +269,6 @@
}
}
qDebug() << "okToStop" << okToStop;
-
- if (okToStop) {
- adaptorReader.stopReader();
- }
}
bool HybrisManager::resumeReader(HybrisAdaptor *adaptor)
@@ -466,7 +498,6 @@
}
}
-
bool HybrisAdaptor::standby()
{
sensordLogD() << "Adaptor '" << id() << "' requested to go to standby" << "deviceStandbyOverride" << deviceStandbyOverride();
@@ -487,7 +518,6 @@
return true;
}
-
bool HybrisAdaptor::resume()
{
sensordLogD() << "Adaptor '" << id() << "' requested to resume from standby";
@@ -591,36 +621,6 @@
return true;
}
-/*/////////////////////////////////////////////////////////////////////
-/// \brief HybrisAdaptorReader::HybrisAdaptorReader
-/// \param parent
-///
-*/
-
-HybrisAdaptorReader::HybrisAdaptorReader(QObject *parent)
- : QThread(parent),
- running_(false)
-{
-}
-
-HybrisAdaptorReader::~HybrisAdaptorReader()
-{
-}
-
-////
-/// \brief HybrisAdaptorReader::stopReader
-///
-void HybrisAdaptorReader::stopReader()
-{
- running_ = false;
-}
-
-void HybrisAdaptorReader::startReader()
-{
- running_ = true;
- start();
-}
-
static void ObtainTemporaryWakeLock()
{
static bool triedToOpen = false;
@@ -644,44 +644,57 @@
}
}
-void HybrisAdaptorReader::run()
+void *HybrisManager::adaptorReaderThread(void *aptr)
{
- int err = 0;
+ HybrisManager *manager = static_cast<HybrisManager *>(aptr);
static const size_t numEvents = 16;
sensors_event_t buffer[numEvents];
- while (running_) {
- int numberOfEvents = hybrisManager()->device->poll(hybrisManager()->device, 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() << "poll() failed" << strerror(-err);
- QThread::msleep(1000);
- } else {
- 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;
- }
- hybrisManager()->processSample(data);
-
+ 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)) {
|
[-]
[+]
|
Changed |
_service:tar_git:hybris-libsensorfw-qt5-0.10.0.tar.bz2/core/hybrisadaptor.h
^
|
@@ -26,31 +26,14 @@
#include <QTimer>
#include <QFile>
+#include <pthread.h>
+
#include "deviceadaptor.h"
#include <hardware/sensors.h>
#define SENSORFW_MCE_WATCHER
class HybrisAdaptor;
-class HybrisAdaptorReader : public QThread
-{
- Q_OBJECT
- Q_DISABLE_COPY(HybrisAdaptorReader)
-
-public:
-
- HybrisAdaptorReader(QObject *parent);
- ~HybrisAdaptorReader();
-
- void run();
- void stopReader();
- void startReader();
-
-private:
- bool running_;
-};
-
-
class HybrisManager : public QObject
{
Q_OBJECT
@@ -90,9 +73,11 @@
int sensorsCount;
QMap <int, int> sensorMap; //type, index
QMap <int, HybrisAdaptor *> registeredAdaptors; //type, obj
- HybrisAdaptorReader adaptorReader;
-
+ pthread_t adaptorReaderTid;
friend class HybrisAdaptorReader;
+
+private:
+ static void *adaptorReaderThread(void *aptr);
};
class HybrisAdaptor : public DeviceAdaptor
@@ -140,7 +125,7 @@
QList<int> sensorIds;
unsigned int interval_;
bool inStandbyMode_;
- bool running_;
+ volatile bool running_;
bool shouldBeRunning_;
};
|
[-]
[+]
|
Changed |
_service:tar_git:hybris-libsensorfw-qt5-0.10.0.tar.bz2/core/loader.cpp
^
|
@@ -31,13 +31,19 @@
#include <QPluginLoader>
#include <QStringList>
#include <QList>
+#include <QDir>
#include <QCoreApplication>
#include "logging.h"
#include "config.h"
+#ifdef USE_SSUSYSINFO
+# include <ssusysinfo/ssusysinfo.h>
+#endif
+
Loader::Loader()
{
+ scanAvailablePlugins();
}
Loader& Loader::instance()
@@ -47,99 +53,183 @@
return the_loader;
}
-bool Loader::loadPluginFile(const QString& name, QString *errorString, QStringList& newPluginNames, QList<PluginBase*>& newPlugins) const
-{
- sensordLogT() << "Loading plugin:" << name;
+#define PLUGIN_PREFIX_ENV "SENSORFW_LIBRARY_PATH"
+#define PLUGIN_DIRECTORY "/usr/lib/sensord-qt5"
+#define PLUGIN_PREFIX "lib"
+#define PLUGIN_SUFFIX "-qt5.so"
+#define SENSOR_SUFFIX "sensor"
-#if QT_VERSION < QT_VERSION_CHECK(5, 0, 0)
- QString pluginPath = QString::fromLatin1("/usr/lib/sensord/lib%1.so").arg(name);
-#else
- QString pluginPath;
- QByteArray env = qgetenv("SENSORFW_LIBRARY_PATH");
- if (env.isEmpty())
- pluginPath = QString::fromLatin1("/usr/lib/sensord-qt5/lib%1-qt5.so").arg(name);
- else
- pluginPath = QString::fromLatin1(env+"/usr/lib/sensord-qt5/lib%1-qt5.so").arg(name);
+static QString getPluginDirectory()
+{
+ QByteArray env = qgetenv(PLUGIN_PREFIX_ENV);
+ return QString::fromUtf8(env + PLUGIN_DIRECTORY);
+}
-#endif
+static QString getPluginPath(const QString &name)
+{
+ return QString("%1/" PLUGIN_PREFIX "%2" PLUGIN_SUFFIX).arg(getPluginDirectory()).arg(name);
+}
- QPluginLoader qpl(pluginPath);
+bool Loader::loadPluginFile(const QString &name, QString &errorString, QStringList &stack)
+{
+ const QString resolvedName(resolveRealPluginName(name));
+ QPluginLoader qpl(getPluginPath(resolvedName));
qpl.setLoadHints(QLibrary::ExportExternalSymbolsHint);
- if (!qpl.load()) {
- *errorString = qpl.errorString();
- sensordLogC() << "plugin loading error: " << *errorString;
- return false;
- }
-
- QObject* object = qpl.instance();
- if (!object) {
- *errorString = "not able to instanciate";
- sensordLogC() << "plugin loading error: " << *errorString;
- return false;
- }
-
- PluginBase* plugin = qobject_cast<PluginBase*>(object);
- if (!plugin) {
- *errorString = "not a Plugin type";
- sensordLogC() << "plugin loading error: " << *errorString;
- return false;
- }
-
- // Add plugins to the front of the list so they are initialized in reverse order. This will guarantee that dependencies are initialized first for each plugin.
- newPluginNames.prepend(name);
- newPlugins.prepend(plugin);
-
- // Get dependencies
- QStringList requiredPlugins(plugin->Dependencies());
- sensordLogT() << name << " requires: " << requiredPlugins;
-
- bool loaded = true;
- for (int i = 0; i < requiredPlugins.size() && loaded; ++i) {
- if (!(loadedPluginNames_.contains(requiredPlugins.at(i)) ||
- newPluginNames.contains(requiredPlugins.at(i))))
- {
- sensordLogT() << requiredPlugins.at(i) << " is not yet loaded, trying to load.";
- QString resolvedName = resolveRealPluginName(requiredPlugins.at(i));
- sensordLogT() << requiredPlugins.at(i) << " resolved as " << resolvedName << ". Loading";
- loaded = loadPluginFile(resolvedName, errorString, newPluginNames, newPlugins);
+ QObject *object = 0;
+ PluginBase *plugin = 0;
+ sensordLogD() << "Loader loading plugin:" << resolvedName << "as:" << name << "from:" << qpl.fileName();
+ bool loaded = false;
+ bool cyclic = stack.contains(resolvedName);
+ stack.prepend(resolvedName);
+ if (cyclic) {
+ errorString = "cyclic plugin dependency";
+ sensordLogC() << "Plugin has cyclic dependency:" << resolvedName;
+ } else if (loadedPluginNames_.contains(resolvedName)) {
+ sensordLogD() << "Plugin is already loaded:" << resolvedName;
+ loaded = true;
+ } else if (!pluginAvailable(resolvedName)) {
+ errorString = "plugin not available";
+ sensordLogW() << "Plugin not available:" << resolvedName;
+ } else if (!qpl.load()) {
+ errorString = qpl.errorString();
+ sensordLogC() << "Plugin loading error:" << resolvedName << "-" << errorString;
+ } else if (!(object = qpl.instance())) {
+ errorString = "not able to instanciate";
+ sensordLogC() << "Plugin loading error: " << resolvedName << "-" << errorString;
+ } else if (!(plugin = qobject_cast<PluginBase*>(object))) {
+ errorString = "not a Plugin type";
+ sensordLogC() << "Plugin loading error: " << resolvedName << "-" << errorString;
+ } else {
+ loaded = true;
+ QStringList dependencies(plugin->Dependencies());
+ sensordLogD() << resolvedName << "requires:" << dependencies;
+ foreach (const QString &dependency, dependencies) {
+ if (!(loaded = loadPluginFile(dependency, errorString, stack))) {
+ break;
+ }
+ }
+ if (loaded) {
+ plugin->Register(*this);
+ loadedPluginNames_.append(resolvedName);
+ plugin->Init(*this);
}
}
+ stack.removeOne(resolvedName);
+ if (!loaded) {
+ invalidatePlugin(resolvedName);
+ }
return loaded;
}
-bool Loader::loadPlugin(const QString& name, QString* errorString)
+bool Loader::loadPlugin(const QString& name, QString *errorString)
{
QString error;
- bool loaded = false;
- QStringList newPluginNames;
- QList<PluginBase*> newPlugins;
-
- if (loadedPluginNames_.contains(name)) {
- sensordLogD() << "Plugin already loaded.";
- return true;
+ QStringList stack;
+ bool loaded = loadPluginFile(name, error, stack);
+ if (!loaded && errorString) {
+ *errorString = error;
}
+ return loaded;
+}
- if (loadPluginFile(name, &error, newPluginNames, newPlugins)) {
+#ifdef USE_SSUSYSINFO
+static ssusysinfo_t *ssusysinfo = 0;
+#endif
- // Register newly loaded plugins
- foreach (PluginBase* base, newPlugins) {
- base->Register(*this);
+static bool evaluateAvailabilityValue(const QString &name, const QString &val)
+{
+ bool available = true;
+ if (val.startsWith("Feature_")) {
+#ifdef USE_SSUSYSINFO
+ const QStringList features(val.split("|"));
+ bool allow = false;
+ bool deny = false;
+ foreach(const QString &feature, features) {
+ hw_feature_t id = ssusysinfo_hw_feature_from_name(feature.toUtf8().constData());
+ if (id == Feature_Invalid ) {
+ sensordLogW() << "unknown hw feature:" << feature;
+ continue;
+ }
+ if( ssusysinfo_has_hw_feature(ssusysinfo, id) ) {
+ allow = true;
+ break;
+ }
+ deny = true;
}
- loadedPluginNames_.append(newPluginNames);
- loaded = true;
+ if( deny && !allow ) {
+ sensordLogD() << "plugin disabled in hw-config: " << name << "value" << val;
+ available = false;
+ }
+#else
+ // When compiled without ssu-support, these are enabled by design
+ sensordLogD() << "sensor plugin enabled implicitly: " << name << "value" << val;
+#endif
|
[-]
[+]
|
Changed |
_service:tar_git:hybris-libsensorfw-qt5-0.10.0.tar.bz2/core/loader.h
^
|
@@ -50,8 +50,31 @@
* @param name plugin name.
* @param errorMessage object to write error message if plugin loading
* fails. If NULL then error message is not written.
+ * @return true on success, false on failure
*/
- bool loadPlugin(const QString& name, QString* errorMessage = 0);
+ bool loadPlugin(const QString &name, QString *errorMessage = 0);
+
+ /**
+ * Test if a plugin is available for loading
+ *
+ * @param name plugin name
+ * @return true if plugin is available, false if not
+ */
+ bool pluginAvailable(const QString &name) const;
+
+ /**
+ * Get a list of plugins available for loading
+ *
+ * @return Array of plugin names
+ */
+ QStringList availablePlugins() const;
+
+ /**
+ * Get a list of sensor plugins available for loading
+ *
+ * @return Array of plugin names
+ */
+ QStringList availableSensorPlugins() const;
private:
Loader();
@@ -63,10 +86,11 @@
*
* @param name plugin to load.
* @param errorString object to write error message if plugin loading fails.
- * @param newPluginNames List of new loaded plugin names.
- * @param newPlugin List of new loaded plugin objects.
+ * @param stack Pending plugin load stack for detecting circular dependencies.
*/
- bool loadPluginFile(const QString& name, QString *errorString, QStringList& newPluginNames, QList<PluginBase*>& newPlugins) const;
+ bool loadPluginFile(const QString &name, QString &errorString, QStringList &stack);
+
+ void invalidatePlugin(const QString &name);
/**
* Resolve plugin name.
@@ -74,9 +98,13 @@
* @param pluginName plugin name.
* @return resolved plugin name.
*/
- QString resolveRealPluginName(const QString& pluginName) const;
+ QString resolveRealPluginName(const QString &pluginName) const;
QStringList loadedPluginNames_; /**< list of loaded plugins */
+
+ QStringList availablePluginNames_; /**< list of loaded plugins */
+
+ void scanAvailablePlugins();
};
#endif
|
[-]
[+]
|
Changed |
_service:tar_git:hybris-libsensorfw-qt5-0.10.0.tar.bz2/core/logging.h
^
|
@@ -30,9 +30,8 @@
#include <QDebug>
#define sensordLogT() (qDebug())
-#define sensordLogD() (qDebug())
+#define sensordLogD() (qInfo())
#define sensordLogW() (qWarning())
#define sensordLogC() (qCritical())
-#define sensordLog() (qDebug())
#endif //LOGGING_H
|
[-]
[+]
|
Changed |
_service:tar_git:hybris-libsensorfw-qt5-0.10.0.tar.bz2/core/nodebase.cpp
^
|
@@ -80,7 +80,7 @@
{
if (!m_dataRangeList.contains(range))
{
- sensordLogD() << "Introduced new data range: " << range.min << "-" << range.max << ", " << range.resolution;
+ sensordLogD() << "Introduced new data range for '" << id_ << "':" << range.min << "-" << range.max << "," << range.resolution;
m_dataRangeList.append(range);
}
}
@@ -273,7 +273,7 @@
{
if (!m_intervalList.contains(interval))
{
- sensordLogD() << "Introduced new interval: " << interval.min << "-" << interval.max;
+ sensordLogD() << "Introduced new interval for '" << id_ << "':" << interval.min << "-" << interval.max;
m_intervalList.append(interval);
}
}
@@ -375,7 +375,7 @@
bool NodeBase::setStandbyOverrideRequest(const int sessionId, const bool override)
{
- sensordLogD() << sessionId << " requested standbyoverride for '" << id() << "' :" << override;
+ sensordLogD() << sessionId << "requested standbyoverride for '" << id() << "' :" << override;
// Only store true requests, id is enough, no need for value
if (override == false)
{
@@ -459,7 +459,7 @@
{
if (!isValidIntervalRequest(value))
{
- sensordLogW() << "Attempting to define invalid default data rate: " << value;
+ sensordLogW() << "Attempting to define invalid default data rate:" << value;
return false;
}
m_defaultInterval = value;
@@ -711,36 +711,41 @@
{
Q_UNUSED(range);
Q_UNUSED(sessionId);
+ sensordLogD() << __func__ << "not implemented in some node using it.";
return false;
}
bool NodeBase::setStandbyOverride(bool override)
{
Q_UNUSED(override);
+ sensordLogD() << __func__ << "not implemented in some node using it.";
return false;
}
unsigned int NodeBase::interval() const
{
+ sensordLogD() << __func__ << "not implemented in some node using it.";
return 0;
}
bool NodeBase::setInterval(unsigned int value, int sessionId)
{
- sensordLogW() << "setInterval() not implemented in some node using it.";
Q_UNUSED(value);
Q_UNUSED(sessionId);
+ sensordLogD() << __func__ << "not implemented in some node using it.";
return false;
}
bool NodeBase::setBufferSize(unsigned int value)
{
Q_UNUSED(value);
+ sensordLogD() << __func__ << "not implemented in some node using it.";
return false;
}
bool NodeBase::setBufferInterval(unsigned int value)
{
Q_UNUSED(value);
+ sensordLogD() << __func__ << "not implemented in some node using it.";
return false;
}
|
[-]
[+]
|
Changed |
_service:tar_git:hybris-libsensorfw-qt5-0.10.0.tar.bz2/core/sensormanager.cpp
^
|
@@ -310,7 +310,7 @@
void SensorManager::removeSensor(const QString& id)
{
- sensordLogD() << "Removing sensor: " << id;
+ sensordLogD() << "SensorManager removing sensor:" << id;
QMap<QString, SensorInstanceEntry>::iterator entryIt = sensorInstanceMap_.find(id);
bus().unregisterObject(OBJECT_PATH + "/" + id);
@@ -321,7 +321,7 @@
bool SensorManager::loadPlugin(const QString& name)
{
- sensordLogD() << "Loading plugin: " << name;
+ sensordLogD() << "SensorManager loading plugin:" << name;
QString errorMessage;
bool result;
@@ -333,9 +333,27 @@
return result;
}
+QStringList SensorManager::availablePlugins() const
+{
+ Loader& l = Loader::instance();
+ return l.availablePlugins();
+}
+
+bool SensorManager::pluginAvailable(const QString &name) const
+{
+ Loader& l = Loader::instance();
+ return l.pluginAvailable(name);
+}
+
+QStringList SensorManager::availableSensorPlugins() const
+{
+ Loader& l = Loader::instance();
+ return l.availableSensorPlugins();
+}
+
int SensorManager::requestSensor(const QString& id)
{
- sensordLogD() << "Requesting sensor: " << id;
+ sensordLogD() << "Requesting sensor:" << id;
clearError();
@@ -440,7 +458,7 @@
{
chain = chainFactoryMap_[type](id);
Q_ASSERT(chain);
- sensordLogD() << "Instantiated chain '" << id << "'. Valid = " << chain->isValid();
+ sensordLogD() << "Instantiated chain '" << id << "'. Valid =" << chain->isValid();
entryIt.value().cnt_++;
entryIt.value().chain_ = chain;
@@ -499,7 +517,7 @@
DeviceAdaptor* SensorManager::requestDeviceAdaptor(const QString& id)
{
- sensordLogD() << "Requesting adaptor: " << id;
+ sensordLogD() << "Requesting adaptor:" << id;
clearError();
if( id.contains(';') ) // no parameter passing in release
@@ -517,7 +535,7 @@
Q_ASSERT( entryIt.value().adaptor_ );
da = entryIt.value().adaptor_;
entryIt.value().cnt_++;
- sensordLogD() << "Found adaptor '" << id << "'. Ref count: " << entryIt.value().cnt_;
+ sensordLogD() << "Found adaptor '" << id << "'. Ref count:" << entryIt.value().cnt_;
}
else
{
@@ -538,7 +556,7 @@
{
entryIt.value().adaptor_ = da;
entryIt.value().cnt_++;
- sensordLogD() << "Instantiated adaptor '" << id << "'. Valid = " << da->isValid();
+ sensordLogD() << "Instantiated adaptor '" << id << "'. Valid =" << da->isValid();
}
else
{
@@ -563,7 +581,7 @@
void SensorManager::releaseDeviceAdaptor(const QString& id)
{
- sensordLogD() << "Releasing adaptor: " << id;
+ sensordLogD() << "Releasing adaptor:" << id;
clearError();
if( id.contains(';') ) // no parameter passing in release
@@ -594,7 +612,7 @@
}
else
{
- sensordLogD() << "Adaptor '" << id << "' has ref count: " << entryIt.value().cnt_;
+ sensordLogD() << "Adaptor '" << id << "' has ref count:" << entryIt.value().cnt_;
}
}
else
@@ -610,7 +628,7 @@
FilterBase* SensorManager::instantiateFilter(const QString& id)
{
- sensordLogD() << "Instantiating filter: " << id;
+ sensordLogD() << "Instantiating filter:" << id;
QMap<QString, FilterFactoryMethod>::iterator it = filterFactoryMap_.find(id);
if(it == filterFactoryMap_.end())
@@ -673,7 +691,7 @@
void SensorManager::displayStateChanged(bool displayState)
{
- sensordLogD() << "Signal detected, display state changed to: " << displayState;
+ sensordLogD() << "Signal detected, display state changed to:" << displayState;
if (displayState) {
/// Emit signal to make background calibration resume from sleep
emit displayOn();
|
[-]
[+]
|
Changed |
_service:tar_git:hybris-libsensorfw-qt5-0.10.0.tar.bz2/core/sensormanager.h
^
|
@@ -277,6 +277,27 @@
bool loadPlugin(const QString& name);
/**
+ * Test if a plugin is available
+ *
+ * @return true if plugin exists, false otherwise
+ */
+ bool pluginAvailable(const QString &name) const;
+
+ /**
+ * List all available plugins.
+ *
+ * @return array of plugin names
+ */
+ QStringList availablePlugins() const;
+
+ /**
+ * List available sensor plugins.
+ *
+ * @return array of plugin names
+ */
+ QStringList availableSensorPlugins() const;
+
+ /**
* Request sensor.
*
* @param id Sensor ID.
|
[-]
[+]
|
Changed |
_service:tar_git:hybris-libsensorfw-qt5-0.10.0.tar.bz2/core/sensormanager_a.cpp
^
|
@@ -54,16 +54,31 @@
return sensorManager()->loadPlugin(name);
}
+QStringList SensorManagerAdaptor::availablePlugins() const
+{
+ return sensorManager()->availablePlugins();
+}
+
+bool SensorManagerAdaptor::pluginAvailable(const QString &name) const
+{
+ return sensorManager()->pluginAvailable(name);
+}
+
+QStringList SensorManagerAdaptor::availableSensorPlugins() const
+{
+ return sensorManager()->availableSensorPlugins();
+}
+
int SensorManagerAdaptor::requestSensor(const QString &id, qint64 pid)
{
int session = sensorManager()->requestSensor(id);
- sensordLog() << "Sensor '" << id << "' requested. Created session: " << session << ". Client PID: " << pid;
+ sensordLogD() << "Sensor '" << id << "' requested. Created session: " << session << ". Client PID: " << pid;
return session;
}
bool SensorManagerAdaptor::releaseSensor(const QString &id, int sessionId, qint64 pid)
{
- sensordLog() << "Sensor '" << id << "' release requested for session " << sessionId << ". Client PID: " << pid;
+ sensordLogD() << "Sensor '" << id << "' release requested for session " << sessionId << ". Client PID: " << pid;
return sensorManager()->releaseSensor(id, sessionId);
}
|
[-]
[+]
|
Changed |
_service:tar_git:hybris-libsensorfw-qt5-0.10.0.tar.bz2/core/sensormanager_a.h
^
|
@@ -88,6 +88,27 @@
bool loadPlugin(const QString& name);
/**
+ * Test if a plugin is available
+ *
+ * @return true if plugin exists, false otherwise
+ */
+ bool pluginAvailable(const QString& name) const;
+
+ /**
+ * List all available plugins.
+ *
+ * @return array of plugin names
+ */
+ QStringList availablePlugins() const;
+
+ /**
+ * List available sensor plugins.
+ *
+ * @return array of plugin names
+ */
+ QStringList availableSensorPlugins() const;
+
+ /**
* Request new sensor session to be created.
*
* @param id Sensor ID.
|
[-]
[+]
|
Changed |
_service:tar_git:hybris-libsensorfw-qt5-0.10.0.tar.bz2/debian/rules
^
|
@@ -48,7 +48,7 @@
dh_testdir
# Add here commands to configure the package.
- cd $(BUILD_DIR) && qmake $(QMAKECONFIG) CONFIG+="configs" "QMAKE_CXXFLAGS=$(CFLAGS)" "MAKE_DOCS=$(MAKE_DOCS)" ../$(PROJECT_NAME).pro
+ cd $(BUILD_DIR) && qmake $(QMAKECONFIG) CONFIG+="configs" CONFIG+="autohybris" "QMAKE_CXXFLAGS=$(CFLAGS)" "MAKE_DOCS=$(MAKE_DOCS)" ../$(PROJECT_NAME).pro
export LD_RUN_PATH=/usr/lib/sensord-qt5/
touch configure-stamp
|
[-]
[+]
|
Changed |
_service:tar_git:hybris-libsensorfw-qt5-0.10.0.tar.bz2/doc/PLUGIN-GUIDE
^
|
@@ -221,7 +221,8 @@
(1) /etc/sensorfw/sensord.conf
(2) /etc/sensorfw/sensord.conf.d/
-Any option set in (1) will override options set in any of the files in (2). Files in (2) are given priority based on alphanumeric order. Using double-digits as the beginning of the filename for clarity is encouraged.
+Any option set in (1) will override options set in any of the files in (2). Files in (2) are processed in alpha-numerical order, and later files can override settings from earlier files. Using double-digits as the beginning of the filename for clarity is encouraged.
+
Configuration files contain sections for different HW. These sections should connect plugin metanames (sampleadaptor) with the real plugin that should be used (sampleadaptor-inputdev). The configuration file also contains option 'deviceId', which specifies which section should be used. This will be removed once we have automatic detection of underlying HW in place.
|
[-]
[+]
|
Changed |
_service:tar_git:hybris-libsensorfw-qt5-0.10.0.tar.bz2/doc/mainpage.h
^
|
@@ -694,9 +694,9 @@
(1) /etc/sensorfw/sensord.conf
(2) /etc/sensorfw/sensord.conf.d/
-Any option set in (1) will override options set in any of the files in (2). Files in (2) are given
-priority based on alphanumeric order. Using double-digits as the beginning of the filename for
-clarity is encouraged.
+Any option set in (1) will override options set in any of the files in (2). Files in (2) are
+processed in alpha-numerical order, and later files can override settings from earlier files.
+Using double-digits as the beginning of the filename for clarity is encouraged.
Configuration files contain sections for different HW. These sections should connect plugin
metanames (sampleadaptor) with the real plugin that should be used (sampleadaptor-inputdev).
|
[-]
[+]
|
Changed |
_service:tar_git:hybris-libsensorfw-qt5-0.10.0.tar.bz2/sensord/main.cpp
^
|
@@ -1,5 +1,3 @@
-
-
/**
@file main.cpp
@brief Sensord initiation point
@@ -32,13 +30,16 @@
#include <QtCore/QCoreApplication>
#include <QtCore/QDebug>
+#include <QSocketNotifier>
#include <systemd/sd-daemon.h>
+#include <unistd.h>
#include <signal.h>
#include <iostream>
#include <errno.h>
#include <unistd.h>
+#include <fcntl.h>
#include "config.h"
#include "sensormanager.h"
@@ -50,9 +51,27 @@
static QtMsgType logLevel;
static QtMessageHandler previousMessageHandler;
+static int normalizeLevel(QtMsgType type)
+{
+ /* Map QtMsgType enum values to something that hopefully
+ * makes sense in less-than / greater-than sense too. */
+ switch (type) {
+ case QtDebugMsg:
+ return 0;
+ case QtInfoMsg:
+ return 1;
+ case QtWarningMsg:
+ return 3;
+ case QtCriticalMsg:
+ return 4;
+ default:
+ return static_cast<int>(type);
+ }
+}
+
static void messageOutput(QtMsgType type, const QMessageLogContext &context, const QString &str)
{
- if (type < logLevel)
+ if (normalizeLevel(type) < normalizeLevel(logLevel))
return;
previousMessageHandler(type, context, str);
@@ -63,11 +82,14 @@
void signalUSR1(int param)
{
Q_UNUSED(param);
-
- logLevel = QtMsgType(logLevel + 1);
- if (logLevel > QtSystemMsg)
+ if (logLevel != QtDebugMsg) {
logLevel = QtDebugMsg;
- qDebug() << "New debugging level: " << logLevel;
+ sensordLogW() << "Debug logging enabled";
+ }
+ else {
+ logLevel = QtWarningMsg;
+ sensordLogW() << "Debug logging disabled";
+ }
}
void signalUSR2(int param)
@@ -87,10 +109,92 @@
void signalINT(int param)
{
- Q_UNUSED(param);
+ signal(param, SIG_DFL);
+ sensordLogD() << "Terminating ...";
QCoreApplication::exit(0);
}
+class SignalNotifier : public QObject
+{
+public:
+ SignalNotifier();
+ ~SignalNotifier();
+private slots:
+ void handleSignalInput(int socket);
+private:
+ static void handleAsyncSignal(int sig);
+ QSocketNotifier *m_socketNotifier;
+ static int s_pipe[2];
+ static const int s_signals[];
+};
+
+SignalNotifier::SignalNotifier()
+ : m_socketNotifier(0)
+{
+ sensordLogD() << "Setup async signal handlers";
+ if (pipe2(s_pipe, O_CLOEXEC) == -1) {
+ qFatal("Failed to create a pipe for signal passunc");
+ }
+ m_socketNotifier = new QSocketNotifier(s_pipe[0], QSocketNotifier::Read, this);
+ connect(m_socketNotifier, &QSocketNotifier::activated,
+ this, &SignalNotifier::handleSignalInput);
+ struct sigaction action;
+ memset(&action, 0, sizeof action);
+ action.sa_handler = handleAsyncSignal;
+ sigemptyset(&action.sa_mask);
+ action.sa_flags = SA_RESTART;
+ for (size_t i = 0; s_signals[i] != -1; ++i )
+ sigaction(s_signals[i], &action, 0);
+}
+
+SignalNotifier::~SignalNotifier()
+{
+ sensordLogD() << "Reset async signal handlers";
+ for (size_t i = 0; s_signals[i] != -1; ++i )
+ signal(s_signals[i], SIG_DFL);
+ delete m_socketNotifier; m_socketNotifier = 0;
+ close(s_pipe[1]), s_pipe[1] = -1;
+ close(s_pipe[0]), s_pipe[0] = -1;
+}
+
+void SignalNotifier::handleAsyncSignal(int sig)
+{
+ /* Can call only async-signal safe functions! */
+ if (write(s_pipe[1], &sig, sizeof sig) == -1) {
+ _exit(EXIT_FAILURE);
+ }
+}
+
+void SignalNotifier::handleSignalInput(int socket)
+{
+ Q_UNUSED(socket);
+ int sig = SIGTERM;
+ uint64_t tmp = 0;
+ if (read(s_pipe[0], &sig, sizeof sig) == -1) {
+ // dontcare
+ }
+ sensordLogD() << "Caught async signal" << strsignal(sig);
+ switch (sig) {
+ case SIGINT:
+ case SIGTERM:
+ signalINT(sig);
+ break;
+ case SIGUSR1:
+ signalUSR1(sig);
+ break;
+ case SIGUSR2:
+ signalUSR2(sig);
+ break;
+ };
+}
+
+int SignalNotifier::s_pipe[2] = { -1, -1 };
+
+const int SignalNotifier::s_signals[] =
+{
+ SIGINT, SIGTERM, SIGUSR1, SIGUSR2, -1
+};
+
int main(int argc, char *argv[])
{
previousMessageHandler = qInstallMessageHandler(messageOutput);
@@ -133,10 +237,6 @@
}
}
- signal(SIGUSR1, signalUSR1);
- signal(SIGUSR2, signalUSR2);
- signal(SIGINT, signalINT);
-
if (parser.createDaemon())
{
fflush(0);
@@ -182,7 +282,10 @@
sd_notify(0, "READY=1");
}
+ SignalNotifier *signalNotifier = new SignalNotifier();
int ret = app.exec();
+ delete signalNotifier; signalNotifier = 0;
+
sensordLogD() << "Exiting...";
Config::close();
return ret;
|
[-]
[+]
|
Changed |
_service:tar_git:hybris-libsensorfw-qt5-0.10.0.tar.bz2/sensord/parser.cpp
^
|
@@ -56,8 +56,10 @@
{
data = opt.split("=");
QString logLevel = data.at(1);
- if (logLevel == "test" || logLevel == "debug")
+ if (logLevel == "test")
logLevel_ = QtDebugMsg;
+ else if (logLevel == "debug")
+ logLevel_ = QtInfoMsg;
else if (logLevel == "warning")
logLevel_ = QtWarningMsg;
else if (logLevel == "critical")
|
[-]
[+]
|
Changed |
_service:tar_git:hybris-libsensorfw-qt5-0.10.0.tar.bz2/sensorfw.pro
^
|
@@ -1,5 +1,17 @@
-load(configure)
-qtCompileTest(hybris)
+# RPM build: Hybris plugin has separate spec file that does:
+# qmake CONFIG+=hybris
+# And pro-file behavioral differences are handled via:
+# contains(CONFIG,hybris) { ... }
+#
+# Debian builds: debian/rules triggers build time hybris check:
+# qmake CONFIG+=autohybris
+# And pro-file behavioral differences are handled via:
+# config_hybris { ... }
+
+contains(CONFIG,autohybris) {
+ load(configure)
+ qtCompileTest(hybris)
+}
TEMPLATE = subdirs
CONFIG += ordered
@@ -92,7 +104,8 @@
DBUSCONFIGFILES.path = /etc/dbus-1/system.d
INSTALLS += DBUSCONFIGFILES
- SENSORDCONFIGFILES.files = config/90-sensord-default.conf
+ SENSORDCONFIGFILES.files = config/10-sensord-default.conf
+ SENSORDCONFIGFILES.files += config/20-sensors-default.conf
SENSORDCONFIGFILES.path = /etc/sensorfw/sensord.conf.d
INSTALLS += SENSORDCONFIGFILES
|
[-]
[+]
|
Changed |
_service:tar_git:hybris-libsensorfw-qt5-0.10.0.tar.bz2/sensors/proximitysensor/proximityplugin.cpp
^
|
@@ -30,7 +30,7 @@
void ProximityPlugin::Register(class Loader&)
{
- sensordLog() << "registering proximitysensor";
+ sensordLogD() << "registering proximitysensor";
SensorManager& sm = SensorManager::instance();
sm.registerSensor<ProximitySensorChannel>("proximitysensor");
}
|
[-]
[+]
|
Deleted |
_service:tar_git:hybris-libsensorfw-qt5-0.9.6.tar.bz2/.gitignore
^
|
@@ -1,29 +0,0 @@
-Makefile
-*.o
-moc_*
-.qmake.cache
-RPMS/
-*.so
-*.so.*
-*.swp
-config.log
-core/Makefile.hybris
-documentation.list
-installroot/
-doc/html/
-sensord/sensorfwd
-tests/adaptors/sensoradaptors-test
-tests/benchmark/benchmarktest/sensorbenchmark-test
-tests/benchmark/dummyclient/sensordummyclient-qt5
-tests/chains/sensorchains-test
-tests/client/sensorapi-test
-tests/dataflow/sensordataflow-test
-tests/deadclient/sensord-deadclient
-tests/filters/sensorfilters-test
-tests/metadata/sensormetadata-test
-tests/powermanagement/driverpolltest/sensordriverpoll-test
-tests/powermanagement/powermanagementtests/sensorpowermanagement-test
-tests/powermanagement/standbyoverridetests/sensorstandbyoverride-test
-tests/testapp/sensortestapp
-tests/testutils/datafaker/datafaker-qt5
-
|
[-]
[+]
|
Changed |
_service:tar_git:sensorfwd.service
^
|
@@ -1,6 +1,7 @@
[Unit]
Description=Sensor daemon for sensor framework
After=dbus.socket
+After=oneshot-root.service
Requires=dbus.service
Conflicts=actdead.target
|