From 2442d49d629f1ce5d9d3bb4914242422246a7e8e Mon Sep 17 00:00:00 2001 From: Chih-Wei Huang Date: Tue, 8 Feb 2011 16:39:15 +0800 Subject: [PATCH] drop keyevents when Surfaceflinger give up the screen It fixes the 100% CPU usage problem switching to Alt-F1 console. --- libs/ui/EventHub.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/libs/ui/EventHub.cpp b/libs/ui/EventHub.cpp index 7498d39f8d0c..0e1182378383 100755 --- a/libs/ui/EventHub.cpp +++ b/libs/ui/EventHub.cpp @@ -375,10 +375,12 @@ bool EventHub::getEvent(int32_t* outDeviceId, int32_t* outType, // mFDs[0] is used for inotify, so process regular events starting at mFDs[1] for(i = 1; i < mFDCount; i++) { - if(mFDs[i].revents && keyGrab::isGrabOn()) { + if (mFDs[i].revents) { LOGV("revents for %d = 0x%08x", i, mFDs[i].revents); if(mFDs[i].revents & POLLIN) { res = read(mFDs[i].fd, &iev, sizeof(iev)); + if (!keyGrab::isGrabOn()) + continue; if (res == sizeof(iev)) { LOGV("%s got: t0=%d, t1=%d, type=%d, code=%d, v=%d", mDevices[i]->path.string(), -- 2.11.0