summaryrefslogtreecommitdiffstats
path: root/libs/utils
diff options
context:
space:
mode:
authorJeff Brown <jeffbrown@google.com>2010-09-08 11:49:43 -0700
committerJeff Brown <jeffbrown@google.com>2010-09-12 16:52:03 -0700
commitb88102f5b7e51552a3576cf197b4c8cf96f193d1 (patch)
treec714dce33893a048f42a36e78b25dc0bc971b1c3 /libs/utils
parent11fe181e16501103d7c0f70344661ea2ef5d3df9 (diff)
downloadframeworks_base-b88102f5b7e51552a3576cf197b4c8cf96f193d1.zip
frameworks_base-b88102f5b7e51552a3576cf197b4c8cf96f193d1.tar.gz
frameworks_base-b88102f5b7e51552a3576cf197b4c8cf96f193d1.tar.bz2
Input dispatcher ANR handling enhancements.
This change is essentially a rewrite of the main input dispatcher loop with the target identification folded in. Since the input dispatcher now has all of the window state, it can make better decisions about when to ANR. Added a .5 second deadline for processing app switch keys. This behavior predates Gingerbread but had not previously been ported. Fixed some timing inaccuracies in the ANR accounting that could cause applications to ANR sooner than they should have. Added a mechanism for tracking key and motion events that have been dispatched to a window so that appropriate cancelation events can be synthesized when recovering from ANR. This change helps to keep applications in sync so they don't end up with stuck buttons upon recovery from ANRs. Added more comments to describe the tricky parts of PollLoop. Change-Id: I13dffca27acb436fc383980db536abc4d8b9e6f1
Diffstat (limited to 'libs/utils')
-rw-r--r--libs/utils/PollLoop.cpp8
1 files changed, 7 insertions, 1 deletions
diff --git a/libs/utils/PollLoop.cpp b/libs/utils/PollLoop.cpp
index 6d3eeee..fe76cd0 100644
--- a/libs/utils/PollLoop.cpp
+++ b/libs/utils/PollLoop.cpp
@@ -119,7 +119,8 @@ int32_t PollLoop::pollOnce(int timeoutMillis, int* outEvents, void** outData) {
if (outData != NULL) *outData = pending.data;
return pending.ident;
}
-
+
+ // Wait for wakeAndLock() waiters to run then set mPolling to true.
mLock.lock();
while (mWaiters != 0) {
mResume.wait(mLock);
@@ -127,6 +128,7 @@ int32_t PollLoop::pollOnce(int timeoutMillis, int* outEvents, void** outData) {
mPolling = true;
mLock.unlock();
+ // Poll.
int32_t result;
size_t requestedCount = mRequestedFds.size();
@@ -168,6 +170,7 @@ int32_t PollLoop::pollOnce(int timeoutMillis, int* outEvents, void** outData) {
}
#endif
+ // Process the poll results.
mPendingCallbacks.clear();
mPendingFds.clear();
mPendingFdsPos = 0;
@@ -218,6 +221,7 @@ int32_t PollLoop::pollOnce(int timeoutMillis, int* outEvents, void** outData) {
}
Done:
+ // Set mPolling to false and wake up the wakeAndLock() waiters.
mLock.lock();
mPolling = false;
if (mWaiters != 0) {
@@ -357,11 +361,13 @@ ssize_t PollLoop::getRequestIndexLocked(int fd) {
void PollLoop::wakeAndLock() {
mLock.lock();
+
mWaiters += 1;
while (mPolling) {
wake();
mAwake.wait(mLock);
}
+
mWaiters -= 1;
if (mWaiters == 0) {
mResume.signal();