summaryrefslogtreecommitdiffstats
path: root/services
diff options
context:
space:
mode:
authorJeff Brown <jeffbrown@google.com>2010-09-13 23:17:30 -0700
committerJeff Brown <jeffbrown@google.com>2010-09-14 01:59:45 -0700
commit4fe6c3e51be77e35f40872cdbca6c80f8f8b7ecb (patch)
tree5cbcfad147ad1bf26deb384e41d27f4e6bfcdb80 /services
parentc891d2b3529b9cf24ef4781a585cd4784815e711 (diff)
downloadframeworks_base-4fe6c3e51be77e35f40872cdbca6c80f8f8b7ecb.zip
frameworks_base-4fe6c3e51be77e35f40872cdbca6c80f8f8b7ecb.tar.gz
frameworks_base-4fe6c3e51be77e35f40872cdbca6c80f8f8b7ecb.tar.bz2
Replace epoll() with poll() and rename PollLoop to Looper.
As part of this change, consolidated and cleaned up the Looper API so that there are fewer distinctions between the NDK and non-NDK declarations (no need for two callback types, etc.). Removed the dependence on specific constants from sys/poll.h such as POLLIN. Instead looper.h defines events like LOOPER_EVENT_INPUT for the events that it supports. That should help make any future under-the-hood implementation changes easier. Fixed a couple of compiler warnings along the way. Change-Id: I449a7ec780bf061bdd325452f823673e2b39b6ae
Diffstat (limited to 'services')
-rw-r--r--services/sensorservice/SensorService.cpp2
-rw-r--r--services/sensorservice/tests/sensorservicetest.cpp17
2 files changed, 11 insertions, 8 deletions
diff --git a/services/sensorservice/SensorService.cpp b/services/sensorservice/SensorService.cpp
index 3025f77..e204e04 100644
--- a/services/sensorservice/SensorService.cpp
+++ b/services/sensorservice/SensorService.cpp
@@ -529,7 +529,7 @@ status_t SensorService::SensorEventConnection::sendEvents(
LOGE_IF(size<0, "dropping %d events on the floor (%s)",
count, strerror(-size));
- return size < 0 ? size : NO_ERROR;
+ return size < 0 ? status_t(size) : status_t(NO_ERROR);
}
sp<SensorChannel> SensorService::SensorEventConnection::getSensorChannel() const
diff --git a/services/sensorservice/tests/sensorservicetest.cpp b/services/sensorservice/tests/sensorservicetest.cpp
index e464713..42bf983 100644
--- a/services/sensorservice/tests/sensorservicetest.cpp
+++ b/services/sensorservice/tests/sensorservicetest.cpp
@@ -18,11 +18,11 @@
#include <gui/Sensor.h>
#include <gui/SensorManager.h>
#include <gui/SensorEventQueue.h>
-#include <utils/PollLoop.h>
+#include <utils/Looper.h>
using namespace android;
-bool receiver(int fd, int events, void* data)
+int receiver(int fd, int events, void* data)
{
sp<SensorEventQueue> q((SensorEventQueue*)data);
ssize_t n;
@@ -41,7 +41,7 @@ bool receiver(int fd, int events, void* data)
if (n<0 && n != -EAGAIN) {
printf("error reading events (%s)\n", strerror(-n));
}
- return true;
+ return 1;
}
@@ -51,7 +51,7 @@ int main(int argc, char** argv)
Sensor const* const* list;
ssize_t count = mgr.getSensorList(&list);
- printf("numSensors=%d\n", count);
+ printf("numSensors=%d\n", int(count));
sp<SensorEventQueue> q = mgr.createEventQueue();
printf("queue=%p\n", q.get());
@@ -63,13 +63,16 @@ int main(int argc, char** argv)
q->setEventRate(accelerometer, ms2ns(10));
- sp<PollLoop> loop = new PollLoop(false);
- loop->setCallback(q->getFd(), POLLIN, receiver, q.get());
+ sp<Looper> loop = new Looper(false);
+ loop->addFd(q->getFd(), 0, ALOOPER_EVENT_INPUT, receiver, q.get());
do {
//printf("about to poll...\n");
- int32_t ret = loop->pollOnce(-1, 0, 0);
+ int32_t ret = loop->pollOnce(-1);
switch (ret) {
+ case ALOOPER_POLL_WAKE:
+ //("ALOOPER_POLL_WAKE\n");
+ break;
case ALOOPER_POLL_CALLBACK:
//("ALOOPER_POLL_CALLBACK\n");
break;