if (mState != INTERACTION_STATE_UNINITIALIZED)
return true;
- int fd = fb_idle_open();
- if (fd < 0)
- return false;
- mIdleFd = fd;
+ mIdleFd = fb_idle_open();
mEventFd = eventfd(0, EFD_NONBLOCK);
if (mEventFd < 0) {
ALOGE("Unable to create event fd (%d)", errno);
- close(mIdleFd);
+ if (mIdleFd >= 0) {
+ close(mIdleFd);
+ }
return false;
}
mThread->join();
close(mEventFd);
- close(mIdleFd);
+ if (mIdleFd >= 0) {
+ close(mIdleFd);
+ }
}
void InteractionHandler::PerfLock() {
return;
}
+ if (mIdleFd < 0) {
+ ret = poll(pfd, 1, timeout_ms);
+ if (ret > 0) {
+ ALOGV("%s: wait for duration aborted", __func__);
+ return;
+ } else if (ret < 0) {
+ ALOGE("%s: Error on waiting for duration (%zd)", __func__, ret);
+ return;
+ }
+ return;
+ }
+
ret = pread(mIdleFd, data, sizeof(data), 0);
if (!ret) {
ALOGE("%s: Unexpected EOF!", __func__);