new SensorService

remove old sensor service and implement SensorManager
on top of the new (native) SensorManger API.

Change-Id: Iddb77d498755da3e11646473a44d651f12f40281
This commit is contained in:
Mathias Agopian
2010-07-14 23:41:37 -07:00
parent ff7049ab28
commit 1bf797857e
28 changed files with 899 additions and 762 deletions

View File

@@ -14,6 +14,8 @@
* limitations under the License.
*/
#define LOG_TAG "Sensors"
#include <stdint.h>
#include <sys/types.h>
@@ -21,6 +23,8 @@
#include <utils/RefBase.h>
#include <utils/Singleton.h>
#include <binder/IServiceManager.h>
#include <gui/ISensorServer.h>
#include <gui/ISensorEventConnection.h>
#include <gui/Sensor.h>
@@ -36,25 +40,40 @@ ANDROID_SINGLETON_STATIC_INSTANCE(SensorManager)
SensorManager::SensorManager()
: mSensorList(0)
{
const String16 name("sensorservice");
while (getService(name, &mSensorServer) != NO_ERROR) {
usleep(250000);
}
mSensors = mSensorServer->getSensorList();
// TODO: needs implementation
size_t count = mSensors.size();
mSensorList = (Sensor const**)malloc(count * sizeof(Sensor*));
for (size_t i=0 ; i<count ; i++) {
mSensorList[i] = mSensors.array() + i;
}
}
SensorManager::~SensorManager()
{
// TODO: needs implementation
free(mSensorList);
}
ssize_t SensorManager::getSensorList(Sensor** list) const
ssize_t SensorManager::getSensorList(Sensor const* const** list) const
{
*list = mSensorList;
return mSensors.size();
}
Sensor* SensorManager::getDefaultSensor(int type)
Sensor const* SensorManager::getDefaultSensor(int type)
{
// TODO: needs implementation
return mSensorList;
// For now we just return the first sensor of that type we find.
// in the future it will make sense to let the SensorService make
// that decision.
for (size_t i=0 ; i<mSensors.size() ; i++) {
if (mSensorList[i]->getType() == type)
return mSensorList[i];
}
return NULL;
}
sp<SensorEventQueue> SensorManager::createEventQueue()