summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLincoln Ramsay <lincoln.ramsay@nokia.com>2011-02-24 10:04:11 +1000
committerLincoln Ramsay <lincoln.ramsay@nokia.com>2011-02-24 13:24:21 +1000
commita85e1b52233747d89fcbdb66d852360fc25d76de (patch)
tree32d6b04dc0976f7e82e75bbde90a1c8f63d0c6e3
parent0b566c9c84e20cdf421ae6c1285c3f5f03a27ab5 (diff)
Allow tweaking of the Symbian backend
Document this in the platform notes.
-rw-r--r--doc/src/sensors.qdoc29
-rw-r--r--plugins/sensors/symbian/accelerometersym.cpp11
-rw-r--r--plugins/sensors/symbian/accelerometersym.h1
-rw-r--r--plugins/sensors/symbian/ambientlightsensorsym.cpp11
-rw-r--r--plugins/sensors/symbian/ambientlightsensorsym.h1
-rw-r--r--plugins/sensors/symbian/compasssym.cpp11
-rw-r--r--plugins/sensors/symbian/compasssym.h3
-rw-r--r--plugins/sensors/symbian/lightsensorsym.cpp13
-rw-r--r--plugins/sensors/symbian/lightsensorsym.h1
-rw-r--r--plugins/sensors/symbian/magnetometersensorsym.cpp11
-rw-r--r--plugins/sensors/symbian/magnetometersensorsym.h1
-rw-r--r--plugins/sensors/symbian/orientationsym.cpp11
-rw-r--r--plugins/sensors/symbian/orientationsym.h1
-rw-r--r--plugins/sensors/symbian/proximitysensorsym.cpp11
-rw-r--r--plugins/sensors/symbian/proximitysensorsym.h1
-rw-r--r--plugins/sensors/symbian/rotationsensorsym.cpp11
-rw-r--r--plugins/sensors/symbian/rotationsensorsym.h1
-rw-r--r--plugins/sensors/symbian/sensorbackendsym.cpp11
-rw-r--r--plugins/sensors/symbian/sensorbackendsym.h44
-rw-r--r--plugins/sensors/symbian/tapsensorsym.cpp11
-rw-r--r--plugins/sensors/symbian/tapsensorsym.h3
21 files changed, 130 insertions, 68 deletions
diff --git a/doc/src/sensors.qdoc b/doc/src/sensors.qdoc
index d35c790077..22b2df5d1c 100644
--- a/doc/src/sensors.qdoc
+++ b/doc/src/sensors.qdoc
@@ -141,7 +141,34 @@ and select one as appropriate.
Readings are delivered to the application via a queue. If the application blocks the event loop or otherwise
interferes with the ability of the system to deliver readings (eg. by using up too much CPU time), they can
get blocked in this queue. Since delayed readings are not useful, the system will drop readings as needed
-so that the application is always dealing with the most recent reading available.
+so that the application is always dealing with the most recent reading available. The application can tweak
+the policy by setting properties on the sensor.
+
+The default policy is to accept up to 100 readings from the system at once and to discard all but the last one.
+
+\code
+QAccelerometer sensor;
+sensor.setProperty("maximumReadingCount", 100);
+sensor.setProperty("processAllReadings", false);
+\endcode
+
+Applications that desire the original behaviour can set the maximumReadingCount to 1. Note that this does not
+guarantee that readings will not be dropped by the system. If the queue fills up, readings will be dropped.
+
+\code
+QAccelerometer sensor;
+sensor.setProperty("maximumReadingCount", 1);
+\endcode
+
+Larger maximumReadingCount values reduce the need for the lower-priority sensor daemon to get CPU timeslices.
+If the application is using lots of CPU but is still able to process readings quickly, it can request that
+all the fetched readings are processed.
+
+\code
+QAccelerometer sensor;
+sensor.setProperty("maximumReadingCount", 10);
+sensor.setProperty("processAllReadings", true);
+\endcode
More information about the native API can be found \l{http://wiki.forum.nokia.com/index.php/Nokia_Sensor_APIs}{here}.
diff --git a/plugins/sensors/symbian/accelerometersym.cpp b/plugins/sensors/symbian/accelerometersym.cpp
index c4dd39623e..9a5a894223 100644
--- a/plugins/sensors/symbian/accelerometersym.cpp
+++ b/plugins/sensors/symbian/accelerometersym.cpp
@@ -150,14 +150,11 @@ void CAccelerometerSensorSym::start()
*/
void CAccelerometerSensorSym::DataReceived(CSensrvChannel &aChannel, TInt aCount, TInt /*aDataLost*/)
{
- for (int i = 0; i < aCount; i++)
- {
- TPckg<TSensrvAccelerometerAxisData> pkg( iData );
- TInt ret = aChannel.GetData( pkg );
- if (ret != KErrNone)
- return;
- }
+ ProcessData(aChannel, aCount, iData);
+ }
+void CAccelerometerSensorSym::ProcessReading()
+ {
TReal x = iData.iAxisX;
TReal y = iData.iAxisY;
TReal z = iData.iAxisZ;
diff --git a/plugins/sensors/symbian/accelerometersym.h b/plugins/sensors/symbian/accelerometersym.h
index 4981e14778..c90677b6a1 100644
--- a/plugins/sensors/symbian/accelerometersym.h
+++ b/plugins/sensors/symbian/accelerometersym.h
@@ -84,6 +84,7 @@ private:
* reading data and provides conversion and utility code
*/
void DataReceived(CSensrvChannel &aChannel, TInt aCount, TInt aDataLost);
+ void ProcessReading();
/**
* Second phase constructor
diff --git a/plugins/sensors/symbian/ambientlightsensorsym.cpp b/plugins/sensors/symbian/ambientlightsensorsym.cpp
index e8444d3b5b..e82d210121 100644
--- a/plugins/sensors/symbian/ambientlightsensorsym.cpp
+++ b/plugins/sensors/symbian/ambientlightsensorsym.cpp
@@ -85,14 +85,11 @@ CAmbientLightSensorSym::CAmbientLightSensorSym(QSensor *sensor):CSensorBackendSy
*/
void CAmbientLightSensorSym::DataReceived(CSensrvChannel &aChannel, TInt aCount, TInt /*aDataLost*/)
{
- for (int i = 0; i < aCount; i++)
- {
- TPckg<TSensrvAmbientLightData> pkg( iData );
- TInt ret = aChannel.GetData( pkg );
- if (ret != KErrNone)
- return;
- }
+ ProcessData(aChannel, aCount, iData);
+ }
+void CAmbientLightSensorSym::ProcessReading()
+ {
// Get a lock on the reading data
iBackendData.iReadingLock.Wait();
switch (iData.iAmbientLight)
diff --git a/plugins/sensors/symbian/ambientlightsensorsym.h b/plugins/sensors/symbian/ambientlightsensorsym.h
index fe3f2c3ef5..bdb6e052eb 100644
--- a/plugins/sensors/symbian/ambientlightsensorsym.h
+++ b/plugins/sensors/symbian/ambientlightsensorsym.h
@@ -82,6 +82,7 @@ private:
* reading data and provides conversion and utility code
*/
void DataReceived(CSensrvChannel &aChannel, TInt aCount, TInt aDataLost);
+ void ProcessReading();
/**
* Second phase constructor
diff --git a/plugins/sensors/symbian/compasssym.cpp b/plugins/sensors/symbian/compasssym.cpp
index 52f86fcc7f..43c88be1ef 100644
--- a/plugins/sensors/symbian/compasssym.cpp
+++ b/plugins/sensors/symbian/compasssym.cpp
@@ -109,14 +109,11 @@ void CCompassSym::stop()
*/
void CCompassSym::DataReceived(CSensrvChannel &aChannel, TInt aCount, TInt /*aDataLost*/)
{
- for (int i = 0; i < aCount; i++)
- {
- TPckg<TSensrvMagneticNorthData> pkg( iData );
- TInt ret = aChannel.GetData( pkg );
- if (ret != KErrNone)
- return;
- }
+ ProcessData(aChannel, aCount, iData);
+ }
+void CCompassSym::ProcessReading()
+ {
// Get a lock on the reading data
iBackendData.iReadingLock.Wait();
iReading.setAzimuth(iData.iAngleFromMagneticNorth);
diff --git a/plugins/sensors/symbian/compasssym.h b/plugins/sensors/symbian/compasssym.h
index 70534da37e..d9257337e0 100644
--- a/plugins/sensors/symbian/compasssym.h
+++ b/plugins/sensors/symbian/compasssym.h
@@ -96,7 +96,8 @@ private:
* It is implemented here to handle compass sensor specific
* reading data and provides conversion and utility code
*/
- void DataReceived(CSensrvChannel &aChannel, TInt aCount, TInt /*aDataLost*/);
+ void DataReceived(CSensrvChannel &aChannel, TInt aCount, TInt aDataLost);
+ void ProcessReading();
/**
* Second phase constructor
diff --git a/plugins/sensors/symbian/lightsensorsym.cpp b/plugins/sensors/symbian/lightsensorsym.cpp
index 2bf4a833c3..cf2a3e5071 100644
--- a/plugins/sensors/symbian/lightsensorsym.cpp
+++ b/plugins/sensors/symbian/lightsensorsym.cpp
@@ -86,16 +86,13 @@ CLightSensorSym::CLightSensorSym(QSensor *sensor):CSensorBackendSym(sensor)
* It is implemented here to handle Light data sensor specific
* reading data and provides conversion and utility code
*/
-void CLightSensorSym::DataReceived(CSensrvChannel &aChannel, TInt aCount, TInt aDataLost)
+void CLightSensorSym::DataReceived(CSensrvChannel &aChannel, TInt aCount, TInt /*aDataLost*/)
{
- for (int i = 0; i < aCount; i++)
- {
- TPckg<TSensrvAmbientLightLuxData> pkg( iData );
- TInt ret = aChannel.GetData( pkg );
- if (ret != KErrNone)
- return;
- }
+ ProcessData(aChannel, aCount, iData);
+ }
+void CLightSensorSym::ProcessReading()
+ {
TReal lightValue = iData.iAmbientLight;
// Get a lock on the reading data
diff --git a/plugins/sensors/symbian/lightsensorsym.h b/plugins/sensors/symbian/lightsensorsym.h
index 3403afbb3a..0e07771ce9 100644
--- a/plugins/sensors/symbian/lightsensorsym.h
+++ b/plugins/sensors/symbian/lightsensorsym.h
@@ -83,6 +83,7 @@ private:
* reading data and provides conversion and utility code
*/
void DataReceived(CSensrvChannel &aChannel, TInt aCount, TInt aDataLost);
+ void ProcessReading();
/**
* Second phase constructor
diff --git a/plugins/sensors/symbian/magnetometersensorsym.cpp b/plugins/sensors/symbian/magnetometersensorsym.cpp
index e864904cc2..ea75dfde5f 100644
--- a/plugins/sensors/symbian/magnetometersensorsym.cpp
+++ b/plugins/sensors/symbian/magnetometersensorsym.cpp
@@ -184,14 +184,11 @@ void CMagnetometerSensorSym::start()
*/
void CMagnetometerSensorSym::DataReceived(CSensrvChannel &aChannel, TInt aCount, TInt /*aDataLost*/)
{
- for (int i = 0; i < aCount; i++)
- {
- TPckg<TSensrvMagnetometerAxisData> pkg( iData );
- TInt ret = aChannel.GetData( pkg );
- if (ret != KErrNone)
- return;
- }
+ ProcessData(aChannel, aCount, iData);
+ }
+void CMagnetometerSensorSym::ProcessReading()
+ {
TReal x, y, z;
// If Geo values are requested set it
if(iReturnGeoValues)
diff --git a/plugins/sensors/symbian/magnetometersensorsym.h b/plugins/sensors/symbian/magnetometersensorsym.h
index af3dbea662..af2f6d1c06 100644
--- a/plugins/sensors/symbian/magnetometersensorsym.h
+++ b/plugins/sensors/symbian/magnetometersensorsym.h
@@ -95,6 +95,7 @@ private:
* reading data and provides conversion and utility code
*/
void DataReceived(CSensrvChannel &aChannel, TInt aCount, TInt aDataLost);
+ void ProcessReading();
/**
* HandlePropertyChange is called from backend, to indicate a change in property
diff --git a/plugins/sensors/symbian/orientationsym.cpp b/plugins/sensors/symbian/orientationsym.cpp
index 778b0a8d93..2bfb619356 100644
--- a/plugins/sensors/symbian/orientationsym.cpp
+++ b/plugins/sensors/symbian/orientationsym.cpp
@@ -86,14 +86,11 @@ COrientationSensorSym::COrientationSensorSym(QSensor *sensor):CSensorBackendSym(
*/
void COrientationSensorSym::DataReceived(CSensrvChannel &aChannel, TInt aCount, TInt /*aDataLost*/)
{
- for (int i = 0; i < aCount; i++)
- {
- TPckg<TSensrvOrientationData> pkg( iData );
- TInt ret = aChannel.GetData( pkg );
- if (ret != KErrNone)
- return;
- }
+ ProcessData(aChannel, aCount, iData);
+ }
+void COrientationSensorSym::ProcessReading()
+ {
// Get a lock on the reading data
iBackendData.iReadingLock.Wait();
//Mapping device orientation enum values to Qt Orientation enum values
diff --git a/plugins/sensors/symbian/orientationsym.h b/plugins/sensors/symbian/orientationsym.h
index 10c7a809c8..2cadf45bdd 100644
--- a/plugins/sensors/symbian/orientationsym.h
+++ b/plugins/sensors/symbian/orientationsym.h
@@ -82,6 +82,7 @@ private:
* reading data and provides conversion and utility code
*/
void DataReceived(CSensrvChannel &aChannel, TInt aCount, TInt aDataLost);
+ void ProcessReading();
/**
* Second phase constructor
diff --git a/plugins/sensors/symbian/proximitysensorsym.cpp b/plugins/sensors/symbian/proximitysensorsym.cpp
index 0b252318dc..3cd408dcae 100644
--- a/plugins/sensors/symbian/proximitysensorsym.cpp
+++ b/plugins/sensors/symbian/proximitysensorsym.cpp
@@ -86,14 +86,11 @@ CProximitySensorSym::CProximitySensorSym(QSensor *sensor):CSensorBackendSym(sens
*/
void CProximitySensorSym::DataReceived(CSensrvChannel &aChannel, TInt aCount, TInt /*aDataLost*/)
{
- for (int i = 0; i < aCount; i++)
- {
- TPckg<TSensrvProximityData> pkg( iData );
- TInt ret = aChannel.GetData( pkg );
- if (ret != KErrNone)
- return;
- }
+ ProcessData(aChannel, aCount, iData);
+ }
+void CProximitySensorSym::ProcessReading()
+ {
// Get a lock on the reading data
iBackendData.iReadingLock.Wait();
iReading.setClose(iData.iProximityState == TSensrvProximityData::EProximityDiscernible);
diff --git a/plugins/sensors/symbian/proximitysensorsym.h b/plugins/sensors/symbian/proximitysensorsym.h
index 44fedae512..75542b8fc3 100644
--- a/plugins/sensors/symbian/proximitysensorsym.h
+++ b/plugins/sensors/symbian/proximitysensorsym.h
@@ -82,6 +82,7 @@ private:
* reading data and provides conversion and utility code
*/
void DataReceived(CSensrvChannel &aChannel, TInt aCount, TInt aDataLost);
+ void ProcessReading();
/**
* Second phase constructor
diff --git a/plugins/sensors/symbian/rotationsensorsym.cpp b/plugins/sensors/symbian/rotationsensorsym.cpp
index 81c0d07f77..f427145cae 100644
--- a/plugins/sensors/symbian/rotationsensorsym.cpp
+++ b/plugins/sensors/symbian/rotationsensorsym.cpp
@@ -90,14 +90,11 @@ CRotationSensorSym::CRotationSensorSym(QSensor *sensor):CSensorBackendSym(sensor
*/
void CRotationSensorSym::DataReceived(CSensrvChannel &aChannel, TInt aCount, TInt /*aDataLost*/)
{
- for (int i = 0; i < aCount; i++)
- {
- TPckg<TSensrvRotationData> pkg( iData );
- TInt ret = aChannel.GetData( pkg );
- if (ret != KErrNone)
- return;
- }
+ ProcessData(aChannel, aCount, iData);
+ }
+void CRotationSensorSym::ProcessReading()
+ {
// Get a lock on the reading data
iBackendData.iReadingLock.Wait();
// To Do verify with ds and ramsay
diff --git a/plugins/sensors/symbian/rotationsensorsym.h b/plugins/sensors/symbian/rotationsensorsym.h
index 641b0fa909..5a7a711484 100644
--- a/plugins/sensors/symbian/rotationsensorsym.h
+++ b/plugins/sensors/symbian/rotationsensorsym.h
@@ -82,6 +82,7 @@ private:
* reading data and provides conversion and utility code
*/
void DataReceived(CSensrvChannel &aChannel, TInt aCount, TInt aDataLost);
+ void ProcessReading();
/**
* Second phase constructor
diff --git a/plugins/sensors/symbian/sensorbackendsym.cpp b/plugins/sensors/symbian/sensorbackendsym.cpp
index 311c8cde41..3e670c4021 100644
--- a/plugins/sensors/symbian/sensorbackendsym.cpp
+++ b/plugins/sensors/symbian/sensorbackendsym.cpp
@@ -48,6 +48,7 @@ const TInt KDesiredReadingCount = 1;
const TInt KMaximumReadingCount = 100;
const TInt KDefaultBufferingPeriod = 0;
const TInt KAccuracyInvalid = -1;
+const TInt KProcessAllReadings = false;
///// Internal Functions
@@ -284,7 +285,7 @@ void CSensorBackendSym::StartListeningL()
// Before calling this api the channel should be found and opened
iBackendData.iSensorChannel->StartDataListeningL( this,
KDesiredReadingCount,
- KMaximumReadingCount,
+ m_maximumReadingCount,
KDefaultBufferingPeriod );
}
// start property listening if required //put it above
@@ -605,6 +606,14 @@ TInt CSensorBackendSym::Close()
*/
void CSensorBackendSym::start()
{
+ m_maximumReadingCount = KMaximumReadingCount;
+ QVariant var = sensor()->property("maximumReadingCount");
+ if (var.isValid())
+ m_maximumReadingCount = var.toInt();
+ m_processAllReadings = KProcessAllReadings;
+ var = sensor()->property("processAllReadings");
+ if (var.isValid())
+ m_processAllReadings = var.toBool();
// Start listening to sensor, after this call DataRecieved will be called
// when data is available
TRAPD(err,StartListeningL())
diff --git a/plugins/sensors/symbian/sensorbackendsym.h b/plugins/sensors/symbian/sensorbackendsym.h
index 92c26bf6ae..a90044bfbc 100644
--- a/plugins/sensors/symbian/sensorbackendsym.h
+++ b/plugins/sensors/symbian/sensorbackendsym.h
@@ -89,6 +89,7 @@ class CSensorBackendSym : public CBase, public QSensorBackend, public MSensrvDat
* DataReceived is called by the Sensor Server when ever data is available in the
* sensor buffer
*/
+ // implemnented by sub-classes
//void DataReceived(CSensrvChannel &aChannel, TInt aCount, TInt aDataLost);
/**
@@ -223,11 +224,54 @@ class CSensorBackendSym : public CBase, public QSensorBackend, public MSensrvDat
*/
void StopListeningL();
+ /*
+ * ProcessReading is used to process one sensor reading
+ * It is implemented the the sensor concrete class and handles sensor specific
+ * reading data and provides conversion and utility code
+ */
+ virtual void ProcessReading() = 0;
+
+ /*
+ * ProcessData is called by the sub-clases to handle the conditional fetching logic
+ * It either processes all arriving readings or just the last one. It calls
+ * ProcessReading to do the actual processing
+ */
+ template <typename T>
+ void ProcessData(CSensrvChannel &aChannel, TInt aCount, T &iData)
+ {
+ int loopMax = aCount;
+ if (!m_processAllReadings)
+ {
+ for (int i = 0; i < aCount; i++)
+ {
+ TPckg<T> pkg( iData );
+ TInt ret = aChannel.GetData( pkg );
+ if (ret != KErrNone)
+ return;
+ }
+ loopMax = 1;
+ }
+
+ for (int i = 0; i < loopMax; i++)
+ {
+ if (m_processAllReadings)
+ {
+ TPckg<T> pkg( iData );
+ TInt ret = aChannel.GetData( pkg );
+ if (ret != KErrNone)
+ return;
+ }
+ ProcessReading();
+ }
+ }
+
private:
TSensrvPropertyType propertyType(TSensrvPropertyId, TInt&);
protected:
TSensorBackendDataSym iBackendData;
+ int m_maximumReadingCount;
+ bool m_processAllReadings;
};
#endif //SENSORBACKENDSYM_H
diff --git a/plugins/sensors/symbian/tapsensorsym.cpp b/plugins/sensors/symbian/tapsensorsym.cpp
index ddac9f455a..2af4b33b6b 100644
--- a/plugins/sensors/symbian/tapsensorsym.cpp
+++ b/plugins/sensors/symbian/tapsensorsym.cpp
@@ -83,14 +83,11 @@ CTapSensorSym::CTapSensorSym(QSensor *sensor):CSensorBackendSym(sensor)
*/
void CTapSensorSym::DataReceived(CSensrvChannel &aChannel, TInt aCount, TInt /*aDataLost*/)
{
- for (int i = 0; i < aCount; i++)
- {
- TPckg<TSensrvTappingData> pkg( iData );
- TInt ret = aChannel.GetData( pkg );
- if (ret != KErrNone)
- return;
- }
+ ProcessData(aChannel, aCount, iData);
+ }
+void CTapSensorSym::ProcessReading()
+ {
// Get a lock on the reading data
iBackendData.iReadingLock.Wait();
//Mapping device tap sensor enum values to Qt tap sensor enum values
diff --git a/plugins/sensors/symbian/tapsensorsym.h b/plugins/sensors/symbian/tapsensorsym.h
index aaedd172a8..13abe48326 100644
--- a/plugins/sensors/symbian/tapsensorsym.h
+++ b/plugins/sensors/symbian/tapsensorsym.h
@@ -79,7 +79,8 @@ private:
* It is implemented here to handle tap sensor specific
* reading data and provides conversion and utility code
*/
- void DataReceived(CSensrvChannel &aChannel, TInt aCount, TInt /*aDataLost*/);
+ void DataReceived(CSensrvChannel &aChannel, TInt aCount, TInt aDataLost);
+ void ProcessReading();
/**
* Second phase constructor
* Initialize the backend resources