Commit ed38fb45 authored by spiiroin's avatar spiiroin

[hybrisadaptor] Subject sensor type specific actions to common policy

Sensor specific adaptors derived from HybrisAdaptor class can be configured
to enable/disable sensors directly via sysfs. While doing that they also
bypass enable/disable policy that is implemented in HybrisAdaptor.

Fix each HybrisXxxAdaptor class so that common policy logic is executed
first, and direct sysfs manipulation is done based on policy decision.
Signed-off-by: spiiroin's avatarSimo Piiroinen <simo.piiroinen@jollamobile.com>
parent 8fab5538
......@@ -44,20 +44,19 @@ HybrisAccelerometerAdaptor::~HybrisAccelerometerAdaptor()
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";
}
......
......@@ -52,11 +52,10 @@ HybrisAlsAdaptor::~HybrisAlsAdaptor()
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::sendInitialData()
void HybrisAlsAdaptor::stopSensor()
{
if(!powerStatePath.isEmpty())
writeToFile(powerStatePath, "0");
HybrisAdaptor::stopSensor();
if (!isRunning() && !powerStatePath.isEmpty())
writeToFile(powerStatePath, "0");
sensordLogD() << "Hybris HybrisAlsAdaptor stop\n";
}
......
......@@ -51,20 +51,19 @@ HybrisGyroscopeAdaptor::~HybrisGyroscopeAdaptor()
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";
}
......
......@@ -48,20 +48,19 @@ HybrisMagnetometerAdaptor::~HybrisMagnetometerAdaptor()
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";
}
......
......@@ -64,20 +64,19 @@ HybrisOrientationAdaptor::~HybrisOrientationAdaptor()
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";
}
......
......@@ -50,20 +50,19 @@ HybrisPressureAdaptor::~HybrisPressureAdaptor()
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";
}
......
......@@ -57,10 +57,10 @@ HybrisProximityAdaptor::~HybrisProximityAdaptor()
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::sendInitialData()
void HybrisProximityAdaptor::stopSensor()
{
if(!powerStatePath.isEmpty())
writeToFile(powerStatePath, "0");
HybrisAdaptor::stopSensor();
if (!isRunning() && !powerStatePath.isEmpty())
writeToFile(powerStatePath, "0");
sensordLogD() << "HybrisProximityAdaptor stop\n";
}
......
......@@ -56,11 +56,10 @@ HybrisStepCounterAdaptor::~HybrisStepCounterAdaptor()
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::sendInitialData()
void HybrisStepCounterAdaptor::stopSensor()
{
if(!powerStatePath.isEmpty())
writeToFile(powerStatePath, "0");
HybrisAdaptor::stopSensor();
if (!isRunning() && !powerStatePath.isEmpty())
writeToFile(powerStatePath, "0");
sensordLogD() << "Hybris HybrisStepCounterAdaptor stop\n";
}
......
......@@ -809,6 +809,7 @@ void HybrisAdaptor::evaluateSensor()
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);
......@@ -819,6 +820,7 @@ bool HybrisAdaptor::startSensor()
void HybrisAdaptor::stopSensor()
{
// 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);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment