summaryrefslogtreecommitdiffstats
path: root/libs/ui
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
commit59abe7e0909bf4b7bf7b9601e1e40a05f6d4fd8a (patch)
tree461f56e9bdc9a3206543f729409ba23e7124dd29 /libs/ui
parent37163248adf9e8e5786b2bc1424efa04efd07252 (diff)
downloadframeworks_native-59abe7e0909bf4b7bf7b9601e1e40a05f6d4fd8a.zip
frameworks_native-59abe7e0909bf4b7bf7b9601e1e40a05f6d4fd8a.tar.gz
frameworks_native-59abe7e0909bf4b7bf7b9601e1e40a05f6d4fd8a.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 'libs/ui')
-rw-r--r--libs/ui/InputDispatcher.cpp42
1 files changed, 21 insertions, 21 deletions
diff --git a/libs/ui/InputDispatcher.cpp b/libs/ui/InputDispatcher.cpp
index b8a26b0..48dea57 100644
--- a/libs/ui/InputDispatcher.cpp
+++ b/libs/ui/InputDispatcher.cpp
@@ -95,7 +95,7 @@ InputDispatcher::InputDispatcher(const sp<InputDispatcherPolicyInterface>& polic
mFocusedApplication(NULL),
mCurrentInputTargetsValid(false),
mInputTargetWaitCause(INPUT_TARGET_WAIT_CAUSE_NONE) {
- mPollLoop = new PollLoop(false);
+ mLooper = new Looper(false);
mInboundQueue.headSentinel.refCount = -1;
mInboundQueue.headSentinel.type = EventEntry::TYPE_SENTINEL;
@@ -156,7 +156,7 @@ void InputDispatcher::dispatchOnce() {
timeoutMillis = 0;
}
- mPollLoop->pollOnce(timeoutMillis);
+ mLooper->pollOnce(timeoutMillis);
}
void InputDispatcher::dispatchOnceInnerLocked(nsecs_t keyRepeatTimeout,
@@ -1784,7 +1784,7 @@ void InputDispatcher::drainOutboundQueueLocked(Connection* connection,
}
}
-bool InputDispatcher::handleReceiveCallback(int receiveFd, int events, void* data) {
+int InputDispatcher::handleReceiveCallback(int receiveFd, int events, void* data) {
InputDispatcher* d = static_cast<InputDispatcher*>(data);
{ // acquire lock
@@ -1794,24 +1794,24 @@ bool InputDispatcher::handleReceiveCallback(int receiveFd, int events, void* dat
if (connectionIndex < 0) {
LOGE("Received spurious receive callback for unknown input channel. "
"fd=%d, events=0x%x", receiveFd, events);
- return false; // remove the callback
+ return 0; // remove the callback
}
nsecs_t currentTime = now();
sp<Connection> connection = d->mConnectionsByReceiveFd.valueAt(connectionIndex);
- if (events & (POLLERR | POLLHUP | POLLNVAL)) {
+ if (events & (ALOOPER_EVENT_ERROR | ALOOPER_EVENT_HANGUP)) {
LOGE("channel '%s' ~ Consumer closed input channel or an error occurred. "
"events=0x%x", connection->getInputChannelName(), events);
d->abortDispatchCycleLocked(currentTime, connection, true /*broken*/);
d->runCommandsLockedInterruptible();
- return false; // remove the callback
+ return 0; // remove the callback
}
- if (! (events & POLLIN)) {
+ if (! (events & ALOOPER_EVENT_INPUT)) {
LOGW("channel '%s' ~ Received spurious callback for unhandled poll event. "
"events=0x%x", connection->getInputChannelName(), events);
- return true;
+ return 1;
}
status_t status = connection->inputPublisher.receiveFinishedSignal();
@@ -1820,12 +1820,12 @@ bool InputDispatcher::handleReceiveCallback(int receiveFd, int events, void* dat
connection->getInputChannelName(), status);
d->abortDispatchCycleLocked(currentTime, connection, true /*broken*/);
d->runCommandsLockedInterruptible();
- return false; // remove the callback
+ return 0; // remove the callback
}
d->finishDispatchCycleLocked(currentTime, connection);
d->runCommandsLockedInterruptible();
- return true;
+ return 1;
} // release lock
}
@@ -1843,7 +1843,7 @@ void InputDispatcher::notifyConfigurationChanged(nsecs_t eventTime) {
} // release lock
if (needWake) {
- mPollLoop->wake();
+ mLooper->wake();
}
}
@@ -1870,7 +1870,7 @@ void InputDispatcher::notifyKey(nsecs_t eventTime, int32_t deviceId, int32_t sou
} // release lock
if (needWake) {
- mPollLoop->wake();
+ mLooper->wake();
}
}
@@ -2007,7 +2007,7 @@ NoBatchingOrStreaming:;
} // release lock
if (needWake) {
- mPollLoop->wake();
+ mLooper->wake();
}
}
@@ -2043,7 +2043,7 @@ int32_t InputDispatcher::injectInputEvent(const InputEvent* event,
} // release lock
if (needWake) {
- mPollLoop->wake();
+ mLooper->wake();
}
int32_t injectionResult;
@@ -2294,7 +2294,7 @@ void InputDispatcher::setInputWindows(const Vector<InputWindow>& inputWindows) {
} // release lock
// Wake up poll loop since it may need to make new input dispatching choices.
- mPollLoop->wake();
+ mLooper->wake();
}
void InputDispatcher::setFocusedApplication(const InputApplication* inputApplication) {
@@ -2317,7 +2317,7 @@ void InputDispatcher::setFocusedApplication(const InputApplication* inputApplica
} // release lock
// Wake up poll loop since it may need to make new input dispatching choices.
- mPollLoop->wake();
+ mLooper->wake();
}
void InputDispatcher::releaseFocusedApplicationLocked() {
@@ -2355,7 +2355,7 @@ void InputDispatcher::setInputDispatchMode(bool enabled, bool frozen) {
if (changed) {
// Wake up poll loop since it may need to make new input dispatching choices.
- mPollLoop->wake();
+ mLooper->wake();
}
}
@@ -2372,7 +2372,7 @@ void InputDispatcher::preemptInputDispatch() {
if (preemptedOne) {
// Wake up the poll loop so it can get a head start dispatching the next event.
- mPollLoop->wake();
+ mLooper->wake();
}
}
@@ -2495,7 +2495,7 @@ status_t InputDispatcher::registerInputChannel(const sp<InputChannel>& inputChan
mMonitoringChannels.push(inputChannel);
}
- mPollLoop->setCallback(receiveFd, POLLIN, handleReceiveCallback, this);
+ mLooper->addFd(receiveFd, 0, ALOOPER_EVENT_INPUT, handleReceiveCallback, this);
runCommandsLockedInterruptible();
} // release lock
@@ -2529,7 +2529,7 @@ status_t InputDispatcher::unregisterInputChannel(const sp<InputChannel>& inputCh
}
}
- mPollLoop->removeCallback(inputChannel->getReceivePipeFd());
+ mLooper->removeFd(inputChannel->getReceivePipeFd());
nsecs_t currentTime = now();
abortDispatchCycleLocked(currentTime, connection, true /*broken*/);
@@ -2539,7 +2539,7 @@ status_t InputDispatcher::unregisterInputChannel(const sp<InputChannel>& inputCh
// Wake the poll loop because removing the connection may have changed the current
// synchronization state.
- mPollLoop->wake();
+ mLooper->wake();
return OK;
}